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

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


                        cpg.addInterfaceMethodref(TRANSLET_OUTPUT_INTERFACE,
                                                  "comment",
                                                  "([CII)V");
                il.append(new INVOKEINTERFACE(comment, 4));
            } else {
                il.append(new PUSH(cpg, rawText.getText()));
                final int comment =
                        cpg.addInterfaceMethodref(TRANSLET_OUTPUT_INTERFACE,
                                                  "comment",
                                                  "(" + STRING_SIG + ")V");
                il.append(new INVOKEINTERFACE(comment, 2));
View Full Code Here


  // Load the translet (for call to displayMessage() function)
  il.append(classGen.loadTranslet());

        switch (elementCount()) {
            case 0:
                il.append(new PUSH(cpg, ""));
            break;
            case 1:
                SyntaxTreeNode child = (SyntaxTreeNode) elementAt(0);
                if (child instanceof Text) {
                    il.append(new PUSH(cpg, ((Text) child).getText()));
                    break;
                }
                // falls through
            default:
                // Push current output handler onto the stack
                il.append(methodGen.loadHandler());

                // Replace the current output handler by a ToXMLStream
                il.append(new NEW(cpg.addClass(STREAM_XML_OUTPUT)));
                il.append(methodGen.storeHandler());

                // Push a reference to a StringWriter
                il.append(new NEW(cpg.addClass(STRING_WRITER)));
                il.append(DUP);
                il.append(DUP);
                il.append(new INVOKESPECIAL(
                    cpg.addMethodref(STRING_WRITER, "<init>", "()V")));

                // Load ToXMLStream
                il.append(methodGen.loadHandler());
                il.append(new INVOKESPECIAL(
                    cpg.addMethodref(STREAM_XML_OUTPUT, "<init>",
                                     "()V")));

                // Invoke output.setWriter(STRING_WRITER)
                il.append(methodGen.loadHandler());
                il.append(SWAP);
                il.append(new INVOKEVIRTUAL(
                    cpg.addMethodref(OUTPUT_BASE, "setWriter",
                                     "("+WRITER_SIG+")V")));

                // Invoke output.setEncoding("UTF-8")
                il.append(methodGen.loadHandler());
                il.append(new PUSH(cpg, "UTF-8"));   // other encodings?
                il.append(new INVOKEVIRTUAL(
                    cpg.addMethodref(OUTPUT_BASE, "setEncoding",
                                     "("+STRING_SIG+")V")));

                // Invoke output.setOmitXMLDeclaration(true)
                il.append(methodGen.loadHandler());
                il.append(ICONST_1);
                il.append(new INVOKEVIRTUAL(
                    cpg.addMethodref(OUTPUT_BASE, "setOmitXMLDeclaration",
                                     "(Z)V")));

                il.append(methodGen.loadHandler());
                il.append(new INVOKEVIRTUAL(
                    cpg.addMethodref(OUTPUT_BASE, "startDocument",
                                     "()V")));

                // Inline translation of contents
                translateContents(classGen, methodGen);

                il.append(methodGen.loadHandler());
                il.append(new INVOKEVIRTUAL(
                    cpg.addMethodref(OUTPUT_BASE, "endDocument",
                                     "()V")));

                // Call toString() on StringWriter
                il.append(new INVOKEVIRTUAL(
                    cpg.addMethodref(STRING_WRITER, "toString",
                                     "()" + STRING_SIG)));

                // Restore old output handler
                il.append(SWAP);
                il.append(methodGen.storeHandler());
            break;
        }

  // Send the resulting string to the message handling method
  il.append(new INVOKEVIRTUAL(cpg.addMethodref(TRANSLET_CLASS,
                 "displayMessage",
                 "("+STRING_SIG+")V")));

  // If 'terminate' attribute is set to 'yes': Instanciate a
  // RunTimeException, but it on the stack and throw an exception
  if (_terminate == true) {
      // Create a new instance of RunTimeException
      final int einit = cpg.addMethodref("java.lang.RuntimeException",
                 "<init>",
                 "(Ljava/lang/String;)V");
      il.append(new NEW(cpg.addClass("java.lang.RuntimeException")));
      il.append(DUP);
      il.append(new PUSH(cpg,"Termination forced by an " +
                 "xsl:message instruction"));
      il.append(new INVOKESPECIAL(einit));
      il.append(ATHROW);
  }
    }
