Examples of LocalVariableGen


Examples of com.sun.org.apache.bcel.internal.generic.LocalVariableGen

        // the suspect arguments to its constructor.  Instead we calculate
        // the values of the arguments to the constructor first, store them
        // in temporary variables, create the object and reload the
        // arguments from the temporaries to avoid the problem.

        LocalVariableGen nodesTemp =
            methodGen.addLocalVariable("sort_tmp1",
                                       Util.getJCRefType(NODE_ITERATOR_SIG),
                                       null, null);

        LocalVariableGen sortRecordFactoryTemp =
            methodGen.addLocalVariable("sort_tmp2",
                                      Util.getJCRefType(NODE_SORT_FACTORY_SIG),
                                      null, null);

        // Get the current node iterator
        if (nodeSet == null) {  // apply-templates default
            final int children = cpg.addInterfaceMethodref(DOM_INTF,
                                                           "getAxisIterator",
                                                           "(I)"+
                                                           NODE_ITERATOR_SIG);
            il.append(methodGen.loadDOM());
            il.append(new PUSH(cpg, Axis.CHILD));
            il.append(new INVOKEINTERFACE(children, 2));
        }
        else {
            nodeSet.translate(classGen, methodGen);
        }

        nodesTemp.setStart(il.append(new ASTORE(nodesTemp.getIndex())));

        // Compile the code for the NodeSortRecord producing class and pass
        // that as the last argument to the SortingIterator constructor.
        compileSortRecordFactory(sortObjects, classGen, methodGen);
        sortRecordFactoryTemp.setStart(
                il.append(new ASTORE(sortRecordFactoryTemp.getIndex())));

        il.append(new NEW(cpg.addClass(SORT_ITERATOR)));
        il.append(DUP);
        nodesTemp.setEnd(il.append(new ALOAD(nodesTemp.getIndex())));
        sortRecordFactoryTemp.setEnd(
                il.append(new ALOAD(sortRecordFactoryTemp.getIndex())));
        il.append(new INVOKESPECIAL(init));
    }
View Full Code Here

Examples of org.apache.bcel.generic.LocalVariableGen

    public void storeObject() {
        if (m_objectType == null) {
            throw new IllegalStateException("Internal error - no object type");
        } else {
            if (m_objectSlot < 0) {
                LocalVariableGen var = createLocal("obj",
                    ClassItem.typeFromName(m_objectType));
                m_objectSlot = var.getIndex();
            } else {
                appendCreateCast(m_objectType);
                appendStoreLocal(m_objectSlot);
            }
        }
View Full Code Here

Examples of org.apache.bcel.generic.LocalVariableGen

        if (name == null) {
             name = "var" + m_generator.getLocalVariables().length;
        }
       
        // allocation local and store value
        LocalVariableGen var = m_generator.addLocalVariable
            (name, type, getLastInstruction(), null);
        append(InstructionFactory.createStore(type, var.getIndex()));
       
        // save type information for local variable slot
        int slot = var.getIndex();
        while (slot >= m_localTypes.size()) {
            m_localTypes.add(null);
        }
        m_localTypes.set(slot, type.toString());
       
View Full Code Here

Examples of org.apache.bcel.generic.LocalVariableGen

     * @param name local variable name
     * @param type variable type
     * @return local variable slot number
     */
    public int addLocal(String name, Type type) {
        LocalVariableGen var = createLocal(name, type);
        return var.getIndex();
    }
View Full Code Here

Examples of org.apache.bcel.generic.LocalVariableGen

     */
    public int defineSlot(Object obj, Type type) {
        if (m_slotMap == null) {
            m_slotMap = new HashMap();
        }
        LocalVariableGen var = createLocal("var" + m_slotMap.size(), type);
        m_slotMap.put(obj, var);
        return var.getIndex();
    }
View Full Code Here

Examples of org.apache.bcel.generic.LocalVariableGen

     * none
     */

    public int getSlot(Object obj) {
        if (m_slotMap != null) {
            LocalVariableGen var = (LocalVariableGen)m_slotMap.get(obj);
            if (var != null) {
                return var.getIndex();
            }
        }
        return -1;
    }
View Full Code Here

Examples of org.apache.bcel.generic.LocalVariableGen

     * @param obj owning object of slot
     */

    public void freeSlot(Object obj) {
        if (m_slotMap != null) {
            LocalVariableGen var = (LocalVariableGen)m_slotMap.get(obj);
            if (var != null) {
                var.setEnd(getLastInstruction());
                m_slotMap.remove(obj);
            }
        }
    }
View Full Code Here

Examples of org.apache.bcel.generic.LocalVariableGen

      il.append(DUP);
      il.append(DUP);
      il.append(new INVOKESPECIAL(index));
     
      // Store new Handler into a local variable
      final LocalVariableGen handler =
    methodGen.addLocalVariable("rt_to_string_handler",
             Util.getJCRefType(STRING_VALUE_HANDLER_SIG),
             null, null);
      il.append(new ASTORE(handler.getIndex()));

      // Call the method that implements this result tree
      index = cpg.addMethodref(className, _methodName,
             "("+DOM_INTF_SIG+TRANSLET_OUTPUT_SIG+")V");
      il.append(new INVOKEVIRTUAL(index));
     
      // Restore new handler and call getValue()
      il.append(new ALOAD(handler.getIndex()));
      index = cpg.addMethodref(STRING_VALUE_HANDLER,
             "getValue",
             "()" + STRING_SIG);
      il.append(new INVOKEVIRTUAL(index));
  }
