Search in sources :

Example 1 with GENERATED_LAMBDA_TYPE

use of org.codehaus.groovy.ast.ClassHelper.GENERATED_LAMBDA_TYPE in project groovy by apache.

the class StaticTypesLambdaWriter method getOrAddLambdaClass.

private ClassNode getOrAddLambdaClass(final LambdaExpression expression, final int modifiers, final MethodNode abstractMethod) {
    return lambdaClassNodes.computeIfAbsent(expression, key -> {
        ClassNode lambdaClass = createLambdaClass(expression, modifiers, abstractMethod);
        controller.getAcg().addInnerClass(lambdaClass);
        lambdaClass.addInterface(GENERATED_LAMBDA_TYPE);
        lambdaClass.putNodeMetaData(StaticCompilationMetadataKeys.STATIC_COMPILE_NODE, Boolean.TRUE);
        lambdaClass.putNodeMetaData(WriterControllerFactory.class, (WriterControllerFactory) x -> controller);
        return lambdaClass;
    });
}
Also used : MethodVisitor(org.objectweb.asm.MethodVisitor) WriterController(org.codehaus.groovy.classgen.asm.WriterController) LambdaWriter(org.codehaus.groovy.classgen.asm.LambdaWriter) GeneralUtils.classX(org.codehaus.groovy.ast.tools.GeneralUtils.classX) ClassHelper.findSAM(org.codehaus.groovy.ast.ClassHelper.findSAM) H_INVOKEVIRTUAL(org.objectweb.asm.Opcodes.H_INVOKEVIRTUAL) NEW(org.objectweb.asm.Opcodes.NEW) BytecodeHelper(org.codehaus.groovy.classgen.asm.BytecodeHelper) Map(java.util.Map) GeneralUtils.block(org.codehaus.groovy.ast.tools.GeneralUtils.block) VOID_TYPE(org.codehaus.groovy.ast.ClassHelper.VOID_TYPE) VariableExpression(org.codehaus.groovy.ast.expr.VariableExpression) AstStringCompiler(org.codehaus.groovy.ast.builder.AstStringCompiler) INVOKEVIRTUAL(org.objectweb.asm.Opcodes.INVOKEVIRTUAL) InnerClassNode(org.codehaus.groovy.ast.InnerClassNode) SERIALIZABLE_TYPE(org.codehaus.groovy.ast.ClassHelper.SERIALIZABLE_TYPE) GroovyBugError(org.codehaus.groovy.GroovyBugError) DUP(org.objectweb.asm.Opcodes.DUP) List(java.util.List) CompileStack(org.codehaus.groovy.classgen.asm.CompileStack) OBJECT_TYPE(org.codehaus.groovy.ast.ClassHelper.OBJECT_TYPE) BlockStatement(org.codehaus.groovy.ast.stmt.BlockStatement) ACC_PUBLIC(org.objectweb.asm.Opcodes.ACC_PUBLIC) Optional(java.util.Optional) ClassHelper.long_TYPE(org.codehaus.groovy.ast.ClassHelper.long_TYPE) Statement(org.codehaus.groovy.ast.stmt.Statement) GeneralUtils.constX(org.codehaus.groovy.ast.tools.GeneralUtils.constX) CodeVisitorSupport(org.codehaus.groovy.ast.CodeVisitorSupport) LambdaExpression(org.codehaus.groovy.ast.expr.LambdaExpression) ACC_FINAL(org.objectweb.asm.Opcodes.ACC_FINAL) ACC_PRIVATE(org.objectweb.asm.Opcodes.ACC_PRIVATE) HashMap(java.util.HashMap) GeneralUtils.declS(org.codehaus.groovy.ast.tools.GeneralUtils.declS) ACC_STATIC(org.objectweb.asm.Opcodes.ACC_STATIC) ClosureUtils.getParametersSafe(org.codehaus.groovy.ast.tools.ClosureUtils.getParametersSafe) GENERATED_LAMBDA_TYPE(org.codehaus.groovy.ast.ClassHelper.GENERATED_LAMBDA_TYPE) MethodNode(org.codehaus.groovy.ast.MethodNode) GeneralUtils.returnS(org.codehaus.groovy.ast.tools.GeneralUtils.returnS) CLOSURE_TYPE(org.codehaus.groovy.ast.ClassHelper.CLOSURE_TYPE) Expression(org.codehaus.groovy.ast.expr.Expression) SERIALIZEDLAMBDA_TYPE(org.codehaus.groovy.ast.ClassHelper.SERIALIZEDLAMBDA_TYPE) LinkedList(java.util.LinkedList) CHECKCAST(org.objectweb.asm.Opcodes.CHECKCAST) Parameter(org.codehaus.groovy.ast.Parameter) BytecodeInstruction(org.codehaus.groovy.classgen.BytecodeInstruction) ICONST_0(org.objectweb.asm.Opcodes.ICONST_0) ClassNode(org.codehaus.groovy.ast.ClassNode) OperandStack(org.codehaus.groovy.classgen.asm.OperandStack) GeneralUtils.cloneParams(org.codehaus.groovy.ast.tools.GeneralUtils.cloneParams) GeneralUtils.localVarX(org.codehaus.groovy.ast.tools.GeneralUtils.localVarX) StaticCompilationMetadataKeys(org.codehaus.groovy.transform.sc.StaticCompilationMetadataKeys) StaticTypesMarker(org.codehaus.groovy.transform.stc.StaticTypesMarker) ClosureExpression(org.codehaus.groovy.ast.expr.ClosureExpression) INVOKESPECIAL(org.objectweb.asm.Opcodes.INVOKESPECIAL) BytecodeSequence(org.codehaus.groovy.classgen.BytecodeSequence) WriterControllerFactory(org.codehaus.groovy.classgen.asm.WriterControllerFactory) ConstructorNode(org.codehaus.groovy.ast.ConstructorNode) ALOAD(org.objectweb.asm.Opcodes.ALOAD) InnerClassNode(org.codehaus.groovy.ast.InnerClassNode) ClassNode(org.codehaus.groovy.ast.ClassNode)

