Search in sources :

Example 6 with JVMInstruction

use of st.gravel.support.compiler.jvm.JVMInstruction 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;
}
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) ArrayList(java.util.ArrayList)

Example 7 with JVMInstruction

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

Example 8 with JVMInstruction

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

the class ASMMethodWriter method write.

public void write(JVMMethod method) {
    mv = cw.visitMethod(ACC_PUBLIC + (method.isStatic() ? ACC_STATIC : 0), method.name(), method.signature().descriptorString(), null, null);
    mv.visitCode();
    // logToErr("Method: " + method);
    Label startLabel = new Label();
    mv.visitLabel(startLabel);
    for (JVMInstruction inst : method.instructions()) {
        inst.accept_(this);
    }
    produceLocalVariableInfo(startLabel, method.locals());
    mv.visitMaxs(0, 0);
    mv.visitEnd();
}
Also used : Label(org.objectweb.asm.Label) JVMInstruction(st.gravel.support.compiler.jvm.JVMInstruction)

Aggregations

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