Search in sources :

Example 1 with JVMClass

use of st.gravel.support.compiler.jvm.JVMClass 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 JVMClass

use of st.gravel.support.compiler.jvm.JVMClass 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 JVMClass

use of st.gravel.support.compiler.jvm.JVMClass 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)

Example 4 with JVMClass

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

the class JVMBlockCompiler method compileBlock.

public JVMClass compileBlock() {
    final JVMMethod _m;
    final JVMField[] _fields;
    final JVMMethodCompiler _methodCompiler;
    final JVMClass _jvmClass;
    _fields = st.gravel.support.jvm.ArrayExtensions.collect_(_block.copiedVariables(), ((st.gravel.support.jvm.Block1<JVMField, JVMVariable>) (new st.gravel.support.jvm.Block1<JVMField, JVMVariable>() {

        @Override
        public JVMField value_(final JVMVariable _each) {
            return (JVMField) _each.asField_isStatic_(_block.ownerType(), false);
        }
    })));
    _methodCompiler = JVMMethodCompiler.factory.parent_(_parent);
    _methodCompiler.isStatic_(false);
    _m = _methodCompiler.buildBlock_copiedVariables_blockType_(_block.blockNode(), _fields, _block.ownerType());
    _jvmClass = JVMClass.factory.type_superType_fields_methods_astConstants_(_block.ownerType(), this.superType(), _fields, st.gravel.support.jvm.ArrayFactory.with_with_(_m, this.createInit()), new BlockSendArgument[] {});
    if (_block.blockNode().sourcePosition() != null) {
        _jvmClass.source_(_block.blockNode().sourcePosition().sourceFile().name());
    }
    return _jvmClass;
}
Also used : JVMClass(st.gravel.support.compiler.jvm.JVMClass) JVMVariable(st.gravel.support.compiler.jvm.JVMVariable) JVMMethod(st.gravel.support.compiler.jvm.JVMMethod) BlockSendArgument(st.gravel.support.compiler.jvm.BlockSendArgument) JVMField(st.gravel.support.compiler.jvm.JVMField) JVMMethodCompiler(st.gravel.support.compiler.jvm.JVMMethodCompiler)

Example 5 with JVMClass

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

the class SystemMapping method compileJVMClasses_.

public Class compileJVMClasses_(final JVMClass[] _jvmClasses) {
    final Class[] _last;
    _last = new Class[1];
    _last[0] = null;
    for (final JVMClass _jvmClass : _jvmClasses) {
        _last[0] = _compilerTools.writeClass_(_jvmClass);
    }
    for (final JVMClass _jvmClass : _jvmClasses) {
        _compilerTools.runAstInit_(_jvmClass);
    }
    return _last[0];
}
Also used : JVMClass(st.gravel.support.compiler.jvm.JVMClass) BlockInnerClass(st.gravel.support.compiler.jvm.BlockInnerClass) JVMClass(st.gravel.support.compiler.jvm.JVMClass)

Aggregations

JVMClass (st.gravel.support.compiler.jvm.JVMClass)7 JVMClassCompiler (st.gravel.support.compiler.jvm.JVMClassCompiler)3 BlockInnerClass (st.gravel.support.compiler.jvm.BlockInnerClass)2 JVMVariable (st.gravel.support.compiler.jvm.JVMVariable)2 BlockNode (st.gravel.support.compiler.ast.BlockNode)1 BlockSendArgument (st.gravel.support.compiler.jvm.BlockSendArgument)1 JVMDefinedObjectType (st.gravel.support.compiler.jvm.JVMDefinedObjectType)1 JVMField (st.gravel.support.compiler.jvm.JVMField)1 JVMMethod (st.gravel.support.compiler.jvm.JVMMethod)1 JVMMethodCompiler (st.gravel.support.compiler.jvm.JVMMethodCompiler)1 JVMNonPrimitiveType (st.gravel.support.compiler.jvm.JVMNonPrimitiveType)1