Examples of InstructionList


Examples of alt.jiapi.reflect.InstructionList

        JiapiClass c = JiapiClass.createClass("HelloWorld");

        // No API to set SourceFile!

        JiapiMethod method = c.addMethod(Modifier.PUBLIC, "<init>", emptySig);
        InstructionList il = method.getInstructionList();
        InstructionFactory iFactory = il.getInstructionFactory();
        il.add(iFactory.aload(0));
        il.add(iFactory.invoke(0, "java/lang/Object", "<init>", emptySig));
        il.add(iFactory.returnMethod(method));

        method = c.addMethod(Modifier.PUBLIC | Modifier.STATIC, "main", mainSig);
        il = method.getInstructionList();
        iFactory = il.getInstructionFactory();
        il.add(iFactory.getField(Modifier.STATIC,
                "java/lang/System",
                "out",
                "Ljava/io/PrintStream;"));
        il.add(iFactory.pushConstant("Hello world!"));
        il.add(iFactory.invoke(0, "java/io/PrintStream", "println", printlnSig));
        il.add(iFactory.returnMethod(method));

        return c.getByteCode();
    }
View Full Code Here

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

     * Translate this node into a fresh instruction list.
     * The original instruction list is saved and restored.
     */
    public final InstructionList compile(ClassGenerator classGen,
           MethodGenerator methodGen) {
  final InstructionList result, save = methodGen.getInstructionList();
  methodGen.setInstructionList(result = new InstructionList());
  translate(classGen, methodGen);
  methodGen.setInstructionList(save);
  return result;
    }
View Full Code Here

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

  Expression expr = this;
  if (expr instanceof CastExpr) {
      expr = ((CastExpr) expr).getExpr();
  }
  if (expr instanceof VariableRefBase == false) {
      final InstructionList il = methodGen.getInstructionList();
      il.append(methodGen.loadContextNode());
      il.append(methodGen.setStartNode());
  }
    }
View Full Code Here

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

     * operand stack for the next statement to succeed. Returns the handle
     * of the instruction to be backpatched.
     */
    public void synthesize(ClassGenerator classGen, MethodGenerator methodGen) {
  final ConstantPoolGen cpg = classGen.getConstantPool();
  final InstructionList il = methodGen.getInstructionList();
  _trueList.backPatch(il.append(ICONST_1));
  final BranchHandle truec = il.append(new GOTO_W(null));
  _falseList.backPatch(il.append(ICONST_0));
  truec.setTarget(il.append(NOP));
    }
View Full Code Here

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

  truec.setTarget(il.append(NOP));
    }

    public void desynthesize(ClassGenerator classGen,
           MethodGenerator methodGen) {
  final InstructionList il = methodGen.getInstructionList();
  _falseList.add(il.append(new IFEQ(null)));
    }
View Full Code Here

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

     * Stylesheet.compileConstructor() and not as the syntax tree is traversed.
     */
    public void translate(ClassGenerator classGen,
        MethodGenerator methodGen) {
  final ConstantPoolGen cpg = classGen.getConstantPool();
  final InstructionList il = methodGen.getInstructionList();

  final int tst = cpg.addMethodref(BASIS_LIBRARY_CLASS,
           "testLanguage",
           "("+STRING_SIG+DOM_INTF_SIG+"I)Z");
  _lang.translate(classGen,methodGen);
  il.append(methodGen.loadDOM());
  if (classGen instanceof FilterGenerator)
      il.append(new ILOAD(1));
  else
      il.append(methodGen.loadContextNode());
  il.append(new INVOKESTATIC(tst));
    }
