Package org.apache.bcel.generic

Examples of org.apache.bcel.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()));
  parentNode.setEnd(il.append(new ILOAD(parentNode.getIndex())));

  // Now get the node value and push 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

          namesArray[i] = encodedName.substring(index);
      }     
  }

        staticConst.markChunkStart();
  il.append(new PUSH(cpg, size));
  il.append(new ANEWARRAY(cpg.addClass(STRING)));   
        int namesArrayRef = cpg.addFieldref(_className,
                    STATIC_NAMES_ARRAY_FIELD,
              NAMES_INDEX_SIG);
  il.append(new PUTSTATIC(namesArrayRef));
        staticConst.markChunkEnd();

  for (int i = 0; i < size; i++) {
      final String name = namesArray[i];
            staticConst.markChunkStart();
      il.append(new GETSTATIC(namesArrayRef));
      il.append(new PUSH(cpg, i));
      il.append(new PUSH(cpg, name));
      il.append(AASTORE);
            staticConst.markChunkEnd();
  }

        staticConst.markChunkStart();
  il.append(new PUSH(cpg, size));
  il.append(new ANEWARRAY(cpg.addClass(STRING)));   
        int urisArrayRef = cpg.addFieldref(_className,
             STATIC_URIS_ARRAY_FIELD,
             URIS_INDEX_SIG);
  il.append(new PUTSTATIC(urisArrayRef));
        staticConst.markChunkEnd();

  for (int i = 0; i < size; i++) {
      final String uri = urisArray[i];
            staticConst.markChunkStart();
      il.append(new GETSTATIC(urisArrayRef));
      il.append(new PUSH(cpg, i));
      il.append(new PUSH(cpg, uri));
      il.append(AASTORE);
            staticConst.markChunkEnd();
  }

        staticConst.markChunkStart();
  il.append(new PUSH(cpg, size));
  il.append(new NEWARRAY(BasicType.INT));   
        int typesArrayRef = cpg.addFieldref(_className,
              STATIC_TYPES_ARRAY_FIELD,
              TYPES_INDEX_SIG);
  il.append(new PUTSTATIC(typesArrayRef));
        staticConst.markChunkEnd();

  for (int i = 0; i < size; i++) {
      final int nodeType = typesArray[i];
            staticConst.markChunkStart();
      il.append(new GETSTATIC(typesArrayRef));
      il.append(new PUSH(cpg, i));
      il.append(new PUSH(cpg, nodeType));
      il.append(IASTORE);
            staticConst.markChunkEnd();
  }

  // Put the namespace names array into the translet
  final Vector namespaces = getXSLTC().getNamespaceIndex();
        staticConst.markChunkStart();
  il.append(new PUSH(cpg, namespaces.size()));
  il.append(new ANEWARRAY(cpg.addClass(STRING)));   
        int namespaceArrayRef = cpg.addFieldref(_className,
                  STATIC_NAMESPACE_ARRAY_FIELD,
                  NAMESPACE_INDEX_SIG);
  il.append(new PUTSTATIC(namespaceArrayRef));
        staticConst.markChunkEnd();

  for (int i = 0; i < namespaces.size(); i++) {
      final String ns = (String)namespaces.elementAt(i);
            staticConst.markChunkStart();
      il.append(new GETSTATIC(namespaceArrayRef));
      il.append(new PUSH(cpg, i));
      il.append(new PUSH(cpg, ns));
      il.append(AASTORE);
            staticConst.markChunkEnd();
  }

        // Put the tree of stylesheet namespace declarations into the translet
        final Vector namespaceAncestors = getXSLTC().getNSAncestorPointers();
        if (namespaceAncestors != null && namespaceAncestors.size() != 0) {
            addStaticField(classGen, NS_ANCESTORS_INDEX_SIG,
                           STATIC_NS_ANCESTORS_ARRAY_FIELD);
            staticConst.markChunkStart();
            il.append(new PUSH(cpg, namespaceAncestors.size()));
            il.append(new NEWARRAY(BasicType.INT));
            int namespaceAncestorsArrayRef =
                    cpg.addFieldref(_className, STATIC_NS_ANCESTORS_ARRAY_FIELD,
                                    NS_ANCESTORS_INDEX_SIG);
            il.append(new PUTSTATIC(namespaceAncestorsArrayRef));
            staticConst.markChunkEnd();
            for (int i = 0; i < namespaceAncestors.size(); i++) {
                int ancestor = ((Integer) namespaceAncestors.get(i)).intValue();
                staticConst.markChunkStart();
                il.append(new GETSTATIC(namespaceAncestorsArrayRef));
                il.append(new PUSH(cpg, i));
                il.append(new PUSH(cpg, ancestor));
                il.append(IASTORE);
                staticConst.markChunkEnd();
            }
        }
        // Put the array of indices into the namespace prefix/URI pairs array
        // into the translet
        final Vector prefixURIPairsIdx = getXSLTC().getPrefixURIPairsIdx();
        if (prefixURIPairsIdx != null && prefixURIPairsIdx.size() != 0) {
            addStaticField(classGen, PREFIX_URIS_IDX_SIG,
                           STATIC_PREFIX_URIS_IDX_ARRAY_FIELD);
            staticConst.markChunkStart();
            il.append(new PUSH(cpg, prefixURIPairsIdx.size()));
            il.append(new NEWARRAY(BasicType.INT));
            int prefixURIPairsIdxArrayRef =
                        cpg.addFieldref(_className,
                                        STATIC_PREFIX_URIS_IDX_ARRAY_FIELD,
                                        PREFIX_URIS_IDX_SIG);
            il.append(new PUTSTATIC(prefixURIPairsIdxArrayRef));
            staticConst.markChunkEnd();
            for (int i = 0; i < prefixURIPairsIdx.size(); i++) {
                int idx = ((Integer) prefixURIPairsIdx.get(i)).intValue();
                staticConst.markChunkStart();
                il.append(new GETSTATIC(prefixURIPairsIdxArrayRef));
                il.append(new PUSH(cpg, i));
                il.append(new PUSH(cpg, idx));
                il.append(IASTORE);
                staticConst.markChunkEnd();
            }
        }

        // Put the array of pairs of namespace prefixes and URIs into the
        // translet
        final Vector prefixURIPairs = getXSLTC().getPrefixURIPairs();
        if (prefixURIPairs != null && prefixURIPairs.size() != 0) {
            addStaticField(classGen, PREFIX_URIS_ARRAY_SIG,
                    STATIC_PREFIX_URIS_ARRAY_FIELD);

            staticConst.markChunkStart();
            il.append(new PUSH(cpg, prefixURIPairs.size()));
            il.append(new ANEWARRAY(cpg.addClass(STRING)));
            int prefixURIPairsRef =
                        cpg.addFieldref(_className,
                                        STATIC_PREFIX_URIS_ARRAY_FIELD,
                                        PREFIX_URIS_ARRAY_SIG);
            il.append(new PUTSTATIC(prefixURIPairsRef));
            staticConst.markChunkEnd();
            for (int i = 0; i < prefixURIPairs.size(); i++) {
                String prefixOrURI = (String) prefixURIPairs.get(i);
                staticConst.markChunkStart();
                il.append(new GETSTATIC(prefixURIPairsRef));
                il.append(new PUSH(cpg, i));
                il.append(new PUSH(cpg, prefixOrURI));
                il.append(AASTORE);
                staticConst.markChunkEnd();
            }
        }

        // 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++) {
            staticConst.markChunkStart();
            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)));
            staticConst.markChunkEnd();
