示例#1
0
    // 水面是否存在实现
    public bool GetWaterExists(float x, float z)
    {
        x -= CFunction.GetTerrainLeft();
        z -= CFunction.GetTerrainTop();

        return(InnerGetWaterExists(x, z));
    }
示例#2
0
 public FileEntry(string path, CFunction funcGraph, CThreadTimeline sortedTimeline)
 {
     filePath             = path;
     similarFiles         = new List <FileEntry>();
     graph                = funcGraph;
     threadSortedTimeline = sortedTimeline;
 }
 public void EnterFunction(CFunction function)
 {
     foreach (var item in functionInterceptors)
     {
         item.EnterFunction(function, this);
     }
 }
示例#4
0
        public static CFunction GenerateCFunctionForNew(Type t)
        {
            CFunction cfunc = (Thread th) =>
            {
                if (th.GetStackSize() == 1)
                {
                    object obj = Activator.CreateInstance(t);
                    th.PushValue(obj);
                    return(1);
                }
                // todo@om has bug, does not work
                foreach (var constructor in t.GetConstructors())
                {
                    object[] args      = null;
                    int[]    out_idxes = null;
                    bool     is_ok     = CheckMatchParams(th, constructor, out args, out out_idxes);
                    if (is_ok)
                    {
                        object obj = constructor.Invoke(args);
                        th.PushValue(obj);
                        return(1);
                    }
                }
                return(0);
            };

            return(cfunc);
        }
示例#5
0
        public static void InsertTreeNodesRecursively(TreeNode node, CFunction func)
        {
            string   time   = func.timeMS > 1000 ? string.Format("{0} s", func.timeMS / 1000.0) : string.Format("{0} ms", func.timeMS);
            TreeNode parent = node.Nodes.Add(func.callCount > 1 ? string.Format("{0} ({1}) ({2} calls)", func.name, time, func.callCount) :
                                             string.Format("{0} ({1})", func.name, time));

            parent.Tag = func;

            for (int i = 0; i < func.subFunctions.Count; ++i)
            {
                InsertTreeNodesRecursively(parent, func.subFunctions[i]);
            }

            int count = Math.Min(1, node.Nodes.Count);

            for (int i = 0; i < count; i++)
            {
                node.Nodes[i].BackColor = Color.PaleVioletRed;
            }

            count = Math.Min(2, node.Nodes.Count);
            for (int i = 1; i < count; i++)
            {
                node.Nodes[i].BackColor = Color.LightGoldenrodYellow;
            }
        }
示例#6
0
    // 获得水面基本高度实现
    public float GetWaterBaseHeight(float x, float z)
    {
        x -= CFunction.GetTerrainLeft();
        z -= CFunction.GetTerrainTop();

        return(InnerGetWaterBaseHeight(x, z));
    }
示例#7
0
        /// <summary>
        /// Analyse all function prototypes
        /// </summary>
        /// <param name="Cursor"></param>
        /// <returns></returns>
        public CElement CParser_VisitFunctionCursor(Cursor Cursor)
        {
            //first compute the md5 of the cursor and check if it already exist in database
            //if yes return the already created object
            string    md5 = CCodeFramework.Util.Util.ComputeMd5(Cursor);
            CFunction function;
            CElement  element = _DB.AstDB_FindElement(md5);

            if (element == null && Cursor.Kind != CursorKind.NoDeclFound)
            {
                function    = new CFunction();
                function.ID = md5;
                string fileName = Cursor.Location.File.Name.Replace('/', '\\');
                function.File          = fileName;
                function.Line          = Cursor.Location.Line;
                function.Column        = Cursor.Location.Column;
                function.ElementID     = CCodeFramework.Util.Util.ComputeElementMd5(Cursor);
                function.ElementKind   = ElementKind.Function;
                function.Name          = Cursor.Spelling;
                function.ProtoTypeHash = CCodeFramework.Util.Util.ComputeMd5(Cursor.ResultType);
                _DB.AstDB_AddElement(function);                                            //add the function object back to database
                CElement retur = _typeParser.CTypeParser_ParseDataType(Cursor.ResultType); //find the datatype of the return Type of the function
                function.ReturnType   = retur.ID;
                function.IsDefinition = Cursor.IsDefinition;

                function.StorageClass = (CCodeTypes.Types.StorageClass)Cursor.StorageClass;
                int argCount = Cursor.NumArguments;
                for (uint i = 0; i < argCount; i++)//iterate through all the arguments and find their name and type
                {
                    ClangSharp.Cursor cur = Cursor.GetArgument(i);
                    function.ProtoTypeHash += CCodeFramework.Util.Util.ComputeMd5(cur.Type);
                    function.Parameters.Add(CParser_VisitVariableCursor(cur));
                }
                var CalledFunctions = Cursor.Descendants.Where(x => x.Kind == CursorKind.CallExpr);//find all functions called from this function
                foreach (Cursor called in CalledFunctions)
                {
                    if (called.Referenced != null)                                                                                      //Referenced contain the original function cursor
                    {
                        if (called.Referenced.Location.File.Name != function.File && called.Referenced.Kind == CursorKind.FunctionDecl) //analyse only those functions which are not defined in the same file
                        {
                            function.Children.Add(CParser_VisitFunctionCursor(called.Referenced).ID);
                        }
                    }
                }
                return(function);
            }
            else
            {
                if (element is CFunction)//if already found in database check if that is of type Function
                {
                    function = element as CFunction;
                    return(function);
                }
                else
                {
                    return(null);
                }
            }
        }
