org.codehaus.groovy.classgen
Class ClassGenerator

java.lang.Object
  extended byorg.codehaus.groovy.ast.CodeVisitorSupport
      extended byorg.codehaus.groovy.classgen.ClassGenerator
All Implemented Interfaces:
org.objectweb.asm.Constants, GroovyClassVisitor, GroovyCodeVisitor

public class ClassGenerator
extends CodeVisitorSupport
implements GroovyClassVisitor, org.objectweb.asm.Constants

Generates Java class versions of Groovy classes

Version:
$Revision: 1.184 $
Author:
James Strachan

Field Summary
 
Fields inherited from interface org.objectweb.asm.Constants
AALOAD, AASTORE, ACC_ABSTRACT, ACC_BRIDGE, ACC_DEPRECATED, ACC_ENUM, ACC_FINAL, ACC_INTERFACE, ACC_NATIVE, ACC_PRIVATE, ACC_PROTECTED, ACC_PUBLIC, ACC_STATIC, ACC_STRICT, ACC_SUPER, ACC_SYNCHRONIZED, ACC_SYNTHETIC, ACC_TRANSIENT, ACC_VARARGS, ACC_VOLATILE, ACONST_NULL, ALOAD, ANEWARRAY, ARETURN, ARRAYLENGTH, ASTORE, ATHROW, BALOAD, BASTORE, BIPUSH, CALOAD, CASTORE, CHECKCAST, D2F, D2I, D2L, DADD, DALOAD, DASTORE, DCMPG, DCMPL, DCONST_0, DCONST_1, DDIV, DLOAD, DMUL, DNEG, DREM, DRETURN, DSTORE, DSUB, DUP, DUP_X1, DUP_X2, DUP2, DUP2_X1, DUP2_X2, F2D, F2I, F2L, FADD, FALOAD, FASTORE, FCMPG, FCMPL, FCONST_0, FCONST_1, FCONST_2, FDIV, FLOAD, FMUL, FNEG, FREM, FRETURN, FSTORE, FSUB, GETFIELD, GETSTATIC, GOTO, I2B, I2C, I2D, I2F, I2L, I2S, IADD, IALOAD, IAND, IASTORE, ICONST_0, ICONST_1, ICONST_2, ICONST_3, ICONST_4, ICONST_5, ICONST_M1, IDIV, IF_ACMPEQ, IF_ACMPNE, IF_ICMPEQ, IF_ICMPGE, IF_ICMPGT, IF_ICMPLE, IF_ICMPLT, IF_ICMPNE, IFEQ, IFGE, IFGT, IFLE, IFLT, IFNE, IFNONNULL, IFNULL, IINC, ILOAD, IMUL, INEG, INSTANCEOF, INVOKEINTERFACE, INVOKESPECIAL, INVOKESTATIC, INVOKEVIRTUAL, IOR, IREM, IRETURN, ISHL, ISHR, ISTORE, ISUB, IUSHR, IXOR, JSR, L2D, L2F, L2I, LADD, LALOAD, LAND, LASTORE, LCMP, LCONST_0, LCONST_1, LDC, LDIV, LLOAD, LMUL, LNEG, LOOKUPSWITCH, LOR, LREM, LRETURN, LSHL, LSHR, LSTORE, LSUB, LUSHR, LXOR, MONITORENTER, MONITOREXIT, MULTIANEWARRAY, NEW, NEWARRAY, NOP, POP, POP2, PUTFIELD, PUTSTATIC, RET, RETURN, SALOAD, SASTORE, SIPUSH, SWAP, T_BOOLEAN, T_BYTE, T_CHAR, T_DOUBLE, T_FLOAT, T_INT, T_LONG, T_SHORT, TABLESWITCH
 
Constructor Summary
ClassGenerator(GeneratorContext context, org.objectweb.asm.ClassVisitor classVisitor, ClassLoader classLoader, String sourceFile)
           
 
Method Summary
protected  void addFieldsToVisitor(VariableScope scope)
           
protected  boolean addInnerClass(ClassNode innerClass)
           
