Package org.apache.bcel.generic

Examples of org.apache.bcel.generic.ConstantPoolGen


        ClassGen classGen = new ClassGen(className,
                AbstractLDAPSSLSocketFactory.class.getName(),
                "<generated>",
                ACC_PUBLIC | ACC_SUPER,
                null);
        ConstantPoolGen constantPoolGen = classGen.getConstantPool();
        InstructionFactory factory = new InstructionFactory(classGen);

        createSslContextStaticField(classGen, constantPoolGen);
        createGetDefaultStaticMethod(classGen, constantPoolGen, factory);
View Full Code Here


    public void reduceKernelPattern() {
  _left.reduceKernelPattern();
    }
 
    public void translate(ClassGenerator classGen, MethodGenerator methodGen) {
  final ConstantPoolGen cpg = classGen.getConstantPool();
  final InstructionList il = methodGen.getInstructionList();

  if (_left != null) {
      if (_left instanceof StepPattern) {
    final LocalVariableGen local =
        // absolute path pattern temporary
        methodGen.addLocalVariable2("apptmp",
            Util.getJCRefType(NODE_SIG),
            il.getEnd());
    il.append(DUP);
    il.append(new ISTORE(local.getIndex()));
    _left.translate(classGen, methodGen);
    il.append(methodGen.loadDOM());
    local.setEnd(il.append(new ILOAD(local.getIndex())));
    methodGen.removeLocalVariable(local);
      }
      else {
    _left.translate(classGen, methodGen);
      }
  }

  final int getParent = cpg.addInterfaceMethodref(DOM_INTF,
              GET_PARENT,
              GET_PARENT_SIG);
  final int getType = cpg.addInterfaceMethodref(DOM_INTF,
                  "getType", "(I)I");

  InstructionHandle begin = il.append(methodGen.loadDOM());
  il.append(SWAP);
  il.append(new INVOKEINTERFACE(getParent, 2));
View Full Code Here

  return _right.typeCheck(stable);
    }

    public void translate(ClassGenerator classGen, MethodGenerator methodGen) {
  InstructionHandle parent;
  final ConstantPoolGen cpg = classGen.getConstantPool();
  final InstructionList il = methodGen.getInstructionList();

  /*
   * The scope of this local var must be the entire method since
   * a another pattern may decide to jump back into the loop
   */
  final LocalVariableGen local =
      methodGen.addLocalVariable2("app", Util.getJCRefType(NODE_SIG),
          il.getEnd());

  final org.apache.bcel.generic.Instruction loadLocal =
      new ILOAD(local.getIndex());
  final org.apache.bcel.generic.Instruction storeLocal =
      new ISTORE(local.getIndex());

  if (_right instanceof StepPattern) {
      il.append(DUP);
      il.append(storeLocal);
      _right.translate(classGen, methodGen);
      il.append(methodGen.loadDOM());
      il.append(loadLocal);
  }
  else {
      _right.translate(classGen, methodGen);

      if (_right instanceof AncestorPattern) {
    il.append(methodGen.loadDOM());
    il.append(SWAP);
      }
  }

  if (_left != null) {
      final int getParent = cpg.addInterfaceMethodref(DOM_INTF,
                  GET_PARENT,
                  GET_PARENT_SIG);
      parent = il.append(new INVOKEINTERFACE(getParent, 2));
     
      il.append(DUP);
View Full Code Here

     * This method is called when the constructor is compiled in
     * Stylesheet.compileConstructor() and not as the syntax tree is traversed.
     */
    public void translate(ClassGenerator classGen, MethodGenerator methodGen) {

  ConstantPoolGen cpg = classGen.getConstantPool();
  InstructionList il = methodGen.getInstructionList();
 
  // DecimalFormatSymbols.<init>();
  final int init = cpg.addMethodref(DFS_CLASS, "<init>", "()V");

  // Push the format name on the stack for call to addDecimalFormat()
  il.append(classGen.loadTranslet());
  il.append(new PUSH(cpg, _name.toString()));

  // Manufacture a DecimalFormatSymbols on the stack
  // for call to addDecimalFormat()
  il.append(new NEW(cpg.addClass(DFS_CLASS)));
  il.append(DUP);
  il.append(new INVOKESPECIAL(init));

  String tmp = getAttribute("NaN");
  if ((tmp == null) || (tmp.equals(EMPTYSTRING))) {
      int nan = cpg.addMethodref(DFS_CLASS,
               "setNaN", "(Ljava/lang/String;)V");
      il.append(DUP);
      il.append(new PUSH(cpg, "NaN"));
      il.append(new INVOKEVIRTUAL(nan));
  }

  tmp = getAttribute("infinity");
  if ((tmp == null) || (tmp.equals(EMPTYSTRING))) {
      int inf = cpg.addMethodref(DFS_CLASS,
               "setInfinity",
               "(Ljava/lang/String;)V");
      il.append(DUP);
      il.append(new PUSH(cpg, "Infinity"));
      il.append(new INVOKEVIRTUAL(inf));
  }
     
  final int nAttributes = _attributes.getLength();
  for (int i = 0; i < nAttributes; i++) {
      final String name = _attributes.getQName(i);
      final String value = _attributes.getValue(i);

      boolean valid = true;
      int method = 0;

      if (name.equals("decimal-separator")) {
    // DecimalFormatSymbols.setDecimalSeparator();
    method = cpg.addMethodref(DFS_CLASS,
            "setDecimalSeparator", "(C)V");
      }
      else if (name.equals("grouping-separator")) {
    method =  cpg.addMethodref(DFS_CLASS,
             "setGroupingSeparator", "(C)V");
      }
      else if (name.equals("minus-sign")) {
    method = cpg.addMethodref(DFS_CLASS,
            "setMinusSign", "(C)V");
      }
      else if (name.equals("percent")) {
    method = cpg.addMethodref(DFS_CLASS,
            "setPercent", "(C)V");
      }
      else if (name.equals("per-mille")) {
    method = cpg.addMethodref(DFS_CLASS,
            "setPerMill", "(C)V");
      }
      else if (name.equals("zero-digit")) {
    method = cpg.addMethodref(DFS_CLASS,
            "setZeroDigit", "(C)V");
      }
      else if (name.equals("digit")) {
    method = cpg.addMethodref(DFS_CLASS,
            "setDigit", "(C)V");
      }
      else if (name.equals("pattern-separator")) {
    method = cpg.addMethodref(DFS_CLASS,
            "setPatternSeparator", "(C)V");
      }
      else if (name.equals("NaN")) {
    method = cpg.addMethodref(DFS_CLASS,
            "setNaN", "(Ljava/lang/String;)V");
          il.append(DUP);
    il.append(new PUSH(cpg, value));
    il.append(new INVOKEVIRTUAL(method));
    valid = false;
      }
      else if (name.equals("infinity")) {
    method = cpg.addMethodref(DFS_CLASS,
            "setInfinity",
            "(Ljava/lang/String;)V");
          il.append(DUP);
    il.append(new PUSH(cpg, value));
    il.append(new INVOKEVIRTUAL(method));
    valid = false;
      }
      else {
    valid = false;
      }

      if (valid) {
    il.append(DUP);
    il.append(new PUSH(cpg, value.charAt(0)));
    il.append(new INVOKEVIRTUAL(method));
      }

  }

  final int put = cpg.addMethodref(TRANSLET_CLASS,
           "addDecimalFormat",
           "("+STRING_SIG+DFS_SIG+")V");
  il.append(new INVOKEVIRTUAL(put));
    }
View Full Code Here

     * may be overridden by later nameless xsl:decimal-format instructions.
     */
    public static void translateDefaultDFS(ClassGenerator classGen,
             MethodGenerator methodGen) {

  ConstantPoolGen cpg = classGen.getConstantPool();
  InstructionList il = methodGen.getInstructionList();
  final int init = cpg.addMethodref(DFS_CLASS, "<init>", "()V");

  // Push the format name, which is empty, on the stack
  // for call to addDecimalFormat()
  il.append(classGen.loadTranslet());
  il.append(new PUSH(cpg, EMPTYSTRING));

  // Manufacture a DecimalFormatSymbols on the stack
  // for call to addDecimalFormat()
  il.append(new NEW(cpg.addClass(DFS_CLASS)));
  il.append(DUP);
  il.append(new INVOKESPECIAL(init));

  int nan = cpg.addMethodref(DFS_CLASS,
           "setNaN", "(Ljava/lang/String;)V");
  il.append(DUP);
  il.append(new PUSH(cpg, "NaN"));
  il.append(new INVOKEVIRTUAL(nan));

  int inf = cpg.addMethodref(DFS_CLASS,
           "setInfinity",
           "(Ljava/lang/String;)V");
  il.append(DUP);
  il.append(new PUSH(cpg, "Infinity"));
  il.append(new INVOKEVIRTUAL(inf));

  final int put = cpg.addMethodref(TRANSLET_CLASS,
           "addDecimalFormat",
           "("+STRING_SIG+DFS_SIG+")V");
  il.append(new INVOKEVIRTUAL(put));
    }
View Full Code Here

      _select = new CastExpr(_select, Type.String);
  return Type.Void;
    }

    public void translate(ClassGenerator classGen, MethodGenerator methodGen) {
  final ConstantPoolGen cpg = classGen.getConstantPool();
  final InstructionList il = methodGen.getInstructionList();
  final int setEscaping = cpg.addInterfaceMethodref(OUTPUT_HANDLER,
                "setEscaping","(Z)Z");
  final int characters = cpg.addMethodref(TRANSLET_CLASS,
            CHARACTERSW,
            CHARACTERSW_SIG);

  // Turn off character escaping if so is wanted.
  if (!_escaping) {
View Full Code Here

    /**
     * Translates the document() function call to a call to LoadDocument()'s
     * static method document().
     */
    public void translate(ClassGenerator classGen, MethodGenerator methodGen) {
  final ConstantPoolGen cpg = classGen.getConstantPool();
  final InstructionList il = methodGen.getInstructionList();

  final int domField = cpg.addFieldref(classGen.getClassName(),
               DOM_FIELD,
               DOM_INTF_SIG);
  final String docParamList =
      "("+OBJECT_SIG+STRING_SIG+STRING_SIG+TRANSLET_SIG+DOM_INTF_SIG+")"+
      NODE_ITERATOR_SIG;
  final int docIdx = cpg.addMethodref(LOAD_DOCUMENT_CLASS,
              "document", docParamList);

  final int uriIdx = cpg.addInterfaceMethodref(DOM_INTF,
                 "getDocumentURI",
                 "(I)"+STRING_SIG);

  final int nextIdx = cpg.addInterfaceMethodref(NODE_ITERATOR,
                  NEXT, NEXT_SIG);

  // The URI can be either a node-set or something else cast to a string
  _uri.translate(classGen, methodGen);
  if (_uriType == Type.NodeSet)
View Full Code Here

  return typeCheckContents(stable);
    }

    public void translate(ClassGenerator classGen, MethodGenerator methodGen) {
  final ConstantPoolGen cpg = classGen.getConstantPool();
  final InstructionList il = methodGen.getInstructionList();

  if (_disabled) return;
  // bug fix #4433133, add a call to named template from applyTemplates
  String className = classGen.getClassName();

  if (_compiled && isNamed()){
      String methodName = Util.escape(_name.toString());
      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

     * uses parameters.
     * TODO: optimize by checking if the callee has parameters.
     */
    public void translate(ClassGenerator classGen, MethodGenerator methodGen) {
  final Stylesheet stylesheet = classGen.getStylesheet();
  final ConstantPoolGen cpg = classGen.getConstantPool();
  final InstructionList il = methodGen.getInstructionList();


  if (stylesheet.hasLocalParams() || hasContents()) {
      // 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));
      // Translate with-params
      translateContents(classGen, methodGen);
  }

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

  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
                 + NODE_SIG
                 +")V")));
 

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

  }
    }

    private void compileNamedTemplate(Template template,
              ClassGenerator classGen) {
  final ConstantPoolGen cpg = classGen.getConstantPool();
  final InstructionList il = new InstructionList();
  String methodName = Util.escape(template.getName().toString());

  final NamedMethodGenerator methodGen =
      new NamedMethodGenerator(ACC_PUBLIC,
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.