示例#8
0
        static BuiltIns()
        {
            /* These aren't fully resolved; we need to use Cecil to load the appropriate .NET type defitinions in.
             * See ClrImporter.LoadBuiltins. */
            Variant   = new CClass("__Variant", null);
            Byte      = new CClass("Byte", false);
            String    = new CClass("String", true);
            Int32     = new CClass("Int32", true);
            Int64     = new CClass("Int64", true);
            Character = new CClass("Character", false);
            Boolean   = new CClass("Boolean", true);
            Date      = new CClass("Date", true);
            Double    = new CClass("Double", true);
            Object    = Variant;
            DbNull    = new CClass("DbNull", false);
            Nothing   = new CClass("Nothing", false);
            Nothing.Attributes.Add(CToken.Identifer(null, "ExecuteAnywhere"), new CTypeRef(null, CToken.Identifer(null, "ExecuteAnywhereAttribute")));
            Void = new CClass("__Void", false);
            FunctionPlaceHolder = new CClass("__FunctionPlaceHolder", false);
            FunctionPlaceHolder.Attributes.Add(CToken.Identifer(null, "ExecuteAnywhere"), new CTypeRef(null, CToken.Identifer(null, "ExecuteAnywhereAttribute")));
            SubPlaceHolder = new CClass("__SubPlaceHolder", false);
            SubPlaceHolder.Attributes.Add(CToken.Identifer(null, "ExecuteAnywhere"), new CTypeRef(null, CToken.Identifer(null, "ExecuteAnywhereAttribute")));

            SetupGlobalTypes();

            CArgumentList arrArgs = new CArgumentList();

            arrArgs.Add(new CArgument(CToken.Keyword(null, "byval"),
                                      CToken.Identifer(null, "arglist"),
                                      new CTypeRef(null, Variant)));
            Array = new CFunction(CToken.Identifer(null, "Array"), "Array", "array", TokenTypes.visPublic, FunctionType.Function,
                                  arrArgs, new CTypeRef(null, new CArrayType(new CTypeRef(null, Variant), 1)));
            Array.Attributes.Add(CToken.Identifer(null, "ExecuteAnywhere"), new CTypeRef(null, CToken.Identifer(null, "ExecuteAnywhereAttribute")));

            CArgumentList dicArgs = new CArgumentList();

            dicArgs.Add(new CArgument(CToken.Keyword(null, "byval"),
                                      CToken.Identifer(null, "arglist"),
                                      new CTypeRef(null, Variant)));
            Dictionary = new CFunction(CToken.Identifer(null, "Dictionary"), "Dictionary", "dictionary", TokenTypes.visPublic, FunctionType.Function,
                                       dicArgs, new CTypeRef(null, new CDictionaryType(new CTypeRef(null, Variant))));
            Dictionary.Attributes.Add(CToken.Identifer(null, "ExecuteAnywhere"), new CTypeRef(null, CToken.Identifer(null, "ExecuteAnywhereAttribute")));

            CArgumentList refArgs = new CArgumentList();

            refArgs.Add(new CArgument(CToken.Keyword(null, "byval"),
                                      CToken.Identifer(null, "func"),
                                      new CTypeRef(null, BuiltIns.String)));
            GetRef = new CFunction(CToken.Identifer(null, "GetRef"), "GetRef", "getref", TokenTypes.visPublic, FunctionType.Function, refArgs,
                                   new CTypeRef(null, BuiltIns.FunctionPlaceHolder));
            GetRef.Attributes.Add(CToken.Identifer(null, "ExecuteAnywhere"), new CTypeRef(null, CToken.Identifer(null, "ExecuteAnywhereAttribute")));

            // add string ienumerator interface
            CToken     ifaceName = CToken.Identifer(null, "System.Collections.Generic.IEnumerable`1<char>");
            CInterface iface     = new CInterface(ifaceName, ifaceName);

            iface.GenericParameters.Add(Character);
            String.AddInterface(new CTypeRef(null, iface));
        }
 protected internal virtual bool internalCanGenerate(CFunction function)
 {
     if (function.Attributes.contains("ExecuteOnClient"))
     {
         return(false);
     }
     return(true);
 }
示例#10
0
        public object CreateParameters(CArgument arg, ParameterInfo info)
        {
            if (arg is CFunction)
            {
                CFunction f = arg as CFunction;
                if (f.Name.Equals("null"))
                {
                    return(null);
                }
                if (info.ParameterType.BaseType == typeof(ValueType) || info.ParameterType.BaseType == typeof(Enum))
                {
                    return(CreateBase(f, info.ParameterType));
                }
                else if (info.ParameterType.BaseType == typeof(Array) && f.Name.Equals("a"))
                {
                    Array array = info.ParameterType.GetConstructors()[0].Invoke(new object[] { f.Arguments.Count }) as Array;
                    for (int i = 0; i < array.Length; i++)
                    {
                        if (f.Arguments[i] is CFunction)
                        {
                            object param = CreateBase(f.Arguments[i] as CFunction, info.ParameterType);
                            array.SetValue(param, i);
                        }
                    }
                    return(array);
                }
                else
                {
                    if (f.Name.Equals("ctor"))
                    {
                        CFunction target = f.Arguments[0] as CFunction;
                        int       index  = int.Parse(f.Arguments[1].Text);

                        if (!info.ParameterType.Name.Equals(f.Arguments[0]))
                        {
                            throw new EntryPointNotFoundException("Could not find Constructor for: " + info.ParameterType.Name);
                        }

                        ConstructorInfo constructor = info.ParameterType.GetConstructors()[index];
                        ParameterInfo[] infos       = constructor.GetParameters();
                        object[]        args        = new object[infos.Length];
                        for (int i = 0; i < infos.Length; i++)
                        {
                            args[i] = CreateParameters(target.Arguments[i], infos[i]);
                        }
                        return(constructor.Invoke(args));
                    }
                    else
                    {
                        throw new Exception("Could not handle CFunction");
                    }
                }
            }
            else
            {
                return((arg as CText)?.Text);
            }
        }
示例#11
0
    // 球体范围碰撞实现
    public bool TraceSphere(Vector3 _center, float radius)
    {
        Vector3 center = _center;

        center.x -= CFunction.GetTerrainLeft();
        center.z -= CFunction.GetTerrainTop();

        return(InnerTraceSphere(center, radius));
    }
示例#12
0
 public void VisitFunction(CFunction function)
 {
     if (canGenerate(function))
     {
         funcname = function.Name;
         visitor.VisitFunction(function);
         funcname = "";
     }
 }
示例#13
0
        public bool canGenerate(CFunction function)
        {
            if (function.Attributes.contains("ExecuteAtCompiler") ||
                (function.Class != null && function.Class.Attributes.contains("ExecuteAtCompiler")))
            {
                return(false);
            }

            return(internalCanGenerate(function));
        }
示例#14
0
        public string Fac_GetInterfaceName(CFunction function)
        {
            string name = Path.GetFileNameWithoutExtension(function.File);

            if (function.IsDefinition)
            {
                name = name + "_impl";
            }
            return(name);
        }