View Full Code Here

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

     */
    private static void compilePredicate(Vector rules,
           int defaultAction,
           ClassGenerator classGen) {
  final ConstantPoolGen cpg = classGen.getConstantPool();
  final InstructionList il = new InstructionList();
  final XSLTC xsltc = classGen.getParser().getXSLTC();

  // private boolean Translet.stripSpace(int type) - cannot be static
  final MethodGenerator stripSpace =
      new MethodGenerator(ACC_PUBLIC | ACC_FINAL ,
      com.sun.org.apache.bcel.internal.generic.Type.BOOLEAN,
      new com.sun.org.apache.bcel.internal.generic.Type[] {
          Util.getJCRefType(DOM_INTF_SIG),
          com.sun.org.apache.bcel.internal.generic.Type.INT,
          com.sun.org.apache.bcel.internal.generic.Type.INT
      },
      new String[] { "dom","node","type" },
      "stripSpace",classGen.getClassName(),il,cpg);

  classGen.addInterface("com/sun/org/apache/xalan/internal/xsltc/StripFilter");

  final int paramDom = stripSpace.getLocalIndex("dom");
  final int paramCurrent = stripSpace.getLocalIndex("node");
  final int paramType = stripSpace.getLocalIndex("type");

  BranchHandle strip[] = new BranchHandle[rules.size()];
  BranchHandle preserve[] = new BranchHandle[rules.size()];
  int sCount = 0;
  int pCount = 0;

  // Traverse all strip/preserve rules
  for (int i = 0; i<rules.size(); i++) {
      // Get the next rule in the prioritised list
      WhitespaceRule rule = (WhitespaceRule)rules.elementAt(i);

      // Returns the namespace for a node in the DOM
      final int gns = cpg.addInterfaceMethodref(DOM_INTF,
                  "getNamespaceName",
                  "(I)Ljava/lang/String;");

      final int strcmp = cpg.addMethodref("java/lang/String",
            "compareTo",
            "(Ljava/lang/String;)I");

      // Handle elements="ns:*" type rule
      if (rule.getStrength() == RULE_NAMESPACE) {
    il.append(new ALOAD(paramDom));
    il.append(new ILOAD(paramCurrent));
    il.append(new INVOKEINTERFACE(gns,2));
    il.append(new PUSH(cpg, rule.getNamespace()));
    il.append(new INVOKEVIRTUAL(strcmp));
    il.append(ICONST_0);

    if (rule.getAction() == STRIP_SPACE) {
        strip[sCount++] = il.append(new IF_ICMPEQ(null));
    }
    else {
        preserve[pCount++] = il.append(new IF_ICMPEQ(null));
    }
      }
      // Handle elements="ns:el" type rule
      else if (rule.getStrength() == RULE_ELEMENT) {
    // Create the QName for the element
    final Parser parser = classGen.getParser();
    QName qname;
    if (rule.getNamespace() != Constants.EMPTYSTRING )
        qname = parser.getQName(rule.getNamespace(), null,
              rule.getElement());
    else
        qname = parser.getQName(rule.getElement());

    // Register the element.
    final int elementType = xsltc.registerElement(qname);
    il.append(new ILOAD(paramType));
    il.append(new PUSH(cpg, elementType));

    // Compare current node type with wanted element type
    if (rule.getAction() == STRIP_SPACE)
        strip[sCount++] = il.append(new IF_ICMPEQ(null));
    else
        preserve[pCount++] = il.append(new IF_ICMPEQ(null));
      }
  }

  if (defaultAction == STRIP_SPACE) {
      compileStripSpace(strip, sCount, il);
View Full Code Here

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

     * Compiles the predicate method
     */
    private static void compileDefault(int defaultAction,
               ClassGenerator classGen) {
  final ConstantPoolGen cpg = classGen.getConstantPool();
  final InstructionList il = new InstructionList();
  final XSLTC xsltc = classGen.getParser().getXSLTC();

  // private boolean Translet.stripSpace(int type) - cannot be static
  final MethodGenerator stripSpace =
      new MethodGenerator(ACC_PUBLIC | ACC_FINAL ,
      com.sun.org.apache.bcel.internal.generic.Type.BOOLEAN,
      new com.sun.org.apache.bcel.internal.generic.Type[] {
          Util.getJCRefType(DOM_INTF_SIG),
          com.sun.org.apache.bcel.internal.generic.Type.INT,
          com.sun.org.apache.bcel.internal.generic.Type.INT
      },
      new String[] { "dom","node","type" },
      "stripSpace",classGen.getClassName(),il,cpg);

  classGen.addInterface("com/sun/org/apache/xalan/internal/xsltc/StripFilter");

  if (defaultAction == STRIP_SPACE)
      il.append(ICONST_1);
  else
      il.append(ICONST_0);
  il.append(IRETURN);

  stripSpace.stripAttributes(true);
  stripSpace.setMaxLocals();
  stripSpace.setMaxStack();
  stripSpace.removeNOPs();
View Full Code Here

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

    }
   
    public void translateLang(ClassGenerator classGen,
                   MethodGenerator methodGen) {
    final ConstantPoolGen cpg = classGen.getConstantPool();
    final InstructionList il = methodGen.getInstructionList();
    il.append(new PUSH(cpg, _lang)); // bug! see 26869
    }
View Full Code Here

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

              MethodGenerator methodGen,
              Expression nodeSet,
              Vector sortObjects)
    {
  final ConstantPoolGen cpg = classGen.getConstantPool();
  final InstructionList il = methodGen.getInstructionList();

  // SortingIterator.SortingIterator(NodeIterator,NodeSortRecordFactory);
  final int init = cpg.addMethodref(SORT_ITERATOR, "<init>",
            "("
            + NODE_ITERATOR_SIG
            + NODE_SORT_FACTORY_SIG
            + ")V")

        // Backwards branches are prohibited if an uninitialized object is
        // on the stack by section 4.9.4 of the JVM Specification, 2nd Ed.
        // We don't know whether this code might contain backwards branches
        // so we mustn't create the new object until after we've created
        // the suspect arguments to its constructor.  Instead we calculate
        // the values of the arguments to the constructor first, store them
        // in temporary variables, create the object and reload the
        // arguments from the temporaries to avoid the problem.

        LocalVariableGen nodesTemp =
            methodGen.addLocalVariable("sort_tmp1",
                                       Util.getJCRefType(NODE_ITERATOR_SIG),
                                       il.getEnd(), null);

        LocalVariableGen sortRecordFactoryTemp =
            methodGen.addLocalVariable("sort_tmp2",
                                      Util.getJCRefType(NODE_SORT_FACTORY_SIG),
                                      il.getEnd(), null);

  // Get the current node iterator
  if (nodeSet == null) {  // apply-templates default
      final int children = cpg.addInterfaceMethodref(DOM_INTF,
                 "getAxisIterator",
                 "(I)"+
                 NODE_ITERATOR_SIG);
      il.append(methodGen.loadDOM());
      il.append(new PUSH(cpg, Axis.CHILD));
      il.append(new INVOKEINTERFACE(children, 2));
  }
  else {
      nodeSet.translate(classGen, methodGen);
  }

        il.append(new ASTORE(nodesTemp.getIndex()));
 
  // Compile the code for the NodeSortRecord producing class and pass
  // that as the last argument to the SortingIterator constructor.
  compileSortRecordFactory(sortObjects, classGen, methodGen);
        il.append(new ASTORE(sortRecordFactoryTemp.getIndex()));

  il.append(new NEW(cpg.addClass(SORT_ITERATOR)));
  il.append(DUP);
        il.append(new ALOAD(nodesTemp.getIndex()));
        il.append(new ALOAD(sortRecordFactoryTemp.getIndex()));
  il.append(new INVOKESPECIAL(init));
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.