Search in sources :

Example 6 with JVMVariable

use of st.gravel.support.compiler.jvm.JVMVariable 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());
}
Also used : JVMVariable(st.gravel.support.compiler.jvm.JVMVariable) Load(st.gravel.support.compiler.jvm.Load) JVMType(st.gravel.support.compiler.jvm.JVMType) ArrayList(java.util.ArrayList) BigInteger(java.math.BigInteger) JVMLocalDeclaration(st.gravel.support.compiler.jvm.JVMLocalDeclaration) ArrayList(java.util.ArrayList) List(java.util.List) JVMInstruction(st.gravel.support.compiler.jvm.JVMInstruction)

Aggregations

JVMVariable (st.gravel.support.compiler.jvm.JVMVariable)6 ArrayList (java.util.ArrayList)3 List (java.util.List)3 BlockNode (st.gravel.support.compiler.ast.BlockNode)3 JVMClass (st.gravel.support.compiler.jvm.JVMClass)2 JVMType (st.gravel.support.compiler.jvm.JVMType)2 BigInteger (java.math.BigInteger)1 ArrayAtNode (st.gravel.support.compiler.ast.ArrayAtNode)1 ArrayAtPutNode (st.gravel.support.compiler.ast.ArrayAtPutNode)1 ArrayLiteralNode (st.gravel.support.compiler.ast.ArrayLiteralNode)1 ArraySizeNode (st.gravel.support.compiler.ast.ArraySizeNode)1 BinaryMessageNode (st.gravel.support.compiler.ast.BinaryMessageNode)1 BooleanAndNode (st.gravel.support.compiler.ast.BooleanAndNode)1 BooleanLiteralNode (st.gravel.support.compiler.ast.BooleanLiteralNode)1 BooleanOrNode (st.gravel.support.compiler.ast.BooleanOrNode)1 ByteArrayLiteralNode (st.gravel.support.compiler.ast.ByteArrayLiteralNode)1 CascadeNode (st.gravel.support.compiler.ast.CascadeNode)1 CharacterLiteralNode (st.gravel.support.compiler.ast.CharacterLiteralNode)1 CreateHolderNode (st.gravel.support.compiler.ast.CreateHolderNode)1 DoubleLiteralNode (st.gravel.support.compiler.ast.DoubleLiteralNode)1