示例#1
0
 public LoxFunction(Expr.Lambda decl, Environment enclosure, bool isIn)
 {
     declaration   = new Statement.function(decl.keyword, decl._params, decl.body);
     closure       = enclosure;
     isInitializer = isIn;
     isGet         = false;
 }
示例#2
0
        public object visitLambdaFunction(Expr.Lambda lambdaFunction)
        {
            FunctionType enclosingFunction = currentFunction;

            currentFunction = FunctionType.FUNCTION;
            beginScope();
            foreach (Token _param in lambdaFunction._params)
            {
                declare(_param);
                define(_param);
            }
            resolve(lambdaFunction.body);
            endScope();
            currentFunction = enclosingFunction;
            return(null);
        }
示例#3
0
 public string visitCallExpr(Expr.Call call)
 {
     Expr[] expressions = new Expr[call.expressionArguments.Count];
     for (int i = 0; i < call.expressionArguments.Count; i++)
     {
         if (call.expressionArguments[i] is Expr)
         {
             expressions[i] = (Expr)call.expressionArguments[i];
         }
         else if (call.expressionArguments[i] is Statement.function)
         {
             Statement.function lambda = (Statement.function)call.expressionArguments[i];
             expressions[i] = new Expr.Lambda(lambda.name, lambda._params, lambda.body);
         }
     }
     return(parenthesize(call.callee.ToString(), expressions));
 }
示例#4
0
 public string visitLambdaFunction(Expr.Lambda lambdaFunction)
 {
     return(parenthesize(lambdaFunction.keyword.lexeme, new Expr[] { }));
 }
示例#5
0
        public object visitLambdaFunction(Expr.Lambda lambdaFunction)
        {
            LoxFunction function = new LoxFunction(lambdaFunction, environment, false);

            return(function); //If the function is lambda
        }