public void visitClosureExpression(ClosureExpression expression) { pushState(); expression.setVariableScope(currentScope); if (expression.isParameterSpecified()) { Parameter[] parameters = expression.getParameters(); for (Parameter parameter : parameters) { parameter.setInStaticContext(currentScope.isInStaticContext()); if (parameter.hasInitialExpression()) { parameter.getInitialExpression().visit(this); } declare(parameter, expression); } } else if (expression.getParameters() != null) { Parameter var = new Parameter(ClassHelper.OBJECT_TYPE, "it"); var.setInStaticContext(currentScope.isInStaticContext()); currentScope.putDeclaredVariable(var); } super.visitClosureExpression(expression); markClosureSharedVariables(); popState(); }
private static FieldNode createFieldCopy(ClassNode buildee, Parameter param) { Map<String, ClassNode> genericsSpec = createGenericsSpec(buildee); extractSuperClassGenerics(param.getType(), buildee, genericsSpec); ClassNode correctedParamType = correctToGenericsSpecRecurse(genericsSpec, param.getType()); return new FieldNode( param.getName(), ACC_PRIVATE, correctedParamType, buildee, param.getInitialExpression()); }
private void declare(Parameter[] parameters, ASTNode node) { for (Parameter parameter : parameters) { if (parameter.hasInitialExpression()) { parameter.getInitialExpression().visit(this); } declare(parameter, node); } }
private void memorizeInitialExpressions(final MethodNode node) { // add node metadata for default parameters because they are erased by the Verifier if (node.getParameters() != null) { for (Parameter parameter : node.getParameters()) { parameter.putNodeMetaData( StaticTypesMarker.INITIAL_EXPRESSION, parameter.getInitialExpression()); } } }
private static Parameter[] copyParameters(Parameter[] parameterTypes) { Parameter[] newParameterTypes = new Parameter[parameterTypes.length]; for (int i = 0; i < parameterTypes.length; i++) { Parameter parameterType = parameterTypes[i]; Parameter newParameter = new Parameter( nonGeneric(parameterType.getType()), parameterType.getName(), parameterType.getInitialExpression()); newParameter.addAnnotations(parameterType.getAnnotations()); newParameterTypes[i] = newParameter; } return newParameterTypes; }