protected  boolean argumentsUseStack(Expression arguments)
           
protected  String checkForQualifiedClass(PropertyExpression expression)
          Checks if the given property expression represents a fully qualified class name
protected  String checkValidType(String type, ASTNode node, String message)
           
protected  Type checkValidType(Type type, ASTNode node, String message)
           
protected  boolean comparisonExpression(Expression expression)
           
protected  ClassNode createClosureClass(ClosureExpression expression)
           
protected  ClassNode createGStringClass(GStringExpression expression)
           
protected  Expression createReturnLHSExpression(Expression expression)
          For assignment expressions, return a safe expression for the LHS we can use to return the value
protected  Expression createReusableExpression(Expression expression)
           
protected  void createSyntheticStaticFields()
           
protected  String createVariableName(String type)
           
protected  Variable defineVariable(String name, String type)
          Defines the given variable in scope and assigns it to the stack
protected  Variable defineVariable(String name, String type, boolean define)
           
protected  void doConvertAndCast(String type)
           
protected  void doConvertAndCast(String type, Expression expression)
          Casts to the given type unless it can be determined that the cast is unnecessary
protected  boolean emptyArguments(Expression arguments)
           
protected  void evaluateBinaryExpression(MethodCaller compareMethod, BinaryExpression expression)
           
protected  void evaluateBinaryExpression(String method, BinaryExpression expression)
           
protected  void evaluateBinaryExpressionWithAsignment(String method, BinaryExpression expression)
           
protected  void evaluateCompareTo(BinaryExpression expression)
           
protected  void evaluateEqual(BinaryExpression expression)
           
protected  void evaluateExpression(Expression expression)
           
protected  void evaluateInstanceof(BinaryExpression expression)
           
protected  void evaluateLogicalAndExpression(BinaryExpression expression)
           
protected  void evaluateLogicalOrExpression(BinaryExpression expression)
           
protected  void evaluatePostfixMethod(String method, Expression expression)
           
protected  void evaluatePrefixMethod(String method, Expression expression)
           
protected  void findMutableVariables()
           
protected  ConstructorNode findSuperConstructor(MethodCallExpression call)
          Attempts to find the constructor in a super class
protected  MethodNode findSuperMethod(MethodCallExpression call)
          Attempts to find the method of the given name in a super class
protected  boolean firstStatementIsSuperInit(Statement code)
           
 ClassLoader getClassLoader()
           
protected  Parameter[] getClosureSharedVariables(ClosureExpression expression)
           
protected  CompileUnit getCompileUnit()
           
protected  String getExpressionType(Expression expression)
           
 LinkedList getInnerClasses()
           
protected  String getLHSType(Expression leftExpression)
          Deduces the type name required for some casting
protected  ClassNode getOutermostClass()
           
protected  VariableScope getVariableScope()
           
protected  String getVariableType(String name)
           
protected  boolean isFieldOrVariable(String name)
           
protected  boolean isGroovyObject(Expression objectExpression)
           
protected  boolean isHolderVariable(Expression expression)
           
protected  boolean isInClosureConstructor()
           
protected  boolean isInScriptBody()
           
protected  boolean isNonStaticField(Expression expression)
           
protected  boolean isNotFieldOfOutermostClass(String var)
           
protected  boolean isPopRequired(Expression expression)
           
protected  boolean isPrimitiveFieldType(String type)
           
protected  boolean isStaticMethod()
           
protected  boolean isThisExpression(Expression expression)
           
protected  boolean isValidTypeForCast(String type)
           
protected  void loadArguments(Parameter[] parameters, Expression expression)
          Loads and coerces the argument values for the given method call
protected  Class loadClass(String name)
           
protected  void loadThisOrOwner()
          Loads either this object or if we're inside a closure then load the top level owner
protected  void onLineNumber(ASTNode statement)
           
protected  void popScope()
           
protected  void processFieldAccess(String name, FieldNode field, int steps)
           
protected  void processPropertyVariable(String name, Variable variable)
           
