Search in sources :

Example 1 with JVMMethod

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

the class JVMBlockCompiler method compileBlock.

public JVMClass compileBlock() {
    final JVMMethod _m;
    final JVMField[] _fields;
    final JVMMethodCompiler _methodCompiler;
    final JVMClass _jvmClass;
    _fields = st.gravel.support.jvm.ArrayExtensions.collect_(_block.copiedVariables(), ((st.gravel.support.jvm.Block1<JVMField, JVMVariable>) (new st.gravel.support.jvm.Block1<JVMField, JVMVariable>() {

        @Override
        public JVMField value_(final JVMVariable _each) {
            return (JVMField) _each.asField_isStatic_(_block.ownerType(), false);
        }
    })));
    _methodCompiler = JVMMethodCompiler.factory.parent_(_parent);
    _methodCompiler.isStatic_(false);
    _m = _methodCompiler.buildBlock_copiedVariables_blockType_(_block.blockNode(), _fields, _block.ownerType());
    _jvmClass = JVMClass.factory.type_superType_fields_methods_astConstants_(_block.ownerType(), this.superType(), _fields, st.gravel.support.jvm.ArrayFactory.with_with_(_m, this.createInit()), new BlockSendArgument[] {});
    if (_block.blockNode().sourcePosition() != null) {
        _jvmClass.source_(_block.blockNode().sourcePosition().sourceFile().name());
    }
    return _jvmClass;
}
Also used : JVMClass(st.gravel.support.compiler.jvm.JVMClass) JVMVariable(st.gravel.support.compiler.jvm.JVMVariable) JVMMethod(st.gravel.support.compiler.jvm.JVMMethod) BlockSendArgument(st.gravel.support.compiler.jvm.BlockSendArgument) JVMField(st.gravel.support.compiler.jvm.JVMField) JVMMethodCompiler(st.gravel.support.compiler.jvm.JVMMethodCompiler)

Example 2 with JVMMethod

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

the class ASMClassWriter method createBytes.

protected byte[] createBytes() {
    cw = newClassWriter();
    cw.visit(V1_7, ACC_PUBLIC + ACC_SUPER, jvmClass.type().className(), null, jvmClass.superType().className(), new String[] { "java/lang/Cloneable" });
    if (jvmClass.source() != null) {
        cw.visitSource(jvmClass.source(), null);
    }
    for (JVMField field : jvmClass.fields()) {
        createField(field);
    }
    for (JVMMethod method : jvmClass.methods()) {
        createMethod(method);
    }
    cw.visitEnd();
    return cw.toByteArray();
}
Also used : JVMMethod(st.gravel.support.compiler.jvm.JVMMethod) JVMField(st.gravel.support.compiler.jvm.JVMField)

Aggregations

JVMField (st.gravel.support.compiler.jvm.JVMField)2 JVMMethod (st.gravel.support.compiler.jvm.JVMMethod)2 BlockSendArgument (st.gravel.support.compiler.jvm.BlockSendArgument)1 JVMClass (st.gravel.support.compiler.jvm.JVMClass)1 JVMMethodCompiler (st.gravel.support.compiler.jvm.JVMMethodCompiler)1 JVMVariable (st.gravel.support.compiler.jvm.JVMVariable)1