Aggregations

HashMap (java.util.HashMap)1 LinkedList (java.util.LinkedList)1 List (java.util.List)1 Map (java.util.Map)1 Optional (java.util.Optional)1 GroovyBugError (org.codehaus.groovy.GroovyBugError)1 CLOSURE_TYPE (org.codehaus.groovy.ast.ClassHelper.CLOSURE_TYPE)1 GENERATED_LAMBDA_TYPE (org.codehaus.groovy.ast.ClassHelper.GENERATED_LAMBDA_TYPE)1 OBJECT_TYPE (org.codehaus.groovy.ast.ClassHelper.OBJECT_TYPE)1 SERIALIZABLE_TYPE (org.codehaus.groovy.ast.ClassHelper.SERIALIZABLE_TYPE)1 SERIALIZEDLAMBDA_TYPE (org.codehaus.groovy.ast.ClassHelper.SERIALIZEDLAMBDA_TYPE)1 VOID_TYPE (org.codehaus.groovy.ast.ClassHelper.VOID_TYPE)1 ClassHelper.findSAM (org.codehaus.groovy.ast.ClassHelper.findSAM)1 ClassHelper.long_TYPE (org.codehaus.groovy.ast.ClassHelper.long_TYPE)1 ClassNode (org.codehaus.groovy.ast.ClassNode)1 CodeVisitorSupport (org.codehaus.groovy.ast.CodeVisitorSupport)1 ConstructorNode (org.codehaus.groovy.ast.ConstructorNode)1 InnerClassNode (org.codehaus.groovy.ast.InnerClassNode)1 MethodNode (org.codehaus.groovy.ast.MethodNode)1 Parameter (org.codehaus.groovy.ast.Parameter)1