示例#15
0
        static BuiltIns()
        {
            /* These aren't fully resolved; we need to use Cecil to load the appropriate .NET type defitinions in.
               See ClrImporter.LoadBuiltins. */
            Variant = new CClass("__Variant", null);
            Byte = new CClass("Byte", false);
            String = new CClass("String", true);
            Int32 = new CClass("Int32", true);
            Int64 = new CClass("Int64", true);
            Character = new CClass("Character", false);
            Boolean = new CClass("Boolean", true);
            Date = new CClass("Date", true);
            Double = new CClass("Double", true);
            Object = Variant;
            DbNull = new CClass("DbNull", false);
            Nothing = new CClass("Nothing", false);
            Nothing.Attributes.Add(CToken.Identifer(null, "ExecuteAnywhere"), new CTypeRef(null, CToken.Identifer(null, "ExecuteAnywhereAttribute")));
            Void = new CClass("__Void", false);
            FunctionPlaceHolder = new CClass("__FunctionPlaceHolder", false);
            FunctionPlaceHolder.Attributes.Add(CToken.Identifer(null, "ExecuteAnywhere"), new CTypeRef(null, CToken.Identifer(null, "ExecuteAnywhereAttribute")));
            SubPlaceHolder = new CClass("__SubPlaceHolder", false);
            SubPlaceHolder.Attributes.Add(CToken.Identifer(null, "ExecuteAnywhere"), new CTypeRef(null, CToken.Identifer(null, "ExecuteAnywhereAttribute")));

            SetupGlobalTypes();

            CArgumentList arrArgs = new CArgumentList();
            arrArgs.Add(new CArgument(CToken.Keyword(null, "byval"),
                CToken.Identifer(null, "arglist"),
                new CTypeRef(null, Variant)));
            Array = new CFunction(CToken.Identifer(null, "Array"), "Array", "array", TokenTypes.visPublic, FunctionType.Function,
                arrArgs, new CTypeRef(null, new CArrayType(new CTypeRef(null, Variant), 1)));
            Array.Attributes.Add(CToken.Identifer(null, "ExecuteAnywhere"), new CTypeRef(null, CToken.Identifer(null, "ExecuteAnywhereAttribute")));

            CArgumentList dicArgs = new CArgumentList();
            dicArgs.Add(new CArgument(CToken.Keyword(null, "byval"),
                CToken.Identifer(null, "arglist"),
                new CTypeRef(null, Variant)));
            Dictionary = new CFunction(CToken.Identifer(null, "Dictionary"), "Dictionary", "dictionary", TokenTypes.visPublic, FunctionType.Function,
                dicArgs, new CTypeRef(null, new CDictionaryType(new CTypeRef(null, Variant))));
            Dictionary.Attributes.Add(CToken.Identifer(null, "ExecuteAnywhere"), new CTypeRef(null, CToken.Identifer(null, "ExecuteAnywhereAttribute")));

            CArgumentList refArgs = new CArgumentList();
            refArgs.Add(new CArgument(CToken.Keyword(null, "byval"),
                CToken.Identifer(null, "func"),
                new CTypeRef(null, BuiltIns.String)));
            GetRef = new CFunction(CToken.Identifer(null, "GetRef"), "GetRef", "getref", TokenTypes.visPublic, FunctionType.Function, refArgs,
                new CTypeRef(null, BuiltIns.FunctionPlaceHolder));
            GetRef.Attributes.Add(CToken.Identifer(null, "ExecuteAnywhere"), new CTypeRef(null, CToken.Identifer(null, "ExecuteAnywhereAttribute")));

            // add string ienumerator interface
            CToken ifaceName = CToken.Identifer(null, "System.Collections.Generic.IEnumerable`1<char>");
            CInterface iface = new CInterface(ifaceName, ifaceName);
            iface.GenericParameters.Add(Character);
            String.AddInterface(new CTypeRef(null, iface));
        }
示例#16
0
        public void HandleFunction(CFunction func, LightingConsole console)
        {
            switch (func.Name)
            {
            case "s":
            {
                //expected 2 args
                if (func.Arguments.Count != 2 || !(func.Arguments[0] is CFunction))
                {
                    throw new ArgumentException("Expected two Arguments");
                }

                CFunction f     = func.Arguments[0] as CFunction;
                int       index = int.Parse(func.Arguments[1].Text);
                Type      t     = RegisteredInstanceTypes.Find((x) => x.Name.Equals(f.Name));
                if (t is null)
                {
                    throw new NullReferenceException("Could not find Type");
                }

                ConstructorInfo constructor = t.GetConstructors()[index];
                ParameterInfo[] infos       = constructor.GetParameters();
                object[]        args        = new object[infos.Length];

                for (int i = 0; i < infos.Length; i++)
                {
                    args[i] = CreateParameters(f.Arguments[i], infos[i]);
                }
                object instance = constructor.Invoke(args);
                PreQuery?.Invoke();
                console.QueryAsync(instance as CPacket).Wait();

                break;
            }

            case "i":
            {
                if (func.Arguments.Count != 2)
                {
                    throw new ArgumentException("Expected two Arguments");
                }

                ushort num       = ushort.Parse(func.Arguments[0].Text);
                byte   intensity = byte.Parse(func.Arguments[1].Text);
                SK     sk        = console.Stromkreise[num];
                sk.Intensity = intensity;
                PreQuery?.Invoke();
                console.QueryAsync(new FixParDimmer(Enums.FixParDst.Current, sk)).Wait();

                break;
            }
            }
        }
