1 46 package org.codehaus.groovy.ast.expr; 47 48 import groovy.lang.Closure; 49 50 import org.codehaus.groovy.ast.GroovyCodeVisitor; 51 import org.codehaus.groovy.ast.Parameter; 52 import org.codehaus.groovy.ast.VariableScope; 53 import org.codehaus.groovy.ast.stmt.Statement; 54 import org.codehaus.groovy.classgen.AsmClassGenerator2; 55 import org.codehaus.groovy.runtime.InvokerHelper; 56 57 58 65 public class ClosureExpression extends Expression { 66 67 private Parameter[] parameters; 68 private Statement code; 69 private VariableScope variableScope; 70 71 public ClosureExpression(Parameter[] parameters, Statement code) { 72 this.parameters = parameters; 73 this.code = code; 74 super.setTypeClass(Closure.class); 75 } 76 77 public void visit(GroovyCodeVisitor visitor) { 78 visitor.visitClosureExpression(this); 79 } 80 81 public Expression transformExpression(ExpressionTransformer transformer) { 82 return this; 83 } 84 85 public String toString() { 86 return super.toString() + InvokerHelper.toString(parameters) + "{ " + code + " }"; 87 } 88 89 public Statement getCode() { 90 return code; 91 } 92 93 public Parameter[] getParameters() { 94 return parameters; 95 } 96 97 public boolean isParameterSpecified() { 98 return parameters != null && parameters.length > 0; 99 } 100 101 public VariableScope getVariableScope() { 102 return variableScope; 103 } 104 105 public void setVariableScope(VariableScope variableScope) { 106 this.variableScope = variableScope; 107 } 108 109 protected void resolveType(AsmClassGenerator2 resolver) { 110 } 112 113 } 114 | Popular Tags |