Examples of ILOAD


Examples of org.apache.bcel.generic.ILOAD

                applyTemplatesSig);
  il.append(classGen.loadTranslet());
  il.append(methodGen.loadDOM());
 
  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

Examples of org.apache.bcel.generic.ILOAD

  final int chars = cpg.addInterfaceMethodref(DOM_INTF,
                CHARACTERS,
                CHARACTERS_SIG);
  il.append(methodGen.loadDOM());
  il.append(new ILOAD(_currentIndex));
  il.append(methodGen.loadHandler());
  il.append(new INVOKEINTERFACE(chars, 3));
  il.append(new GOTO_W(next));
  return il;
    }
View Full Code Here

Examples of org.apache.bcel.generic.ILOAD

      // Append first code in applyTemplates() - get type of current node
      final int getNS = cpg.addInterfaceMethodref(DOM_INTF,
              "getNamespaceType",
              "(I)I");
      il.append(methodGen.loadDOM());
      il.append(new ILOAD(_currentIndex));
      il.append(new INVOKEINTERFACE(getNS, 2));
      il.append(new SWITCH(types, targets, defaultTarget));
      return(il);
  }
  else {
View Full Code Here

Examples of org.apache.bcel.generic.ILOAD

  // Append first code in applyTemplates() - get type of current node
  final int getType = cpg.addInterfaceMethodref(DOM_INTF,
                  "getExpandedTypeID",
                                                      "(I)I");
  body.append(methodGen.loadDOM());
  body.append(new ILOAD(_currentIndex));
  body.append(new INVOKEINTERFACE(getType, 2));

  // Append switch() statement - main dispatch loop in applyTemplates()
  InstructionHandle disp = body.append(new SWITCH(types, targets, ihLoop));
View Full Code Here

Examples of org.apache.bcel.generic.ILOAD

  current = methodGen.addLocalVariable2("current",
                org.apache.bcel.generic.Type.INT,
                null);
  _currentIndex = current.getIndex();

    mainIL.append(new ILOAD(methodGen.getLocalIndex(NODE_PNAME)));
    current.setStart(mainIL.append(new ISTORE(_currentIndex)));
   
  // Create the "body" instruction list that will eventually hold the
  // code for the entire method (other ILs will be appended).
  final InstructionList body = new InstructionList();
  body.append(NOP);

  // Create an instruction list that contains the default next-node
  // iteration
  final InstructionList ilLoop = new InstructionList();
    ilLoop.append(RETURN);
  final InstructionHandle ihLoop = ilLoop.getStart();

  // Compile default handling of elements (traverse children)
  InstructionList ilRecurse =
      compileDefaultRecursion(classGen, methodGen, ihLoop);
  InstructionHandle ihRecurse = ilRecurse.getStart();

  // Compile default handling of text/attribute nodes (output text)
  InstructionList ilText =
      compileDefaultText(classGen, methodGen, ihLoop);
  InstructionHandle ihText = ilText.getStart();

  // Distinguish attribute/element/namespace tests for further processing
  final int[] types = new int[DTM.NTYPES + names.size()];
  for (int i = 0; i < types.length; i++) {
      types[i] = i;
  }

  final boolean[] isAttribute = new boolean[types.length];
  final boolean[] isNamespace = new boolean[types.length];
  for (int i = 0; i < names.size(); i++) {
      final String name = (String)names.elementAt(i);
      isAttribute[i+DTM.NTYPES] = isAttributeName(name);
      isNamespace[i+DTM.NTYPES] = isNamespaceName(name);
  }

  // Compile all templates - regardless of pattern type
  compileTemplateCalls(classGen, methodGen, ihLoop, min, max);

  // Handle template with explicit "*" pattern
  final TestSeq elemTest = _testSeq[DTM.ELEMENT_NODE];
  InstructionHandle ihElem = ihRecurse;
  if (elemTest != null) {
      ihElem = elemTest.compile(classGen, methodGen, ihLoop);
  }

  // Handle template with explicit "@*" pattern
  final TestSeq attrTest = _testSeq[DTM.ATTRIBUTE_NODE];
  InstructionHandle ihAttr = ihLoop;
  if (attrTest != null) {
      ihAttr = attrTest.compile(classGen, methodGen, ihAttr);
  }

  // Do tests for id() and key() patterns first
  InstructionList ilKey = null;
  if (_idxTestSeq != null) {
      ilKey = _idxTestSeq.getInstructionList();
  }

  // If there is a match on node() we need to replace ihElem
  // and ihText if the priority of node() is higher
  if (_childNodeTestSeq != null) {
      // Compare priorities of node() and "*"
      double nodePrio = _childNodeTestSeq.getPriority();
      int    nodePos  = _childNodeTestSeq.getPosition();
      double elemPrio = (0 - Double.MAX_VALUE);
      int    elemPos  = Integer.MIN_VALUE;

      if (elemTest != null) {
    elemPrio = elemTest.getPriority();
    elemPos  = elemTest.getPosition();
      }

      if (elemPrio == Double.NaN || elemPrio < nodePrio ||
    (elemPrio == nodePrio && elemPos < nodePos))
      {
    ihElem = _childNodeTestSeq.compile(classGen, methodGen, ihLoop);
      }

      // Compare priorities of node() and text()
      final TestSeq textTest = _testSeq[DTM.TEXT_NODE];
      double textPrio = (0 - Double.MAX_VALUE);
      int    textPos  = Integer.MIN_VALUE;

      if (textTest != null) {
    textPrio = textTest.getPriority();
    textPos  = textTest.getPosition();
      }

      if (Double.isNaN(textPrio) || textPrio < nodePrio ||
          (textPrio == nodePrio && textPos < nodePos))
      {
    ihText = _childNodeTestSeq.compile(classGen, methodGen, ihLoop);
    _testSeq[DTM.TEXT_NODE] = _childNodeTestSeq;
      }
  }

  // Handle templates with "ns:*" pattern
  InstructionHandle elemNamespaceHandle = ihElem;
  InstructionList nsElem = compileNamespaces(classGen, methodGen,
               isNamespace, isAttribute,
               false, ihElem);
  if (nsElem != null) elemNamespaceHandle = nsElem.getStart();

  // Handle templates with "ns:@*" pattern
  InstructionList nsAttr = compileNamespaces(classGen, methodGen,
               isNamespace, isAttribute,
               true, ihAttr);
  InstructionHandle attrNamespaceHandle = ihAttr;
  if (nsAttr != null) attrNamespaceHandle = nsAttr.getStart();

  // Handle templates with "ns:elem" or "ns:@attr" pattern
  final InstructionHandle[] targets = new InstructionHandle[types.length];
  for (int i = DTM.NTYPES; i < targets.length; i++) {
      final TestSeq testSeq = _testSeq[i];
      // Jump straight to namespace tests ?
      if (isNamespace[i]) {
    if (isAttribute[i])
        targets[i] = attrNamespaceHandle;
    else
        targets[i] = elemNamespaceHandle;
      }
      // Test first, then jump to namespace tests
      else if (testSeq != null) {
    if (isAttribute[i])
        targets[i] = testSeq.compile(classGen, methodGen,
             attrNamespaceHandle);
    else
        targets[i] = testSeq.compile(classGen, methodGen,
             elemNamespaceHandle);
      }
      else {
    targets[i] = ihLoop;
      }
  }

  // Handle pattern with match on root node - default: traverse children
  targets[DTM.ROOT_NODE] = _rootPattern != null
      ? getTemplateInstructionHandle(_rootPattern.getTemplate())
      : ihRecurse;
  // Handle pattern with match on root node - default: traverse children
  targets[DTM.DOCUMENT_NODE] = _rootPattern != null
      ? getTemplateInstructionHandle(_rootPattern.getTemplate())
      : ihRecurse;    // %HZ%:  Was ihLoop in XSLTC_DTM branch
 
  // Handle any pattern with match on text nodes - default: loop
  targets[DTM.TEXT_NODE] = _testSeq[DTM.TEXT_NODE] != null
      ? _testSeq[DTM.TEXT_NODE].compile(classGen, methodGen, ihText)
      : ihText;

  // This DOM-type is not in use - default: process next node
  targets[DTM.NAMESPACE_NODE] = ihLoop;

  // Match unknown element in DOM - default: check for namespace match
  targets[DTM.ELEMENT_NODE] = elemNamespaceHandle;

  // Match unknown attribute in DOM - default: check for namespace match
  targets[DTM.ATTRIBUTE_NODE] = attrNamespaceHandle;

  // Match on processing instruction - default: loop
  InstructionHandle ihPI = ihLoop;
  if (_childNodeTestSeq != null) ihPI = ihElem;
  if (_testSeq[DTM.PROCESSING_INSTRUCTION_NODE] != null) {
      targets[DTM.PROCESSING_INSTRUCTION_NODE] =
    _testSeq[DTM.PROCESSING_INSTRUCTION_NODE].
    compile(classGen, methodGen, ihPI);
  }
  else {
      targets[DTM.PROCESSING_INSTRUCTION_NODE] = ihPI;
  }
 
  // Match on comments - default: process next node
  InstructionHandle ihComment = ihLoop;
  if (_childNodeTestSeq != null) ihComment = ihElem;
  targets[DTM.COMMENT_NODE] = _testSeq[DTM.COMMENT_NODE] != null
      ? _testSeq[DTM.COMMENT_NODE].compile(classGen, methodGen, ihComment)
      : ihComment;
     
          // This DOM-type is not in use - default: process next node
  targets[DTM.CDATA_SECTION_NODE] = ihLoop;

  // This DOM-type is not in use - default: process next node
  targets[DTM.DOCUMENT_FRAGMENT_NODE] = ihLoop;
 
  // This DOM-type is not in use - default: process next node
  targets[DTM.DOCUMENT_TYPE_NODE] = ihLoop;

  // This DOM-type is not in use - default: process next node
  targets[DTM.ENTITY_NODE] = ihLoop;

  // This DOM-type is not in use - default: process next node
  targets[DTM.ENTITY_REFERENCE_NODE] = ihLoop;
 
  // This DOM-type is not in use - default: process next node
  targets[DTM.NOTATION_NODE] = ihLoop;



  // Now compile test sequences for various match patterns:
  for (int i = DTM.NTYPES; i < targets.length; i++) {
      final TestSeq testSeq = _testSeq[i];
      // Jump straight to namespace tests ?
      if ((testSeq == null) || (isNamespace[i])) {
    if (isAttribute[i])
        targets[i] = attrNamespaceHandle;
    else
        targets[i] = elemNamespaceHandle;
      }
      // Match on node type
      else {
    if (isAttribute[i])
        targets[i] = testSeq.compile(classGen, methodGen,
             attrNamespaceHandle);
    else
        targets[i] = testSeq.compile(classGen, methodGen,
             elemNamespaceHandle);
      }
  }

  if (ilKey != null) body.insert(ilKey);

  // Append first code in applyTemplates() - get type of current node
  final int getType = cpg.addInterfaceMethodref(DOM_INTF,
                  "getExpandedTypeID",
                                                      "(I)I");
  body.append(methodGen.loadDOM());
  body.append(new ILOAD(_currentIndex));
  body.append(new INVOKEINTERFACE(getType, 2));

  // Append switch() statement - main dispatch loop in applyTemplates()
  InstructionHandle disp = body.append(new SWITCH(types,targets,ihLoop));

View Full Code Here

Examples of org.apache.bcel.generic.ILOAD

  if (methodGen instanceof CompareGenerator) {
      il.append(((CompareGenerator)methodGen).loadLastNode());
  }
  else if (methodGen instanceof TestGenerator) {
      il.append(new ILOAD(LAST_INDEX));
  }
  else {
      final ConstantPoolGen cpg = classGen.getConstantPool();
      final int getLast = cpg.addInterfaceMethodref(NODE_ITERATOR,
                "getLast",
View Full Code Here

Examples of org.apache.bcel.generic.ILOAD

           "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 org.apache.bcel.generic.ILOAD

            "(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));
View Full Code Here

Examples of org.apache.bcel.generic.ILOAD

  InstructionHandle tblswitch = null;

  // Compile switch statement only if the key has multiple levels
  if (levels > 1) {
      // Put the parameter to the swtich statement on the stack
      il.append(new ILOAD(extractMethod.getLocalIndex("level")));
      // Append the switch statement here later on
      tblswitch = il.append(new NOP());
  }

  // Append all the cases for the switch statment
View Full Code Here

Examples of org.apache.bcel.generic.ILOAD

  if (methodGen instanceof CompareGenerator) {
      il.append(((CompareGenerator)methodGen).loadCurrentNode());
  }
  else if (methodGen instanceof TestGenerator) {
      il.append(new ILOAD(POSITION_INDEX));
  }
  else {
      final ConstantPoolGen cpg = classGen.getConstantPool();
            final int index = cpg.addInterfaceMethodref(NODE_ITERATOR,
                                                       "getPosition",
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.