public virtual Expression visit(FunctionLiteral literal) { write("function "); if (literal.name != null) { literal.name.visitExpression(this); } write('('); for (int i = 0; i < literal.parameters.Length; i++) { if (i > 0) { write(", "); } literal.parameters[i].visitExpression(this); } write(") {"); increaseIndent(); visitStatementArray(literal.statements); decreaseIndent(); writeIndent(); write("}"); return(literal); }
public static FunctionLiteral[] vectorToFunctionLiteralArray(ArrayList vector) { FunctionLiteral[] literalArray = new FunctionLiteral[vector.Count]; vector.CopyTo(literalArray); return(literalArray); }
public override Expression visit(FunctionLiteral literal) { Console.WriteLine(this + " visit #1 to " + literal); new TraversalVisitor(new FooTraversal(this)).visit(literal); Console.WriteLine(this + " visit #2 to " + literal); return(literal); }
public override Expression visit(FunctionLiteral literal) { ArrayList oldFunctionVector = functionVector; ArrayList oldVariableVector = variableVector; bool oldHasWithStatement = hasWithStatement; bool oldHasArgumentsVariable = hasArgumentsVariable; functionVector = new ArrayList(); variableVector = new ArrayList(); hasWithStatement = false; hasArgumentsVariable = false; hasFunctionLiteral = false; Identifier[] parameters = literal.parameters; for (int i = 0; i < parameters.Length; i++) { addVariable(parameters[i]); } literal = (FunctionLiteral)base.visit(literal); literal.functions = CompilerUtil.vectorToStatementArray(functionVector); literal.variables = CompilerUtil.vectorToIdentifierArray(variableVector); // if this function literal: // * contains a function literal // * contains a 'with' statement // * contains a reference to 'arguments' // // then we need to disable the "access locals by index" optimisation for // this function literal. literal.enableLocalsOptimization = !(hasWithStatement | hasArgumentsVariable | hasFunctionLiteral); functionVector = oldFunctionVector; variableVector = oldVariableVector; hasWithStatement = oldHasWithStatement; hasArgumentsVariable = oldHasArgumentsVariable; hasFunctionLiteral = true; return(literal); }
public virtual Expression visit(FunctionLiteral literal) { write("function literal"); return(literal); }
public override Expression visit(FunctionLiteral literal) { return(literal.visitExpression(new FooVisitor())); }