Package com.sun.org.apache.bcel.internal.generic

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


    }

    public void translate(ClassGenerator classGen, MethodGenerator methodGen) {
  final ConstantPoolGen cpg = classGen.getConstantPool();
  final InstructionList il = methodGen.getInstructionList();
  il.append(new PUSH(cpg, _value));
    }
View Full Code Here


  final BranchHandle nextNode = il.append(new GOTO(null));
  final InstructionHandle loop = il.append(NOP);

  // Prepare to call buildKeyIndex(String name, int node, String value);
  il.append(classGen.loadTranslet());
  il.append(new PUSH(cpg, _name.toString()));
  il.append(new ILOAD(parentNode.getIndex()));

  // Now get the node value and feck it on the parameter stack
  il.append(methodGen.loadDOM());
  il.append(methodGen.loadCurrentNode());
  il.append(new INVOKEINTERFACE(getNodeValue, 2));   

  // Finally do the call to add an entry in the index for this key.
  il.append(new INVOKEVIRTUAL(buildKeyIndex));
 
  il.append(classGen.loadTranslet());
  il.append(new PUSH(cpg, getName()));
  il.append(methodGen.loadDOM());
  il.append(new INVOKEVIRTUAL(keyDom));

  nextNode.setTarget(il.append(methodGen.loadIterator()));
  il.append(methodGen.nextNode())
View Full Code Here

  il.append(methodGen.loadCurrentNode());
  il.append(methodGen.loadIterator());

  // Get an iterator for all nodes in the DOM
  il.append(methodGen.loadDOM())
  il.append(new PUSH(cpg,Axis.DESCENDANT));
  il.append(new INVOKEINTERFACE(git, 2));

  // Reset the iterator to start with the root node
  il.append(methodGen.loadCurrentNode());
  il.append(methodGen.setStartNode());
  il.append(methodGen.storeIterator());

  // Loop for traversing all nodes in the DOM
  final BranchHandle nextNode = il.append(new GOTO(null));
  final InstructionHandle loop = il.append(NOP);

  // Check if the current node matches the pattern in "match"
  il.append(methodGen.loadCurrentNode());
  _match.translate(classGen, methodGen);
  _match.synthesize(classGen, methodGen); // Leaves 0 or 1 on stack
  final BranchHandle skipNode = il.append(new IFEQ(null));
 
  // If this is a node-set we must go through each node in the set
  if (_useType instanceof NodeSetType) {
      // Pass current node as parameter (we're indexing on that node)
      il.append(methodGen.loadCurrentNode());
      traverseNodeSet(classGen, methodGen, key);
  }
  else {
      il.append(classGen.loadTranslet());
      il.append(DUP);
      il.append(new PUSH(cpg, _name.toString()));
      il.append(DUP_X1);
      il.append(methodGen.loadCurrentNode());
      _use.translate(classGen, methodGen);
      il.append(new INVOKEVIRTUAL(key));
     
View Full Code Here

      else {
          namesArray[i] = encodedName.substring(index);
      }     
  }
 
  il.append(new PUSH(cpg, size));
  il.append(new ANEWARRAY(cpg.addClass(STRING)));   

  for (int i = 0; i < size; i++) {
      final String name = namesArray[i];
      il.append(DUP);
      il.append(new PUSH(cpg, i));
      il.append(new PUSH(cpg, name));
      il.append(AASTORE);
  }
  il.append(new PUTSTATIC(cpg.addFieldref(_className,
                 STATIC_NAMES_ARRAY_FIELD,
                 NAMES_INDEX_SIG)));

  il.append(new PUSH(cpg, size));
  il.append(new ANEWARRAY(cpg.addClass(STRING)));   

  for (int i = 0; i < size; i++) {
      final String uri = urisArray[i];
      il.append(DUP);
      il.append(new PUSH(cpg, i));
      il.append(new PUSH(cpg, uri));
      il.append(AASTORE);
  }
  il.append(new PUTSTATIC(cpg.addFieldref(_className,
                 STATIC_URIS_ARRAY_FIELD,
                 URIS_INDEX_SIG)));

  il.append(new PUSH(cpg, size));
  il.append(new NEWARRAY(BasicType.INT));   

  for (int i = 0; i < size; i++) {
      final int nodeType = typesArray[i];
      il.append(DUP);
      il.append(new PUSH(cpg, i));
      il.append(new PUSH(cpg, nodeType));
      il.append(IASTORE);
  }
  il.append(new PUTSTATIC(cpg.addFieldref(_className,
                 STATIC_TYPES_ARRAY_FIELD,
                 TYPES_INDEX_SIG)));

  // Put the namespace names array into the translet
  final Vector namespaces = getXSLTC().getNamespaceIndex();
  il.append(new PUSH(cpg, namespaces.size()));
  il.append(new ANEWARRAY(cpg.addClass(STRING)));   

  for (int i = 0; i < namespaces.size(); i++) {
      final String ns = (String)namespaces.elementAt(i);
      il.append(DUP);
      il.append(new PUSH(cpg, i));
      il.append(new PUSH(cpg, ns));
      il.append(AASTORE);
  }
  il.append(new PUTSTATIC(cpg.addFieldref(_className,
                 STATIC_NAMESPACE_ARRAY_FIELD,
                 NAMESPACE_INDEX_SIG)));

        // Grab all the literal text in the stylesheet and put it in a char[]
        final int charDataCount = getXSLTC().getCharacterDataCount();
        final int toCharArray = cpg.addMethodref(STRING, "toCharArray", "()[C");
        for (int i = 0; i < charDataCount; i++) {
            il.append(new PUSH(cpg, getXSLTC().getCharacterData(i)));
            il.append(new INVOKEVIRTUAL(toCharArray));
            il.append(new PUTSTATIC(cpg.addFieldref(_className,
                                               STATIC_CHAR_DATA_FIELD+i,
                                               STATIC_CHAR_DATA_FIELD_SIG)));
        }