protected  void processStackVariable(String name, Variable variable)
           
protected  void pushBlockScope()
           
protected  void resetVariableStack(Parameter[] parameters)
           
protected  String resolveClassName(String type)
           
protected  void visitAndAutobox(Expression expression)
           
 void visitArrayExpression(ArrayExpression expression)
           
 void visitAssertStatement(AssertStatement statement)
           
 void visitBinaryExpression(BinaryExpression expression)
           
 void visitBooleanExpression(BooleanExpression expression)
           
 void visitBreakStatement(BreakStatement statement)
           
 void visitCaseStatement(CaseStatement statement)
           
 void visitCaseStatement(CaseStatement statement, int switchVariableIndex, org.objectweb.asm.Label thisLabel, org.objectweb.asm.Label nextLabel)
           
 void visitCastExpression(CastExpression expression)
           
 void visitClass(ClassNode classNode)
           
 void visitClassExpression(ClassExpression expression)
           
 void visitClosureExpression(ClosureExpression expression)
           
 void visitConstantExpression(ConstantExpression expression)
          Generate byte code for constants
 void visitConstructor(ConstructorNode node)
           
 void visitConstructorCallExpression(ConstructorCallExpression call)
           
 void visitContinueStatement(ContinueStatement statement)
           
 void visitDoWhileLoop(DoWhileStatement loop)
           
 void visitExpressionStatement(ExpressionStatement statement)
           
 void visitField(FieldNode fieldNode)
           
 void visitFieldExpression(FieldExpression expression)
           
 void visitForLoop(ForStatement loop)
           
 void visitGStringExpression(GStringExpression expression)
           
 void visitIfElse(IfStatement ifElse)
           
 void visitListExpression(ListExpression expression)
           
 void visitMapEntryExpression(MapEntryExpression expression)
           
 void visitMapExpression(MapExpression expression)
           
 void visitMethod(MethodNode node)
           
 void visitMethodCallExpression(MethodCallExpression call)
           
 void visitNegationExpression(NegationExpression expression)
           
 void visitNotExpression(NotExpression expression)
           
protected  void visitOuterFieldExpression(FieldExpression expression, ClassNode outerClassNode, int steps, boolean first)
           
protected  void visitParameter(ASTNode node, Parameter parameter)
           
protected  void visitParameters(ASTNode node, Parameter[] parameters)
           
 void visitPostfixExpression(PostfixExpression expression)
           
 void visitPrefixExpression(PrefixExpression expression)
           
 void visitProperty(PropertyNode statement)
          Creates a getter, setter and field
 void visitPropertyExpression(PropertyExpression expression)
           
 void visitRangeExpression(RangeExpression expression)
           
 void visitRegexExpression(RegexExpression expression)
           
 void visitReturnStatement(ReturnStatement statement)
           
 void visitStaticMethodCallExpression(StaticMethodCallExpression call)
           
 void visitSwitch(SwitchStatement statement)
           
 void visitSynchronizedStatement(SynchronizedStatement statement)
           
 void visitTernaryExpression(TernaryExpression expression)
           
 void visitThrowStatement(ThrowStatement statement)
           
 void visitTryCatchFinally(TryCatchStatement statement)
           
 void visitTupleExpression(TupleExpression expression)
           
 void visitVariableExpression(VariableExpression expression)
          Visits a bare (unqualified) variable expression.
 void visitWhileLoop(WhileStatement loop)
           
 
Methods inherited from class org.codehaus.groovy.ast.CodeVisitorSupport
visitBlockStatement, visitListOfExpressions
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ClassGenerator

public ClassGenerator(GeneratorContext context,
                      org.objectweb.asm.ClassVisitor classVisitor,
                      ClassLoader classLoader,
                      String sourceFile)
Method Detail

getInnerClasses

public LinkedList getInnerClasses()

getClassLoader

public ClassLoader getClassLoader()

visitClass

public void visitClass(ClassNode classNode)
Specified by:
visitClass in interface GroovyClassVisitor

visitConstructor

