use of st.gravel.support.compiler.jvm.JVMLocalDeclaration in project gravel by gravel-st.
the class JVMBlockCompiler method createInit.
public JVMMethod createInit() {
final List<JVMInstruction>[] _instructions;
final Load[] _read0;
final JVMLocalDeclaration[] _locals;
_instructions = new List[1];
_read0 = new Load[1];
_instructions[0] = new java.util.ArrayList();
_read0[0] = Load.factory.index_type_(0, _block.ownerType());
for (int _temp1 = 0; _temp1 < _block.copiedVariables().length; _temp1++) {
final int _i = _temp1 + 1;
final JVMVariable _elem = _block.copiedVariables()[_temp1];
_instructions[0].add(_read0[0]);
_instructions[0].add(Load.factory.index_type_(_i, _elem.type()));
_instructions[0].add(PutField.factory.ownerType_name_type_(_block.ownerType(), _elem.varName(), _elem.type()));
}
_instructions[0].add(_read0[0]);
_instructions[0].add(InvokeSpecial.factory.init_voidArguments_(this.superType(), new JVMType[] {}));
_instructions[0].add(Return.factory.basicNew());
_locals = st.gravel.support.jvm.ArrayExtensions.copyWithFirst_(st.gravel.support.jvm.ArrayExtensions.keysAndValuesCollect_(_block.copiedVariables(), new st.gravel.support.jvm.Block2<JVMLocalDeclaration, Integer, JVMVariable>() {
@Override
public JVMLocalDeclaration value_value_(final Integer _i, final JVMVariable _var) {
return (JVMLocalDeclaration) _var.asLocalDeclaration_(_i);
}
}), JVMLocalDeclaration.factory.blockSelf());
return JVMMethod.factory.name_locals_instructions_isStatic_signature_("<init>", _locals, _instructions[0].toArray(new JVMInstruction[_instructions[0].size()]), false, _block.initSignature());
}
use of st.gravel.support.compiler.jvm.JVMLocalDeclaration 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;
}
use of st.gravel.support.compiler.jvm.JVMLocalDeclaration in project gravel by gravel-st.
the class JVMMethodCompiler method newSubFrame_.
public Frame newSubFrame_(final st.gravel.support.jvm.Block0<Object> _aBlock) {
final JVMStack _oldStack;
final List<JVMInstruction> _oldInstructions;
final Frame _frame;
final Map<String, JVMLocalDeclaration> _oldLocals;
_oldStack = _stack;
_oldInstructions = _instructions;
_oldLocals = _locals;
_locals = st.gravel.support.jvm.DictionaryExtensions.copy(_oldLocals);
_instructions = new java.util.ArrayList();
_stack = _oldStack.copy();
_aBlock.value();
_frame = Frame.factory.instructions_endStack_(_instructions.toArray(new JVMInstruction[_instructions.size()]), _stack);
_stack = _oldStack;
_instructions = _oldInstructions;
_locals = _oldLocals;
return _frame;
}
use of st.gravel.support.compiler.jvm.JVMLocalDeclaration in project gravel by gravel-st.
the class JVMMethodCompiler method localStore_.
public JVMMethodCompiler localStore_(final String _localName) {
final JVMLocalDeclaration _local;
_local = _locals.get(_localName);
this.ensureCast_(_local.type());
this.emit_(((JVMInstruction) Store.factory.local_(_local)));
return this;
}
use of st.gravel.support.compiler.jvm.JVMLocalDeclaration in project gravel by gravel-st.
the class JVMMethodCompiler method renameLocal_to_.
public JVMMethodCompiler renameLocal_to_(final String _oldName, final String _newName) {
final JVMLocalDeclaration _local;
_local = _locals.remove(_oldName);
_locals.put(_newName, _local.withVarName_(_newName));
return this;
}
Aggregations