View Full Code Here

  il.append(new PUTFIELD(cpg.addFieldref(TRANSLET_CLASS,
                                         NAMESPACE_INDEX,
                                         NAMESPACE_INDEX_SIG)));

  il.append(classGen.loadTranslet());
        il.append(new PUSH(cpg, AbstractTranslet.CURRENT_TRANSLET_VERSION));
  il.append(new PUTFIELD(cpg.addFieldref(TRANSLET_CLASS,
                                         TRANSLET_VERSION_INDEX,
                                         TRANSLET_VERSION_INDEX_SIG)));
 
  if (_hasIdCall) {
      il.append(classGen.loadTranslet());
      il.append(new PUSH(cpg, Boolean.TRUE));
      il.append(new PUTFIELD(cpg.addFieldref(TRANSLET_CLASS,
                     HASIDCALL_INDEX,
                     HASIDCALL_INDEX_SIG)));
  }
 
View Full Code Here

  final int setFilter = cpg.addInterfaceMethodref(DOM_INTF,
             "setFilter",
             "(Lcom/sun/org/apache/xalan/internal/xsltc/StripFilter;)V");

  il.append(new PUSH(cpg, DTM.ROOT_NODE));
  il.append(new ISTORE(current.getIndex()));

        // Create a new list containing variables/params + keys
        Vector varDepElements = new Vector(_globals);
  Enumeration elements = elements();
View Full Code Here

 
  //store to _dom variable
  il.append(new PUTFIELD(domField));

  // continue with globals initialization
  il.append(new PUSH(cpg, DTM.ROOT_NODE));
  il.append(new ISTORE(current.getIndex()));

  // Transfer the output settings to the output post-processor
  il.append(classGen.loadTranslet());
  il.append(transf.loadHandler());
View Full Code Here

        _allAttributesUnique = checkAttributesUnique();

  // Compile code to emit element start tag
  il.append(methodGen.loadHandler());
 
  il.append(new PUSH(cpg, _name));
  il.append(DUP2);     // duplicate these 2 args for endElement
  il.append(methodGen.startElement());

  // The value of an attribute may depend on a (sibling) variable
    int j=0;
    while (j < elementCount())
    {
        final SyntaxTreeNode item = (SyntaxTreeNode) elementAt(j);
        if (item instanceof Variable) {
            item.translate(classGen, methodGen);
            removeElement(item)// avoid translating it twice
            /* When removing an element we do not increment j
             * but the removal will reduce the value of elementCount()
             * so this loop WILL end. The next iteration will process
             * elementAt(j), but with the old element removed
             * we are actually processing the next element.
             */
      }
        else
            j++;
  }

  // Compile code to emit namespace attributes
  if (_accessedPrefixes != null) {
      boolean declaresDefaultNS = false;
      Enumeration e = _accessedPrefixes.keys();

      while (e.hasMoreElements()) {
    final String prefix = (String)e.nextElement();
    final String uri = (String)_accessedPrefixes.get(prefix);

    if (uri != Constants.EMPTYSTRING ||
      prefix != Constants.EMPTYSTRING)
    {
        if (prefix == Constants.EMPTYSTRING) {
      declaresDefaultNS = true;
        }
        il.append(methodGen.loadHandler());
        il.append(new PUSH(cpg,prefix));
        il.append(new PUSH(cpg,uri));
        il.append(methodGen.namespace());
    }
      }

      /*
       * If our XslElement parent redeclares the default NS, and this
       * element doesn't, it must be redeclared one more time.
       */
      if (!declaresDefaultNS && (_parent instanceof XslElement)
        && ((XslElement) _parent).declaresDefaultNS())
      {
    il.append(methodGen.loadHandler());
    il.append(new PUSH(cpg, Constants.EMPTYSTRING));
    il.append(new PUSH(cpg, Constants.EMPTYSTRING));
    il.append(methodGen.namespace());
      }
  }

  // Output all attributes
