Package org.apache.bcel.generic

Examples of org.apache.bcel.generic.INVOKESTATIC


      }

      // Invoke the method in the basis library
      index = cpg.addMethodref(BASIS_LIBRARY_CLASS, name,
             _chosenMethodType.toSignature(args));
      il.append(new INVOKESTATIC(index));
  }
  // Add call to BasisLibrary.unresolved_externalF() to generate
  // run-time error message for unsupported external functions
  else if (unresolvedExternal) {
      index = cpg.addMethodref(BASIS_LIBRARY_CLASS,
             "unresolved_externalF",
             "(Ljava/lang/String;)V");
      il.append(new PUSH(cpg, _fname.toString()));
      il.append(new INVOKESTATIC(index));
  }
  else if (_isExtConstructor) {
      final String clazz =
    _chosenConstructor.getDeclaringClass().getName();
      Class[] paramTypes = _chosenConstructor.getParameterTypes();
     
      il.append(new NEW(cpg.addClass(_className)));
      il.append(InstructionConstants.DUP);

      for (int i = 0; i < n; i++) {
    final Expression exp = argument(i);
    exp.translate(classGen, methodGen);
    // Convert the argument to its Java type
    exp.startResetIterator(classGen, methodGen);
    exp.getType().translateTo(classGen, methodGen, paramTypes[i]);
      }

      final StringBuffer buffer = new StringBuffer();
      buffer.append('(');
      for (int i = 0; i < paramTypes.length; i++) {
    buffer.append(getSignature(paramTypes[i]));
      }
      buffer.append(')');
      buffer.append("V");

      index = cpg.addMethodref(clazz,
             "<init>",
             buffer.toString());
      il.append(new INVOKESPECIAL(index));

      // Convert the return type back to our internal type
      (Type.Object).translateFrom(classGen, methodGen,
        _chosenConstructor.getDeclaringClass());
     
  }
  // Invoke function calls that are handled in separate classes
  else {
      final String clazz = _chosenMethod.getDeclaringClass().getName();
      Class[] paramTypes = _chosenMethod.getParameterTypes();

      // Push "this" if it is an instance method
      if (_thisArgument != null) {
    _thisArgument.translate(classGen, methodGen);
      }     

      for (int i = 0; i < n; i++) {
    final Expression exp = argument(i);
    exp.translate(classGen, methodGen);
    // Convert the argument to its Java type
    exp.startResetIterator(classGen, methodGen);
    exp.getType().translateTo(classGen, methodGen, paramTypes[i]);
      }

      final StringBuffer buffer = new StringBuffer();
      buffer.append('(');
      for (int i = 0; i < paramTypes.length; i++) {
    buffer.append(getSignature(paramTypes[i]));
      }
      buffer.append(')');
      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


          "("   
           + "Lorg/w3c/dom/NodeList;"
           + TRANSLET_INTF_SIG
           + DOM_INTF_SIG
           + ")" + NODE_ITERATOR_SIG );
     il.append(new INVOKESTATIC(convert));
  }
  else if (clazz.getName().equals("org.w3c.dom.Node")) {
     // w3c Node is on the stack from the external Java function call.
     // call BasisLibrary.node2Iterator() to consume Node and leave
     // Iterator on the stack.
     il.append(classGen.loadTranslet());   // push translet onto stack
     il.append(methodGen.loadDOM());      // push DOM onto stack
     final int convert = cpg.addMethodref(BASIS_LIBRARY_CLASS,
          "node2Iterator",
          "("   
           + "Lorg/w3c/dom/Node;"
           + TRANSLET_INTF_SIG
           + DOM_INTF_SIG
           + ")" + NODE_ITERATOR_SIG );
     il.append(new INVOKESTATIC(convert));
  }
  else {
      ErrorMsg err = new ErrorMsg(ErrorMsg.DATA_CONVERSION_ERR,
    toString(), clazz.getName());
      classGen.getParser().reportError(Constants.FATAL, err);
View Full Code Here

      // Get next node from the iterator
      il.append(new INVOKEINTERFACE(next, 1));
      // Get the node's string value (from the DOM)
      il.append(new INVOKEINTERFACE(index, 2));
      // Create a new Integer object from the string value
      il.append(new INVOKESTATIC(str));
  }
  else {
      ErrorMsg err = new ErrorMsg(ErrorMsg.DATA_CONVERSION_ERR,
          toString(), className);
      classGen.getParser().reportError(Constants.FATAL, err);
View Full Code Here

     */
    public void translateTo(ClassGenerator classGen, MethodGenerator methodGen,
          RealType type) {
  final ConstantPoolGen cpg = classGen.getConstantPool();
  final InstructionList il = methodGen.getInstructionList();
  il.append(new INVOKESTATIC(cpg.addMethodref(BASIS_LIBRARY_CLASS,
                STRING_TO_REAL,
                STRING_TO_REAL_SIG)));
    }
View Full Code Here

               "("
               + OBJECT_SIG
               + NODE_SIG
               + DOM_INTF_SIG
               + ")" + STRING_SIG);
  il.append(new INVOKESTATIC(stringF));
    }
View Full Code Here

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

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

  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

          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

                 + 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;");
      il.append(methodGen.loadDOM());
      il.append(new INVOKESTATIC(index));
  }
  else if (clazz.getName().equals("org.apache.xalan.xsltc.DOM")) {
      translateTo(classGen, methodGen, Type.ResultTree);
  }
  else {
View Full Code Here

TOP

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

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.