Package: org.codehaus.groovy.classgen

## [Java] Class AsmClassGenerator

- org.codehaus.groovy.classgen.AsmClassGenerator

- Generates Java class versions of Groovy classes using ASM.

- - ### Field Summary

    Fields
    Modifiers | Name | Description
    --- | --- | ---
    `static boolean` | `ASM_DEBUG` |
    `static boolean` | `CREATE_DEBUG_INFO` |
    `static boolean` | `CREATE_LINE_NUMBER_INFO` |
    `static String` | `MINIMUM_BYTECODE_VERSION` |
    `static MethodCallerMultiAdapter` | `getField` |
    `static MethodCallerMultiAdapter` | `getGroovyObjectField` |
    `static MethodCallerMultiAdapter` | `setField` |
    `static MethodCallerMultiAdapter` | `setGroovyObjectField` |
    `static MethodCallerMultiAdapter` | `setProperty` |

  - Inherited fields
    Fields inherited from class | Fields
    --- | ---
    `class ClassGenerator` | `innerClasses`

  - ### Constructor Summary

    Constructors
    Constructor and description
    `AsmClassGenerator (org.codehaus.groovy.control.SourceUnit source, GeneratorContext context, org.objectweb.asm.ClassVisitor classVisitor, String sourceFile)`

  - ### Methods Summary

    Methods
    Type Params | Return Type | Name and description
    --- | --- | ---
    `` | `boolean` | `addInnerClass(ClassNode innerClass)`
    `` | `static int` | `argumentSize(Expression arguments)`
    `` | `static boolean` | `containsSpreadExpression(Expression arguments)`
    `` | `protected void` | `createInterfaceSyntheticStaticFields()`
    `` | `protected void` | `createSyntheticStaticFields()`
    `` | `void` | `despreadList(List expressions, boolean wrap)`
    `` | `protected boolean` | `emptyArguments(Expression arguments)`
    `` | `protected CompileUnit` | `getCompileUnit()`
    `` | `WriterController` | `getController()`
    `` | `static FieldNode` | `getDeclaredFieldOfCurrentClassOrAccessibleFieldOfSuper(ClassNode accessingNode, ClassNode current, String name, boolean skipCurrent)`
    `` | `org.codehaus.groovy.control.SourceUnit` | `getSourceUnit()`
    `` | `static boolean` | `isNullConstant(Expression expr)`
    `` | `static boolean` | `isThisExpression(Expression expression)`
    `` | `void` | `loadInstanceField(FieldExpression fldExp)` RHS instance field. should move most of the code in the BytecodeHelper
    `` | `void` | `loadStaticField(FieldExpression fldExp)` @param fldExp
    `` | `protected void` | `loadThisOrOwner()` Loads either this object or if we're inside a closure then load the top level owner
    `` | `void` | `loadWrapper(Expression argument)`
    `` | `void` | `onLineNumber(ASTNode statement, String message)`
    `` | `static boolean` | `samePackages(String pkg1, String pkg2)`
    `` | `void` | `throwException(String s)`
    `` | `void` | `visitAnnotations(AnnotatedNode node)` Note: ignore it.
    `` | `void` | `visitArgumentlistExpression(ArgumentListExpression ale)`
    `` | `void` | `visitArrayExpression(ArrayExpression expression)`
    `` | `void` | `visitAssertStatement(AssertStatement statement)`
    `` | `void` | `visitAttributeExpression(AttributeExpression expression)`
    `` | `void` | `visitBinaryExpression(BinaryExpression expression)`
    `` | `void` | `visitBitwiseNegationExpression(BitwiseNegationExpression expression)`
    `` | `void` | `visitBlockStatement(BlockStatement block)`
    `` | `void` | `visitBooleanExpression(BooleanExpression expression)` return a primitive boolean value of the BooleanExpression.
    `` | `void` | `visitBreakStatement(BreakStatement statement)`
    `` | `void` | `visitBytecodeExpression(BytecodeExpression cle)`
    `` | `void` | `visitBytecodeSequence(BytecodeSequence bytecodeSequence)`
    `` | `void` | `visitCaseStatement(CaseStatement statement)`
    `` | `void` | `visitCastExpression(CastExpression castExpression)`
    `` | `void` | `visitCatchStatement(CatchStatement statement)`
    `` | `void` | `visitClass(ClassNode classNode)`
    `` | `void` | `visitClassExpression(ClassExpression expression)` load class object on stack
    `` | `void` | `visitClosureExpression(ClosureExpression expression)`
    `` | `void` | `visitClosureListExpression(ClosureListExpression expression)`
    `` | `void` | `visitConstantExpression(ConstantExpression expression)` Generate byte code for constants
    `` | `void` | `visitConstructor(ConstructorNode node)`
    `` | `void` | `visitConstructorCallExpression(ConstructorCallExpression call)`
    `` | `protected void` | `visitConstructorOrMethod(MethodNode node, boolean isConstructor)`
    `` | `void` | `visitContinueStatement(ContinueStatement statement)`
    `` | `void` | `visitDeclarationExpression(DeclarationExpression expression)`
    `` | `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` | `visitGenericType(GenericsType genericsType)`
    `` | `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` | `visitMethodPointerExpression(MethodPointerExpression expression)`
    `` | `void` | `visitNotExpression(NotExpression expression)`
    `` | `void` | `visitPostfixExpression(PostfixExpression expression)`
    `` | `void` | `visitPrefixExpression(PrefixExpression expression)`
    `` | `void` | `visitProperty(PropertyNode statement)`
    `` | `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` | `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` | `visitUnaryMinusExpression(UnaryMinusExpression expression)`
    `` | `void` | `visitUnaryPlusExpression(UnaryPlusExpression expression)`
    `` | `void` | `visitVariableExpression(VariableExpression expression)` Visits a bare (unqualified) variable expression.
    `` | `void` | `visitWhileLoop(WhileStatement loop)`

  - ### Inherited Methods Summary

    Inherited Methods
    Methods inherited from class | Name
    --- | ---
    `class ClassGenerator` | `getInnerClasses, getSourceUnit, visitBytecodeSequence`
    `class ClassCodeVisitorSupport` | `addError, getSourceUnit, visitAnnotations, visitAssertStatement, visitBlockStatement, visitBreakStatement, visitCaseStatement, visitCatchStatement, visitClass, visitClassCodeContainer, visitConstructor, visitConstructorOrMethod, visitContinueStatement, visitDeclarationExpression, visitDoWhileLoop, visitExpressionStatement, visitField, visitForLoop, visitIfElse, visitImports, visitMethod, visitObjectInitializerStatements, visitPackage, visitProperty, visitReturnStatement, visitStatement, visitSwitch, visitSynchronizedStatement, visitThrowStatement, visitTryCatchFinally, visitWhileLoop`
    `class CodeVisitorSupport` | `visitArgumentlistExpression, visitArrayExpression, visitAssertStatement, visitAttributeExpression, visitBinaryExpression, visitBitwiseNegationExpression, visitBlockStatement, visitBooleanExpression, visitBreakStatement, visitBytecodeExpression, visitCaseStatement, visitCastExpression, visitCatchStatement, visitClassExpression, visitClosureExpression, visitClosureListExpression, visitConstantExpression, visitConstructorCallExpression, visitContinueStatement, visitDeclarationExpression, visitDoWhileLoop, visitEmptyStatement, visitExpressionStatement, visitFieldExpression, visitForLoop, visitGStringExpression, visitIfElse, visitListExpression, visitListOfExpressions, visitMapEntryExpression, visitMapExpression, visitMethodCallExpression, visitMethodPointerExpression, visitNotExpression, visitPostfixExpression, visitPrefixExpression, visitPropertyExpression, visitRangeExpression, visitReturnStatement, visitShortTernaryExpression, visitSpreadExpression, visitSpreadMapExpression, visitStaticMethodCallExpression, visitSwitch, visitSynchronizedStatement, visitTernaryExpression, visitThrowStatement, visitTryCatchFinally, visitTupleExpression, visitUnaryMinusExpression, visitUnaryPlusExpression, visitVariableExpression, visitWhileLoop`
    `class Object` | `wait, wait, wait, equals, toString, hashCode, getClass, notify, notifyAll`

