Beispiel #1
0
 public static void PushScope(CodeScope scope)
 {
     if (Main.Scopes.Count != 0)
     {
         scope.OutterScope = Main.Scopes.Peek( );
     }
     else
     {
         scope.OutterScope = null;
     }
     Main.Scopes.Push(scope);
 }
Beispiel #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);
        }