View Full Code Here

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

  // If no current, conversion is a top-level
  if (current < 0) {
      il.append(new PUSH(cpg, DTM.ROOT_NODE))// push root node
  }
  else {
      il.append(new ILOAD(current));
  }
  il.append(methodGen.loadDOM());
View Full Code Here

      ConstantPoolGen cpg = classGen.getConstantPool();
      InstructionList il = methodGen.getInstructionList();
     
      final int unsupportedElem = cpg.addMethodref(BASIS_LIBRARY_CLASS, "unsupported_ElementF",
                                                         "(" + STRING_SIG + "Z)V");  
      il.append(new PUSH(cpg, getQName().toString()));
      il.append(new PUSH(cpg, _isExtension));
      il.append(new INVOKESTATIC(unsupportedElem));   
  }
    }
View Full Code Here

     * @see  com.sun.org.apache.xalan.internal.xsltc.compiler.util.Type#translateTo
     */
    public void translateTo(ClassGenerator classGen, MethodGenerator methodGen,
          StringType type) {
  final InstructionList il = methodGen.getInstructionList();
  il.append(new PUSH(classGen.getConstantPool(), ""));
    }
View Full Code Here

  final ConstantPoolGen cpg = classGen.getConstantPool();
  final InstructionList il = methodGen.getInstructionList();
  il.append(new NEW(cpg.addClass(RUNTIME_NODE_CLASS)));
  il.append(DUP_X1);
  il.append(SWAP);
  il.append(new PUSH(cpg, _type));
  il.append(new INVOKESPECIAL(cpg.addMethodref(RUNTIME_NODE_CLASS,
                 "<init>", "(II)V")));
    }
View Full Code Here

                ifBlock.setTarget(il.append(NOP));
                return;
            }
           
      il.append(classGen.loadTranslet());
      il.append(new PUSH(cpg, name));
      translateValue(classGen, methodGen);
      il.append(new PUSH(cpg, true));

      // Call addParameter() from this class
      il.append(new INVOKEVIRTUAL(cpg.addMethodref(TRANSLET_CLASS,
               ADD_PARAMETER,
               ADD_PARAMETER_SIG)));
      if (className != EMPTYSTRING) {
    il.append(new CHECKCAST(cpg.addClass(className)));
      }

      _type.translateUnBox(classGen, methodGen);

      if (_refs.isEmpty()) { // nobody uses the value
    il.append(_type.POP());
    _local = null;
      }
      else {    // normal case
    _local = methodGen.addLocalVariable2(name,
                 _type.toJCType(),
                 il.getEnd());
    // Cache the result of addParameter() in a local variable
    il.append(_type.STORE(_local.getIndex()));
      }
  }
  else {
      if (classGen.containsField(name) == null) {
    classGen.addField(new Field(ACC_PUBLIC, cpg.addUtf8(name),
              cpg.addUtf8(signature),
              null, cpg.getConstantPool()));
    il.append(classGen.loadTranslet());
    il.append(DUP);
    il.append(new PUSH(cpg, name));
    translateValue(classGen, methodGen);
    il.append(new PUSH(cpg, true));

    // Call addParameter() from this class
    il.append(new INVOKEVIRTUAL(cpg.addMethodref(TRANSLET_CLASS,
                 ADD_PARAMETER,
                 ADD_PARAMETER_SIG)));
View Full Code Here

                                             + KEY_INDEX_ITERATOR_SIG);

        // Initialise the index specified in the first parameter of key()
        il.append(classGen.loadTranslet());
        if (_name == null) {
            il.append(new PUSH(cpg,"##id"));
        } else if (_resolvedQName != null) {
            il.append(new PUSH(cpg, _resolvedQName.toString()));
        } else {
            _name.translate(classGen, methodGen);
        }

        // Generate following byte code:
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

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.