public void visitConstructor(ConstructorNode node)
Specified by:
visitConstructor in interface GroovyClassVisitor

visitMethod

public void visitMethod(MethodNode node)
Specified by:
visitMethod in interface GroovyClassVisitor

visitParameters

protected void visitParameters(ASTNode node,
                               Parameter[] parameters)

visitParameter

protected void visitParameter(ASTNode node,
                              Parameter parameter)

visitField

public void visitField(FieldNode fieldNode)
Specified by:
visitField in interface GroovyClassVisitor

visitProperty

public void visitProperty(PropertyNode statement)
Creates a getter, setter and field

Specified by:
visitProperty in interface GroovyClassVisitor

visitForLoop

public void visitForLoop(ForStatement loop)
Specified by:
visitForLoop in interface GroovyCodeVisitor
Overrides:
visitForLoop in class CodeVisitorSupport

visitWhileLoop

public void visitWhileLoop(WhileStatement loop)
Specified by:
visitWhileLoop in interface GroovyCodeVisitor
Overrides:
visitWhileLoop in class CodeVisitorSupport

visitDoWhileLoop

public void visitDoWhileLoop(DoWhileStatement loop)
Specified by:
visitDoWhileLoop in interface GroovyCodeVisitor
Overrides:
visitDoWhileLoop in class CodeVisitorSupport

visitIfElse

public void visitIfElse(IfStatement ifElse)
Specified by:
visitIfElse in interface GroovyCodeVisitor
Overrides:
visitIfElse in class CodeVisitorSupport

visitTernaryExpression

public void visitTernaryExpression(TernaryExpression expression)
Specified by:
visitTernaryExpression in interface GroovyCodeVisitor
Overrides:
visitTernaryExpression in class CodeVisitorSupport

visitAssertStatement

public void visitAssertStatement(AssertStatement statement)
Specified by:
visitAssertStatement in interface GroovyCodeVisitor
Overrides:
visitAssertStatement in class CodeVisitorSupport

visitTryCatchFinally

public void visitTryCatchFinally(TryCatchStatement statement)
Specified by:
visitTryCatchFinally in interface GroovyCodeVisitor
Overrides:
visitTryCatchFinally in class CodeVisitorSupport

visitSwitch

public void visitSwitch(SwitchStatement statement)
Specified by:
visitSwitch in interface GroovyCodeVisitor
Overrides:
visitSwitch in class CodeVisitorSupport

visitCaseStatement

public void visitCaseStatement(CaseStatement statement)
Specified by:
visitCaseStatement in interface GroovyCodeVisitor
Overrides:
visitCaseStatement in class CodeVisitorSupport

visitCaseStatement

public void visitCaseStatement(CaseStatement statement,
                               int switchVariableIndex,
                               org.objectweb.asm.Label thisLabel,
                               org.objectweb.asm.Label nextLabel)

visitBreakStatement

public void visitBreakStatement(BreakStatement statement)
Specified by:
visitBreakStatement in interface GroovyCodeVisitor
Overrides:
visitBreakStatement in class CodeVisitorSupport

visitContinueStatement

public void visitContinueStatement(ContinueStatement statement)
Specified by:
visitContinueStatement in interface GroovyCodeVisitor
Overrides:
visitContinueStatement in class CodeVisitorSupport

visitSynchronizedStatement

public void visitSynchronizedStatement(SynchronizedStatement statement)
Specified by:
visitSynchronizedStatement in interface GroovyCodeVisitor
Overrides:
visitSynchronizedStatement in class CodeVisitorSupport

visitThrowStatement

public void visitThrowStatement(ThrowStatement statement)
Specified by:
visitThrowStatement in interface GroovyCodeVisitor
Overrides:
visitThrowStatement in class CodeVisitorSupport

visitReturnStatement

public void visitReturnStatement(ReturnStatement statement)
Specified by:
visitReturnStatement in interface GroovyCodeVisitor
Overrides:
visitReturnStatement in class CodeVisitorSupport

doConvertAndCast

protected void doConvertAndCast(String type,
                                Expression expression)
