Package org.apache.bcel.generic

Examples of org.apache.bcel.generic.ALOAD


             MethodGenerator methodGen) {
    }


    public Instruction LOAD(int slot) {
  return new ALOAD(slot);
    }
View Full Code Here


           String fileName,
           int accessFlags, String[] interfaces,
           Stylesheet stylesheet) {
  super(className, superClassName, fileName,
        accessFlags, interfaces, stylesheet);
  _aloadTranslet = new ALOAD(TRANSLET_INDEX);
    }
View Full Code Here

    /* public <init> -- constructor
     */
    il.dispose(); // Dispose instruction handles for better memory utilization

    il = new InstructionList();
    il.append(new ALOAD(0)); // Push `this'
    il.append(new INVOKESPECIAL(cp.addMethodref("java.lang.Object",
            "<init>", "()V")));
    il.append(new RETURN());

    method = new MethodGen(ACC_PUBLIC, Type.VOID, Type.NO_ARGS, null,
View Full Code Here

            Constants.GETSTATIC));

    il.append(new PUSH(cp, "Please enter your name> "));
    il.append(factory.createInvoke("java.io.PrintStream", "print", Type.VOID,
           new Type[] { Type.STRING }, Constants.INVOKEVIRTUAL));
    il.append(new ALOAD(in));
    il.append(factory.createInvoke("java.io.BufferedReader", "readLine",
           Type.STRING, Type.NO_ARGS, Constants.INVOKEVIRTUAL));
    il.append(new ASTORE(name));

    /* Upon normal execution we jump behind exception handler,
     * the target address is not known yet.
     */
    GOTO g = new GOTO(null);
    InstructionHandle try_end = il.append(g);

    /* } catch() { ... }
     * Add exception handler: print exception and return from method
     */
    InstructionHandle handler =
      il.append(factory.createFieldAccess("java.lang.System", "out", p_stream,
            Constants.GETSTATIC));
    // Little trick in order not to save exception object temporarily
    il.append(InstructionConstants.SWAP);

    il.append(factory.createInvoke("java.io.PrintStream", "println", Type.VOID,
     new Type[] { Type.OBJECT }, Constants.INVOKEVIRTUAL));
    il.append(InstructionConstants.RETURN);
    mg.addExceptionHandler(try_start, try_end, handler,
         new ObjectType("java.io.IOException"));

    /* Normal code continues, now we can set the branch target of the GOTO
     * that jumps over the handler code.
     */
    InstructionHandle ih =
      il.append(factory.createFieldAccess("java.lang.System", "out", p_stream,
            Constants.GETSTATIC));
    g.setTarget(ih);

    /* String concatenation compiles to StringBuffer operations.
     */
    il.append(factory.createNew(Type.STRINGBUFFER));
    il.append(InstructionConstants.DUP);
    il.append(new PUSH(cp, "Hello, "));
    il.append(factory.createInvoke("java.lang.StringBuffer", "<init>",
           Type.VOID, new Type[] { Type.STRING },
           Constants.INVOKESPECIAL));
    il.append(new ALOAD(name));
   
    /* Concatenate strings using a StringBuffer and print them.
     */
    il.append(factory.createInvoke("java.lang.StringBuffer", "append",
           Type.STRINGBUFFER, new Type[] { Type.STRING },
View Full Code Here

      il.append(InstructionConstants.DUP);
      il.append(new PUSH(cp, "actionPerformed:"));
      il.append(factory.createInvoke("java.lang.StringBuffer", "<init>", Type.VOID,
             new Type[] {Type.STRING}, Constants.INVOKESPECIAL));

      il.append(new ALOAD(1));
      il.append(factory.createAppend(Type.OBJECT));
      il.append(new INVOKEVIRTUAL(println));
      il.append(InstructionConstants.RETURN);

      mg.stripAttributes(true);
View Full Code Here

  // catch
  handler = il.append(new ASTORE(slot)); // save exception object
  il.append(new GETSTATIC(cp.addFieldref("java.lang.System", "err",
                 "Ljava/io/PrintStream;")));
  il.append(new ALOAD(slot)); push(2);
  il.append(new INVOKEVIRTUAL(cp.addMethodref("java.io.PrintStream",
            "println",
            "(Ljava/lang/Object;)V")));
  pop(2);
  end_handler = il.append(InstructionConstants.RETURN);
View Full Code Here

                    il.getEnd());
                   
            // store the name into a variable first so _name.translate only needs to be called once 
            _name.translate(classGen, methodGen);
            il.append(new ASTORE(nameValue.getIndex()));
            il.append(new ALOAD(nameValue.getIndex()));
           
            // call checkQName if the name is an AVT
            final int check = cpg.addMethodref(BASIS_LIBRARY_CLASS, "checkAttribQName",
                            "("
                            +STRING_SIG
                            +")V");                
            il.append(new INVOKESTATIC(check));
           
            // Save the current handler base on the stack
            il.append(methodGen.loadHandler());
            il.append(DUP);     // first arg to "attributes" call           
           
            // load name value again   
            il.append(new ALOAD(nameValue.getIndex()));           
        } else {   
            // Save the current handler base on the stack
            il.append(methodGen.loadHandler());
            il.append(DUP);     // first arg to "attributes" call
           
View Full Code Here

            "compareTo",
            "(Ljava/lang/String;)I");

      // Handle elements="ns:*" type rule
      if (rule.getStrength() == RULE_NAMESPACE) {
    il.append(new ALOAD(paramDom));
    il.append(new ILOAD(paramCurrent));
    il.append(new INVOKEINTERFACE(gns,2));
    il.append(new PUSH(cpg, rule.getNamespace()));
    il.append(new INVOKEVIRTUAL(strcmp));
    il.append(ICONST_0);
View Full Code Here

              +NODE_ITERATOR_SIG
              +")V");
  il.append(new NEW(cpg.addClass(STEP_ITERATOR_CLASS)));
  il.append(DUP);

        il.append(new ALOAD(pathTemp.getIndex()));
        il.append(new ALOAD(stepTemp.getIndex()));

  // Initialize StepIterator with iterators from the stack
  il.append(new INVOKESPECIAL(initSI));

  // This is a special case for the //* path with or without predicates
View Full Code Here

           "<init>", _className, il, cpg);

  il.append(ALOAD_0);     // this
  il.append(ALOAD_1);     // translet
  il.append(ALOAD_2);     // DOM
  il.append(new ALOAD(3));// iterator

  int index = cpg.addMethodref(ClassNames[_level],
             "<init>",
             "(" + TRANSLET_INTF_SIG
             + DOM_INTF_SIG
View Full Code Here

TOP

Related Classes of org.apache.bcel.generic.ALOAD

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.