Package org.apache.bcel.generic

Examples of org.apache.bcel.generic.PUSH


  if (hasValue()) {
      compileDefault(classGen, methodGen);
      _value.translate(classGen, methodGen);

      // Using java.lang.Math.floor(number + 0.5) to return a double value
            il.append(new PUSH(cpg, 0.5));
            il.append(DADD);
      index = cpg.addMethodref(MATH_CLASS, "floor", "(D)D");
      il.append(new INVOKESTATIC(index));

      // Call setValue on the node counter
      index = cpg.addMethodref(NODE_COUNTER,
             "setValue",
             "(D)" + NODE_COUNTER_SIG);
      il.append(new INVOKEVIRTUAL(index));
  }
  else if (isDefault()) {
      compileDefault(classGen, methodGen);
  }
  else {
      compilePatterns(classGen, methodGen);
  }

  // Call setStartNode()
  if (!hasValue()) {
      il.append(methodGen.loadContextNode());
      index = cpg.addMethodref(NODE_COUNTER,
             SET_START_NODE,
             "(I)" + NODE_COUNTER_SIG);
      il.append(new INVOKEVIRTUAL(index));
  }

  // Call getCounter() with or without args
  if (_formatNeeded) {
      if (_format != null) {
    _format.translate(classGen, methodGen);
      }
      else {
    il.append(new PUSH(cpg, "1"));
      }

      if (_lang != null) {
    _lang.translate(classGen, methodGen);
      }
      else {
    il.append(new PUSH(cpg, "en"));   // TODO ??
      }

      if (_letterValue != null) {
    _letterValue.translate(classGen, methodGen);
      }
      else {
    il.append(new PUSH(cpg, Constants.EMPTYSTRING));
      }

      if (_groupingSeparator != null) {
    _groupingSeparator.translate(classGen, methodGen);
      }
      else {
    il.append(new PUSH(cpg, Constants.EMPTYSTRING));
      }

      if (_groupingSize != null) {
    _groupingSize.translate(classGen, methodGen);
      }
      else {
    il.append(new PUSH(cpg, "0"));
      }

      index = cpg.addMethodref(NODE_COUNTER, "getCounter",
             "(" + STRING_SIG + STRING_SIG
             + STRING_SIG + STRING_SIG
View Full Code Here


      {
    int iter = cpg.addInterfaceMethodref(DOM_INTF,
                 "getTypedAxisIterator",
                 "(II)"+NODE_ITERATOR_SIG);
    il.append(methodGen.loadDOM());
    il.append(new PUSH(cpg, Axis.ATTRIBUTE));
    il.append(new PUSH(cpg, _nodeType));
    il.append(new INVOKEINTERFACE(iter, 3));
    return;
      }

      SyntaxTreeNode parent = getParent();
      // Special case for '.'
      if (isAbbreviatedDot()) {
    if (_type == Type.Node) {
        // Put context node on stack if using Type.Node
        il.append(methodGen.loadContextNode());
    }
    else {
        if (parent instanceof ParentLocationPath){
      // Wrap the context node in a singleton iterator if not.
      int init = cpg.addMethodref(SINGLETON_ITERATOR,
                "<init>",
                "("+NODE_SIG+")V");
      il.append(new NEW(cpg.addClass(SINGLETON_ITERATOR)));
      il.append(DUP);
      il.append(methodGen.loadContextNode());
      il.append(new INVOKESPECIAL(init));
        } else {
      // DOM.getAxisIterator(int axis);
      int git = cpg.addInterfaceMethodref(DOM_INTF,
            "getAxisIterator",
            "(I)"+NODE_ITERATOR_SIG);
      il.append(methodGen.loadDOM());
      il.append(new PUSH(cpg, _axis));
      il.append(new INVOKEINTERFACE(git, 2));
        }
    }
    return;
      }

      // Special case for /foo/*/bar
      if ((parent instanceof ParentLocationPath) &&
    (parent.getParent() instanceof ParentLocationPath)) {
    if ((_nodeType == NodeTest.ELEMENT) && (!_hadPredicates)) {
        _nodeType = NodeTest.ANODE;
    }
      }

      // "ELEMENT" or "*" or "@*" or ".." or "@attr" with a parent.
      switch (_nodeType) {
      case NodeTest.ATTRIBUTE:
    _axis = Axis.ATTRIBUTE;
      case NodeTest.ANODE:
    // DOM.getAxisIterator(int axis);
    int git = cpg.addInterfaceMethodref(DOM_INTF,
                "getAxisIterator",
                "(I)"+NODE_ITERATOR_SIG);
    il.append(methodGen.loadDOM());
    il.append(new PUSH(cpg, _axis));
    il.append(new INVOKEINTERFACE(git, 2));
    break;
      default:
    if (star > 1) {
        final String namespace;
        if (_axis == Axis.ATTRIBUTE)
      namespace = name.substring(0,star-2);
        else
      namespace = name.substring(0,star-1);

        final int nsType = xsltc.registerNamespace(namespace);
        final int ns = cpg.addInterfaceMethodref(DOM_INTF,
                "getNamespaceAxisIterator",
                "(II)"+NODE_ITERATOR_SIG);
        il.append(methodGen.loadDOM());
        il.append(new PUSH(cpg, _axis));
        il.append(new PUSH(cpg, nsType));
        il.append(new INVOKEINTERFACE(ns, 3));
        break;
    }
      case NodeTest.ELEMENT:
    // DOM.getTypedAxisIterator(int axis, int type);
    final int ty = cpg.addInterfaceMethodref(DOM_INTF,
            "getTypedAxisIterator",
            "(II)"+NODE_ITERATOR_SIG);
    // Get the typed iterator we're after
    il.append(methodGen.loadDOM());
    il.append(new PUSH(cpg, _axis));
    il.append(new PUSH(cpg, _nodeType));
    il.append(new INVOKEINTERFACE(ty, 3));

    break;
      }
  }
View Full Code Here

      il.append(DUP2);
      il.append(methodGen.startElement());

      if (_namespace != null) {
    il.append(methodGen.loadHandler());
    il.append(new PUSH(cpg, _prefix));
    _namespace.translate(classGen,methodGen);
    il.append(methodGen.namespace());
      }
  }
