use of st.gravel.support.compiler.jvm.JVMType in project gravel by gravel-st.
the class JVMClassCompiler method compileAstInit.
public JVMClassCompiler compileAstInit() {
final List<JVMInstruction>[] _instructions;
final int[] _i;
_i = new int[1];
_instructions = new List[1];
_instructions[0] = new java.util.ArrayList();
_i[0] = 0;
for (final BlockSendArgument _each : _astConstants) {
final JVMType _type;
_type = JVMDynamicObjectType.factory.basicNew();
_instructions[0].add(ALoad.factory.index_type_(_i[0], _type));
_instructions[0].add(PutStatic.factory.ownerType_name_type_(_ownerType, _each.name(), _type));
_i[0] = ((_i[0]) + 1);
_fields.add(JVMField.factory.ownerType_varName_type_isStatic_(_ownerType, _each.name(), _type, true));
}
_instructions[0].add(Return.factory.basicNew());
_jvmMethods.add(JVMMethod.factory.name_locals_instructions_isStatic_signature_("_astinit", new JVMLocalDeclaration[] {}, _instructions[0].toArray(new JVMInstruction[_instructions[0].size()]), true, JVMMethodType.factory.voidDynamic_(_astConstants.size())));
return this;
}
use of st.gravel.support.compiler.jvm.JVMType in project gravel by gravel-st.
the class JVMMethodCompiler method ensureCast_.
public JVMMethodCompiler ensureCast_(final JVMType _aType) {
final JVMType _lastType;
JVMType _temp1 = _lastType = _stack.peek();
if (!st.gravel.support.jvm.ObjectExtensions.equals_(_temp1, _aType)) {
JVMMethodCompiler.this.emit_(_lastType.newCastInstructionTo_(_aType));
}
return this;
}
use of st.gravel.support.compiler.jvm.JVMType in project gravel by gravel-st.
the class JVMMethodCompiler method visitFieldWriteNode_.
@Override
public JVMMethodCompiler visitFieldWriteNode_(final FieldWriteNode _aNode) {
final JVMType _fieldType;
this.visit_(_aNode.owner());
this.visit_(_aNode.value());
_fieldType = TypeNodeToJVMTypeConverter.factory.namespace_(_parent.namespace()).visit_(_aNode.type());
this.ensureCast_(_fieldType);
this.emit_(DupX1.factory.basicNew());
this.emit_(DynamicFieldWrite.factory.name_type_(_aNode.name(), _fieldType));
return this;
}
use of st.gravel.support.compiler.jvm.JVMType in project gravel by gravel-st.
the class JVMMethodType method sourceOn_.
@Override
public JVMMethodType sourceOn_(final StringBuilder _aStream) {
_aStream.append('(');
for (final JVMType _each : _arguments) {
_each.printOn_(_aStream);
}
_aStream.append(')');
_returnType.printOn_(_aStream);
return this;
}
use of st.gravel.support.compiler.jvm.JVMType in project gravel by gravel-st.
the class JVMStack method pop.
public JVMType pop() {
final JVMType _last;
_last = _elements[_elements.length - 1];
if (_last.isWide()) {
throw new RuntimeException("Cannot pop a wide element");
}
_elements = st.gravel.support.jvm.ArrayExtensions.copyWithoutLast(_elements);
return _last;
}
Aggregations