Example usage for org.objectweb.asm Opcodes ACC_PUBLIC

List of usage examples for org.objectweb.asm Opcodes ACC_PUBLIC

Introduction

In this page you can find the example usage for org.objectweb.asm Opcodes ACC_PUBLIC.

Prototype

int ACC_PUBLIC

To view the source code for org.objectweb.asm Opcodes ACC_PUBLIC.

Click Source Link

Usage

From source file:com.xruby.compiler.codegen.FieldManager.java

License:BSD License

private void addNewBlockFieldToClass(String name) {
    FieldVisitor fv = cv_.visitField(Opcodes.ACC_PUBLIC, getNameFromFullpath(name),
            Type.getType("L" + name + ";").getDescriptor(), null, null);
    fv.visitEnd();/*from   ww  w  .j  av  a2  s .  c o m*/
}

From source file:com.xruby.compiler.codegen.FieldManager.java

License:BSD License

private MethodGenerator visitRubyBlock() {
    cv_.visit(CgConfig.TARGET_VERSION, Opcodes.ACC_PUBLIC, //need to modify fields when doing Proc#call, see RubyProc.java
            name_, null, // signature
            this.helper.getSuperName(), // superName
            null // interface
    );/* w  w  w . ja  v  a  2 s .  c o m*/

    // set source file's name, for debug
    if (file_name_ != null) {
        cv_.visitSource(file_name_, null);
    }

    return new MethodGenerator(Opcodes.ACC_PROTECTED, Method.getMethod(this.helper.getRunMethodName()), cv_,
            null, symbol_table_of_the_current_scope_, false);
}

From source file:com.xruby.compiler.codegen.FieldManager.java

License:BSD License

private void createConstructorOfRubyBlock() {

    MethodGenerator mg = new MethodGenerator(Opcodes.ACC_PUBLIC, Method.getMethod(buildContructorSignature()),
            cv_, null, symbol_table_of_the_current_scope_, false);

    mg.loadThis();//w  ww. jav  a2s  .  co  m

    this.helper.pushBasciArgForSuperArg(mg, argc_, has_asterisk_parameter_, default_argc_);

    final int FIXED_PARAMETERS = 7;
    for (int i = 0; i < FIXED_PARAMETERS; ++i) {
        mg.loadArg(i);
    }

    mg.invokeConstructor(this.helper.getSuperClassType(), Method.getMethod(this.helper.getSuperCtorName()));

    mg.returnValue();
    mg.endMethod();
}

From source file:com.xruby.compiler.codegen.ClassGeneratorForRubyMethod.java

License:BSD License

private void createCtorForRubyMethod(int argc, boolean has_asterisk_parameter, int default_argc) {
    MethodGenerator mg = new MethodGenerator(Opcodes.ACC_PUBLIC, CgUtil.CONSTRUCTOR, cv_, null, null, false);
    mg.loadThis();//from   w  w  w .j a va 2  s. c om

    this.pushBasciArgForSuperArg(mg, argc, has_asterisk_parameter, default_argc);

    mg.invokeConstructor(getSuperClassType(), Method.getMethod(this.getSuperCtorName()));
    mg.returnValue();
    mg.endMethod();
}

From source file:com.xruby.compiler.codegen.ClassGeneratorForRubyProgram.java

License:BSD License

private MethodGenerator startRubyProgram(boolean createMain, boolean is_singleton) {
    cv_.visit(CgConfig.TARGET_VERSION, Opcodes.ACC_PUBLIC, name_, null, // signature
            Types.RUBY_PROGRAM_TYPE.getInternalName(), // superName
            null // interface
    );/*  ww w. j  av a2  s .  c  om*/

    // set source file's name, for debug
    if (this.fileName != null) {
        cv_.visitSource(this.fileName, null);
    }

    CgUtil.createImplicitConstructor(this.cv_, Types.RUBY_PROGRAM_TYPE);

    if (createMain) {
        createStaticVoidMain(cv_);
    }

    //Implement RubyProgram
    return new MethodGenerator(Opcodes.ACC_PROTECTED, RUBY_PROGRAM_RUN, cv_, this.binding, null, is_singleton);
}

