Package org.apache.bcel.generic

Examples of org.apache.bcel.generic.ICONST


            break;
            case Constants.T_INT:
            case Constants.T_BOOLEAN:
            case Constants.T_SHORT:
            case Constants.T_CHAR:
                patch.append(new ICONST(0));
                patch.append(new IRETURN());
            break;
            case Constants.T_FLOAT:
                patch.append(new FCONST(0));
                patch.append(new FRETURN());


      /*
       * Give the DOM adapter an empty type mapping if the nodeset
       * extension function is never called.
       */
      if (!stylesheet.callsNodeset()) {
    il.append(new ICONST(0));
    il.append(new ANEWARRAY(cpg.addClass(STRING)));
    il.append(DUP);
    il.append(DUP);
    il.append(new ICONST(0));
    il.append(new NEWARRAY(BasicType.INT));
    il.append(SWAP);
    il.append(new INVOKESPECIAL(index));
      }
      else {

  if (_iloadCurrent == null) {
      int idx = getLocalIndex("current");
      if (idx > 0)
    _iloadCurrent = new ILOAD(idx);
      else
    _iloadCurrent = new ICONST(0);
  }
  return _iloadCurrent;
    }

    il.append(methodGen.loadDOM());
    // If the predicate's Step is simply '.' we translate this Step
    // and place the node test on top of the resulting iterator
    if (step.isAbbreviatedDot()) {
        translate(classGen, methodGen);
        il.append(new ICONST(DOM.RETURN_CURRENT));
    }
    // Otherwise we create a parent location path with this Step and
    // the predicates Step, and place the node test on top of that
    else {
        ParentLocationPath path = new ParentLocationPath(this,step);
        try {
      path.typeCheck(getParser().getSymbolTable());
        }
        catch (TypeCheckError e) { }
        path.translate(classGen, methodGen);
        il.append(new ICONST(DOM.RETURN_PARENT));
    }
    predicate.translate(classGen, methodGen);
    idx = cpg.addInterfaceMethodref(DOM_INTF,
            GET_NODE_VALUE_ITERATOR,
            GET_NODE_VALUE_ITERATOR_SIG);
    il.append(new INVOKEINTERFACE(idx, 5));
      }           
      // Handle '//*[n]' expression
      else if (predicate.isNthDescendant()) {
    il.append(methodGen.loadDOM());
    // il.append(new ICONST(NodeTest.ELEMENT));
    il.append(new ICONST(predicate.getPosType()));
    predicate.translate(classGen, methodGen);
    il.append(new ICONST(0));
    idx = cpg.addInterfaceMethodref(DOM_INTF,
            "getNthDescendant",
            "(IIZ)"+NODE_ITERATOR_SIG);
    il.append(new INVOKEINTERFACE(idx, 4));
      }

      }
      // Push the default value on the JVM's stack
      if ((_type instanceof IntType) ||
    (_type instanceof NodeType) ||
    (_type instanceof BooleanType))
    il.append(new ICONST(0)); // 0 for node-id, integer and boolean
      else if (_type instanceof RealType)
    il.append(new DCONST(0)); // 0.0 for floating point numbers
      else
    il.append(new ACONST_NULL()); // and 'null' for anything else
      il.append(_type.STORE(_local.getIndex()));

    il.append(methodGen.loadDOM());
    // If the predicate's Step is simply '.' we translate this Step
    // and place the node test on top of the resulting iterator
    if (step.isAbbreviatedDot()) {
        translate(classGen, methodGen);
        il.append(new ICONST(DOM.RETURN_CURRENT));
    }
    // Otherwise we create a parent location path with this Step and
    // the predicates Step, and place the node test on top of that
    else {
        ParentLocationPath path = new ParentLocationPath(this,step);
        try {
      path.typeCheck(getParser().getSymbolTable());
        }
        catch (TypeCheckError e) { }
        path.translate(classGen, methodGen);
        il.append(new ICONST(DOM.RETURN_PARENT));
    }
    predicate.translate(classGen, methodGen);
    idx = cpg.addInterfaceMethodref(DOM_INTF,
            GET_NODE_VALUE_ITERATOR,
            GET_NODE_VALUE_ITERATOR_SIG);
    il.append(new INVOKEINTERFACE(idx, 5));
      }           
      // Handle '//*[n]' expression
      else if (predicate.isNthDescendant()) {
    il.append(methodGen.loadDOM());
    // il.append(new ICONST(NodeTest.ELEMENT));
    il.append(new ICONST(predicate.getPosType()));
    predicate.translate(classGen, methodGen);
    il.append(new ICONST(0));
    idx = cpg.addInterfaceMethodref(DOM_INTF,
            "getNthDescendant",
            "(IIZ)"+NODE_ITERATOR_SIG);
    il.append(new INVOKEINTERFACE(idx, 4));
      }

  @SuppressWarnings("unused")
  // Called using reflection
  private Instruction createInstructionIconst(Element inst)
  {
    int value= Integer.parseInt(inst.getAttributeValue("value"));
    return new ICONST(value);
  }

TOP

Related Classes of org.apache.bcel.generic.ICONST

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.