/* ************************************************************************
Visitor methods for expressions
***********************************************************************
511760
public void visitApply(JCMethodInvocation tree) {
        setTypeAnnotationPositions(tree.pos);
        // Generate code for method.
        Item m = genExpr(tree.meth, methodType);
        // Generate code for all arguments, where the expected types are
        // the parameters of the method's external type (that is, any implicit
        // outer instance of a super(...) call appears as first parameter).
        MethodSymbol msym = (MethodSymbol)TreeInfo.symbol(tree.meth);
        genArgs(tree.args,
                msym.externalType(types).getParameterTypes());
        if (!msym.isDynamic()) {
            code.statBegin(tree.pos);
        }
        result = m.invoke();
    }
604635
@Override
    public void visit(NodeVisitor v) {
        if (v.visit(this)) {
            if (expression != null) {
                expression.visit(v);
            }
            if (statements != null) {
                for (AstNode s : statements) {
                    s.visit(v);
                }
            }
        }
    }
623397
function (expr, cb, joinCond) {
            expr = (isUndefined(expr) || isNull(expr) || (Array.isArray(expr) && !expr.length)) ? null : expr;
            if (expr && cb) {
                return new BooleanExpression(joinCond || "AND", this._filterExpr(expr, null, joinCond), this._filterExpr(cb, null, joinCond));
            } else if (cb) {
                expr = cb;
            }
            if (isInstanceOf(expr, Expression)) {
                if (isInstanceOf(expr, NumericExpression, StringExpression)) {
                    throw new QueryError("Invalid SQL Expression type : " + expr);
                }
                return expr;
            } else if (Array.isArray(expr)) {
                if (expr.length) {
                    var first = expr[0];
                    if (isString(first)) {
                        return new PlaceHolderLiteralString(first, expr.slice(1), true);
                    } else if (Expression.isConditionSpecifier(expr)) {
                        return BooleanExpression.fromValuePairs(expr, joinCond);
                    } else {
                        return BooleanExpression.fromArgs([joinCond || "AND"].concat(expr.map(function (e) {
                            return this._filterExpr(e, null, "AND");
                        }, this)));
                    }
                }
            } else if (isFunction(expr)) {
                return this._filterExpr(expr.call(sql, sql), null, joinCond);
            } else if (isBoolean(expr)) {
                return new BooleanExpression("NOOP", expr);
            } else if (isString(expr)) {
                return this.stringToIdentifier(expr);
            } else if (isInstanceOf(expr, LiteralString)) {
                return new LiteralString("(" + expr + ")");
            } else if (isHash(expr)) {
                return BooleanExpression.fromValuePairs(expr, joinCond);
            } else {
                throw new QueryError("Invalid filter argument");
            }
        }
999700
private void visitParentExpression(AbstractFunctionExpression parentExpr) {

        if (nextFunctionBodyStart == null) {
            nextFunctionBodyStart = parentExpr;
        }

        if (currentFunctionName != null) {
            updateCurrentFunction(parentExpr);
        } else {
            createFunctionIfNeeded(parentExpr);
        }

        if (GremlinQueryOptimizer.isOrExpression(parentExpr)) {
            //reset
            currentFunctionName = null;
            //don't include 'or' in generated functions
            nextFunctionBodyStart = null;
        }

    }
1320129
function visitEvalCallExpressions(traverse, node, path, state) {
    utils.catchup(node.range[1], state, function(value) {
      if(optimizeFunction(node.callee.name)) {
        // Unpack the id
        var id = extractId(node.callee.name);
        // Create path and object call
        var pathDeclaration = f('var path_%s = %s;\n', id, transformedFileData1.code.substring(node.arguments[0].range[0], node.arguments[0].range[1]));
        var objectDeclaration = f('var object_%s = %s;\n', id, transformedFileData1.code.substring(node.arguments[1].range[0], node.arguments[1].range[1]));

        // Get the function code
        var code = functions[node.callee.name].code;

        // Replace path and object in source
        var functionSource = code
          .replace(/object/g, f('object_%s', id))
          .replace(/path/g, f('path_%s', id))
          .replace(/return errors\;/, '');

        // Return the in-lined function
        return f('%s\n%s\n%s', objectDeclaration, pathDeclaration, functionSource);
      } else if(!skipTopLevelOptimization && ast.type == 'object' && node.callee.name === f('object_validation_%s', ast.id)) {
        return '';
      } else {
        return value;
      }
    });
  }
189646
@Override
  protected void visitSoyNode(SoyNode node) {
    if (isComputableAsJsExprsVisitor.exec(node)) {
      // Simply generate JS expressions for this node and add them to the current output var.
      jsCodeBuilder.addChunksToOutputVar(genJsExprsVisitor.exec(node));

    } else {
      // Need to implement visit*Node() for the specific case.
      throw new UnsupportedOperationException("implement visit*Node for" + node.getKind());
    }
  }
145180
private void evaluateExpressions() throws JspException {
        Integer tempInt = null;

        if (dataSourceEL != null) {
            rawDataSource = (Object) ExpressionEvaluatorManager.evaluate(
                    "dataSource", dataSourceEL, Object.class, this, pageContext);
        }

        if (sqlEL != null) {
            sql = (String) ExpressionEvaluatorManager.evaluate("sql", sqlEL,
                    String.class, this, pageContext);
        }

        if (startRowEL != null) {
            tempInt = (Integer) ExpressionEvaluatorManager.evaluate(
                    "startRow", startRowEL, Integer.class, this, pageContext);
            if (tempInt != null) {
                startRow = tempInt.intValue();
            }
        }

        if (maxRowsEL != null) {
            tempInt = (Integer) ExpressionEvaluatorManager.evaluate(
                    "maxRows", maxRowsEL, Integer.class, this, pageContext);
            if (tempInt != null) {
                maxRows = tempInt.intValue();
            }
        }
    }
856152
public void visitVariableExpression(VariableExpression expression) {
        String variableName = expression.getName();

        //-----------------------------------------------------------------------
        // SPECIAL CASES

        // "this" for static methods is the Class instance
        ClassNode classNode = controller.getClassNode();
        //if (controller.isInClosure()) classNode = controller.getOutermostClass();

        if (variableName.equals("this")) {
            if (controller.isStaticMethod() || (!controller.getCompileStack().isImplicitThis() && controller.isStaticContext())) {
                if (controller.isInClosure()) classNode = controller.getOutermostClass();
                visitClassExpression(new ClassExpression(classNode));
            } else {
                loadThis(expression);
            }
            return;
        }

        // "super" also requires special handling
        if (variableName.equals("super")) {
            if (controller.isStaticMethod()) {
                visitClassExpression(new ClassExpression(classNode.getSuperClass()));
            } else {
                loadThis(expression);
            }
            return;
        }

        BytecodeVariable variable = controller.getCompileStack().getVariable(variableName, false);
        if (variable == null) {
            processClassVariable(variableName);
        } else {
            controller.getOperandStack().loadOrStoreVariable(variable, expression.isUseReferenceDirectly());
        }
        if (!controller.getCompileStack().isLHS()) controller.getAssertionWriter().record(expression);
    }
768874
@Override
    public void visit(NodeVisitor v) {
        if (v.visit(this)) {
            expression.visit(v);
            for (SwitchCase sc: getCases()) {
                sc.visit(v);
            }
        }
    }
84440
def apply_visitor(self, Visitor):
        
        expressions = self.expressions
        v = [Visitor(e).result() for e in expressions]
        return [item for sublist in v for item in sublist]
336269
def visit_and_update_expressions(self, visitor_fn):
        """"""
        new_predicate = self.predicate.visit_and_update(visitor_fn)
        if new_predicate is not self.predicate:
            return Filter(new_predicate)
        else:
            return self
1102688
@Override
  protected void visitLetValueNode(LetValueNode node) {

    String generatedVarName = node.getUniqueVarName();

    // Generate code to define the local var.
    Expression value = translateExpr(node.getExpr());
    jsCodeBuilder.append(VariableDeclaration.builder(generatedVarName).setRhs(value).build());

    // Add a mapping for generating future references to this local var.
    templateTranslationContext
        .soyToJsVariableMappings()
        .put(node.getVarName(), id(generatedVarName));
  }
1305927
function visit (node, visitor) {
  if (Array.isArray(node)) {
    visitor(node);
    node.forEach(function (node) { visit(node, visitor) });
  }
}
458459
def make_replacement_visitor(find_expression, replace_expression):
    """"""
    def visitor_fn(expression):
        """Return the replacement if this expression matches the expression we're looking for."""
        if expression == find_expression:
            return replace_expression
        else:
            return expression

    return visitor_fn
293481
function visitor(parent) {
    var index = -1
    var children = parent && parent.children

    if (!children) {
      throw new Error('Missing children in `parent` for `visitor`')
    }

    while (++index in children) {
      callback(children[index], index, parent)
    }
  }
844712
function () {
                var entities = [], e, delim;

                do {
                    e = this.addition() || this.entity();
                    if (e) {
                        entities.push(e);
                        // operations do not allow keyword "/" dimension (e.g. small/20px) so we support that here
                        if (!peek(/^\/[\/*]/)) {
                            delim = $char('/');
                            if (delim) {
                                entities.push(new(tree.Anonymous)(delim));
                            }
                        }
                    }
                } while (e);
                if (entities.length > 0) {
                    return new(tree.Expression)(entities);
                }
            }
312275
@Override
  protected Expression visitVarRefNode(VarRefNode node) {
    Expression translation = variableMappings.maybeGet(node.getName());
    if (translation != null) {
      // Case 1: In-scope local var.
      return translation;
    } else {
      // Case 2: Data reference.
      return genCodeForParamAccess(node.getName(), node.getDefnDecl());
    }
  }