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

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


  // Create the new output handler (leave it on stack)
  il.append(classGen.loadTranslet());
  _filename.translate(classGen, methodGen);
        il.append(new PUSH(cpg, _append));
  il.append(new INVOKEVIRTUAL(open));

  // Overwrite current handler
  il.append(methodGen.storeHandler());
 
  // Translate contents with substituted handler
  translateContents(classGen, methodGen);

  // Close the output handler (close file)
  il.append(classGen.loadTranslet());
  il.append(methodGen.loadHandler());
  il.append(new INVOKEVIRTUAL(close));

  // Restore old output handler from stack
  il.append(methodGen.storeHandler());
    }
View Full Code Here


            }
            else {
          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,
View Full Code Here

               MethodGenerator methodGen) {
  final ConstantPoolGen cpg = classGen.getConstantPool();
  final InstructionList il = methodGen.getInstructionList();
  _base.translate(classGen, methodGen);
  _token.translate(classGen, methodGen);
  il.append(new INVOKEVIRTUAL(cpg.addMethodref(STRING_CLASS,
                 "indexOf",
                 "("+STRING_SIG+")I")));
  _falseList.add(il.append(new IFLT(null)));
    }
View Full Code Here

          // Push parameter frame
          final int push = cpg.addMethodref(TRANSLET_CLASS,
                    PUSH_PARAM_FRAME,
                    PUSH_PARAM_FRAME_SIG);
          il.append(classGen.loadTranslet());
          il.append(new INVOKEVIRTUAL(push));
          translateContents(classGen, methodGen);
      }
  }

        // Generate a valid Java method name
  final String className = stylesheet.getClassName();
        String methodName = Util.escape(_name.toString());

        // Load standard arguments
  il.append(classGen.loadTranslet());
  il.append(methodGen.loadDOM());
  il.append(methodGen.loadIterator());
  il.append(methodGen.loadHandler());
  il.append(methodGen.loadCurrentNode());
       
        // Initialize prefix of method signature
  StringBuffer methodSig = new StringBuffer("(" + DOM_INTF_SIG
            + NODE_ITERATOR_SIG + TRANSLET_OUTPUT_SIG + NODE_SIG);
 
        // If calling a simply named template, push actual arguments
  if (_calleeTemplate != null) {
      Vector calleeParams = _calleeTemplate.getParameters();
      int numParams = _parameters.length;
     
      for (int i = 0; i < numParams; i++) {
          SyntaxTreeNode node = (SyntaxTreeNode)_parameters[i];
                methodSig.append(OBJECT_SIG);   // append Object to signature
               
                // Push 'null' if Param to indicate no actual parameter specified
                if (node instanceof Param) {
                    il.append(ACONST_NULL);
                }
                else // translate WithParam
                    node.translate(classGen, methodGen);
                }
            }
        }

        // Complete signature and generate invokevirtual call
  methodSig.append(")V");
  il.append(new INVOKEVIRTUAL(cpg.addMethodref(className,
                 methodName,
                 methodSig.toString())));
 
  // Do not need to call Translet.popParamFrame() if we are
  // calling a simple named template.
  if (_calleeTemplate == null && (stylesheet.hasLocalParams() || hasContents())) {
      // Pop parameter frame
      final int pop = cpg.addMethodref(TRANSLET_CLASS,
               POP_PARAM_FRAME,
               POP_PARAM_FRAME_SIG);
      il.append(classGen.loadTranslet());
      il.append(new INVOKEVIRTUAL(pop));
  }
    }
View Full Code Here

            // 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 "comment"
            final int comment =
                        cpg.addInterfaceMethodref(TRANSLET_OUTPUT_INTERFACE,
View Full Code Here

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

        //   KeyIndex ki = translet.getKeyIndex(_name)
        //   ki.setDom(translet.dom);
        //   ki.getKeyIndexIterator(_value, true)  - for key()
        //        OR
        //   ki.getKeyIndexIterator(_value, false)  - for id()
        il.append(new INVOKEVIRTUAL(getKeyIndex));
        il.append(DUP);
        il.append(methodGen.loadDOM());
        il.append(methodGen.loadCurrentNode());
        il.append(new INVOKEVIRTUAL(keyDom));

        _value.translate(classGen, methodGen);
        il.append((_name != null) ? ICONST_1: ICONST_0);
        il.append(new INVOKEVIRTUAL(getKeyIterator));
    }
View Full Code Here

  // Add the various iterators to the UnionIterator
  final int length = _components.length;
  for (int i = 0; i < length; i++) {
      _components[i].translate(classGen, methodGen);
      il.append(new INVOKEVIRTUAL(iter));
  }

  // Order the iterator only if strictly needed
  if (_reverse) {
      final int order = cpg.addInterfaceMethodref(DOM_INTF,
View Full Code Here

      final ConstantPoolGen cpg = classGen.getConstantPool();
      final InstructionList il = methodGen.getInstructionList();
      final int initBuffer = cpg.addMethodref(STRING_BUFFER_CLASS,
                "<init>", "()V");
      final Instruction append =
    new INVOKEVIRTUAL(cpg.addMethodref(STRING_BUFFER_CLASS,
               "append",
               "(" + STRING_SIG + ")"
               + STRING_BUFFER_SIG));
     
      final int toString = cpg.addMethodref(STRING_BUFFER_CLASS,
              "toString",
              "()"+STRING_SIG);
      il.append(new NEW(cpg.addClass(STRING_BUFFER_CLASS)));
      il.append(DUP);
      il.append(new INVOKESPECIAL(initBuffer));
      // StringBuffer is on the stack
      final Enumeration elements = elements();
      while (elements.hasMoreElements()) {
    final Expression exp = (Expression)elements.nextElement();
    exp.translate(classGen, methodGen);
    il.append(append);
      }
      il.append(new INVOKEVIRTUAL(toString));
  }
    }
View Full Code Here

TOP

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