示例#17
0
 public void SetFunctionUsers(string functionName, List <CUser> userList)
 {
     if (functionName != "XmlSettingFilePath")
     {
         m_Dba.DeleteAllPrivelegeForFunciton(functionName);
         List <CPrivilege> lstPrivilege = new List <CPrivilege>();
         CFunction         tmpFunc      = m_Dba.GetFunctionByName(functionName);
         foreach (CUser tmpUser in userList)
         {
             lstPrivilege.Add(new CPrivilege()
             {
                 CFunctionId = tmpFunc.Id, CUserId = tmpUser.Id
             });
         }
         m_Dba.SaveAllPrivelege(lstPrivilege);
     }
     else
     {
         CSetting tmpSetting = m_Setting.GetXmlSettingFilePath();
         if (tmpSetting != null)
         {
             List <string> lstUserID        = new List <string>();
             string        tmpDirectoryName = (new System.IO.FileInfo(tmpSetting.Value)).DirectoryName;
             GetDirectorySecurity(tmpDirectoryName,
                                  FileSystemRights.FullControl,
                                  AccessControlType.Allow,
                                  ref lstUserID);
             // add new fullcontrol access permision
             foreach (CUser tmpUser in userList)
             {
                 if (!lstUserID.Exists(tmp => tmp == tmpUser.Id))
                 {
                     AddDirectorySecurity(tmpDirectoryName,
                                          "SF\\" + tmpUser.Id,
                                          FileSystemRights.FullControl,
                                          AccessControlType.Allow);
                 }
             }
             // remove useless fullcontrol access permision
             foreach (string tmpUserId in lstUserID)
             {
                 if (!userList.Exists(tmp => tmp.Id == tmpUserId))
                 {
                     RemoveDirectorySecurity(tmpDirectoryName,
                                             "SF\\" + tmpUserId,
                                             FileSystemRights.FullControl,
                                             AccessControlType.Allow);
                 }
             }
         }
     }
 }
示例#18
0
 public CLambdaFunction(CToken token, CFunction containingFunction, CFile containingFile, String name, CTypeRef tref,
                        CArgumentList args)
     : base(token, name, name, TokenTypes.visInternal, FunctionType.Function, args, tref)
 {
     this.containingFunction = containingFunction;
     this.containingFile = containingFile;
     if (this.containingFunction != null)
         this.containingFunction.Lambdas.Add(this);
     else
         this.containingFile.Lambdas.Add(this);
     CallCount++;
     Attributes.Add(CToken.Identifer(null, "ExecuteAnywhere"), new CTypeRef(null, CToken.Identifer(null, "ExecuteAnywhereAttribute")));
 }
示例#19
0
    public bool TraceDetail(Vector3 _src, Vector3 _dst, ref RaycastHit[] hits, ref int hit_count)
    {
        Vector3 src = _src;
        Vector3 dst = _dst;

        src.x -= CFunction.GetTerrainLeft();
        src.z -= CFunction.GetTerrainTop();

        dst.x -= CFunction.GetTerrainLeft();
        dst.z -= CFunction.GetTerrainTop();

        return(InnerTraceDetail(src, dst, ref hits, ref hit_count));
    }
示例#20
0
    // 碰撞测试是否有阻挡实现
    public bool TraceHitted(Vector3 _src, Vector3 _dst)
    {
        Vector3 src = _src;
        Vector3 dst = _dst;

        src.x -= CFunction.GetTerrainLeft();
        src.z -= CFunction.GetTerrainTop();

        dst.x -= CFunction.GetTerrainLeft();
        dst.z -= CFunction.GetTerrainTop();

        return(InnerTraceHitted(src, dst));
    }
示例#21
0
        public void Loop(string cmd, LightingConsole console)
        {
            CArgument a = ParseString(cmd);

            if (a is CText)
            {
                throw new Exception("No Function in Command");
            }
            else
            {
                CFunction func = a as CFunction;
                HandleFunction(func, console);
            }
        }
示例#22
0
        public DALViewModel(IRegionManager regionManager, IXmlCompareUserControl UserControl)
        {
            _regionManager = regionManager;
            m_UserControl  = UserControl;
            CancelCommand  = new DelegateCommand(CancelExecute);
            ToCommand      = new DelegateCommand(ToCommandExecute);
            FromCommand    = new DelegateCommand(FromCommandExecute);
            OkCommand      = new DelegateCommand(OkCommandExecute);
            List <CFunction> lstFunc = m_UserControl.GetFunctions();

            foreach (CFunction tmp in lstFunc)
            {
                Function.Add(tmp);
            }
            m_CurrentFunction = null;
        }
示例#23
0
 public void OkCommandExecute()
 {
     m_UserControl.SetFunctionUsers(m_CurrentFunction.Name, m_ListAuthUser.ToList());
     m_CurrentFunction = null;
     if (SelectedUser != null)
     {
         m_CurrentFunction = SelectFunc;
         //get users
         m_ListAuthUser = new ObservableCollection <CUser>(m_UserControl.GetFunctionUsers(m_CurrentFunction.Name, true));
         m_ListUser     = new ObservableCollection <CUser>(m_UserControl.GetFunctionUsers(m_CurrentFunction.Name, false));
         //bind data
         ReBindAuthoData(m_ListAuthUser);
         ReBindData(m_ListUser);
     }
     MessageBox.Show("Setting has been submitted.");
 }
示例#24
0
        public Function Fac_GetXmlFunctionType(CFunction f)
        {
            Function ft = new Function();

            ft.Name         = f.Name;
            ft.ID           = f.ID;
            ft.File         = f.File;
            ft.Column       = f.Column.ToString();
            ft.Line         = f.Line.ToString();
            ft.StorageClass = f.StorageClass.ToString();
            ft.IsDefinition = f.IsDefinition;
            ft.ReturnIDRef  = f.ReturnType;
            foreach (CVariable v in f.Parameters)
            {
                ft.Parameters.Add(Fac_GetXmlVariableType(v));
            }
            return(ft);
        }
示例#25
0
        private void leftNavigationTabs_SelectedIndexChanged(object sender, EventArgs e)
        {
            this.mainSplit.Panel2.Controls.Clear( );
            if (leftNavigationTabs.SelectedItem == this.myDocPage ||
                leftNavigationTabs.SelectedItem == this.archiveTab ||
                leftNavigationTabs.SelectedItem == this.shareSpaceTab ||
                leftNavigationTabs.SelectedItem == this.orgManageTab)
            {
                DirTree dirTree = (DirTree)leftNavigationTabs.SelectedItem.Controls [0];
                ActiveRigthPanel(dirTree.FileListUI);
            }
            else if (leftNavigationTabs.SelectedItem == this.systemPage)
            {
                CFunction func = sysFunctionTree.SelectedFunction;
                if (func != null && func.Ui != null)
                {
                    ActiveRigthPanel(func.Ui);
                }
            }
            else if (leftNavigationTabs.SelectedItem == this.myInfoPage)
            {
                CFunction func = myinfofunctionTree.SelectedFunction;
                if (func != null && func.Ui != null)
                {
                    ActiveRigthPanel(func.Ui);
                }
            }

            //删除由于备份产生的临时文件夹——赵英武
            if (leftNavigationTabs.SelectedItem != systemPage)
            {
                string path = (string)Context.Session["temperoryFolder"];
                if (System.IO.Directory.Exists(path))
                {
                    COrganizeEntity org      = new COrganizeEntity().Load(_currentUser.Usr_Organize);
                    string          filePath = path + @"\" + org.Org_Name + ".zip";
                    System.IO.File.Delete(filePath);
                    System.IO.Directory.Delete(path);
                    Context.Session["temperoryFolder"] = "";
                }
            }
        }
