Search in sources :

Example 6 with JVMDefinedObjectType

use of st.gravel.support.compiler.jvm.JVMDefinedObjectType in project gravel by gravel-st.

the class JavaSystemMappingCompilerTools method runAstInit_.

@Override
public SystemMappingCompilerTools runAstInit_(JVMClass jvmClass) {
    JVMDefinedObjectType key = jvmClass.type();
    CompiledClass current = jvmClasses.get(key);
    Object[] astConstants = jvmClass.astConstants();
    if (astConstants.length == 0)
        return this;
    MethodType type = MethodType.genericMethodType(astConstants.length).changeReturnType(void.class);
    MethodHandle findStatic;
    try {
        findStatic = MethodHandles.lookup().findStatic(current.javaClass, "_astinit", type);
        findStatic.invokeWithArguments(astConstants);
    } catch (Throwable e) {
        throw new RuntimeException(e);
    }
    return this;
}
Also used : JVMMethodType(st.gravel.support.compiler.jvm.JVMMethodType) MethodType(java.lang.invoke.MethodType) JVMDefinedObjectType(st.gravel.support.compiler.jvm.JVMDefinedObjectType) MethodHandle(java.lang.invoke.MethodHandle)

Aggregations

JVMDefinedObjectType (st.gravel.support.compiler.jvm.JVMDefinedObjectType)6 Reference (st.gravel.support.compiler.ast.Reference)2 VariableDeclarationNode (st.gravel.support.compiler.ast.VariableDeclarationNode)2 JVMMethodType (st.gravel.support.compiler.jvm.JVMMethodType)2 MethodHandle (java.lang.invoke.MethodHandle)1 MethodType (java.lang.invoke.MethodType)1 ArrayList (java.util.ArrayList)1 ASMClassWriter (st.gravel.support.compiler.ASMClassWriter)1 BlockNode (st.gravel.support.compiler.ast.BlockNode)1 BoundVariableDeclarationNode (st.gravel.support.compiler.ast.BoundVariableDeclarationNode)1 ClassDescriptionNode (st.gravel.support.compiler.ast.ClassDescriptionNode)1 MethodNode (st.gravel.support.compiler.ast.MethodNode)1 BlockInnerClass (st.gravel.support.compiler.jvm.BlockInnerClass)1 Invoke (st.gravel.support.compiler.jvm.Invoke)1 JVMClass (st.gravel.support.compiler.jvm.JVMClass)1 JVMClassCompiler (st.gravel.support.compiler.jvm.JVMClassCompiler)1 JVMVariable (st.gravel.support.compiler.jvm.JVMVariable)1 PushString (st.gravel.support.compiler.jvm.PushString)1