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` | `visit(org.objectweb.asm.MethodVisitor mv)`
    `` | `public void` | `visit(org.objectweb.asm.MethodVisitor mv)`
    `` | `public void` | `visit(org.objectweb.asm.MethodVisitor mv)`
    `` | `public void` | `visit(org.objectweb.asm.MethodVisitor mv)`
    `` | `public void` | `visit(org.objectweb.asm.MethodVisitor mv)`
    `` | `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` | `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` | `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, 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)

    - #### @Override
      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)

    - #### @Override
      public void visit(org.objectweb.asm.MethodVisitor mv)

    - #### @Override
      public void visit(org.objectweb.asm.MethodVisitor mv)

    - #### @Override
      public void visit(org.objectweb.asm.MethodVisitor mv)

    - #### @Override
      public void visit(org.objectweb.asm.MethodVisitor mv)

    - #### @Override
      public void visit(org.objectweb.asm.MethodVisitor mv)

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

      Generates the annotation attributes.

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

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

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

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

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

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

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

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

    - #### @Override
      public void visitBlockStatement(BlockStatement statement)

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

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

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

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

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

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

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

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

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

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

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

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

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

      Generates byte code for constants.

      See Also:
        Class field types

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

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

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

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

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

    - #### @Override
      public void visitDoWhileLoop(DoWhileStatement statement)

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    - #### @Override
      public void visitMethodReferenceExpression(MethodReferenceExpression expression)

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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