示例#26
0
        public void add(CFunction func)
        {
            if (func.Class == null)
            {
                funcs[func.Name] = func;
                funcs[func.FunctionAlias.ToLower()] = func;
            }
            switch (func.FunctionType)
            {
                case CFunction.vbPropertySet:
                case CFunction.vbSub:
                    break;

                case CFunction.vbPropertyGet:
                case CFunction.vbFunction:
                default:
                    func.scope.add(func.Name, func);
                    break;
            }
        }
示例#27
0
        public CFunctionType(CToken token, CFunction function, bool declarationOnly)
            : base(token, function.TypeSignature)
        {
            target = function;
            this.declarationOnly = declarationOnly;

            CMethod method = new CMethod(function);
            DefaultMember = method;

            function.TypeChanged += new EventHandler(function_TypeChanged);
            foreach (CArgument arg in function.Arguments)
                arg.TypeChanged += new EventHandler(function_TypeChanged);

            this.IsSealed = true;

            // we don't actually want people accessing the default method directly
            // we also don't want it to get visited through the type.
            // so we don't do this: Members.Add(function.Name, method);
            Attributes.Add(CToken.Identifer(null, "ExecuteAnywhere"), new CTypeRef(null, CToken.Identifer(null, "ExecuteAnywhereAttribute")));
        }
示例#28
0
        private static CFunction ReadFunctionFromXML(XmlNode functionRootNode, CFunction parent)
        {
            // Read function info
            string    name         = functionRootNode.Attributes.GetNamedItem("name").Value;
            int       callCount    = Convert.ToInt32(functionRootNode.Attributes.GetNamedItem("callCount").Value);
            float     timeMS       = Single.Parse(functionRootNode.Attributes.GetNamedItem("tMS").Value);
            CFunction functionInfo = new CFunction(name, timeMS, 0, 0, "", parent);

            functionInfo.callCount = callCount;
            if (parent != null)
            {
                parent.subFunctions.Add(functionInfo);
            }

            foreach (XmlNode subFunctionNode in functionRootNode)
            {
                ReadFunctionFromXML(subFunctionNode, functionInfo);
            }

            return(functionInfo);
        }
        internal CStatementBlock StartInitialize(CFunction containingFunction, CFile containingFile, CTypeRef tref, CArgumentList args)
        {
            if (lambdaFunction != null)
                throw new InvalidOperationException("Lambdas can only be initalized once");

            CClass @class = null;
            string extra = "";
            if (containingFunction != null)
            {
                @class = containingFunction.Class;
                extra += containingFunction.RawName;
            }

            lambdaFunction =
                new CLambdaFunction(Token, containingFunction, containingFile, "Lambda_" + extra + "_" + lambdaId, tref, args);
            base.LoadType(lambdaType = new CFunctionType(Token, lambdaFunction, false));

            lambdaFunction.Class = @class;

            return lambdaFunction.Statements;
        }
示例#30
0
        private object CreateBase(CFunction f, Type t)
        {
            string a = f.Arguments[0].Text;

            switch (f.Name)
            {
            case "e":
            {
                return(Enum.Parse(t, a));
            }

            case "b":
            {
                return(byte.Parse(a));
            }

            case "i":
            {
                return(int.Parse(a));
            }

            case "d":
            {
                return(double.Parse(a));
            }

            case "s":
            {
                return(short.Parse(a));
            }

            case "us":
            {
                return(ushort.Parse(a));
            }

            default:
                throw new ArgumentException("Could not find " + f.Name);
            }
        }
示例#31
0
        void OpCallCFunction(CFunction cfunc, int func_idx, int arg_count)
        {
            SetMaxUsedStackIdx(func_idx + OmsConf.MAX_CFUNC_ARG_COUNT);

            _cfunc_register_idx = func_idx + 1;
            // call c function
            int ret_count = cfunc(this);

            // copy result to stack
            int src = _active_top - ret_count;
            int dst = func_idx;

            if (src != dst)
            {
                for (int i = 0; i < ret_count; ++i)
                {
                    _stack[dst + i] = _stack[src + i];
                }
                _active_top = dst + ret_count;
            }
            _stack[_active_top] = null;
            // coroutine.resume use it to tell father how many args pass to resume
            _cfunc_register_idx = func_idx;
        }
 public void VisitFunction(CFunction function)
 {
     if (canGenerate(function))
     {
         funcname = function.Name;
         visitor.VisitFunction(function);
         funcname = "";
     }
 }
示例#33
0
 private void Form1_Load(object sender, EventArgs e)
 {
     mFunction = new CFunction(mParser, "Soundfunc", "");
 }
示例#34
0
 public bool canAssign(CClass currentclass, CFunction currentfunction)
 {
     return false;
 }
示例#35
0
 public CMethod(CFunction func)
     : base(func.Token, func.Name, "method", 1, false)
 {
     Declared[0] = func;
     function = func;
 }
 /// <summary>
 /// AddFunction(CFunction): This member accepts a function object and
 ///		adds it to the compilers set of functions.
 /// </summary>
 /// <param name="oFunc">CFunction object that implements a functionality extension for the compiler.</param>
 public void AddFunction(CFunction oFunc)
 {
     m_slFunctions.Add( oFunc.GetFunction(), oFunc );
 }
示例#37
0
 public string GetFlywayFileName(CFunction function)
 {
     return($"{FlywayVersionNumber}__Create_Function_{function.Schema.SchemaName}_{function.FunctionName}.sql");
 }
