Package org.apache.bcel.generic

Examples of org.apache.bcel.generic.INVOKEVIRTUAL


                    "(" + WRITER_SIG + STRING_SIG + ")V")));

                // Invoke output.omitHeader(true)
                il.append(methodGen.loadHandler());
                il.append(ICONST_1);
                il.append(new INVOKEVIRTUAL(
                    cpg.addMethodref(OUTPUT_BASE, "omitHeader",
                                     "(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
View Full Code Here


      buffer.append(getSignature(_chosenMethod.getReturnType()));

      index = cpg.addMethodref(clazz,
             _fname.getLocalPart(),
             buffer.toString());
      il.append(_thisArgument != null ? (InvokeInstruction) new INVOKEVIRTUAL(index) :
            (InvokeInstruction) new INVOKESTATIC(index));
      // Convert the return type back to our internal type
      _type.translateFrom(classGen, methodGen,
        _chosenMethod.getReturnType());
View Full Code Here

      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)));

    _type.translateUnBox(classGen, methodGen);
View Full Code Here

      _value.startResetIterator(classGen, methodGen);
      il.append(methodGen.storeIterator());

      // Create the KeyIndex object (the iterator) we'll return
      il.append(classGen.loadTranslet());
      il.append(new INVOKEVIRTUAL(indexConstructor));
      il.append(new ASTORE(returnIndex.getIndex()));

      // 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);
      }

      il.append(new INVOKEVIRTUAL(getKeyIndex));
      il.append(new ASTORE(searchIndex.getIndex()));

      // LOOP STARTS HERE

      // Now we're ready to start traversing the node-set given in
      // the key() function's second argument....
      final BranchHandle nextNode = il.append(new GOTO(null));
      final InstructionHandle loop = il.append(NOP);

      // Push returnIndex on stack to prepare for call to merge()
      il.append(new ALOAD(returnIndex.getIndex()));
     
      // Lookup index using the string value from the current node
      il.append(new ALOAD(searchIndex.getIndex()));
      il.append(DUP);
      il.append(methodGen.loadDOM());
      il.append(methodGen.loadCurrentNode());
      il.append(new INVOKEINTERFACE(getNodeValue, 2));
      if (_name == null) {
    il.append(new INVOKEVIRTUAL(lookupId));
      }
      else {
    il.append(new INVOKEVIRTUAL(lookupKey));
      }

      // Call to returnIndex.merge(searchIndex);
      il.append(new INVOKEVIRTUAL(merge));
   
      // Go on with next node in the 2nd parameter node-set
      nextNode.setTarget(il.append(methodGen.loadIterator()));
      il.append(methodGen.nextNode());
      il.append(DUP);
      il.append(methodGen.storeCurrentNode());
      il.append(new IFNE(loop));

      // LOOP ENDS HERE

      // Restore current node and current iterator from the stack
      il.append(methodGen.storeIterator());
      il.append(methodGen.storeCurrentNode());

      // Return with the an iterator for all resulting nodes
      il.append(new ALOAD(returnIndex.getIndex()));
  }
  // If the second parameter is a single value we just lookup the named
  // index and initialise the iterator to return nodes with this value.
  else {
      // Call getKeyIndex in AbstractTranslet with the name of the key
      // to get the index for this key (which is also a node iterator).
      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);
      }
      il.append(new INVOKEVIRTUAL(getKeyIndex));

      // Now use the value in the second argument to determine what nodes
      // the iterator should return.
      il.append(DUP);

      _value.translate(classGen, methodGen);

      if (_name == null) {
    il.append(new INVOKEVIRTUAL(lookupId));
      }
      else {
    il.append(new INVOKEVIRTUAL(lookupKey));
      }
  }
    }
View Full Code Here

      if ((path == Axis.DESCENDANTORSELF && step == Axis.CHILD) ||
    (path == Axis.PRECEDING        && step == Axis.PARENT)) {
    final int incl = cpg.addMethodref(NODE_ITERATOR_BASE,
              "includeSelf",
              "()" + NODE_ITERATOR_SIG);
    il.append(new INVOKEVIRTUAL(incl));
      }
  }

  /*
   * If this pattern contains a sequence of descendant iterators we
View Full Code Here

      il.append(DUP);
      il.append(methodGen.storeHandler());
      // translate contents with substituted handler
      translateContents(classGen, methodGen);
      // get String out of the handler
      il.append(new INVOKEVIRTUAL(cpg.addMethodref(STRING_VALUE_HANDLER,
               "getValue",
               "()" + STRING_SIG)));
  }

  // call "attribute"
View Full Code Here

      il.append(new PUSH(cpg, _resolvedQName.toString()));
  }
  else {
      _name.translate(classGen, methodGen);
  }
  il.append(new INVOKEVIRTUAL(get));
  il.append(new INVOKESTATIC(fn3arg));
    }
View Full Code Here

  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())

  il.append(DUP);
View Full Code Here

      il.append(SWAP);
      il.append(methodGen.loadDOM());
      il.append(SWAP);
      il.append(new INVOKEINTERFACE(getNodeIdent, 2));
      il.append(SWAP);
      il.append(new INVOKEVIRTUAL(key));
     
      il.append(methodGen.loadDOM());
      il.append(new INVOKEVIRTUAL(keyDom));
  }
 
  // Get the next node from the iterator and do loop again...
  final InstructionHandle skip = il.append(NOP);
 
View Full Code Here

      final int equals = cpg.addMethodref(STRING_CLASS,
            "equals",
            "(" + OBJECT_SIG +")Z");
      _left.translate(classGen, methodGen);
      _right.translate(classGen, methodGen);
      il.append(new INVOKEVIRTUAL(equals));

        if (_op == Operators.NE) {
    il.append(ICONST_1);
    il.append(IXOR);      // not x <-> x xor 1
      }
      return;
  }

  BranchHandle truec, falsec;
 
  if (tleft instanceof ResultTreeType) {
      if (tright instanceof BooleanType) {
    _right.translate(classGen, methodGen);
        if (_op == Operators.NE) {
        il.append(ICONST_1);
        il.append(IXOR); // not x <-> x xor 1
    }
    return;
      }

      if (tright instanceof RealType) {
    _left.translate(classGen, methodGen);
    tleft.translateTo(classGen, methodGen, Type.Real);
    _right.translate(classGen, methodGen);

    il.append(DCMPG);
        falsec = il.append(_op == Operators.EQ ?
           (BranchInstruction) new IFNE(null) :
           (BranchInstruction) new IFEQ(null));
    il.append(ICONST_1);
    truec = il.append(new GOTO(null));
    falsec.setTarget(il.append(ICONST_0));
    truec.setTarget(il.append(NOP));
    return;
      }

      // Next, result-tree/string and result-tree/result-tree comparisons

      _left.translate(classGen, methodGen);
      tleft.translateTo(classGen, methodGen, Type.String);
      _right.translate(classGen, methodGen);

      if (tright instanceof ResultTreeType) {
    tright.translateTo(classGen, methodGen, Type.String);
      }

      final int equals = cpg.addMethodref(STRING_CLASS,
            "equals",
            "(" +OBJECT_SIG+ ")Z");
      il.append(new INVOKEVIRTUAL(equals));

        if (_op == Operators.NE) {
    il.append(ICONST_1);
    il.append(IXOR);      // not x <-> x xor 1
      }
View Full Code Here

TOP

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

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.