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;
}
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);
}
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);
}
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;
}
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];
}
Aggregations