Casts to the given type unless it can be determined that the cast is unnecessary


evaluateExpression

protected void evaluateExpression(Expression expression)
Parameters:
expression -

visitExpressionStatement

public void visitExpressionStatement(ExpressionStatement statement)
Specified by:
visitExpressionStatement in interface GroovyCodeVisitor
Overrides:
visitExpressionStatement in class CodeVisitorSupport

visitBinaryExpression

public void visitBinaryExpression(BinaryExpression expression)
Specified by:
visitBinaryExpression in interface GroovyCodeVisitor
Overrides:
visitBinaryExpression in class CodeVisitorSupport

visitPostfixExpression

public void visitPostfixExpression(PostfixExpression expression)
Specified by:
visitPostfixExpression in interface GroovyCodeVisitor
Overrides:
visitPostfixExpression in class CodeVisitorSupport

visitPrefixExpression

public void visitPrefixExpression(PrefixExpression expression)
Specified by:
visitPrefixExpression in interface GroovyCodeVisitor
Overrides:
visitPrefixExpression in class CodeVisitorSupport

visitClosureExpression

public void visitClosureExpression(ClosureExpression expression)
Specified by:
visitClosureExpression in interface GroovyCodeVisitor
Overrides:
visitClosureExpression in class CodeVisitorSupport

loadThisOrOwner

protected void loadThisOrOwner()
Loads either this object or if we're inside a closure then load the top level owner


visitRegexExpression

public void visitRegexExpression(RegexExpression expression)
Specified by:
visitRegexExpression in interface GroovyCodeVisitor
Overrides:
visitRegexExpression in class CodeVisitorSupport

visitConstantExpression

public void visitConstantExpression(ConstantExpression expression)
Generate byte code for constants

Specified by:
visitConstantExpression in interface GroovyCodeVisitor
Overrides:
visitConstantExpression in class CodeVisitorSupport
See Also:
Class field types

visitNegationExpression

public void visitNegationExpression(NegationExpression expression)
Specified by:
visitNegationExpression in interface GroovyCodeVisitor
Overrides:
visitNegationExpression in class CodeVisitorSupport

visitCastExpression

public void visitCastExpression(CastExpression expression)
Specified by:
visitCastExpression in interface GroovyCodeVisitor
Overrides:
visitCastExpression in class CodeVisitorSupport

visitNotExpression

public void visitNotExpression(NotExpression expression)
Specified by:
visitNotExpression in interface GroovyCodeVisitor
Overrides:
visitNotExpression in class CodeVisitorSupport

visitBooleanExpression

public void visitBooleanExpression(BooleanExpression expression)
Specified by:
visitBooleanExpression in interface GroovyCodeVisitor
Overrides:
visitBooleanExpression in class CodeVisitorSupport

visitMethodCallExpression

public void visitMethodCallExpression(MethodCallExpression call)
Specified by:
visitMethodCallExpression in interface GroovyCodeVisitor
Overrides:
visitMethodCallExpression in class CodeVisitorSupport

loadArguments

protected void loadArguments(Parameter[] parameters,
                             Expression expression)
Loads and coerces the argument values for the given method call


findSuperMethod

protected MethodNode findSuperMethod(MethodCallExpression call)
Attempts to find the method of the given name in a super class


findSuperConstructor

protected ConstructorNode findSuperConstructor(MethodCallExpression call)
Attempts to find the constructor in a super class


emptyArguments

protected boolean emptyArguments(Expression arguments)

visitStaticMethodCallExpression

public void visitStaticMethodCallExpression(StaticMethodCallExpression call)
Specified by:
visitStaticMethodCallExpression in interface GroovyCodeVisitor
Overrides:
visitStaticMethodCallExpression in class CodeVisitorSupport

visitConstructorCallExpression

public void visitConstructorCallExpression(ConstructorCallExpression call)
Specified by:
visitConstructorCallExpression in interface GroovyCodeVisitor
Overrides:
visitConstructorCallExpression in class CodeVisitorSupport

visitPropertyExpression