- - ### Field Detail

    - #### public static final boolean ASM_DEBUG

    - #### public static final boolean CREATE_DEBUG_INFO

    - #### public static final boolean CREATE_LINE_NUMBER_INFO

    - #### public static final String MINIMUM_BYTECODE_VERSION

    - #### public static final MethodCallerMultiAdapter getField

    - #### public static final MethodCallerMultiAdapter getGroovyObjectField

    - #### public static final MethodCallerMultiAdapter setField

    - #### public static final MethodCallerMultiAdapter setGroovyObjectField

    - #### public static final MethodCallerMultiAdapter setProperty

  - ### Constructor Detail

    - #### public AsmClassGenerator(org.codehaus.groovy.control.SourceUnit source, GeneratorContext context, org.objectweb.asm.ClassVisitor classVisitor, String sourceFile)

  - ### Method Detail

    - #### public boolean addInnerClass(ClassNode innerClass)

    - #### public static int argumentSize(Expression arguments)

    - #### public static boolean containsSpreadExpression(Expression arguments)

    - #### protected void createInterfaceSyntheticStaticFields()

    - #### protected void createSyntheticStaticFields()

    - #### public void despreadList(List expressions, boolean wrap)

    - #### protected boolean emptyArguments(Expression arguments)

    - #### protected CompileUnit getCompileUnit()

    - #### public WriterController getController()

    - #### public static FieldNode getDeclaredFieldOfCurrentClassOrAccessibleFieldOfSuper(ClassNode accessingNode, ClassNode current, String name, boolean skipCurrent)

    - #### public org.codehaus.groovy.control.SourceUnit getSourceUnit()

    - #### public static boolean isNullConstant(Expression expr)

    - #### public static boolean isThisExpression(Expression expression)

    - #### public void loadInstanceField(FieldExpression fldExp)

      RHS instance field. should move most of the code in the BytecodeHelper

      Parameters:
        fldExp

    - #### public void loadStaticField(FieldExpression fldExp)

      Parameters:
        fldExp

    - #### protected void loadThisOrOwner()

      Loads either this object or if we're inside a closure then load the top level owner

    - #### public void loadWrapper(Expression argument)

    - #### public void onLineNumber(ASTNode statement, String message)

    - #### public static boolean samePackages(String pkg1, String pkg2)

    - #### public void throwException(String s)

    - #### public void visitAnnotations(AnnotatedNode node)

      Note: ignore it. Annotation generation needs the current visitor.

    - #### public void visitArgumentlistExpression(ArgumentListExpression ale)

    - #### public void visitArrayExpression(ArrayExpression expression)

    - #### public void visitAssertStatement(AssertStatement statement)

    - #### public void visitAttributeExpression(AttributeExpression expression)

    - #### public void visitBinaryExpression(BinaryExpression expression)

    - #### public void visitBitwiseNegationExpression(BitwiseNegationExpression expression)

    - #### public void visitBlockStatement(BlockStatement block)

    - #### public void visitBooleanExpression(BooleanExpression expression)

      return a primitive boolean value of the BooleanExpression.

      Parameters:
        expression

    - #### public void visitBreakStatement(BreakStatement statement)

    - #### public void visitBytecodeExpression(BytecodeExpression cle)

    - #### public void visitBytecodeSequence(BytecodeSequence bytecodeSequence)

    - #### public void visitCaseStatement(CaseStatement statement)

    - #### public void visitCastExpression(CastExpression castExpression)

    - #### @Override public void visitCatchStatement(CatchStatement statement)

    - #### public void visitClass(ClassNode classNode)

    - #### public void visitClassExpression(ClassExpression expression)

      load class object on stack

    - #### public void visitClosureExpression(ClosureExpression expression)

    - #### public void visitClosureListExpression(ClosureListExpression expression)

    - #### public void visitConstantExpression(ConstantExpression expression)

      Generate byte code for constants

      See Also:
        Class field types

    - #### public void visitConstructor(ConstructorNode node)

    - #### public void visitConstructorCallExpression(ConstructorCallExpression call)

    - #### protected void visitConstructorOrMethod(MethodNode node, boolean isConstructor)

    - #### public void visitContinueStatement(ContinueStatement statement)

    - #### public void visitDeclarationExpression(DeclarationExpression expression)

    - #### public void visitDoWhileLoop(DoWhileStatement loop)

    - #### public void visitExpressionStatement(ExpressionStatement statement)

    - #### public void visitField(FieldNode fieldNode)

    - #### public void visitFieldExpression(FieldExpression expression)

    - #### public void visitForLoop(ForStatement loop)

    - #### public void visitGStringExpression(GStringExpression expression)

    - #### public void visitGenericType(GenericsType genericsType)

    - #### public void visitIfElse(IfStatement ifElse)

    - #### public void visitListExpression(ListExpression expression)

    - #### public void visitMapEntryExpression(MapEntryExpression expression)

    - #### public void visitMapExpression(MapExpression expression)

    - #### public void visitMethod(MethodNode node)

    - #### public void visitMethodCallExpression(MethodCallExpression call)

    - #### public void visitMethodPointerExpression(MethodPointerExpression expression)

    - #### public void visitNotExpression(NotExpression expression)

    - #### public void visitPostfixExpression(PostfixExpression expression)

    - #### public void visitPrefixExpression(PrefixExpression expression)

    - #### public void visitProperty(PropertyNode statement)

    - #### public void visitPropertyExpression(PropertyExpression expression)

    - #### public void visitRangeExpression(RangeExpression expression)

    - #### public void visitReturnStatement(ReturnStatement statement)

    - #### public void visitSpreadExpression(SpreadExpression expression)

    - #### public void visitSpreadMapExpression(SpreadMapExpression expression)

    - #### protected void visitStatement(Statement statement)

    - #### public void visitStaticMethodCallExpression(StaticMethodCallExpression call)

    - #### public void visitSwitch(SwitchStatement statement)

    - #### public void visitSynchronizedStatement(SynchronizedStatement statement)

    - #### public void visitTernaryExpression(TernaryExpression expression)

    - #### public void visitThrowStatement(ThrowStatement statement)

    - #### public void visitTryCatchFinally(TryCatchStatement statement)

    - #### public void visitTupleExpression(TupleExpression expression)

    - #### public void visitUnaryMinusExpression(UnaryMinusExpression expression)

    - #### public void visitUnaryPlusExpression(UnaryPlusExpression expression)

    - #### public void visitVariableExpression(VariableExpression expression)

      Visits a bare (unqualified) variable expression.

    - #### public void visitWhileLoop(WhileStatement loop)