コード例 #1
0
  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();
  }
コード例 #2
0
 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());
 }
コード例 #3
0
 private void declare(Parameter[] parameters, ASTNode node) {
   for (Parameter parameter : parameters) {
     if (parameter.hasInitialExpression()) {
       parameter.getInitialExpression().visit(this);
     }
     declare(parameter, node);
   }
 }
コード例 #4
0
 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());
     }
   }
 }
コード例 #5
0
ファイル: GrailsASTUtils.java プロジェクト: erdi/grails-core
 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;
 }