Exemplo n.º 1
0
        public void AddClass(Type type)
        {
            var mod = new Module();

            mod.CMod          = new CModule();
            mod.CMod.BaseName = type.Name;
            foreach (var prop in type.GetProperties())
            {
                if (type.GetProperty(prop.Name, System.Reflection.BindingFlags.Public | System.Reflection.BindingFlags.Static) != null)
                {
                    mod.CMod.StaticProps.Add(prop.Name);
                }
                else
                {
                    mod.CMod.Props.Add(prop.Name);
                }
            }
            mod.CMod.CType = type;
            Mods.Add(mod);
            Var cvar = new Var();

            cvar.Name  = type.Name;
            cvar.Value = mod;
            SystemScope.RegisterVar(cvar);
        }
Exemplo n.º 2
0
        public dynamic ExecuteMethod(StructModule cls, string func, dynamic[] pars)
        {
            foreach (var f in cls.Methods)
            {
                if (f.FuncName == func)
                {
                    if (pars != null)
                    {
                        if (f.Pars.Pars.Count != pars.Length)
                        {
                            continue;
                        }
                    }
                    else
                    {
                        if (f.Pars != null)
                        {
                            if (f.Pars.Pars.Count != 0)
                            {
                                continue;
                            }
                        }
                    }
                    int ii = 0;
                    var ns = new CodeScope("func_pars");

                    if (pars != null)
                    {
                        foreach (var p in pars)
                        {
                            var rp = f.Pars.Pars[ii];

                            ns.RegisterVar(rp);
                            rp.Value = p;
                            ii++;
                        }
                    }
                    PushScope(SystemScope);
                    PushScope(cls.InstanceScope);
                    PushScope(ns);
                    return(f.Code.Exec());

                    PopScope();
                    PopScope();
                    PopScope();
                    return(null);
                }
            }
            return(null);
        }