示例#38
0
        /// <summary>
        /// Evaluates parenthesis in the equation and insures they are handled properly according to the Order of Operations.
        /// Because this is last in the chain, it also evaluates Variable and Function names.
        /// </summary>
        /// <returns>CValue object that holds an operation.</returns>
        private CValue Paren()
        {
            bool   isFunction = false;
            CValue value      = null;

            if (_currentToken == null)
            {
                throw new InvalidEquationException("Unexpected end of equation (are you missing an operator argument?).");
            }

            if (_currentToken.ToString() == "(")
            {
                NextToken();

                value = Or();

                if (string.Equals(_currentToken, ","))
                {
                    return(value);
                }
            }
            else
            {
                switch (_currentToken.TokenType)
                {
                case TokenType.Number:
                    value = new CNumber(_currentToken.ToString());
                    break;

                case TokenType.Letter:
                    if (string.Equals(_nextToken, "("))
                    {
                        if (!_functions.ContainsKey(_currentToken.ToString()))
                        {
                            throw new InvalidFunctionException(_currentToken.ToString());
                        }

                        CFunction function   = _functions[_currentToken.ToString()];
                        var       parameters = new List <CValue>();

                        do
                        {
                            NextToken();

                            try
                            {
                                value = Paren();
                            }
                            catch (InvalidEquationException)
                            {
                                throw new ArgumentCountException(parameters.Count);
                            }

                            parameters.Add(value);
                        }while (string.Equals(_currentToken, ","));

                        isFunction = true;

                        value = function.SetParameters(parameters);

                        if (string.Equals(_currentToken, ")") && parameters.Count > 1)
                        {
                            NextToken();
                        }
                    }
                    else
                    {
                        value = GetVariableByName(_currentToken.ToString());
                    }

                    break;
                }
            }

            if (!isFunction)
            {
                NextToken();
            }

            return(value);
        }
        public void VisitFile(CFile file)
        {
            if (!canGenerate(file))
                return;

            visitor.PreVisitFile(file);

            filenamesrc = file.Token;

            new CNewline(null).Accept(visitor);

            if (instrument)
            {
                COption cCodeCoverage =
                    new COption(new CToken(file.Filename, TokenTypes.keyword, "option"),
                                new CToken(file.Filename, TokenTypes.keyword, "include"),
                                new CToken(file.Filename, TokenTypes.str, "cCodeCoverage.asp"));
                cCodeCoverage.Accept(this);
            }

            visitor.VisitFile(file);

            if (file.Attributes.contains("GenerateProcessAjaxFunction"))
            {
                CFunction unicoderequest = CProgram.Global.FindFunction("unicoderequest");
                CFunction intrequest = CProgram.Global.FindFunction("intrequest");
                CFunction boolrequest = CProgram.Global.FindFunction("boolrequest");

                CToken tok = CreateTokenWithAdditionalInfo("ProcessAjax", "processajax", TokenTypes.identifier);
                CFunction processAjax =
                    new CFunction(tok, tok.RawValue, tok.Value, TokenTypes.visPublic, CFunction.vbSub, null,
                                  new CTypeRef(null, BuiltIns.Void));

                CAccess pivotitem = new CAccess(unicoderequest.Token, unicoderequest.Token);
                pivotitem.ReferenceTarget = unicoderequest;
                CParameters pivotparams = new CParameters();
                pivotparams.Unnamed.Add(
                    new CConstantExpression(CreateTokenWithAdditionalInfo("sFunction", TokenTypes.str)));
                CSelect select =
                    new CSelect(CreateTokenWithAdditionalInfo("select", TokenTypes.controlFlow),
                                new CDefaultAccess(pivotitem.Token, pivotitem, pivotparams));

                IEnumerator it = CProgram.Global.Functions.GetEnumerator();
                List<CVariable> vars = new List<CVariable>();
                while (it.MoveNext())
                {
                    CFunction func = (CFunction)it.Current;
                    if (!func.Attributes.contains("ExecuteOnServer"))
                        continue;

                    CStatementBlock block = new CStatementBlock();
                    CParameters funcParams = new CParameters();
                    for (int ixArg = 0; ixArg < func.Arguments.Count - 3; ixArg++)
                    {
                        CArgument arg = func.Arguments[ixArg];

                        tok =
                            CreateTokenWithAdditionalInfo("vParam" + (ixArg + 1), "vparam" + (ixArg + 1),
                                                          TokenTypes.identifier);
                        if (ixArg >= vars.Count)
                            vars.Add(new CVariable(tok, false, new CTypeRef(null, BuiltIns.Variant), null, null, null));

                        CAssignment assign = new CAssignment(tok);

                        CAccess left = new CAccess(tok, tok);
                        left.ReferenceTarget = vars[ixArg];
                        assign.Target = left;
                        funcParams.Unnamed.Add(left);

                        CFunction rightfunc = intrequest;
                        if (arg.Type.RawName == "Boolean")
                            rightfunc = boolrequest;
                        else if (arg.Type.RawName == "String")
                            rightfunc = unicoderequest;

                        CParameters parameters = new CParameters();
                        parameters.Unnamed.Add(
                            new CConstantExpression(CreateTokenWithAdditionalInfo(tok.RawValue, TokenTypes.str)));

                        CAccess rightitem = new CAccess(rightfunc.Token, rightfunc.Token);
                        rightitem.ReferenceTarget = rightfunc;

                        assign.Source = new CDefaultAccess(rightfunc.Token, rightitem, parameters);
                        assign.Source.RhsAssignmentSource = true;

                        block.Add(assign);
                    }

                    CAccess calledItem = new CAccess(func.Token, func.Token);
                    CDefaultAccess called = new CDefaultAccess(func.Token, calledItem, funcParams);
                    calledItem.ReferenceTarget = calledItem.ReferenceTarget = func;

                    if (func.Attributes.contains("picture") || func.FunctionType == CFunction.vbFunction)
                    {
                        CAccess returnItem = new CAccess(processAjax.Token, processAjax.Token);
                        returnItem.ReferenceTarget = processAjax;

                        CAssignment assign = new CAssignment(processAjax.Token);
                        assign.Target = returnItem;

                        if (func.FunctionType == CFunction.vbFunction)
                            assign.Source = called;
                        else
                            assign.Source = new CPictureOfExpression(tok, called);

                        block.Add(assign);
                    }
                    else
                        block.Add(new CExpressionStatement(called));

                    tok = CreateTokenWithAdditionalInfo("case", TokenTypes.controlFlow);
                    CExpression exp =
                        new CConstantExpression(CreateTokenWithAdditionalInfo(func.RawName, TokenTypes.str));
                    select.Cases.Add(new CCase(tok, exp, block));
                }

                CDim dim = new CDim(CreateTokenWithAdditionalInfo("Dim", TokenTypes.declaration));
                dim.Variables.AddRange(vars);
                processAjax.Statements.Add(dim);
                processAjax.Statements.Add(select);

                CNewline nl = new CNewline(CreateTokenWithAdditionalInfo("\n", TokenTypes.newline));
                nl.Accept(this);
                processAjax.Accept(this);
                nl.Accept(this);
            }
        }
 public void ExitFunction(CFunction function)
 {
     foreach (var item in functionInterceptors)
         item.ExitFunction(function, this);
 }
