use of st.gravel.support.compiler.jvm.BlockInnerClass 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.BlockInnerClass in project gravel by gravel-st.
the class JVMClassCompiler method createBlockInnerClass_copiedVariables_.
public BlockInnerClass createBlockInnerClass_copiedVariables_(final BlockNode _aBlockNode, final JVMVariable[] _anArray) {
final BlockInnerClass _innerclass;
_innerclass = BlockInnerClass.factory.ownerType_blockNode_copiedVariables_(this.newInnerClassType(), _aBlockNode, _anArray);
_innerclasses.add(_innerclass);
return _innerclass;
}
use of st.gravel.support.compiler.jvm.BlockInnerClass in project gravel by gravel-st.
the class JVMMethodCompiler method visitBlockNode_.
@Override
public JVMMethodCompiler visitBlockNode_(final BlockNode _blockNode) {
final JVMVariable[] _nCopiedVariables;
final BlockInnerClass[] _innerClassDefinition;
_innerClassDefinition = new BlockInnerClass[1];
_nCopiedVariables = this.copiedVariablesForBlockNode_(_blockNode);
_innerClassDefinition[0] = this.createBlockInnerClass_copiedVariables_(_blockNode, _nCopiedVariables);
if (_nCopiedVariables.length == 0) {
JVMMethodCompiler.this.produceConstant_ifAbsentPut_(_blockNode, new st.gravel.support.jvm.Block0<Object>() {
@Override
public Object value() {
JVMMethodCompiler.this.emit_(NewInstance.factory.type_(_innerClassDefinition[0].ownerType()));
JVMMethodCompiler.this.emit_(Dup.factory.basicNew());
return JVMMethodCompiler.this.emit_(InvokeSpecial.factory.init_voidArguments_(_innerClassDefinition[0].ownerType(), new JVMType[] {}));
}
});
} else {
JVMMethodCompiler.this.emit_(NewInstance.factory.type_(_innerClassDefinition[0].ownerType()));
JVMMethodCompiler.this.emit_(Dup.factory.basicNew());
for (final JVMVariable _each : _nCopiedVariables) {
JVMMethodCompiler.this.produceVarRead_(_each.varName());
JVMMethodCompiler.this.ensureCast_(_each.type());
}
JVMMethodCompiler.this.emit_(InvokeSpecial.factory.init_voidArguments_(_innerClassDefinition[0].ownerType(), st.gravel.support.jvm.ArrayExtensions.collect_(_nCopiedVariables, ((st.gravel.support.jvm.Block1<JVMType, JVMVariable>) (new st.gravel.support.jvm.Block1<JVMType, JVMVariable>() {
@Override
public JVMType value_(final JVMVariable _each) {
return (JVMType) _each.type();
}
})))));
}
return this;
}
use of st.gravel.support.compiler.jvm.BlockInnerClass in project gravel by gravel-st.
the class JVMClassCompiler method compileBlocks.
public JVMClassCompiler compileBlocks() {
final java.util.Set<JVMDefinedObjectType>[] _done;
BlockInnerClass _cl;
_done = new java.util.Set[1];
_done[0] = new java.util.HashSet();
_cl = null;
boolean _temp1 = false;
while (!_temp1) {
_cl = ((BlockInnerClass) st.gravel.support.jvm.OrderedCollectionExtensions.detect_ifNone_(_innerclasses, new st.gravel.support.jvm.Predicate1<BlockInnerClass>() {
@Override
public boolean value_(final BlockInnerClass _e) {
return !_done[0].contains(_e.ownerType());
}
}, ((st.gravel.support.jvm.Block0<BlockInnerClass>) (new st.gravel.support.jvm.Block0<BlockInnerClass>() {
@Override
public BlockInnerClass value() {
return (BlockInnerClass) null;
}
}))));
_temp1 = _cl == null;
if (!_temp1) {
JVMClassCompiler.this.compileBlock_(_cl);
_done[0].add(_cl.ownerType());
}
}
return this;
}
Aggregations