Search in sources :

Example 1 with JVMClassCompiler

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

the class SystemMappingUpdater method compileClass_extensionPostfix_isStatic_identityClass_.

public Class compileClass_extensionPostfix_isStatic_identityClass_(final ClassDescriptionNode _aClassDescriptionNode, final String _extensionPostfix, final boolean _isStatic, final Class _identityClass) {
    final JVMClassCompiler _compiler;
    final Class _extensionClass;
    final JVMClass _jvmClass;
    _compiler = JVMClassCompiler.factory.classDescriptionNode_systemNode_systemMappingUpdater_isStatic_(_aClassDescriptionNode, _systemMapping.systemNode(), this, _isStatic);
    if (_extensionPostfix != null) {
        _compiler.extensionPostfix_(_extensionPostfix);
    }
    if (_identityClass != null) {
        _compiler.selfType_(((JVMNonPrimitiveType) _compilerTools.jvmTypeForClass_(_identityClass)));
    }
    _jvmClass = _compiler.compileClassNode();
    _extensionClass = _compilerTools.writeClass_(_jvmClass);
    _compiler.extraClassesDo_(new st.gravel.support.jvm.Block1<Object, JVMClass>() {

        @Override
        public Object value_(final JVMClass _each) {
            return _compilerTools.writeClass_(_each);
        }
    });
    _compilerTools.runAstInit_(_jvmClass);
    _compiler.extraClassesDo_(new st.gravel.support.jvm.Block1<Object, JVMClass>() {

        @Override
        public Object value_(final JVMClass _each) {
            return _compilerTools.runAstInit_(_each);
        }
    });
    return _extensionClass;
}
Also used : JVMClass(st.gravel.support.compiler.jvm.JVMClass) JVMNonPrimitiveType(st.gravel.support.compiler.jvm.JVMNonPrimitiveType) JVMClassCompiler(st.gravel.support.compiler.jvm.JVMClassCompiler) JVMClass(st.gravel.support.compiler.jvm.JVMClass)

Example 2 with JVMClassCompiler

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

the class SystemMapping method compileInlinedMethod_selfType_allowBlockInlining_.

public Class compileInlinedMethod_selfType_allowBlockInlining_(final MethodNode _aMethodNode, final JVMNonPrimitiveType _selfType, final boolean _allowBlockInlining) {
    final JVMClassCompiler _jvmClassCompiler;
    final JVMClass _inlinedMethodClass;
    final JVMClass[] _jvmClasses;
    _jvmClassCompiler = JVMClassCompiler.factory.classDescriptionNode_systemNode_systemMappingUpdater_isStatic_(null, _systemNode, this.newSystemMappingUpdater(), true);
    _jvmClassCompiler.allowBlockInlining_(_allowBlockInlining);
    _jvmClassCompiler.selfType_(_selfType);
    _jvmClassCompiler.superType_(JVMDefinedObjectType.factory.object());
    _jvmClassCompiler.ownerType_(JVMDefinedObjectType.factory.dottedClassName_("InlinedMethod$" + _compilerTools.nextExtensionPostfix()));
    _inlinedMethodClass = _jvmClassCompiler.compileInlinedMethod_(_aMethodNode);
    _jvmClasses = st.gravel.support.jvm.ArrayExtensions.copyWith_(_jvmClassCompiler.extraClasses(), _inlinedMethodClass);
    return this.compileJVMClasses_(_jvmClasses);
}
Also used : JVMClass(st.gravel.support.compiler.jvm.JVMClass) JVMClassCompiler(st.gravel.support.compiler.jvm.JVMClassCompiler)

Example 3 with JVMClassCompiler

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

the class SystemMapping method compileExpression_reference_.

public JVMClass[] compileExpression_reference_(final Node _anExpression, final Reference _aReference) {
    final JVMDefinedObjectType _ownerType;
    final BlockNode _fieldAccessed;
    final BlockInnerClass _aBlockInnerClass;
    final BlockNode _intermediate;
    final BlockNode _holderized;
    final JVMClassCompiler _jvmClassCompiler;
    final JVMClass _blockClass;
    _intermediate = ((BlockNode) IntermediateNodeRewriter.factory.visit_(BlockNode.factory.expression_(_anExpression)));
    _holderized = ((BlockNode) NonLocalTempWritesToHolderConverter.factory.visit_(_intermediate));
    _fieldAccessed = ((BlockNode) VariableAccessToFieldAccessConverter.factory.instVars_owner_ownerReference_(new VariableDeclarationNode[] {}, NilLiteralNode.factory.basicNew(), _aReference).visit_(_holderized));
    _ownerType = JVMDefinedObjectType.factory.dottedClassName_("Expression$" + _compilerTools.nextExtensionPostfix());
    _aBlockInnerClass = BlockInnerClass.factory.ownerType_blockNode_copiedVariables_(_ownerType, _fieldAccessed, new JVMVariable[] {});
    _jvmClassCompiler = JVMClassCompiler.factory.classDescriptionNode_systemNode_systemMappingUpdater_isStatic_(null, _systemNode, this.newSystemMappingUpdater(), false);
    _jvmClassCompiler.ownerType_(JVMDefinedObjectType.factory.dottedClassName_("ExpressionContainer$" + _compilerTools.nextExtensionPostfix()));
    _blockClass = _jvmClassCompiler.compileBlockNoAdd_(_aBlockInnerClass);
    return _jvmClassCompiler.withContainerAndExtraClasses_(_blockClass);
}
Also used : BlockNode(st.gravel.support.compiler.ast.BlockNode) JVMClass(st.gravel.support.compiler.jvm.JVMClass) JVMVariable(st.gravel.support.compiler.jvm.JVMVariable) JVMClassCompiler(st.gravel.support.compiler.jvm.JVMClassCompiler) JVMDefinedObjectType(st.gravel.support.compiler.jvm.JVMDefinedObjectType) BlockInnerClass(st.gravel.support.compiler.jvm.BlockInnerClass)

Aggregations

JVMClass (st.gravel.support.compiler.jvm.JVMClass)3 JVMClassCompiler (st.gravel.support.compiler.jvm.JVMClassCompiler)3 BlockNode (st.gravel.support.compiler.ast.BlockNode)1 BlockInnerClass (st.gravel.support.compiler.jvm.BlockInnerClass)1 JVMDefinedObjectType (st.gravel.support.compiler.jvm.JVMDefinedObjectType)1 JVMNonPrimitiveType (st.gravel.support.compiler.jvm.JVMNonPrimitiveType)1 JVMVariable (st.gravel.support.compiler.jvm.JVMVariable)1