示例#41
0
 public void incAccessCount(CClass currentclass, CFunction currentfunction)
 {
     accesses++;
 }
示例#42
0
 public void incAssignmentCount(CClass currentclass, CFunction currentfunction)
 {
     throw new Exception("Const variable is readonly");
 }
        private static List <CFunction> ParseCFunctionsFromBindingFile(string pFile)
        {
            List <CFunction> functions = new List <CFunction>();
            StreamReader     SR        = new StreamReader(pFile);

            while (!SR.EndOfStream)
            {
                string line = SR.ReadLine().Trim();
                if (line.StartsWith("ConsoleMethod(") ||
                    line.StartsWith("ConsoleMethodWithDocs(") ||
                    line.StartsWith("ConsoleStaticMethod(") ||
                    line.StartsWith("ConsoleStaticMethodWithDocs(") ||
                    line.StartsWith("ConsoleFunction(") ||
                    line.StartsWith("ConsoleFunctionWithDocs(") ||
                    line.StartsWith("ConsoleNamespaceFunction("))
                {
                    Match matches =
                        Regex.Matches(line,
                                      "Console(?:Static|Namespace)?(Method|Function)(?:WithDocs)?\\s*\\(\\s*(?:([a-zA-Z0-9_]+)[\\s,]+)?([a-zA-Z0-9_:\\* ]+)\\s*,\\s*(?:[a-zA-Z_][\\sa-zA-Z0-9:_ \\*]+\\s*,)?\\s*([0-9]+)\\s*,\\s*([0-9a-zA-Z: +]+)")
                        [0];
                    string functionName = null;
                    if (matches.Groups[1].Value.Equals("Method"))
                    {
                        functionName = matches.Groups[3].Value;
                        functionName = functionName[0].ToString().ToUpper() + functionName.Substring(1);
                        functionName = matches.Groups[2].Value + functionName;
                        consoleMethodList.Add(functionName);
                    }
                    if (matches.Groups[1].Value.Equals("Function"))
                    {
                        if (line.StartsWith("ConsoleNamespaceFunction("))
                        {
                            functionName = matches.Groups[3].Value;
                            functionName = functionName[0].ToString().ToUpper() + functionName.Substring(1);
                            consoleFunctionList.Add(functionName);
                        }
                        else
                        {
                            functionName = matches.Groups[2].Value;
                            functionName = functionName[0].ToString().ToUpper() + functionName.Substring(1);
                            consoleFunctionList.Add(functionName);
                        }
                    }
                    if (!matches.Groups[4].Value.Equals(matches.Groups[5].Value))
                    {
                        overloadedFunctionList.Add(functionName);
                    }
                }
                if (line.StartsWith("DLL_PUBLIC"))
                {
                    Match matches =
                        Regex.Matches(line,
                                      "DLL_PUBLIC ([a-zA-Z\\* _0-9:<>]+) ([a-zA-Z\\* _0-9:]+)\\(\\s*(?:([a-zA-Z\\* _0-9:]+)[\\s,]*)*\\s*\\)")
                        [0];
                    CFunction function = new CFunction(matches.Groups[1].Value, matches.Groups[2].Value,
                                                       matches.Groups[3].Captures);
                    StringBuilder bodyBuilder = new StringBuilder();
                    int           indentation = 0;
                    while ((line = SR.ReadLine()) != null)
                    {
                        if (line.Contains("}"))
                        {
                            indentation--;
                        }
                        if (indentation != 0)
                        {
                            bodyBuilder.AppendLine(line);
                        }
                        if (line.Contains("{"))
                        {
                            indentation++;
                        }
                        if (indentation == 0)
                        {
                            break;
                        }
                    }
                    function.FunctionBody = bodyBuilder.ToString();
                    functions.Add(function);
                }
            }
            SR.Close();
            return(functions);
        }
 protected internal virtual bool internalCanGenerate(CFunction function)
 {
     if (function.Attributes.contains("ExecuteOnClient"))
         return false;
     return true;
 }
