use of st.gravel.support.compiler.jvm.JVMField 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.JVMField in project gravel by gravel-st.
the class JVMMethodCompiler method buildBlock_copiedVariables_blockType_.
public JVMMethod buildBlock_copiedVariables_blockType_(final BlockNode _aBlockNode, final JVMField[] _anArray, final JVMDefinedObjectType _blockType) {
final int _numArgs;
this.reset();
_isBlock = true;
_copiedVariables = new java.util.HashMap<String, JVMField>();
for (final JVMField _each : _anArray) {
_copiedVariables.put(_each.varName(), _each);
}
_copiedVariablesOwner = this.newTempName();
this.pushLocal_type_(_copiedVariablesOwner, _blockType);
for (final VariableDeclarationNode _each : _aBlockNode.arguments()) {
JVMMethodCompiler.this.pushLocal_(_each.name());
}
this.produceBlockBody_(_aBlockNode.body());
_numArgs = _aBlockNode.arguments().length;
_methodName = _parent.selectorConverter().functionNameForNumArgs_(_numArgs);
_signature = JVMMethodType.factory.dynamic_(_numArgs);
return this.buildMethod();
}
use of st.gravel.support.compiler.jvm.JVMField in project gravel by gravel-st.
the class ASMClassWriter method createBytes.
protected byte[] createBytes() {
cw = newClassWriter();
cw.visit(V1_7, ACC_PUBLIC + ACC_SUPER, jvmClass.type().className(), null, jvmClass.superType().className(), new String[] { "java/lang/Cloneable" });
if (jvmClass.source() != null) {
cw.visitSource(jvmClass.source(), null);
}
for (JVMField field : jvmClass.fields()) {
createField(field);
}
for (JVMMethod method : jvmClass.methods()) {
createMethod(method);
}
cw.visitEnd();
return cw.toByteArray();
}
use of st.gravel.support.compiler.jvm.JVMField in project gravel by gravel-st.
the class JVMMethodCompiler method produceVarRead_.
public JVMMethodCompiler produceVarRead_(final String _aString) {
final JVMLocalDeclaration _local;
final JVMField _cv;
JVMLocalDeclaration _temp1 = _locals.get(_aString);
_local = ((JVMLocalDeclaration) _temp1);
if (_local != null) {
return JVMMethodCompiler.this.emit_(Load.factory.local_(_local));
}
_cv = _copiedVariables.get(_aString);
this.produceVarRead_(_copiedVariablesOwner);
this.emit_(_cv.asGetField());
return this;
}
Aggregations