示例#1
0
 private LuaScope(CodeContext context)
 {
     this.context = context;
     this.parent = null;
     this.variables = new Dictionary<string, ParamExpr>();
     this.labels = new Dictionary<string, LabelTarget>();
 }
示例#2
0
 private LuaScope(LuaScope parent)
 {
     this.context = parent.context;
     this.parent = parent;
     this.variables = new Dictionary<string, ParamExpr>();
     this.labels = new Dictionary<string, LabelTarget>();
 }
示例#3
0
 public static LuaScope CreateRoot(ParamExpr dlrGlobals)
 {
     Contract.Requires(dlrGlobals != null);
     var scope = new LuaScope();
     scope.dlrGlobals = dlrGlobals;
     scope.labels.Add(ReturnLabelName, Expr.Label(typeof(object)));
     return scope;
 }
示例#4
0
 public static LuaScope CreateChildFrom(LuaScope parent)
 {
     var scope = new LuaScope(parent);
     LabelTarget breakLabel;
     if (parent.labels.TryGetValue(BreakLabelName, out breakLabel))
         scope.labels.Add(BreakLabelName, breakLabel);
     return scope;
 }
 private void _RegisterFunction(Delegate function, LuaScope scope)
 {
     if (!_FunctionScopes.ContainsKey(function))
         _FunctionScopes.Add(function, scope);
     else
         _FunctionScopes[function] = scope;
 }
 private void _OnScopeEnter(LuaScope scope)
 {
     //accessStackExpectedSize.Push(variableAccessStack.Count);
 }
        private IDynamicMetaObjectProvider _GetExecutionEnvironment(LuaScope scope)
        {
            LuaScope current = scope;
            while (current != null && !HasCustomEnvironment(current))
                current = current.GetParent();

            if (current != null)
                return GetFunctionEnvironment(current) ?? ExecutingScopeStorage;

            return ExecutingScopeStorage;
        }
 internal static Expr RegisterFunction(CodeContext context, Expression function, LuaScope scope)
 {
     return CallBackingMethod("_RegisterFunction", context, function, Expr.Constant(scope));
 }
示例#9
0
 public FunctionStack(CodeContext context, LuaScope upScope, LuaScope execScope, IEnumerable<string> identifiers)
     : this(context, upScope, execScope, Flatten(identifiers, "."))
 {
 }
示例#10
0
        public FunctionStack(CodeContext context, LuaScope upScope, LuaScope execScope, string identifier)
        {
            ContractUtils.Requires(context != null);

            Context = context;
            UpScope = upScope;
            ExecScope = execScope;

            if (UpScope != null)
                UpValueNames = UpScope.GetLocalNames().ToArray();

            if (ExecScope != null)
                LocalVariableNames = ExecScope.GetLocalNames().ToArray();

            if (ExecScope != null && ExecScope.LocalsCount > 0)
                Locals = new Stack<VariableAccess>();
            else
                Locals = null;

            Identifier = identifier;

            LocalVariableNames = null;
            LocalVariables = null;
            UpValueNames = null;
            UpValues = null;
        }
示例#11
0
 public void UpdateCurrentEvaluationScope(LuaScope scope)
 {
     CurrentEvaluationScope = scope;
 }
示例#12
0
 public static Expression MakeUpdateCurrentEvaluationScope(LuaContext context, LuaScope scope)
 {
     return Expression.Block(
         Expression.Call(Expression.Constant(context.Trace), UpdateCurrentEvaluationScopeMethodInfo, Expression.Constant(scope)),
         Expression.Call(Expression.Constant(context.Trace), UpdateScopeStorageMethodInfo, scope.GetDlrGlobals()));
 }
示例#13
0
 public static LuaScope CreateFunctionChildFrom(LuaScope parent)
 {
     var scope = new LuaScope(parent);
     scope.labels.Add(ReturnLabelName, Expr.Label(typeof(object)));
     return scope;
 }
示例#14
0
 public static LuaScope CreateRoot(CodeContext context)
 {
     Contract.Requires(context != null);
     var scope = new LuaScope(context);
     scope.labels.Add(ReturnLabelName, Expr.Label(typeof(object)));
     return scope;
 }
 internal static Expr GetExecutionEnvironment(CodeContext context, LuaScope scope)
 {
     return CallBackingMethod("_GetExecutionEnvironment", context, Expr.Constant(scope));
 }
 internal static Expr OnScopeEnter(CodeContext context, LuaScope scope)
 {
     return CallBackingMethod("_OnScopeEnter", context, Expr.Constant(scope));
 }
示例#17
0
        public FunctionStack(string identifier)
        {
            Identifier = identifier;

            Context = null;
            UpScope = null;
            ExecScope = null;
            UpValues = null;
            UpValueNames = null;
            LocalVariables = null;
            LocalVariableNames = null;
            Locals = null;
        }