示例#45
0
        private void MainForm_Load(object sender, EventArgs e)
        {
            //this.Menu = mainMenu1;
            _currentUser = (CUserEntity)Context.Session["CurrentUser"];

            try
            {
                myDirTree.CurrentUser         = _currentUser;
                myDirTree.RootResourceId      = _currentUser.Usr_Resource;
                archiveDirTree.CurrentUser    = _currentUser;
                archiveDirTree.RootResourceId = _currentUser.GetUserOrganize().Org_ArchiveRes;
                _myFileList.CurrentUser       = _currentUser;
                _archiveFileLst.CurrentUser   = _currentUser;
                shareDirTree.CurrentUser      = _currentUser;
                shareDirTree.Helper           = new ShareHelpClass();
                _shareFileList.CurrentUser    = _currentUser;
                _userList.CurrentUser         = _currentUser;
                _groupList.CurrentUser        = _currentUser;
                _userUpdate.CurrentUser       = _currentUser;
                _myApply.CurrentUser          = _currentUser;
                _auditeApply.CurrentUser      = _currentUser;

                orgMgerDirTree.CurrentUser    = _currentUser;
                orgMgerDirTree.RootResourceId = _currentUser.GetUserOrganize().Org_Resource;
                _orgMgerList.CurrentUser      = _currentUser;

                _orgMemo.CurrentUser = _currentUser;
                _mailSet.CurrentUser = _currentUser;

                // Create resource clipboard and save in session
                ResourceClip clipBoard = new ResourceClip();
                Context.Session["ResourceClipBoard"] = clipBoard;

                //系统管理
                List <CFunction> systemFunctions = new List <CFunction>();
                CFunction        function        = new CFunction();
                function.Name  = "备份";
                function.Ui    = _orgMemo;
                function.Image = new IconResourceHandle("save.gif");
                systemFunctions.Add(function);

                function       = new CFunction();
                function.Name  = "用户管理";
                function.Image = new IconResourceHandle("member.png");
                function.Ui    = _userList;
                systemFunctions.Add(function);

                function       = new CFunction();
                function.Name  = "用户组管理";
                function.Image = new IconResourceHandle("member.png");
                function.Ui    = _groupList;
                systemFunctions.Add(function);


                function       = new CFunction();
                function.Name  = "系统配置";
                function.Image = new IconResourceHandle("properties.gif");
                function.Ui    = _mailSet;
                systemFunctions.Add(function);
                this.sysFunctionTree.FunctionList = systemFunctions;
                this.sysFunctionTree.TreeEvent   += FunctionTreeEventHandler;

                //我的信息
                List <CFunction> myinfoFunctions = new List <CFunction>();
//                 function = new CFunction();
//                 function.Name = "安全信息";
//                 function.Image = new IconResourceHandle("importantmail.gif");
//                 myinfoFunctions.Add(function);

//                 function = new CFunction();
//                 function.Name = "其它信息";
//                 function.Image = new IconResourceHandle("member.gif");
//                 myinfoFunctions.Add(function);

                function       = new CFunction();
                function.Name  = "修改个人资料";
                function.Image = new IconResourceHandle("member.gif");
                function.Ui    = _userUpdate;
                myinfoFunctions.Add(function);

                function       = new CFunction();
                function.Name  = "审核归档申请";
                function.Image = new IconResourceHandle("member.gif");
                function.Ui    = _auditeApply;
                CACLEntity acl = new CACLEntity();
                acl.Acl_Operation = (int)ACLOPERATION.AUDITAPPLY;
                acl.Acl_Resource  = _currentUser.Usr_Organize;
                if (_currentUser.CheckPrivilege(acl) == true)
                {
                    myinfoFunctions.Add(function);
                }

                function       = new CFunction();
                function.Name  = "我的归档申请";
                function.Image = new IconResourceHandle("member.gif");
                function.Ui    = _myApply;
                myinfoFunctions.Add(function);

                this.myinfofunctionTree.FunctionList = myinfoFunctions;
                this.myinfofunctionTree.TreeEvent   += FunctionTreeEventHandler;

                //我的文档
                // myDirTree.RootDir = Context.Server.MapPath("~/App_Data");
                //myDirTree.RootDir = Context.Server.MapPath("~/"+ConfigurationManager.AppSettings["Userdata"]);
                myDirTree.RootDir = ConfigurationManager.AppSettings["UserData"];
                myDirTree.Init();
                myDirTree.FileListUI   = _myFileList;
                myDirTree.TreeEvent   += DirTreeEventHandler;
                myDirTree.SearchEvent += DirTreeSearchEventHandler;

                //共享空间

                /*
                 * List<CFunction> shareSpaceFunctionList = new List<CFunction>();
                 * function = new CFunction();
                 * function.Name = "我共享给他人的文档";
                 * function.Image = new IconResourceHandle("folders.gif");
                 * shareSpaceFunctionList.Add(function);
                 * function = new CFunction();
                 * function.Name = "他人共享给我的文档";
                 * function.Image = new IconResourceHandle("folders.gif");
                 * shareSpaceFunctionList.Add(function);
                 * shareSpacefunctionTree.FunctionList = shareSpaceFunctionList;
                 */
                shareDirTree.Init();
                shareDirTree.FileListUI   = _shareFileList;
                shareDirTree.TreeEvent   += DirTreeEventHandler;
                shareDirTree.SearchEvent += DirTreeSearchEventHandler;

                //归档区
                //archiveDirTree.RootDir = Context.Server.MapPath("~/App_Data");
                archiveDirTree.RootDir = ConfigurationManager.AppSettings["UserData"];
                archiveDirTree.Init();
                archiveDirTree.FileListUI   = _archiveFileLst;
                archiveDirTree.TreeEvent   += DirTreeEventHandler;
                archiveDirTree.SearchEvent += DirTreeSearchEventHandler;

                //组织管理——赵英武
                // orgMgerDirTree.RootDir = Context.Server.MapPath("~/App_Data");
                orgMgerDirTree.RootDir = ConfigurationManager.AppSettings["UserData"];
                orgMgerDirTree.Init();
                orgMgerDirTree.FileListUI   = _orgMgerList;
                orgMgerDirTree.TreeEvent   += DirTreeEventHandler;
                orgMgerDirTree.SearchEvent += DirTreeSearchEventHandler;

                systemPage.Image    = new IconResourceHandle("24X24.applications.gif");
                myInfoPage.Image    = new IconResourceHandle("24X24.behaviors.gif");
                myDocPage.Image     = new IconResourceHandle("24X24.controls.gif");
                shareSpaceTab.Image = new IconResourceHandle("24X24.sharedspace.gif");
                archiveTab.Image    = new IconResourceHandle("24X24.folders.gif");
                orgManageTab.Image  = new IconResourceHandle("24X24.orgAdmin.gif");

                // only administrator can see system admin page
                if (_currentUser.Usr_Type != (int)USERTYPE.ORGANIZEADMIN &&
                    _currentUser.Usr_Type != (int)USERTYPE.SYSTEMADMIN)
                {
                    leftNavigationTabs.Controls.Remove(systemPage);
                }
                //only orgnizeAdministrator can see orgnize admin page
                if (_currentUser.Usr_Type != (int)USERTYPE.ORGANIZEADMIN)
                {
                    leftNavigationTabs.Controls.Remove(orgManageTab);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("系统错误:" + ex.Message, "文档管理系统", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
        public bool canGenerate(CFunction function)
        {
            if (function.Attributes.contains("ExecuteAtCompiler") ||
                (function.Class != null && function.Class.Attributes.contains("ExecuteAtCompiler")))
                return false;

            return internalCanGenerate(function);
        }
示例#47
0
 public CProperty(CProperty property, bool isUnionMember)
     : base(property.Token, property.Name, "property", 3, isUnionMember)
 {
     Declared[ixGet] = m_get = property.m_get;
     Declared[ixSet] = m_set = property.m_set;
 }
示例#48
0
 public CMethod(CMethod method, bool isUnionMember)
     : base(method.Token, method.Name, "method", 1, isUnionMember)
 {
     Declared[0] = function = method.function;
 }