/// <summary>
        /// Wraps a new function definition, so that the function can be registered as a Lua function with the relevant
        /// CodeContext. This allows the function to benefit from custom execution environments.
        /// </summary>
        public FunctionDefinitionExpression(CodeContext context, LuaScope scope, IEnumerable<string> identifiers, LambdaExpression function)
        {
            _context = context;
            _scope = scope;
            _body = function;

            _identifier = identifiers.Merge((s1, s2) => s1 + "." + s2);
        }
        /// <summary>
        /// Creates a wrapper around a function which represents entry into its scope
        /// </summary>
        /// <param name="context">The context under which this function is compiled</param>
        /// <param name="body">The block expression which represents this function's execution</param>
        /// <param name="evalScope">The scope in which the body will be executed, holding local values</param>
        /// <param name="upScope">The scope in which the function will execute, storing up values (which persist between calls)</param>
        public FunctionScopeExpression(CodeContext context, LuaScope evalScope, LuaScope upScope, string identifier, Expression body)
        {
            _context = Expression.Constant(context);
            _body = body;
            _stack = Expression.Constant(new FunctionStack(context, upScope, evalScope, identifier));

            _evalScope = evalScope;
            _upScope = upScope;
        }
        /// <summary>
        /// Creates a wrapper around a function which represents entry into its scope
        /// </summary>
        /// <param name="context">The context under which this function is compiled</param>
        /// <param name="body">The block expression which represents this function's execution</param>
        /// <param name="evalScope">The scope in which the body will be executed, holding local values</param>
        /// <param name="upScope">The scope in which the function will execute, storing up values (which persist between calls)</param>
        public FunctionScopeExpression(Expression context, LuaScope evalScope, LuaScope upScope, string identifier, Expression body)
        {
            _context = context;
            _body = body;

            _evalScope = evalScope;
            _upScope = upScope;

            _stack = Expression.New(NewFunctionStack, context, Expression.Constant(evalScope, typeof(LuaScope)), Expression.Constant(upScope, typeof(LuaScope)), Expression.Constant(identifier));
        }
Exemple #4
0
 /// <summary>
 /// Creates a wrapper around a block of code representing entry in a scope's domain, and the subsequent exit
 /// </summary>
 public static Expr Scope(CodeContext context, LuaScope scope, Expression body)
 {
     return new ScopeExpression(context, scope, body).Reduce();
 }
Exemple #5
0
 /// <summary>
 /// Creates a wrapper around a function which represents entry into its scope
 /// </summary>
 /// <param name="context">The context under which this function is compiled</param>
 /// <param name="body">The block expression which represents this function's execution</param>
 /// <param name="evalScope">The scope in which the body will be executed, holding local values</param>
 /// <param name="upScope">The scope in which the function will execute, storing up values (which persist between calls)</param>
 public static Expr FunctionScope(Expr context, LuaScope evalScope, LuaScope upScope, string identifier, Expr body)
 {
     return new FunctionScopeExpression(context, evalScope, upScope, identifier, body).Reduce();
 }
Exemple #6
0
 /// <summary>
 /// Creates a wrapper around a function which represents entry into its scope
 /// </summary>
 /// <param name="context">The context under which this function is compiled</param>
 /// <param name="body">The block expression which represents this function's execution</param>
 /// <param name="evalScope">The scope in which the body will be executed, holding local values</param>
 /// <param name="upScope">The scope in which the function will execute, storing up values (which persist between calls)</param>
 public static Expr FunctionScope(CodeContext context, LuaScope evalScope, LuaScope upScope, IEnumerable<string> identifiers, Expr body)
 {
     return new FunctionScopeExpression(context, evalScope, upScope, identifiers, body).Reduce();
 }
Exemple #7
0
 /// <summary>
 /// Wraps a new function definition, so that the function can be registered as a Lua function with the relevant
 /// CodeContext. This allows the function to benefit from custom execution environments.
 /// </summary>
 public static Expr FunctionDefinitionExpression(CodeContext context, LuaScope scope, IEnumerable<string> identifiers, LambdaExpression function)
 {
     return new FunctionDefinitionExpression(context, scope, identifiers, function).Reduce();
 }
        private readonly LuaScope _scope; //The scope that is being entered and exited from

        #endregion Fields

        #region Constructors

        /// <summary>
        /// Creates a wrapper around a block of code representing entry in a scope's domain, and the subsequent exit
        /// </summary>
        public ScopeExpression(CodeContext context, LuaScope scope, Expression body)
        {
            _context = context;
            _body = body;
            _scope = scope;
        }