View Full Code Here

                                         NAMESPACE_INDEX_SIG)));
        constructor.markChunkEnd();

        constructor.markChunkStart();
  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)));
        constructor.markChunkEnd();
 
  if (_hasIdCall) {
            constructor.markChunkStart();
      il.append(classGen.loadTranslet());
      il.append(new PUSH(cpg, Boolean.TRUE));
      il.append(new PUTFIELD(cpg.addFieldref(TRANSLET_CLASS,
                     HASIDCALL_INDEX,
                     HASIDCALL_INDEX_SIG)));
            constructor.markChunkEnd();
  }
View Full Code Here

  if (tleft instanceof NodeSetType && tright instanceof StringType) {
      _left.translate(classGen, methodGen);
      _left.startIterator(classGen, methodGen); // needed ?
      _right.translate(classGen, methodGen);
      il.append(new PUSH(cpg, _op));
      il.append(methodGen.loadDOM());
      final int cmp = cpg.addMethodref(BASIS_LIBRARY_CLASS,
               "compare",
               "("
               + tleft.toSignature()
               + tright.toSignature()
               + "I"
               + DOM_INTF_SIG
               + ")Z");
      il.append(new INVOKESTATIC(cmp));
      return;
  }

  // Next, node-set/t for t in {real, string, node-set, result-tree}
  _left.translate(classGen, methodGen);
  _left.startIterator(classGen, methodGen);
  _right.translate(classGen, methodGen);
  _right.startIterator(classGen, methodGen);

  // Cast a result tree to a string to use an existing compare
  if (tright instanceof ResultTreeType) {
      tright.translateTo(classGen, methodGen, Type.String)
      tright = Type.String;
  }

  // Call the appropriate compare() from the BasisLibrary
  il.append(new PUSH(cpg, _op));
  il.append(methodGen.loadDOM());

  final int compare = cpg.addMethodref(BASIS_LIBRARY_CLASS,
               "compare",
               "("
View Full Code Here

  final InstructionList il = methodGen.getInstructionList();

  // push handler
  il.append(methodGen.loadHandler());
  // push attribute name - namespace prefix set by parent node
  il.append(new PUSH(cpg, _name));
  // push attribute value
  _value.translate(classGen, methodGen);
 
  // Generate code that calls SerializationHandler.addUniqueAttribute()
  // if all attributes are unique.
  SyntaxTreeNode parent = getParent();
  if (parent instanceof LiteralElement
      && ((LiteralElement)parent).allAttributesUnique()) {     
     
      int flags = 0;
      boolean isHTMLAttrEmpty = false;
      ElemDesc elemDesc = ((LiteralElement)parent).getElemDesc();
     
      // Set the HTML flags
      if (elemDesc != null) {
        if (elemDesc.isAttrFlagSet(_name, ElemDesc.ATTREMPTY)) {
            flags = flags | SerializationHandler.HTML_ATTREMPTY;
            isHTMLAttrEmpty = true;
        }
        else if (elemDesc.isAttrFlagSet(_name, ElemDesc.ATTRURL)) {
            flags = flags | SerializationHandler.HTML_ATTRURL;
        }
      }
     
      if (_value instanceof SimpleAttributeValue) {
          String attrValue = ((SimpleAttributeValue)_value).toString();
         
          if (!hasBadChars(attrValue) && !isHTMLAttrEmpty) {
              flags = flags | SerializationHandler.NO_BAD_CHARS;
          }
      }
         
      il.append(new PUSH(cpg, flags));
      il.append(methodGen.uniqueAttribute());
  }
  else {
      // call attribute
      il.append(methodGen.attribute());
View Full Code Here

           "(Ljava/lang/String;)"+
           "Ljava/text/DecimalFormat;");
 
  il.append(classGen.loadTranslet());
  if (_name == null) {
      il.append(new PUSH(cpg, EMPTYSTRING));
  }
  else if (_resolvedQName != null) {
      il.append(new PUSH(cpg, _resolvedQName.toString()));
  }
  else {
      _name.translate(classGen, methodGen);
  }
  il.append(new INVOKEVIRTUAL(get));
View Full Code Here

    }

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

     * the namespaces declared in the stylsheet are not available at run
     * time. Consequently, arguments to this function must be literals.
     */
    public void translate(ClassGenerator classGen, MethodGenerator methodGen) {
  final ConstantPoolGen cpg = classGen.getConstantPool();
  methodGen.getInstructionList().append(new PUSH(cpg, getResult()));
    }
View Full Code Here

TOP

Related Classes of org.apache.bcel.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.