Package org.codehaus.groovy.classgen
Class AsmClassGenerator
java.lang.Object
org.codehaus.groovy.ast.CodeVisitorSupport
org.codehaus.groovy.ast.ClassCodeVisitorSupport
org.codehaus.groovy.classgen.ClassGenerator
org.codehaus.groovy.classgen.AsmClassGenerator
- All Implemented Interfaces:
GroovyClassVisitor
,GroovyCodeVisitor
,ErrorCollecting
Generates Java class versions of Groovy classes using ASM.
-
Field Summary
Modifier and TypeFieldDescriptionstatic final boolean
static final boolean
static final boolean
static final MethodCallerMultiAdapter
static final MethodCallerMultiAdapter
static final String
static final MethodCallerMultiAdapter
static final MethodCallerMultiAdapter
static final MethodCallerMultiAdapter
Fields inherited from class org.codehaus.groovy.classgen.ClassGenerator
innerClasses
-
Constructor Summary
ConstructorDescriptionAsmClassGenerator
(SourceUnit source, GeneratorContext context, org.objectweb.asm.ClassVisitor classVisitor, String sourceFile) -
Method Summary
Modifier and TypeMethodDescriptionboolean
addInnerClass
(ClassNode innerClass) static int
argumentSize
(Expression arguments) static boolean
containsSpreadExpression
(Expression expression) protected void
protected void
void
despreadList
(List<Expression> expressions, boolean wrap) static FieldNode
getDeclaredFieldOfCurrentClassOrAccessibleFieldOfSuper
(ClassNode accessingNode, ClassNode current, String fieldName, boolean skipCurrent) static boolean
isFieldDirectlyAccessible
(FieldNode field, ClassNode accessingClass) Determines if the given class can directly access the given field (viaGETFIELD
,GETSTATIC
, etc.static boolean
isMemberDirectlyAccessible
(int modifiers, ClassNode declaringClass, ClassNode accessingClass) void
loadInstanceField
(FieldExpression expression) RHS instance field.void
loadStaticField
(FieldExpression expression) protected void
Loads either this object or if we're inside a closure then load the top level ownervoid
loadWrapper
(Expression expression) void
onLineNumber
(ASTNode node, String message) void
throwException
(String message) void
void
void
visitArrayExpression
(ArrayExpression expression) void
visitAssertStatement
(AssertStatement statement) void
visitAttributeExpression
(AttributeExpression expression) void
visitBinaryExpression
(BinaryExpression expression) void
void
visitBlockStatement
(BlockStatement statement) void
visitBooleanExpression
(BooleanExpression expression) void
visitBreakStatement
(BreakStatement statement) void
visitBytecodeExpression
(BytecodeExpression expression) void
visitBytecodeSequence
(BytecodeSequence bytecodeSequence) void
visitCaseStatement
(CaseStatement statement) void
visitCastExpression
(CastExpression castExpression) void
visitCatchStatement
(CatchStatement statement) void
visitClass
(ClassNode classNode) Visit a ClassNode.void
visitClassExpression
(ClassExpression expression) void
visitClosureExpression
(ClosureExpression expression) void
visitClosureListExpression
(ClosureListExpression expression) void
visitConstantExpression
(ConstantExpression expression) Generates byte code for constants.void
Visit a ConstructorNode.void
protected void
visitConstructorOrMethod
(MethodNode node, boolean isConstructor) void
visitContinueStatement
(ContinueStatement statement) void
visitDeclarationExpression
(DeclarationExpression expression) void
visitDoWhileLoop
(DoWhileStatement statement) void
visitExpressionStatement
(ExpressionStatement statement) void
visitField
(FieldNode fieldNode) Visit a FieldNode.void
visitFieldExpression
(FieldExpression expression) void
visitForLoop
(ForStatement statement) void
visitGStringExpression
(GStringExpression expression) void
visitIfElse
(IfStatement statement) void
visitLambdaExpression
(LambdaExpression expression) void
visitListExpression
(ListExpression expression) void
visitMapEntryExpression
(MapEntryExpression expression) void
visitMapExpression
(MapExpression expression) void
visitMethod
(MethodNode node) Visit a MethodNode.void
void
visitMethodPointerExpression
(MethodPointerExpression expression) void
void
visitNotExpression
(NotExpression expression) void
visitPostfixExpression
(PostfixExpression expression) void
visitPrefixExpression
(PrefixExpression expression) void
visitProperty
(PropertyNode statement) Visit a PropertyNode.void
visitPropertyExpression
(PropertyExpression expression) void
visitRangeExpression
(RangeExpression expression) void
visitReturnStatement
(ReturnStatement statement) void
visitSpreadExpression
(SpreadExpression expression) void
visitSpreadMapExpression
(SpreadMapExpression expression) protected void
visitStatement
(Statement statement) void
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
visitUnaryMinusExpression
(UnaryMinusExpression expression) void
visitUnaryPlusExpression
(UnaryPlusExpression expression) void
visitVariableExpression
(VariableExpression expression) void
visitWhileLoop
(WhileStatement statement) Methods inherited from class org.codehaus.groovy.classgen.ClassGenerator
getInnerClasses
Methods inherited from class org.codehaus.groovy.ast.ClassCodeVisitorSupport
addError, visitAnnotation, visitAnnotations, visitClassCodeContainer, visitImports, visitObjectInitializerStatements, visitPackage
Methods inherited from class org.codehaus.groovy.ast.CodeVisitorSupport
afterSwitchCaseStatementsVisited, afterSwitchConditionExpressionVisited, visitEmptyStatement, visitShortTernaryExpression
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.codehaus.groovy.ast.GroovyCodeVisitor
visit, visit, visitEmptyExpression, visitListOfExpressions
-
Field Details
-
setField
-
getField
-
setGroovyObjectField
-
getGroovyObjectField
-
setProperty
-
CREATE_DEBUG_INFO
public static final boolean CREATE_DEBUG_INFO- See Also:
-
CREATE_LINE_NUMBER_INFO
public static final boolean CREATE_LINE_NUMBER_INFO- See Also:
-
ASM_DEBUG
public static final boolean ASM_DEBUG- See Also:
-
MINIMUM_BYTECODE_VERSION
- See Also:
-
-
Constructor Details
-
AsmClassGenerator
public AsmClassGenerator(SourceUnit source, GeneratorContext context, org.objectweb.asm.ClassVisitor classVisitor, String sourceFile)
-
-
Method Details
-
getSourceUnit
- Overrides:
getSourceUnit
in classClassGenerator
-
getController
-
visitClass
Description copied from interface:GroovyClassVisitor
Visit a ClassNode.- Specified by:
visitClass
in interfaceGroovyClassVisitor
- Overrides:
visitClass
in classClassCodeVisitorSupport
-
visitConstructorOrMethod
- Overrides:
visitConstructorOrMethod
in classClassCodeVisitorSupport
-
visitConstructor
Description copied from interface:GroovyClassVisitor
Visit a ConstructorNode.- Specified by:
visitConstructor
in interfaceGroovyClassVisitor
- Overrides:
visitConstructor
in classClassCodeVisitorSupport
-
visitMethod
Description copied from interface:GroovyClassVisitor
Visit a MethodNode.- Specified by:
visitMethod
in interfaceGroovyClassVisitor
- Overrides:
visitMethod
in classClassCodeVisitorSupport
-
visitField
Description copied from interface:GroovyClassVisitor
Visit a FieldNode.- Specified by:
visitField
in interfaceGroovyClassVisitor
- Overrides:
visitField
in classClassCodeVisitorSupport
-
visitProperty
Description copied from interface:GroovyClassVisitor
Visit a PropertyNode.- Specified by:
visitProperty
in interfaceGroovyClassVisitor
- Overrides:
visitProperty
in classClassCodeVisitorSupport
-
visitStatement
- Overrides:
visitStatement
in classClassCodeVisitorSupport
-
visitBlockStatement
- Specified by:
visitBlockStatement
in interfaceGroovyCodeVisitor
- Overrides:
visitBlockStatement
in classClassCodeVisitorSupport
-
visitForLoop
- Specified by:
visitForLoop
in interfaceGroovyCodeVisitor
- Overrides:
visitForLoop
in classClassCodeVisitorSupport
-
visitWhileLoop
- Specified by:
visitWhileLoop
in interfaceGroovyCodeVisitor
- Overrides:
visitWhileLoop
in classClassCodeVisitorSupport
-
visitDoWhileLoop
- Specified by:
visitDoWhileLoop
in interfaceGroovyCodeVisitor
- Overrides:
visitDoWhileLoop
in classClassCodeVisitorSupport
-
visitIfElse
- Specified by:
visitIfElse
in interfaceGroovyCodeVisitor
- Overrides:
visitIfElse
in classClassCodeVisitorSupport
-
visitAssertStatement
- Specified by:
visitAssertStatement
in interfaceGroovyCodeVisitor
- Overrides:
visitAssertStatement
in classClassCodeVisitorSupport
-
visitTryCatchFinally
- Specified by:
visitTryCatchFinally
in interfaceGroovyCodeVisitor
- Overrides:
visitTryCatchFinally
in classClassCodeVisitorSupport
-
visitCatchStatement
- Specified by:
visitCatchStatement
in interfaceGroovyCodeVisitor
- Overrides:
visitCatchStatement
in classClassCodeVisitorSupport
-
visitSwitch
- Specified by:
visitSwitch
in interfaceGroovyCodeVisitor
- Overrides:
visitSwitch
in classClassCodeVisitorSupport
-
visitCaseStatement
- Specified by:
visitCaseStatement
in interfaceGroovyCodeVisitor
- Overrides:
visitCaseStatement
in classClassCodeVisitorSupport
-
visitBreakStatement
- Specified by:
visitBreakStatement
in interfaceGroovyCodeVisitor
- Overrides:
visitBreakStatement
in classClassCodeVisitorSupport
-
visitContinueStatement
- Specified by:
visitContinueStatement
in interfaceGroovyCodeVisitor
- Overrides:
visitContinueStatement
in classClassCodeVisitorSupport
-
visitSynchronizedStatement
- Specified by:
visitSynchronizedStatement
in interfaceGroovyCodeVisitor
- Overrides:
visitSynchronizedStatement
in classClassCodeVisitorSupport
-
visitThrowStatement
- Specified by:
visitThrowStatement
in interfaceGroovyCodeVisitor
- Overrides:
visitThrowStatement
in classClassCodeVisitorSupport
-
visitReturnStatement
- Specified by:
visitReturnStatement
in interfaceGroovyCodeVisitor
- Overrides:
visitReturnStatement
in classClassCodeVisitorSupport
-
visitExpressionStatement
- Specified by:
visitExpressionStatement
in interfaceGroovyCodeVisitor
- Overrides:
visitExpressionStatement
in classClassCodeVisitorSupport
-
visitTernaryExpression
- Specified by:
visitTernaryExpression
in interfaceGroovyCodeVisitor
- Overrides:
visitTernaryExpression
in classCodeVisitorSupport
-
visitDeclarationExpression
- Specified by:
visitDeclarationExpression
in interfaceGroovyCodeVisitor
- Overrides:
visitDeclarationExpression
in classClassCodeVisitorSupport
-
visitBinaryExpression
- Specified by:
visitBinaryExpression
in interfaceGroovyCodeVisitor
- Overrides:
visitBinaryExpression
in classCodeVisitorSupport
-
visitPostfixExpression
- Specified by:
visitPostfixExpression
in interfaceGroovyCodeVisitor
- Overrides:
visitPostfixExpression
in classCodeVisitorSupport
-
visitPrefixExpression
- Specified by:
visitPrefixExpression
in interfaceGroovyCodeVisitor
- Overrides:
visitPrefixExpression
in classCodeVisitorSupport
-
visitClosureExpression
- Specified by:
visitClosureExpression
in interfaceGroovyCodeVisitor
- Overrides:
visitClosureExpression
in classClassCodeVisitorSupport
-
visitLambdaExpression
- Specified by:
visitLambdaExpression
in interfaceGroovyCodeVisitor
- Overrides:
visitLambdaExpression
in classCodeVisitorSupport
-
loadThisOrOwner
protected void loadThisOrOwner()Loads either this object or if we're inside a closure then load the top level owner -
visitConstantExpression
Generates byte code for constants.- Specified by:
visitConstantExpression
in interfaceGroovyCodeVisitor
- Overrides:
visitConstantExpression
in classCodeVisitorSupport
- See Also:
-
visitSpreadExpression
- Specified by:
visitSpreadExpression
in interfaceGroovyCodeVisitor
- Overrides:
visitSpreadExpression
in classCodeVisitorSupport
-
visitSpreadMapExpression
- Specified by:
visitSpreadMapExpression
in interfaceGroovyCodeVisitor
- Overrides:
visitSpreadMapExpression
in classCodeVisitorSupport
-
visitMethodPointerExpression
- Specified by:
visitMethodPointerExpression
in interfaceGroovyCodeVisitor
- Overrides:
visitMethodPointerExpression
in classCodeVisitorSupport
-
visitMethodReferenceExpression
- Specified by:
visitMethodReferenceExpression
in interfaceGroovyCodeVisitor
- Overrides:
visitMethodReferenceExpression
in classCodeVisitorSupport
-
visitUnaryMinusExpression
- Specified by:
visitUnaryMinusExpression
in interfaceGroovyCodeVisitor
- Overrides:
visitUnaryMinusExpression
in classCodeVisitorSupport
-
visitUnaryPlusExpression
- Specified by:
visitUnaryPlusExpression
in interfaceGroovyCodeVisitor
- Overrides:
visitUnaryPlusExpression
in classCodeVisitorSupport
-
visitBitwiseNegationExpression
- Specified by:
visitBitwiseNegationExpression
in interfaceGroovyCodeVisitor
- Overrides:
visitBitwiseNegationExpression
in classCodeVisitorSupport
-
visitCastExpression
- Specified by:
visitCastExpression
in interfaceGroovyCodeVisitor
- Overrides:
visitCastExpression
in classCodeVisitorSupport
-
visitNotExpression
- Specified by:
visitNotExpression
in interfaceGroovyCodeVisitor
- Overrides:
visitNotExpression
in classCodeVisitorSupport
-
visitBooleanExpression
- Specified by:
visitBooleanExpression
in interfaceGroovyCodeVisitor
- Overrides:
visitBooleanExpression
in classCodeVisitorSupport
-
visitMethodCallExpression
- Specified by:
visitMethodCallExpression
in interfaceGroovyCodeVisitor
- Overrides:
visitMethodCallExpression
in classCodeVisitorSupport
-
visitStaticMethodCallExpression
- Specified by:
visitStaticMethodCallExpression
in interfaceGroovyCodeVisitor
- Overrides:
visitStaticMethodCallExpression
in classCodeVisitorSupport
-
visitConstructorCallExpression
- Specified by:
visitConstructorCallExpression
in interfaceGroovyCodeVisitor
- Overrides:
visitConstructorCallExpression
in classCodeVisitorSupport
-
isFieldDirectlyAccessible
Determines if the given class can directly access the given field (viaGETFIELD
,GETSTATIC
, etc. bytecode instructions). -
isMemberDirectlyAccessible
-
getDeclaredFieldOfCurrentClassOrAccessibleFieldOfSuper
-
visitPropertyExpression
- Specified by:
visitPropertyExpression
in interfaceGroovyCodeVisitor
- Overrides:
visitPropertyExpression
in classCodeVisitorSupport
-
visitAttributeExpression
- Specified by:
visitAttributeExpression
in interfaceGroovyCodeVisitor
- Overrides:
visitAttributeExpression
in classCodeVisitorSupport
-
visitFieldExpression
- Specified by:
visitFieldExpression
in interfaceGroovyCodeVisitor
- Overrides:
visitFieldExpression
in classCodeVisitorSupport
-
loadStaticField
-
loadInstanceField
RHS instance field. should move most of the code in the BytecodeHelper -
visitVariableExpression
- Specified by:
visitVariableExpression
in interfaceGroovyCodeVisitor
- Overrides:
visitVariableExpression
in classCodeVisitorSupport
-
createInterfaceSyntheticStaticFields
protected void createInterfaceSyntheticStaticFields() -
createSyntheticStaticFields
protected void createSyntheticStaticFields() -
visitClassExpression
- Specified by:
visitClassExpression
in interfaceGroovyCodeVisitor
- Overrides:
visitClassExpression
in classCodeVisitorSupport
-
visitRangeExpression
- Specified by:
visitRangeExpression
in interfaceGroovyCodeVisitor
- Overrides:
visitRangeExpression
in classCodeVisitorSupport
-
visitMapEntryExpression
- Specified by:
visitMapEntryExpression
in interfaceGroovyCodeVisitor
- Overrides:
visitMapEntryExpression
in classCodeVisitorSupport
-
visitMapExpression
- Specified by:
visitMapExpression
in interfaceGroovyCodeVisitor
- Overrides:
visitMapExpression
in classCodeVisitorSupport
-
visitArgumentlistExpression
- Specified by:
visitArgumentlistExpression
in interfaceGroovyCodeVisitor
- Overrides:
visitArgumentlistExpression
in classCodeVisitorSupport
-
visitTupleExpression
- Specified by:
visitTupleExpression
in interfaceGroovyCodeVisitor
- Overrides:
visitTupleExpression
in classCodeVisitorSupport
-
visitArrayExpression
- Specified by:
visitArrayExpression
in interfaceGroovyCodeVisitor
- Overrides:
visitArrayExpression
in classCodeVisitorSupport
-
visitClosureListExpression
- Specified by:
visitClosureListExpression
in interfaceGroovyCodeVisitor
- Overrides:
visitClosureListExpression
in classCodeVisitorSupport
-
visitBytecodeExpression
- Specified by:
visitBytecodeExpression
in interfaceGroovyCodeVisitor
- Overrides:
visitBytecodeExpression
in classCodeVisitorSupport
-
visitBytecodeSequence
- Overrides:
visitBytecodeSequence
in classClassGenerator
-
visitListExpression
- Specified by:
visitListExpression
in interfaceGroovyCodeVisitor
- Overrides:
visitListExpression
in classCodeVisitorSupport
-
visitGStringExpression
- Specified by:
visitGStringExpression
in interfaceGroovyCodeVisitor
- Overrides:
visitGStringExpression
in classCodeVisitorSupport
-
visitAnnotations
- Overrides:
visitAnnotations
in classClassCodeVisitorSupport
-
addInnerClass
-
argumentSize
-
containsSpreadExpression
-
despreadList
-
loadWrapper
-
onLineNumber
-
throwException
-