Package org.apache.bcel.generic

Examples of org.apache.bcel.generic.ConstantPoolGen


     *
     * @see  org.apache.xalan.xsltc.compiler.util.Type#translateTo
     */
    public void translateTo(ClassGenerator classGen, MethodGenerator methodGen,
          BooleanType type) {
  final ConstantPoolGen cpg = classGen.getConstantPool();
  final InstructionList il = methodGen.getInstructionList();

  int index = cpg.addMethodref(BASIS_LIBRARY_CLASS, "booleanF",
             "("
             + OBJECT_SIG
             + ")Z");
  il.append(new INVOKESTATIC(index));
    }
View Full Code Here


     *
     * @see  org.apache.xalan.xsltc.compiler.util.Type#translateTo
     */
    public void translateTo(ClassGenerator classGen, MethodGenerator methodGen,
          NodeSetType type) {
  final ConstantPoolGen cpg = classGen.getConstantPool();
  final InstructionList il = methodGen.getInstructionList();
  int index = cpg.addMethodref(BASIS_LIBRARY_CLASS, "referenceToNodeSet",
             "("
             + OBJECT_SIG
             + ")"
             + NODE_ITERATOR_SIG);
  il.append(new INVOKESTATIC(index));
 
  // Reset this iterator
  index = cpg.addInterfaceMethodref(NODE_ITERATOR, RESET, RESET_SIG);
  il.append(new INVOKEINTERFACE(index, 1));
    }
View Full Code Here

     *
     * @see  org.apache.xalan.xsltc.compiler.util.Type#translateTo
     */
    public void translateTo(ClassGenerator classGen, MethodGenerator methodGen,
          ResultTreeType type) {
  final ConstantPoolGen cpg = classGen.getConstantPool();
  final InstructionList il = methodGen.getInstructionList();
  int index = cpg.addMethodref(BASIS_LIBRARY_CLASS, "referenceToResultTree",
             "(" + OBJECT_SIG + ")" + DOM_INTF_SIG);
  il.append(new INVOKESTATIC(index));
    }