View Full Code Here

                //                name, stylesheetNode, ancestorsArray,
                //                prefixURIsIndexArray, prefixURIPairsArray,
                //                !ignoreDefaultNamespace)
                String transletClassName = getXSLTC().getClassName();
                il.append(DUP);
                il.append(new PUSH(cpg, getNodeIDForStylesheetNSLookup()));
                il.append(new GETSTATIC(cpg.addFieldref(
                                             transletClassName,
                                             STATIC_NS_ANCESTORS_ARRAY_FIELD,
                                             NS_ANCESTORS_INDEX_SIG)));
                il.append(new GETSTATIC(cpg.addFieldref(
View Full Code Here

      _exp.translate(classGen, methodGen);
  }
  else if (isNodeValueTest() && (getParent() instanceof Step)) {
      _value.translate(classGen, methodGen);
      il.append(new CHECKCAST(cpg.addClass(STRING_CLASS)));
      il.append(new PUSH(cpg, ((EqualityExpr)_exp).getOp()));
  }
  else {
      translateFilter(classGen, methodGen);
  }
    }
View Full Code Here

  // Only update _version field if set and different from default
  if ((_version != null) && (!_version.equals(XML_VERSION))) {
      field = cpg.addFieldref(TRANSLET_CLASS, "_version", STRING_SIG);
      il.append(DUP);
      il.append(new PUSH(cpg, _version));
      il.append(new PUTFIELD(field));
  }

  // Only update _method field if "method" attribute used
  if (_method != null) {
      field = cpg.addFieldref(TRANSLET_CLASS, "_method", STRING_SIG);
      il.append(DUP);
      il.append(new PUSH(cpg, _method));
      il.append(new PUTFIELD(field));
  }

  // Only update if _encoding field is "encoding" attribute used
  if (_encoding != null) {
      field = cpg.addFieldref(TRANSLET_CLASS, "_encoding", STRING_SIG);
      il.append(DUP);
      il.append(new PUSH(cpg, _encoding));
      il.append(new PUTFIELD(field));
  }

  // Only update if "omit-xml-declaration" used and set to 'yes'
  if (_omitHeader) {
      field = cpg.addFieldref(TRANSLET_CLASS, "_omitHeader", "Z");
      il.append(DUP);
      il.append(new PUSH(cpg, _omitHeader));
      il.append(new PUTFIELD(field));
  }

  // Add 'standalone' decaration to output - use text as is
  if (_standalone != null) {
      field = cpg.addFieldref(TRANSLET_CLASS, "_standalone", STRING_SIG);
      il.append(DUP);
      il.append(new PUSH(cpg, _standalone));
      il.append(new PUTFIELD(field));
  }

  // Set system/public doctype only if both are set
  field = cpg.addFieldref(TRANSLET_CLASS,"_doctypeSystem",STRING_SIG);
  il.append(DUP);
  il.append(new PUSH(cpg, _doctypeSystem));
  il.append(new PUTFIELD(field));
  field = cpg.addFieldref(TRANSLET_CLASS,"_doctypePublic",STRING_SIG);
  il.append(DUP);
  il.append(new PUSH(cpg, _doctypePublic));
  il.append(new PUTFIELD(field));
 
  // Add 'medye-type' decaration to output - if used
  if (_mediaType != null) {
      field = cpg.addFieldref(TRANSLET_CLASS, "_mediaType", STRING_SIG);
      il.append(DUP);
      il.append(new PUSH(cpg, _mediaType));
      il.append(new PUTFIELD(field));
  }

  // Compile code to set output indentation on/off
  if (_indent) {
      field = cpg.addFieldref(TRANSLET_CLASS, "_indent", "Z");
      il.append(DUP);
      il.append(new PUSH(cpg, _indent));
      il.append(new PUTFIELD(field));
  }

        //Compile code to set indent amount.
        if(_indentamount != null && !_indentamount.equals(EMPTYSTRING)){
            field = cpg.addFieldref(TRANSLET_CLASS, "_indentamount", "I");
      il.append(DUP);
      il.append(new PUSH(cpg, Integer.parseInt(_indentamount)));
      il.append(new PUTFIELD(field));
        }
       
  // Forward to the translet any elements that should be output as CDATA
  if (_cdata != null) {
      int index = cpg.addMethodref(TRANSLET_CLASS,
           "addCdataElement",
           "(Ljava/lang/String;)V");

      StringTokenizer tokens = new StringTokenizer(_cdata);
      while (tokens.hasMoreTokens()) {
    il.append(DUP);
    il.append(new PUSH(cpg, tokens.nextToken()));
    il.append(new INVOKEVIRTUAL(index));
      }
  }
  il.append(POP); // Cleanup - pop last translet reference off stack
    }
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

  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);
  // call attribute
  il.append(methodGen.attribute());
    }
View Full Code Here

  // DecimalFormatSymbols.<init>();
  final int init = cpg.addMethodref(DFS_CLASS, "<init>", "()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()
  il.append(new NEW(cpg.addClass(DFS_CLASS)));
  il.append(DUP);
  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

  final int init = cpg.addMethodref(DFS_CLASS, "<init>", "()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()
  il.append(new NEW(cpg.addClass(DFS_CLASS)));
  il.append(DUP);
  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 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.