Search in sources :

Example 1 with JVMType

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;
}
Also used : BlockSendArgument(st.gravel.support.compiler.jvm.BlockSendArgument) JVMLocalDeclaration(st.gravel.support.compiler.jvm.JVMLocalDeclaration) JVMType(st.gravel.support.compiler.jvm.JVMType) ArrayList(java.util.ArrayList) List(java.util.List) ArrayList(java.util.ArrayList)

Example 2 with JVMType

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;
}
Also used : JVMType(st.gravel.support.compiler.jvm.JVMType)

Example 3 with JVMType

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;
}
Also used : JVMType(st.gravel.support.compiler.jvm.JVMType)

Example 4 with JVMType

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;
}
Also used : JVMType(st.gravel.support.compiler.jvm.JVMType)

Example 5 with JVMType

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;
}
Also used : JVMType(st.gravel.support.compiler.jvm.JVMType)

Aggregations

JVMType (st.gravel.support.compiler.jvm.JVMType)24 ArrayList (java.util.ArrayList)4 List (java.util.List)3 BigInteger (java.math.BigInteger)2 JVMInstruction (st.gravel.support.compiler.jvm.JVMInstruction)2 JVMLocalDeclaration (st.gravel.support.compiler.jvm.JVMLocalDeclaration)2 JVMVariable (st.gravel.support.compiler.jvm.JVMVariable)2 TypeCast (st.gravel.support.compiler.ast.TypeCast)1 BlockInnerClass (st.gravel.support.compiler.jvm.BlockInnerClass)1 BlockSendArgument (st.gravel.support.compiler.jvm.BlockSendArgument)1 JVMArrayType (st.gravel.support.compiler.jvm.JVMArrayType)1 JVMClass (st.gravel.support.compiler.jvm.JVMClass)1 JVMMethodType (st.gravel.support.compiler.jvm.JVMMethodType)1 Load (st.gravel.support.compiler.jvm.Load)1 ObjectClass (st.gravel.support.jvm.ObjectClass)1