View Full Code Here

Examples of org.apache.bcel.generic.LocalVariableGen

  if (_methodName == null) {
      il.append(NOP);
  }
  else {
      LocalVariableGen domBuilder, newDom;
      final String className = classGen.getClassName();
      final int current = methodGen.getLocalIndex("current");

      // Push required parameters
      il.append(classGen.loadTranslet());
      if (classGen.isExternal()) {
    il.append(new CHECKCAST(cpg.addClass(className)));
      }
      il.append(methodGen.loadDOM());

      // Create new instance of DOM class
      int index = cpg.addMethodref(DOM_IMPL, "<init>", "(I)V");
      il.append(new NEW(cpg.addClass(DOM_IMPL)));
      il.append(DUP);
      il.append(DUP);
      il.append(new PUSH(cpg, RTF_INITIAL_SIZE));
      il.append(new INVOKESPECIAL(index));
     
      // Store new DOM into a local variable
      newDom = methodGen.addLocalVariable("rt_to_reference_dom",
            Util.getJCRefType(DOM_INTF_SIG),
            null, null);
      il.append(new CHECKCAST(cpg.addClass(DOM_INTF_SIG)));
      il.append(new ASTORE(newDom.getIndex()));

      // Overwrite old handler with DOM handler
      index = cpg.addMethodref(DOM_IMPL,
             "getOutputDomBuilder",
             "()" + TRANSLET_OUTPUT_SIG);
      il.append(new INVOKEVIRTUAL(index));
      il.append(DUP);
      il.append(DUP);

      // Store DOM handler in a local in order to call endDocument()
      domBuilder =
    methodGen.addLocalVariable("rt_to_reference_handler",
             Util.getJCRefType(TRANSLET_OUTPUT_SIG),
             null, null);
      il.append(new ASTORE(domBuilder.getIndex()));

      // Call startDocument on the new handler
      index = cpg.addInterfaceMethodref(TRANSLET_OUTPUT_INTERFACE,
                "startDocument", "()V");
      il.append(new INVOKEINTERFACE(index, 1));

      // Call the method that implements this result tree
      index = cpg.addMethodref(className,
             _methodName,
             "("
             + DOM_INTF_SIG
             + TRANSLET_OUTPUT_SIG
             +")V");
      il.append(new INVOKEVIRTUAL(index));

      // Call endDocument on the DOM handler
      il.append(new ALOAD(domBuilder.getIndex()));
      index = cpg.addInterfaceMethodref(TRANSLET_OUTPUT_INTERFACE,
                "endDocument", "()V");
      il.append(new INVOKEINTERFACE(index, 1));

      // Push the new DOM on the stack
View Full Code Here

Examples of org.apache.bcel.generic.LocalVariableGen

  final ConstantPoolGen cpg = classGen.getConstantPool();
  final InstructionList il = methodGen.getInstructionList();

  if (_left != null) {
      if (_left instanceof StepPattern) {
    final LocalVariableGen local =
        // absolute path pattern temporary
        methodGen.addLocalVariable2("apptmp",
            Util.getJCRefType(NODE_SIG),
            il.getEnd());
    il.append(DUP);
    il.append(new ISTORE(local.getIndex()));
    _left.translate(classGen, methodGen);
    il.append(methodGen.loadDOM());
    local.setEnd(il.append(new ILOAD(local.getIndex())));
    methodGen.removeLocalVariable(local);
      }
      else {
    _left.translate(classGen, methodGen);
      }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.