From source file:com.xruby.compiler.codegen.ClassGeneratorForRubyProgram.java

License:BSD License

private void createStaticVoidMain(ClassVisitor cv) {
    MethodGenerator mg = new MethodGenerator(Opcodes.ACC_PUBLIC + Opcodes.ACC_STATIC,
            Method.getMethod("void main (String[])"), cv, null, null, false);

    mg.loadArg(0);/* w ww .ja  va 2  s.co m*/
    mg.invokeStatic(Types.RUBY_RUNTIME_TYPE, Method.getMethod("void init(String[])"));

    Type program = Type.getType("L" + name_ + ";");
    mg.newInstance(program);
    mg.dup();
    mg.invokeConstructor(program, CgUtil.CONSTRUCTOR);
    mg.invokeVirtual(program, CgUtil.getMethod("invoke", Types.RUBY_VALUE_TYPE));
    mg.pop();

    mg.invokeStatic(Types.RUBY_RUNTIME_TYPE, CgUtil.getMethod("fini", Type.VOID_TYPE));

    mg.returnValue();
    mg.endMethod();
}

From source file:com.xruby.compiler.codegen.RubyIDClassGenerator.java

License:BSD License

private static byte[] visitEnd() {
    ClassWriter cw = new ClassWriter(ClassWriter.COMPUTE_MAXS);
    cw.visit(Opcodes.V1_1, Opcodes.ACC_PUBLIC, RubyIDClassName, null, "java/lang/Object", null);
    Method staticBlock = Method.getMethod("void <clinit> ()V");
    GeneratorAdapter staticBlockMg = new GeneratorAdapter(Opcodes.ACC_STATIC, staticBlock, null, null, cw);

    for (Map.Entry<String, String> e : idMap.entrySet()) {
        cw.visitField(Opcodes.ACC_PUBLIC + Opcodes.ACC_STATIC, e.getValue(), Types.RUBY_ID_TYPE.getDescriptor(),
                null, null);/*w  ww  . ja va 2s . c o  m*/

        staticBlockMg.push(e.getKey());
        staticBlockMg.invokeStatic(Type.getType(RubyID.class),
                Method.getMethod("com.xruby.runtime.lang.RubyID intern(String)"));
        staticBlockMg.putStatic(Type.getType("L" + RubyIDClassName + ";"), e.getValue(), Types.RUBY_ID_TYPE);
    }

    staticBlockMg.returnValue();
    staticBlockMg.endMethod();
    cw.visitEnd();

    clear();

    return cw.toByteArray();
}

From source file:com.xruby.runtime.lang.util.MethodFactory.java

License:BSD License

private void startInvoker(ClassVisitor cv, MethodFactoryHelper helper, String invokerName) {
    Type superType = helper.getSuperType();
    cv.visit(CgConfig.TARGET_VERSION, Opcodes.ACC_PUBLIC, invokerName, null, superType.getInternalName(), null);
    CgUtil.createImplicitConstructor(cv, superType);
}

From source file:com.xruby.runtime.lang.util.RubyTypeFactory.java

License:BSD License

private void startBuilder(String name) {
    this.cv.visit(CgConfig.TARGET_VERSION, Opcodes.ACC_PUBLIC, name, null, OBJECT_TYPE.getInternalName(),
            new String[] { getInterface().getInternalName() });

    CgUtil.createImplicitConstructor(this.cv, OBJECT_TYPE);
}

From source file:com.xruby.runtime.lang.util.RubyTypeFactory.java

License:BSD License

private GeneratorAdapter startBuilderMethod() {
    GeneratorAdapter mg = new GeneratorAdapter(Opcodes.ACC_PUBLIC, getBuilderMethod(), null, null, this.cv);
    mg.visitCode();//from  w w w. j a v  a2 s .  c o  m
    return mg;
}