View Full Code Here

    /**
     * Translates a reference into the Java type denoted by <code>clazz</code>.
     */
    public void translateTo(ClassGenerator classGen, MethodGenerator methodGen,
          Class clazz) {
  final ConstantPoolGen cpg = classGen.getConstantPool();
  final InstructionList il = methodGen.getInstructionList();
 
  if (clazz.getName().equals("java.lang.Object")) {
      il.append(NOP)
  }
  else if (clazz == Double.TYPE) {
      translateTo(classGen, methodGen, Type.Real);
  }
  else if (clazz.getName().equals("java.lang.String")) {
      translateTo(classGen, methodGen, Type.String);
  }
  else if (clazz.getName().equals("org.w3c.dom.Node")) {
      int index = cpg.addMethodref(BASIS_LIBRARY_CLASS, "referenceToNode",
                 "("
                 + OBJECT_SIG
                 + DOM_INTF_SIG
                 + ")"
                 + "Lorg/w3c/dom/Node;");
      il.append(methodGen.loadDOM());
      il.append(new INVOKESTATIC(index));
  }
  else if (clazz.getName().equals("org.w3c.dom.NodeList")) {
      int index = cpg.addMethodref(BASIS_LIBRARY_CLASS, "referenceToNodeList",
                 "("
                 + OBJECT_SIG
                 + DOM_INTF_SIG
                 + ")"
                 + "Lorg/w3c/dom/NodeList;");
View Full Code Here

     *
     * @see  org.apache.xalan.xsltc.compiler.util.Type#translateTo
     */
    public void translateTo(ClassGenerator classGen, MethodGenerator methodGen,
          StringType type) {
  final ConstantPoolGen cpg = classGen.getConstantPool();
  final InstructionList il = methodGen.getInstructionList();

  il.append(DUP);
  final BranchHandle ifNull = il.append(new IFNULL(null));
  il.append(new INVOKEVIRTUAL(cpg.addMethodref(_javaClassName,
                "toString",
                "()" + STRING_SIG)));
  final BranchHandle gotobh = il.append(new GOTO(null));
  ifNull.setTarget(il.append(POP));
  il.append(new PUSH(cpg, ""));
View Full Code Here

     */
    public void translateTo(ClassGenerator classGen, MethodGenerator methodGen,
          BooleanType type) {
  // A result tree is always 'true' when converted to a boolean value,
  // since the tree always has at least one node (the root).
  final ConstantPoolGen cpg = classGen.getConstantPool();
  final InstructionList il = methodGen.getInstructionList();
  il.append(POP);      // don't need the DOM reference
  il.append(ICONST_1); // push 'true' on the stack
    }
View Full Code Here

     * @param type An instance of StringType (any)
     * @see org.apache.xalan.xsltc.compiler.util.Type#translateTo
     */
    public void translateTo(ClassGenerator classGen, MethodGenerator methodGen,
          StringType type) {
  final ConstantPoolGen cpg = classGen.getConstantPool();
  final InstructionList il = methodGen.getInstructionList();
 
  if (_methodName == null) {
      int index = cpg.addInterfaceMethodref(DOM_INTF,
              "getStringValue",
              "()"+STRING_SIG);
      il.append(new INVOKEINTERFACE(index, 1));
  }
  else {
      final String className = classGen.getClassName();
      final int current = methodGen.getLocalIndex("current");
     
      // Push required parameters
      il.append(classGen.loadTranslet());
      if (classGen.isExternal()) {
    il.append(new CHECKCAST(cpg.addClass(className)));
      }
      il.append(DUP);
      il.append(new GETFIELD(cpg.addFieldref(className, "_dom",
               DOM_INTF_SIG)));

      // Create a new instance of a StringValueHandler
      int index = cpg.addMethodref(STRING_VALUE_HANDLER, "<init>", "()V");
      il.append(new NEW(cpg.addClass(STRING_VALUE_HANDLER)));
      il.append(DUP);
      il.append(DUP);
      il.append(new INVOKESPECIAL(index));
     
      // Store new Handler into a local variable
      final LocalVariableGen handler =
    methodGen.addLocalVariable("rt_to_string_handler",
             Util.getJCRefType(STRING_VALUE_HANDLER_SIG),
             null, null);
      il.append(new ASTORE(handler.getIndex()));

      // Call the method that implements this result tree
      index = cpg.addMethodref(className, _methodName,
             "("+DOM_INTF_SIG+TRANSLET_OUTPUT_SIG+")V");
      il.append(new INVOKEVIRTUAL(index));
     
      // Restore new handler and call getValue()
      il.append(new ALOAD(handler.getIndex()));
      index = cpg.addMethodref(STRING_VALUE_HANDLER,
             "getValue",
             "()" + STRING_SIG);
      il.append(new INVOKEVIRTUAL(index));
  }
    }
View Full Code Here

     * @param type An instance of ReferenceType (any)
     * @see org.apache.xalan.xsltc.compiler.util.Type#translateTo
     */
    public void translateTo(ClassGenerator classGen, MethodGenerator methodGen,
          ReferenceType type) {
  final ConstantPoolGen cpg = classGen.getConstantPool();
  final InstructionList il = methodGen.getInstructionList();

  if (_methodName == null) {
      il.append(NOP);
  }
  else {
      LocalVariableGen domBuilder, newDom;
      final String className = classGen.getClassName();
      final int current = methodGen.getLocalIndex("current");

      // Push required parameters
      il.append(classGen.loadTranslet());
      if (classGen.isExternal()) {
    il.append(new CHECKCAST(cpg.addClass(className)));
      }
      il.append(methodGen.loadDOM());

      // Create new instance of DOM class
      int index = cpg.addMethodref(DOM_IMPL, "<init>", "(I)V");
      il.append(new NEW(cpg.addClass(DOM_IMPL)));
      il.append(DUP);
      il.append(DUP);
      il.append(new PUSH(cpg, RTF_INITIAL_SIZE));
      il.append(new INVOKESPECIAL(index));
     
      // Store new DOM into a local variable
      newDom = methodGen.addLocalVariable("rt_to_reference_dom",
            Util.getJCRefType(DOM_INTF_SIG),
            null, null);
      il.append(new CHECKCAST(cpg.addClass(DOM_INTF_SIG)));
      il.append(new ASTORE(newDom.getIndex()));

      // Overwrite old handler with DOM handler
      index = cpg.addMethodref(DOM_IMPL,
             "getOutputDomBuilder",
             "()" + TRANSLET_OUTPUT_SIG);
      il.append(new INVOKEVIRTUAL(index));
      il.append(DUP);
      il.append(DUP);

      // Store DOM handler in a local in order to call endDocument()
      domBuilder =
    methodGen.addLocalVariable("rt_to_reference_handler",
             Util.getJCRefType(TRANSLET_OUTPUT_SIG),
             null, null);
      il.append(new ASTORE(domBuilder.getIndex()));

      // Call startDocument on the new handler
      index = cpg.addInterfaceMethodref(TRANSLET_OUTPUT_INTERFACE,
                "startDocument", "()V");
      il.append(new INVOKEINTERFACE(index, 1));

      // Call the method that implements this result tree
      index = cpg.addMethodref(className,
             _methodName,
             "("
             + DOM_INTF_SIG
             + TRANSLET_OUTPUT_SIG
             +")V");
      il.append(new INVOKEVIRTUAL(index));

      // Call endDocument on the DOM handler
      il.append(new ALOAD(domBuilder.getIndex()));
      index = cpg.addInterfaceMethodref(TRANSLET_OUTPUT_INTERFACE,
                "endDocument", "()V");
      il.append(new INVOKEINTERFACE(index, 1));

      // Push the new DOM on the stack
      il.append(new ALOAD(newDom.getIndex()));
View Full Code Here

     * @param type An instance of NodeSetType (any)
     * @see org.apache.xalan.xsltc.compiler.util.Type#translateTo
     */
    public void translateTo(ClassGenerator classGen, MethodGenerator methodGen,
          NodeSetType type) {
  final ConstantPoolGen cpg = classGen.getConstantPool();
  final InstructionList il = methodGen.getInstructionList();

  // Put an extra copy of the result tree (DOM) on the stack
  il.append(DUP);

  // DOM adapters containing a result tree are not initialised with
  // translet-type to DOM-type mapping. This must be done now for
  // XPath expressions and patterns to work for the iterator we create.
  il.append(classGen.loadTranslet()); // get names array
  il.append(new GETFIELD(cpg.addFieldref(TRANSLET_CLASS,
                 NAMES_INDEX,
                 NAMES_INDEX_SIG)));
  il.append(classGen.loadTranslet()); // get namespaces array
  il.append(new GETFIELD(cpg.addFieldref(TRANSLET_CLASS,
                 NAMESPACE_INDEX,
                 NAMESPACE_INDEX_SIG)));
  // Pass the type mappings to the DOM adapter
  final int mapping = cpg.addInterfaceMethodref(DOM_INTF,
                  "setupMapping",
                  "(["+STRING_SIG+
                  "["+STRING_SIG+")V");
  il.append(new INVOKEINTERFACE(mapping, 3));
  il.append(DUP);

  // Create an iterator for the root node of the DOM adapter
  final int iter = cpg.addInterfaceMethodref(DOM_INTF,
               "getIterator",
               "()"+NODE_ITERATOR_SIG);
  il.append(new INVOKEINTERFACE(iter, 1))
    }
View Full Code Here

     * @see org.apache.xalan.xsltc.compiler.util.Type#translateTo
     */
    public void translateTo(ClassGenerator classGen, MethodGenerator methodGen,
          Class clazz) {
  final String className = clazz.getName();
  final ConstantPoolGen cpg = classGen.getConstantPool();
  final InstructionList il = methodGen.getInstructionList();

  if (className.equals("org.w3c.dom.Node")) {
      translateTo(classGen, methodGen, Type.NodeSet);
      int index = cpg.addInterfaceMethodref(DOM_INTF,
              MAKE_NODE,
              MAKE_NODE_SIG2);
      il.append(new INVOKEINTERFACE(index, 2));
  }
  else if (className.equals("org.w3c.dom.NodeList")) {
      translateTo(classGen, methodGen, Type.NodeSet);
      int index = cpg.addInterfaceMethodref(DOM_INTF,
              MAKE_NODE_LIST,
              MAKE_NODE_LIST_SIG2);
      il.append(new INVOKEINTERFACE(index, 2));
  }
  else if (className.equals("java.lang.Object")) {
View Full Code Here

TOP

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

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.