Package org.apache.bcel.generic

Examples of org.apache.bcel.generic.INVOKEVIRTUAL


      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(),
                 null);
    // Cache the result of addParameter() in a local variable
    _local.setStart(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


 
  il.append(methodGen.loadDOM());
  il.append(new ILOAD(_currentIndex));
  il.append(new INVOKEINTERFACE(git, 2));
  il.append(methodGen.loadHandler());
  il.append(new INVOKEVIRTUAL(applyTemplates));
  il.append(new GOTO_W(next));
  return il;
    }
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(new INVOKEVIRTUAL(keyDom));

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

               MethodGenerator methodGen,
               BooleanType type) {
  final ConstantPoolGen cpg = classGen.getConstantPool();
  final InstructionList il = methodGen.getInstructionList();

  il.append(new INVOKEVIRTUAL(cpg.addMethodref(STRING_CLASS,
                 "length", "()I")));
  return new FlowList(il.append(new IFEQ(null)));
    }
View Full Code Here

      il.append(classGen.loadTranslet());
      il.append(methodGen.loadDOM());
      il.append(methodGen.loadIterator());
      il.append(methodGen.loadHandler());
      il.append(methodGen.loadCurrentNode());
      il.append(new INVOKEVIRTUAL(cpg.addMethodref(className,
               methodName,
               "("
               + DOM_INTF_SIG
               + NODE_ITERATOR_SIG
               + TRANSLET_OUTPUT_SIG
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

        } else {
            oldMethCopyOutIL.append(InstructionConstants.THIS);
            oldMethCopyOutIL.append(InstructionConstants.SWAP);
            outlinedMethodRef =
                oldMethCopyOutIL.append(
                    new INVOKEVIRTUAL(cpg.addMethodref(
                                          classGen.getClassName(),
                                          outlinedMethodName,
                                          outlinedMethodGen.getSignature())));
        }
View Full Code Here

  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

                                                    CHARACTERSW_SIG);

            il.append(classGen.loadTranslet());
            _select.translate(classGen, methodGen);
            il.append(methodGen.loadHandler());
            il.append(new INVOKEVIRTUAL(characters));
        } else {
            final int characters = cpg.addInterfaceMethodref(DOM_INTF,
                                                             CHARACTERS,
                                                             CHARACTERS_SIG);
View Full Code Here

    public void translateUnBox(ClassGenerator classGen,
             MethodGenerator methodGen) {
  final ConstantPoolGen cpg = classGen.getConstantPool();
  final InstructionList il = methodGen.getInstructionList();
  il.append(new CHECKCAST(cpg.addClass(BOOLEAN_CLASS)));
  il.append(new INVOKEVIRTUAL(cpg.addMethodref(BOOLEAN_CLASS,
                 BOOLEAN_VALUE,
                 BOOLEAN_VALUE_SIG)));
    }
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.