View Full Code Here

  final int init = cpg.addMethodref(DFS_CLASS, "<init>",
                                          "("+LOCALE_SIG+")V");

  // Push the format name on the stack for call to addDecimalFormat()
  il.append(classGen.loadTranslet());
  il.append(new PUSH(cpg, _name.toString()));

  // Manufacture a DecimalFormatSymbols on the stack
  // for call to addDecimalFormat()
        // Use the US Locale as the default, as most of its settings
        // are equivalent to the default settings required of
  il.append(new NEW(cpg.addClass(DFS_CLASS)));
  il.append(DUP);
        il.append(new GETSTATIC(cpg.addFieldref(LOCALE_CLASS, "US",
                                                LOCALE_SIG)));
  il.append(new INVOKESPECIAL(init));

  String tmp = getAttribute("NaN");
  if ((tmp == null) || (tmp.equals(EMPTYSTRING))) {
      int nan = cpg.addMethodref(DFS_CLASS,
               "setNaN", "(Ljava/lang/String;)V");
      il.append(DUP);
      il.append(new PUSH(cpg, "NaN"));
      il.append(new INVOKEVIRTUAL(nan));
  }

  tmp = getAttribute("infinity");
  if ((tmp == null) || (tmp.equals(EMPTYSTRING))) {
      int inf = cpg.addMethodref(DFS_CLASS,
               "setInfinity",
               "(Ljava/lang/String;)V");
      il.append(DUP);
      il.append(new PUSH(cpg, "Infinity"));
      il.append(new INVOKEVIRTUAL(inf));
  }
     
  final int nAttributes = _attributes.getLength();
  for (int i = 0; i < nAttributes; i++) {
      final String name = _attributes.getQName(i);
      final String value = _attributes.getValue(i);

      boolean valid = true;
      int method = 0;

      if (name.equals("decimal-separator")) {
    // DecimalFormatSymbols.setDecimalSeparator();
    method = cpg.addMethodref(DFS_CLASS,
            "setDecimalSeparator", "(C)V");
      }
      else if (name.equals("grouping-separator")) {
    method =  cpg.addMethodref(DFS_CLASS,
             "setGroupingSeparator", "(C)V");
      }
      else if (name.equals("minus-sign")) {
    method = cpg.addMethodref(DFS_CLASS,
            "setMinusSign", "(C)V");
      }
      else if (name.equals("percent")) {
    method = cpg.addMethodref(DFS_CLASS,
            "setPercent", "(C)V");
      }
      else if (name.equals("per-mille")) {
    method = cpg.addMethodref(DFS_CLASS,
            "setPerMill", "(C)V");
      }
      else if (name.equals("zero-digit")) {
    method = cpg.addMethodref(DFS_CLASS,
            "setZeroDigit", "(C)V");
      }
      else if (name.equals("digit")) {
    method = cpg.addMethodref(DFS_CLASS,
            "setDigit", "(C)V");
      }
      else if (name.equals("pattern-separator")) {
    method = cpg.addMethodref(DFS_CLASS,
            "setPatternSeparator", "(C)V");
      }
      else if (name.equals("NaN")) {
    method = cpg.addMethodref(DFS_CLASS,
            "setNaN", "(Ljava/lang/String;)V");
          il.append(DUP);
    il.append(new PUSH(cpg, value));
    il.append(new INVOKEVIRTUAL(method));
    valid = false;
      }
      else if (name.equals("infinity")) {
    method = cpg.addMethodref(DFS_CLASS,
            "setInfinity",
            "(Ljava/lang/String;)V");
          il.append(DUP);
    il.append(new PUSH(cpg, value));
    il.append(new INVOKEVIRTUAL(method));
    valid = false;
      }
      else {
    valid = false;
      }

      if (valid) {
    il.append(DUP);
    il.append(new PUSH(cpg, value.charAt(0)));
    il.append(new INVOKEVIRTUAL(method));
      }

  }
View Full Code Here

                                          "("+LOCALE_SIG+")V");

  // Push the format name, which is empty, on the stack
  // for call to addDecimalFormat()
  il.append(classGen.loadTranslet());
  il.append(new PUSH(cpg, EMPTYSTRING));

  // Manufacture a DecimalFormatSymbols on the stack for
  // call to addDecimalFormat().  Use the US Locale as the
        // default, as most of its settings are equivalent to
        // the default settings required of xsl:decimal-format -
        // except for the NaN and infinity attributes.
  il.append(new NEW(cpg.addClass(DFS_CLASS)));
  il.append(DUP);
        il.append(new GETSTATIC(cpg.addFieldref(LOCALE_CLASS, "US",
                                                LOCALE_SIG)));
  il.append(new INVOKESPECIAL(init));

  int nan = cpg.addMethodref(DFS_CLASS,
           "setNaN", "(Ljava/lang/String;)V");
  il.append(DUP);
  il.append(new PUSH(cpg, "NaN"));
  il.append(new INVOKEVIRTUAL(nan));

  int inf = cpg.addMethodref(DFS_CLASS,
           "setInfinity",
           "(Ljava/lang/String;)V");
  il.append(DUP);
  il.append(new PUSH(cpg, "Infinity"));
  il.append(new INVOKEVIRTUAL(inf));

  final int put = cpg.addMethodref(TRANSLET_CLASS,
           "addDecimalFormat",
           "("+STRING_SIG+DFS_SIG+")V");
View Full Code Here

TOP

Related Classes of com.sun.org.apache.bcel.internal.generic.PUSH

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.