Package: org.codehaus.groovy.classgen

## [Java] Class AsmClassGenerator

- org.codehaus.groovy.classgen.AsmClassGenerator

-     public class AsmClassGenerator
      extends ClassGenerator

  Generates Java class versions of Groovy classes using ASM.

- - ### Field Summary

    Fields
    Modifiers | Name | Description
    --- | --- | ---
    `static boolean` | `ASM_DEBUG` | Add marker in the bytecode to show source-bytecode relationship.
    `static boolean` | `CREATE_DEBUG_INFO` |
    `static boolean` | `CREATE_LINE_NUMBER_INFO` |
    `static String` | `ELIDE_EXPRESSION_VALUE` |
    `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(SourceUnit source, GeneratorContext context, org.objectweb.asm.ClassVisitor classVisitor, String sourceFile)`

  - ### Methods Summary

    Methods
    Type Params | Return Type | Name and description
    --- | --- | ---
    `` | `public boolean` | `addInnerClass(ClassNode innerClass)`
    `` | `public static int` | `argumentSize(Expression arguments)`
    `` | `public static boolean` | `containsSpreadExpression(Expression expression)`
    `` | `protected void` | `createInterfaceSyntheticStaticFields()`
    `` | `protected void` | `createSyntheticStaticFields()`
    `` | `public void` | `despreadList(List<Expression> expressions, boolean wrap)`
    `` | `public WriterController` | `getController()`
    `` | `public static FieldNode` | `getDeclaredFieldOfCurrentClassOrAccessibleFieldOfSuper(ClassNode accessingNode, ClassNode current, String fieldName, boolean skipCurrent)`
    `` | `public SourceUnit` | `getSourceUnit()`
    `` | `public static boolean` | `isFieldDirectlyAccessible(FieldNode field, ClassNode accessingClass)` Determines if the given field can be directly accessed by the given class (via `GETFIELD`, `GETSTATIC`, etc. bytecode instructions).
    `` | `public static boolean` | `isMemberDirectlyAccessible(int modifiers, ClassNode declaringClass, ClassNode accessingClass)`
    `` | `public void` | `loadInstanceField(FieldExpression expression)` RHS instance field. should move most of the code in the BytecodeHelper
    `` | `public void` | `loadStaticField(FieldExpression expression)`
    `` | `public void` | `loadWrapper(Expression expression)`
    `` | `public void` | `onLineNumber(ASTNode node, String message)`
    `` | `public void` | `throwException(String message)`
    `` | `public void` | `visitAnnotationAttributes(AnnotationNode an, AnnotationVisitor av)` Generates the annotation attributes.
    `` | `public void` | `visitAnnotations(AnnotatedNode node)`
    `` | `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 statement)`
    `` | `public void` | `visitBooleanExpression(BooleanExpression expression)`
    `` | `public void` | `visitBreakStatement(BreakStatement statement)`
    `` | `public void` | `visitBytecodeExpression(BytecodeExpression expression)`
    `` | `public void` | `visitBytecodeSequence(BytecodeSequence bytecodeSequence)`
    `` | `public void` | `visitCaseStatement(CaseStatement statement)`
    `` | `public void` | `visitCastExpression(CastExpression castExpression)`
    `` | `public void` | `visitCatchStatement(CatchStatement statement)`
    `` | `public void` | `visitClass(ClassNode classNode)`
    `` | `public void` | `visitClassExpression(ClassExpression expression)`
    `` | `public void` | `visitClosureExpression(ClosureExpression expression)`
    `` | `public void` | `visitClosureListExpression(ClosureListExpression expression)`
    `` | `public void` | `visitConstantExpression(ConstantExpression expression)` Generates byte code for constants.
    `` | `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 statement)`
    `` | `public void` | `visitExpressionStatement(ExpressionStatement statement)`
    `` | `public void` | `visitField(FieldNode fieldNode)`
    `` | `public void` | `visitFieldExpression(FieldExpression expression)`
    `` | `public void` | `visitForLoop(ForStatement statement)`
    `` | `public void` | `visitGStringExpression(GStringExpression expression)`
    `` | `public void` | `visitIfElse(IfStatement statement)`
    `` | `public void` | `visitLambdaExpression(LambdaExpression expression)`
    `` | `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` | `visitMethodReferenceExpression(MethodReferenceExpression 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)`
    `` | `public void` | `visitWhileLoop(WhileStatement statement)`

  - ### Inherited Methods Summary

    Inherited Methods
    Methods inherited from class | Name
    --- | ---
    `class ClassGenerator` | `getInnerClasses, getSourceUnit, visitBytecodeSequence`
    `class ClassCodeVisitorSupport` | `addError, getSourceUnit, visitAnnotation, visitAnnotations, visitAnnotations, visitAssertStatement, visitBlockStatement, visitBreakStatement, visitCaseStatement, visitCatchStatement, visitClass, visitClassCodeContainer, visitClosureExpression, visitConstructor, visitConstructorOrMethod, visitContinueStatement, visitDeclarationExpression, visitDoWhileLoop, visitExpressionStatement, visitField, visitForLoop, visitIfElse, visitImports, visitMethod, visitObjectInitializerStatements, visitPackage, visitProperty, visitReturnStatement, visitStatement, visitStatementAnnotations, visitSwitch, visitSynchronizedStatement, visitThrowStatement, visitTryCatchFinally, visitWhileLoop`
    `class CodeVisitorSupport` | `afterSwitchCaseStatementsVisited, afterSwitchConditionExpressionVisited, 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, visitLambdaExpression, visitListExpression, visitMapEntryExpression, visitMapExpression, visitMethodCallExpression, visitMethodPointerExpression, visitMethodReferenceExpression, visitNotExpression, visitPostfixExpression, visitPrefixExpression, visitPropertyExpression, visitRangeExpression, visitReturnStatement, visitShortTernaryExpression, visitSpreadExpression, visitSpreadMapExpression, visitStaticMethodCallExpression, visitSwitch, visitSynchronizedStatement, visitTernaryExpression, visitThrowStatement, visitTryCatchFinally, visitTupleExpression, visitUnaryMinusExpression, visitUnaryPlusExpression, visitVariableExpression, visitWhileLoop`

- - ### Field Detail

    - #### public static final boolean ASM_DEBUG

      Add marker in the bytecode to show source-bytecode relationship.

    - #### public static final boolean CREATE_DEBUG_INFO

    - #### public static final boolean CREATE_LINE_NUMBER_INFO

    - #### public static final String ELIDE_EXPRESSION_VALUE

    - #### 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(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 expression)

    - #### protected void createInterfaceSyntheticStaticFields()

    - #### protected void createSyntheticStaticFields()

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

    - #### public WriterController getController()

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

    - #### public SourceUnit getSourceUnit()

    - #### public static boolean isFieldDirectlyAccessible(FieldNode field, ClassNode accessingClass)

      Determines if the given field can be directly accessed by the given class (via `GETFIELD`, `GETSTATIC`, etc. bytecode instructions).

    - #### public static boolean isMemberDirectlyAccessible(int modifiers, ClassNode declaringClass, ClassNode accessingClass)

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

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

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

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

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

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

    - #### public void visitAnnotationAttributes(AnnotationNode an, AnnotationVisitor av)

      Generates the annotation attributes.

      Parameters:
        `an` - the node with an annotation
        `av` - the visitor to use

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

    - #### 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 statement)

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

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

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

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

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

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

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

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

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

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

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

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

      Generates 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 statement)

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

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

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

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

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

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

    - #### public void visitLambdaExpression(LambdaExpression expression)

    - #### 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 visitMethodReferenceExpression(MethodReferenceExpression 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)

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