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; }
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); }
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)); }
public string visitLambdaFunction(Expr.Lambda lambdaFunction) { return(parenthesize(lambdaFunction.keyword.lexeme, new Expr[] { })); }
public object visitLambdaFunction(Expr.Lambda lambdaFunction) { LoxFunction function = new LoxFunction(lambdaFunction, environment, false); return(function); //If the function is lambda }