Class StaticTypesWriterController
java.lang.Object
org.codehaus.groovy.classgen.asm.WriterController
org.codehaus.groovy.classgen.asm.DelegatingController
org.codehaus.groovy.classgen.asm.sc.StaticTypesWriterController
An alternative
WriterController which handles static types and method
dispatch. In case of a "mixed mode" where only some methods are annotated with TypeChecked
then this writer will delegate to the classic writer controller.-
Field Summary
FieldsFields inherited from class org.codehaus.groovy.classgen.asm.WriterController
optimizeForInt -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionReturns the appropriate BinaryExpressionHelper for the current code path.Returns the CallSiteWriter responsible for generating dynamic call site infrastructure.getCallSiteWriterFor(Expression expression) Returns the CallSiteWriter for a specific expression.Returns the ClosureWriter for compiling Groovy closure literals into inner classes implementing GroovyObject and supporting variable capture.Returns the InvocationWriter for compiling method calls and dynamic function invocations into appropriate bytecode patterns.Returns the LambdaWriter for compiling Java-style lambda expressions (using the->operator) into functional interfaces.Returns the MethodReferenceExpressionWriter for compiling method reference expressions compatible with Java functional interface targets.Returns the StatementWriter for compiling Groovy statements into bytecode.Returns the TypeChooser used to select appropriate type representations for expressions during compilation, supporting both dynamic and typed paths.Returns the appropriate UnaryExpressionHelper for the current code path.voidinit(AsmClassGenerator asmClassGenerator, GeneratorContext gcon, org.objectweb.asm.ClassVisitor cv, ClassNode cn) Initializes this controller with compilation context and ASM infrastructure.booleanReturns true if the compiler is currently in fast-path mode, emitting specialized bytecode for primitive type operations.booleanGROOVY-11968: returnstruewhen the current statically compiled method contains one or more sub-expressions that will be routed through the regular (non-static) call site writer viagetCallSiteWriterFor(org.codehaus.groovy.ast.expr.Expression).voidSets the ConstructorNode for the constructor currently being compiled.voidSets the MethodNode for the method currently being compiled.Methods inherited from class org.codehaus.groovy.classgen.asm.DelegatingController
getAcg, getAssertionWriter, getBytecodeVersion, getClassName, getClassNode, getClassVisitor, getCompileStack, getConstructorNode, getContext, getCv, getInterfaceClassLoadingClass, getInternalBaseClassName, getInternalClassName, getLineNumber, getMethodNode, getMethodPointerExpressionWriter, getMethodVisitor, getOperandStack, getOutermostClass, getReturnType, getSourceUnit, isConstructor, isInGeneratedFunction, isInGeneratedFunctionConstructor, isInScriptBody, isNotClinit, isStaticConstructor, isStaticContext, isStaticMethod, resetLineNumber, setInterfaceClassLoadingClass, setLineNumber, setMethodVisitor, shouldOptimizeForInt, switchToFastPath, switchToSlowPathMethods inherited from class org.codehaus.groovy.classgen.asm.WriterController
getNextHelperMethodIndex, getSuperMethodNames, getThisType, visitLineNumber
-
Field Details
-
isInStaticallyCheckedMethod
protected boolean isInStaticallyCheckedMethod
-
-
Constructor Details
-
StaticTypesWriterController
-
-
Method Details
-
init
public void init(AsmClassGenerator asmClassGenerator, GeneratorContext gcon, org.objectweb.asm.ClassVisitor cv, ClassNode cn) Description copied from class:WriterControllerInitializes this controller with compilation context and ASM infrastructure. Must be called exactly once before any bytecode generation operations. Sets up all supporting writers (call site, closure, lambda, etc.) and configures optimization strategies based on compiler configuration.- Overrides:
initin classDelegatingController- Parameters:
asmClassGenerator- the class generator managing the overall compilationgcon- the compilation context tracking state across the compilation unitcv- the ASM ClassVisitor for emitting bytecode directivescn- the ClassNode being compiled
-
setMethodNode
Description copied from class:WriterControllerSets the MethodNode for the method currently being compiled. Automatically clears any active constructor node, since only one can be active. Used during compilation to track which method's bytecode is being generated.- Overrides:
setMethodNodein classDelegatingController- Parameters:
mn- the MethodNode to compile, or null to deactivate
-
setConstructorNode
Description copied from class:WriterControllerSets the ConstructorNode for the constructor currently being compiled. Automatically clears any active method node, since only one can be active. Used during compilation to track which constructor's bytecode is being generated.- Overrides:
setConstructorNodein classDelegatingController- Parameters:
cn- the ConstructorNode to compile, or null to deactivate
-
methodHasDynamicResolution
public boolean methodHasDynamicResolution()GROOVY-11968: returnstruewhen the current statically compiled method contains one or more sub-expressions that will be routed through the regular (non-static) call site writer viagetCallSiteWriterFor(org.codehaus.groovy.ast.expr.Expression). The regular writer's per-method state must then be initialized at method entry.- Since:
- 6.0.0
-
isFastPath
public boolean isFastPath()Description copied from class:WriterControllerReturns true if the compiler is currently in fast-path mode, emitting specialized bytecode for primitive type operations. Use this to determine whether expression helpers should apply optimizations.- Overrides:
isFastPathin classDelegatingController- Returns:
- true if fast-path compilation mode is active
-
getCallSiteWriter
Description copied from class:WriterControllerReturns the CallSiteWriter responsible for generating dynamic call site infrastructure. Behavior depends on bytecode strategy: either invokedynamic for modern JVMs or traditional call-site caching for broader compatibility.- Overrides:
getCallSiteWriterin classDelegatingController
-
getCallSiteWriterFor
Description copied from class:WriterControllerReturns the CallSiteWriter for a specific expression. Currently delegates to the default CallSiteWriter; reserved for future expression-specific optimization strategies.- Overrides:
getCallSiteWriterForin classDelegatingController- Parameters:
expression- the expression being processed- Returns:
- the appropriate call site writer for this expression
-
getRegularCallSiteWriter
-
getStatementWriter
Description copied from class:WriterControllerReturns the StatementWriter for compiling Groovy statements into bytecode. Selection depends on optimization mode: OptimizingStatementWriter forWriterController.optimizeForInt, otherwise generic StatementWriter.- Overrides:
getStatementWriterin classDelegatingController
-
getTypeChooser
Description copied from class:WriterControllerReturns the TypeChooser used to select appropriate type representations for expressions during compilation, supporting both dynamic and typed paths.- Overrides:
getTypeChooserin classDelegatingController
-
getInvocationWriter
Description copied from class:WriterControllerReturns the InvocationWriter for compiling method calls and dynamic function invocations into appropriate bytecode patterns.- Overrides:
getInvocationWriterin classDelegatingController
-
getRegularInvocationWriter
-
getBinaryExpressionHelper
Description copied from class:WriterControllerReturns the appropriate BinaryExpressionHelper for the current code path. Selects fast-path specialized handling whenWriterController.isFastPath()is true, otherwise delegates to the general-purpose binary expression handler. Fast-path optimization is controlled byWriterController.optimizeForInt.- Overrides:
getBinaryExpressionHelperin classDelegatingController- Returns:
- the binary expression writer for the active compilation mode
-
getMethodReferenceExpressionWriter
Description copied from class:WriterControllerReturns the MethodReferenceExpressionWriter for compiling method reference expressions compatible with Java functional interface targets.- Overrides:
getMethodReferenceExpressionWriterin classDelegatingController
-
getUnaryExpressionHelper
Description copied from class:WriterControllerReturns the appropriate UnaryExpressionHelper for the current code path. Selects fast-path specialized handling whenWriterController.isFastPath()is true, otherwise delegates to the general-purpose unary expression handler. Fast-path optimization is controlled byWriterController.optimizeForInt.- Overrides:
getUnaryExpressionHelperin classDelegatingController- Returns:
- the unary expression writer for the active compilation mode
-
getClosureWriter
Description copied from class:WriterControllerReturns the ClosureWriter for compiling Groovy closure literals into inner classes implementing GroovyObject and supporting variable capture.- Overrides:
getClosureWriterin classDelegatingController
-
getLambdaWriter
Description copied from class:WriterControllerReturns the LambdaWriter for compiling Java-style lambda expressions (using the->operator) into functional interfaces.- Overrides:
getLambdaWriterin classDelegatingController
-