public void visitPropertyExpression(PropertyExpression expression)
Specified by:
visitPropertyExpression in interface GroovyCodeVisitor
Overrides:
visitPropertyExpression in class CodeVisitorSupport

isGroovyObject

protected boolean isGroovyObject(Expression objectExpression)

checkForQualifiedClass

protected String checkForQualifiedClass(PropertyExpression expression)
Checks if the given property expression represents a fully qualified class name

Returns:
the class name or null if the property is not a valid class name

visitFieldExpression

public void visitFieldExpression(FieldExpression expression)
Specified by:
visitFieldExpression in interface GroovyCodeVisitor
Overrides:
visitFieldExpression in class CodeVisitorSupport

visitOuterFieldExpression

protected void visitOuterFieldExpression(FieldExpression expression,
                                         ClassNode outerClassNode,
                                         int steps,
                                         boolean first)

visitVariableExpression

public void visitVariableExpression(VariableExpression expression)
Visits a bare (unqualified) variable expression.

Specified by:
visitVariableExpression in interface GroovyCodeVisitor
Overrides:
visitVariableExpression in class CodeVisitorSupport

processStackVariable

protected void processStackVariable(String name,
                                    Variable variable)

processPropertyVariable

protected void processPropertyVariable(String name,
                                       Variable variable)

processFieldAccess

protected void processFieldAccess(String name,
                                  FieldNode field,
                                  int steps)

isInScriptBody

protected boolean isInScriptBody()
Returns:
true if we are in a script body, where all variables declared are no longer local variables but are properties

isPopRequired

protected boolean isPopRequired(Expression expression)
Returns:
true if this expression will have left a value on the stack that must be popped

firstStatementIsSuperInit

protected boolean firstStatementIsSuperInit(Statement code)

createSyntheticStaticFields

protected void createSyntheticStaticFields()

visitClassExpression

public void visitClassExpression(ClassExpression expression)
Specified by:
visitClassExpression in interface GroovyCodeVisitor
Overrides:
visitClassExpression in class CodeVisitorSupport

visitRangeExpression

public void visitRangeExpression(RangeExpression expression)
Specified by:
visitRangeExpression in interface GroovyCodeVisitor
Overrides:
visitRangeExpression in class CodeVisitorSupport

visitMapEntryExpression

public void visitMapEntryExpression(MapEntryExpression expression)
Specified by:
visitMapEntryExpression in interface GroovyCodeVisitor
Overrides:
visitMapEntryExpression in class CodeVisitorSupport

visitMapExpression

public void visitMapExpression(MapExpression expression)
Specified by:
visitMapExpression in interface GroovyCodeVisitor
Overrides:
visitMapExpression in class CodeVisitorSupport

visitTupleExpression

public void visitTupleExpression(TupleExpression expression)
Specified by:
visitTupleExpression in interface GroovyCodeVisitor
Overrides:
visitTupleExpression in class CodeVisitorSupport

visitArrayExpression

public void visitArrayExpression(ArrayExpression expression)
Specified by:
visitArrayExpression in interface GroovyCodeVisitor
Overrides:
visitArrayExpression in class CodeVisitorSupport

visitListExpression

public void visitListExpression(ListExpression expression)
Specified by:
visitListExpression in interface GroovyCodeVisitor
Overrides:
visitListExpression in class CodeVisitorSupport

visitGStringExpression

public void visitGStringExpression(GStringExpression expression)
Specified by:
visitGStringExpression in interface GroovyCodeVisitor
Overrides:
visitGStringExpression in class CodeVisitorSupport

addInnerClass

protected boolean addInnerClass(ClassNode innerClass)

createClosureClass

protected ClassNode createClosureClass(ClosureExpression expression)

getOutermostClass

protected ClassNode getOutermostClass()

createGStringClass

protected ClassNode createGStringClass(GStringExpression expression)

doConvertAndCast

protected void doConvertAndCast(String type)

evaluateLogicalOrExpression

protected void evaluateLogicalOrExpression(BinaryExpression expression)

evaluateLogicalAndExpression

