Search in sources :

Example 1 with JVMLocalDeclaration

use of st.gravel.support.compiler.jvm.JVMLocalDeclaration in project gravel by gravel-st.

the class JVMClassCompiler method compileClinit.

public JVMClassCompiler compileClinit() {
    final List<JVMInstruction>[] _instructions;
    _instructions = new List[1];
    _instructions[0] = new java.util.ArrayList();
    for (final JVMMethodConstant _each : _constants) {
        st.gravel.support.jvm.OrderedCollectionExtensions.addAll_(_instructions[0], _each.clinitInstructions());
        _fields.add(_each.fieldDefinition());
    }
    _instructions[0].add(Return.factory.basicNew());
    _jvmMethods.add(JVMMethod.factory.name_locals_instructions_isStatic_signature_("<clinit>", new JVMLocalDeclaration[] {}, _instructions[0].toArray(new JVMInstruction[_instructions[0].size()]), true, JVMMethodType.factory.r_void()));
    return this;
}
Also used : JVMMethodConstant(st.gravel.support.compiler.jvm.JVMMethodConstant) JVMLocalDeclaration(st.gravel.support.compiler.jvm.JVMLocalDeclaration) ArrayList(java.util.ArrayList) List(java.util.List) ArrayList(java.util.ArrayList)

Example 2 with JVMLocalDeclaration

use of st.gravel.support.compiler.jvm.JVMLocalDeclaration 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 3 with JVMLocalDeclaration

use of st.gravel.support.compiler.jvm.JVMLocalDeclaration in project gravel by gravel-st.

the class JVMMethodCompiler method newFrame_.

public Frame newFrame_(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;
    this.reset();
    _locals = st.gravel.support.jvm.DictionaryExtensions.copy(_oldLocals);
    _aBlock.value();
    _frame = Frame.factory.instructions_endStack_(_instructions.toArray(new JVMInstruction[_instructions.size()]), _stack);
    _stack = _oldStack;
    _instructions = _oldInstructions;
    _locals = _oldLocals;
    return _frame;
}
Also used : Frame(st.gravel.support.compiler.jvm.Frame) JVMLocalDeclaration(st.gravel.support.compiler.jvm.JVMLocalDeclaration) PushString(st.gravel.support.compiler.jvm.PushString) JVMStack(st.gravel.support.compiler.jvm.JVMStack) JVMInstruction(st.gravel.support.compiler.jvm.JVMInstruction)

Example 4 with JVMLocalDeclaration

use of st.gravel.support.compiler.jvm.JVMLocalDeclaration in project gravel by gravel-st.

the class JVMMethodCompiler method localOrCopiedAt_.

public JVMVariable localOrCopiedAt_(final String _varName) {
    final JVMLocalDeclaration _local;
    JVMLocalDeclaration _temp1 = _locals.get(_varName);
    _local = ((JVMLocalDeclaration) _temp1);
    if (_local != null) {
        return _local;
    }
    return _copiedVariables.get(_varName);
}
Also used : JVMLocalDeclaration(st.gravel.support.compiler.jvm.JVMLocalDeclaration)

Example 5 with JVMLocalDeclaration

use of st.gravel.support.compiler.jvm.JVMLocalDeclaration in project gravel by gravel-st.

the class JVMMethodCompiler method reset.

public JVMMethodCompiler reset() {
    _locals = new java.util.HashMap<String, JVMLocalDeclaration>();
    _stack = JVMStack.factory.basicNew();
    _instructions = new java.util.ArrayList();
    return this;
}
Also used : JVMLocalDeclaration(st.gravel.support.compiler.jvm.JVMLocalDeclaration) PushString(st.gravel.support.compiler.jvm.PushString) ArrayList(java.util.ArrayList)

Aggregations

JVMLocalDeclaration (st.gravel.support.compiler.jvm.JVMLocalDeclaration)11 ArrayList (java.util.ArrayList)5 JVMInstruction (st.gravel.support.compiler.jvm.JVMInstruction)4 List (java.util.List)3 PushString (st.gravel.support.compiler.jvm.PushString)3 Frame (st.gravel.support.compiler.jvm.Frame)2 JVMStack (st.gravel.support.compiler.jvm.JVMStack)2 JVMType (st.gravel.support.compiler.jvm.JVMType)2 BigInteger (java.math.BigInteger)1 Label (org.objectweb.asm.Label)1 BlockSendArgument (st.gravel.support.compiler.jvm.BlockSendArgument)1 JVMField (st.gravel.support.compiler.jvm.JVMField)1 JVMMethodConstant (st.gravel.support.compiler.jvm.JVMMethodConstant)1 JVMVariable (st.gravel.support.compiler.jvm.JVMVariable)1 Load (st.gravel.support.compiler.jvm.Load)1