Search in sources :

Example 1 with JVMMethodConstant

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

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

the class JVMClassCompiler method constantAt_ifAbsentPut_.

public JVMMethodConstant constantAt_ifAbsentPut_(final Expression _anObject, final st.gravel.support.jvm.Block0<JVMMethodConstant> _aBlock) {
    return ((JVMMethodConstant) st.gravel.support.jvm.OrderedCollectionExtensions.detect_ifNone_(_constants, new st.gravel.support.jvm.Predicate1<JVMMethodConstant>() {

        @Override
        public boolean value_(final JVMMethodConstant _each) {
            return st.gravel.support.jvm.ObjectExtensions.equals_(_each.expression(), _anObject);
        }
    }, ((st.gravel.support.jvm.Block0<JVMMethodConstant>) (new st.gravel.support.jvm.Block0<JVMMethodConstant>() {

        @Override
        public JVMMethodConstant value() {
            final JVMMethodConstant _constant;
            _constant = _aBlock.value();
            _constants.add(_constant);
            return (JVMMethodConstant) _constant;
        }
    }))));
}
Also used : ArrayList(java.util.ArrayList) List(java.util.List) JVMMethodConstant(st.gravel.support.compiler.jvm.JVMMethodConstant)

Example 3 with JVMMethodConstant

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

the class JVMMethodCompiler method produceConstant_ifAbsentPut_.

public JVMMethodCompiler produceConstant_ifAbsentPut_(final Expression _anExpression, final st.gravel.support.jvm.Block0<Object> _aBlock) {
    final JVMMethodConstant _const;
    _const = _parent.constantAt_ifAbsentPut_(_anExpression, ((st.gravel.support.jvm.Block0<JVMMethodConstant>) (new st.gravel.support.jvm.Block0<JVMMethodConstant>() {

        @Override
        public JVMMethodConstant value() {
            return (JVMMethodConstant) JVMMethodConstant.factory.expression_name_frame_ownerType_(_anExpression, _parent.newConstantName(), JVMMethodCompiler.this.newFrame_(_aBlock), JVMMethodCompiler.this.ownerType());
        }
    })));
    this.emit_(_const.asReadInstruction());
    return this;
}
Also used : JVMMethodConstant(st.gravel.support.compiler.jvm.JVMMethodConstant)

Aggregations

JVMMethodConstant (st.gravel.support.compiler.jvm.JVMMethodConstant)3 ArrayList (java.util.ArrayList)2 List (java.util.List)2 JVMLocalDeclaration (st.gravel.support.compiler.jvm.JVMLocalDeclaration)1