protected void evaluateLogicalAndExpression(BinaryExpression expression)

evaluateBinaryExpression

protected void evaluateBinaryExpression(String method,
                                        BinaryExpression expression)

evaluateCompareTo

protected void evaluateCompareTo(BinaryExpression expression)

evaluateBinaryExpressionWithAsignment

protected void evaluateBinaryExpressionWithAsignment(String method,
                                                     BinaryExpression expression)

evaluateBinaryExpression

protected void evaluateBinaryExpression(MethodCaller compareMethod,
                                        BinaryExpression expression)

evaluateEqual

protected void evaluateEqual(BinaryExpression expression)

getLHSType

protected String getLHSType(Expression leftExpression)
Deduces the type name required for some casting

Returns:
the type of the given (LHS) expression or null if it is java.lang.Object or it cannot be deduced

isValidTypeForCast

protected boolean isValidTypeForCast(String type)

visitAndAutobox

protected void visitAndAutobox(Expression expression)

evaluatePrefixMethod

protected void evaluatePrefixMethod(String method,
                                    Expression expression)

evaluatePostfixMethod

protected void evaluatePostfixMethod(String method,
                                     Expression expression)

isHolderVariable

protected boolean isHolderVariable(Expression expression)

evaluateInstanceof

protected void evaluateInstanceof(BinaryExpression expression)

argumentsUseStack

protected boolean argumentsUseStack(Expression arguments)
Returns:
true if the given argument expression requires the stack, in which case the arguments are evaluated first, stored in the variable stack and then reloaded to make a method call

isNonStaticField

protected boolean isNonStaticField(Expression expression)
Returns:
true if the given expression represents a non-static field

isThisExpression

protected boolean isThisExpression(Expression expression)

createReturnLHSExpression

protected Expression createReturnLHSExpression(Expression expression)
For assignment expressions, return a safe expression for the LHS we can use to return the value


createReusableExpression

protected Expression createReusableExpression(Expression expression)

comparisonExpression

protected boolean comparisonExpression(Expression expression)

onLineNumber

protected void onLineNumber(ASTNode statement)

getVariableScope

protected VariableScope getVariableScope()

getClosureSharedVariables

protected Parameter[] getClosureSharedVariables(ClosureExpression expression)
Returns:
a list of parameters for each local variable which needs to be passed into a closure

isNotFieldOfOutermostClass

protected boolean isNotFieldOfOutermostClass(String var)

findMutableVariables

protected void findMutableVariables()

addFieldsToVisitor

protected void addFieldsToVisitor(VariableScope scope)

getVariableType

protected String getVariableType(String name)

resetVariableStack

protected void resetVariableStack(Parameter[] parameters)

popScope

protected void popScope()

pushBlockScope

protected void pushBlockScope()

defineVariable

protected Variable defineVariable(String name,
                                  String type)
Defines the given variable in scope and assigns it to the stack


defineVariable

protected Variable defineVariable(String name,
                                  String type,
                                  boolean define)

isFieldOrVariable

protected boolean isFieldOrVariable(String name)
Returns:
true if the given name is a local variable or a field

checkValidType

protected Type checkValidType(Type type,
                              ASTNode node,
                              String message)

checkValidType

protected String checkValidType(String type,
                                ASTNode node,
                                String message)

resolveClassName

protected String resolveClassName(String type)

createVariableName

protected String createVariableName(String type)

getExpressionType

protected String getExpressionType(Expression expression)
Returns:
if the type of the expression can be determined at compile time then this method returns the type - otherwise null

isPrimitiveFieldType

protected boolean isPrimitiveFieldType(String type)
Returns:
true if the value is an Integer, a Float, a Long, a Double or a String .

isInClosureConstructor

protected boolean isInClosureConstructor()

isStaticMethod

protected boolean isStaticMethod()

loadClass

protected Class loadClass(String name)
Returns:
loads the given type name

getCompileUnit

protected CompileUnit getCompileUnit()


Copyright © 2003-2004 The Codehaus. All Rights Reserved.