com.sun.org.apache.xpath.internal.compiler.Compiler Java Examples

The following examples show how to use com.sun.org.apache.xpath.internal.compiler.Compiler. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: WalkerFactory.java    From Bytecoder with Apache License 2.0 6 votes vote down vote up
/**
 * Analyze a step and give information about it's predicates.  Right now this
 * just returns true or false if the step has a predicate.
 *
 * @param compiler non-null reference to compiler object that has processed
 *                 the XPath operations into an opcode map.
 * @param opPos The opcode position for the step.
 * @param stepType The type of step, one of OP_GROUP, etc.
 *
 * @return true if step has a predicate.
 *
 * @throws javax.xml.transform.TransformerException
 */
static boolean analyzePredicate(Compiler compiler, int opPos, int stepType)
        throws javax.xml.transform.TransformerException
{

  int argLen;

  switch (stepType)
  {
  case OpCodes.OP_VARIABLE :
  case OpCodes.OP_EXTFUNCTION :
  case OpCodes.OP_FUNCTION :
  case OpCodes.OP_GROUP :
    argLen = compiler.getArgLength(opPos);
    break;
  default :
    argLen = compiler.getArgLengthOfStep(opPos);
  }

  int pos = compiler.getFirstPredicateOpPos(opPos);
  int nPredicates = compiler.countPredicates(pos);

  return (nPredicates > 0) ? true : false;
}
 
Example #2
Source File: WalkerFactory.java    From openjdk-8-source with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Analyze a step and give information about it's predicates.  Right now this
 * just returns true or false if the step has a predicate.
 *
 * @param compiler non-null reference to compiler object that has processed
 *                 the XPath operations into an opcode map.
 * @param opPos The opcode position for the step.
 * @param stepType The type of step, one of OP_GROUP, etc.
 *
 * @return true if step has a predicate.
 *
 * @throws javax.xml.transform.TransformerException
 */
static boolean analyzePredicate(Compiler compiler, int opPos, int stepType)
        throws javax.xml.transform.TransformerException
{

  int argLen;

  switch (stepType)
  {
  case OpCodes.OP_VARIABLE :
  case OpCodes.OP_EXTFUNCTION :
  case OpCodes.OP_FUNCTION :
  case OpCodes.OP_GROUP :
    argLen = compiler.getArgLength(opPos);
    break;
  default :
    argLen = compiler.getArgLengthOfStep(opPos);
  }

  int pos = compiler.getFirstPredicateOpPos(opPos);
  int nPredicates = compiler.countPredicates(pos);

  return (nPredicates > 0) ? true : false;
}
 
Example #3
Source File: BasicTestIterator.java    From jdk1.8-source-analysis with Apache License 2.0 6 votes vote down vote up
/**
 * Create a LocPathIterator object, including creation
 * of step walkers from the opcode list, and call back
 * into the Compiler to create predicate expressions.
 *
 * @param compiler The Compiler which is creating
 * this expression.
 * @param opPos The position of this iterator in the
 * opcode list from the compiler.
 *
 * @throws javax.xml.transform.TransformerException
 */
protected BasicTestIterator(Compiler compiler, int opPos, int analysis)
        throws javax.xml.transform.TransformerException
{
  super(compiler, opPos, analysis, false);

  int firstStepPos = OpMap.getFirstChildPos(opPos);
  int whatToShow = compiler.getWhatToShow(firstStepPos);

  if ((0 == (whatToShow
             & (DTMFilter.SHOW_ATTRIBUTE
             | DTMFilter.SHOW_NAMESPACE
             | DTMFilter.SHOW_ELEMENT
             | DTMFilter.SHOW_PROCESSING_INSTRUCTION)))
             || (whatToShow == DTMFilter.SHOW_ALL))
    initNodeTest(whatToShow);
  else
  {
    initNodeTest(whatToShow, compiler.getStepNS(firstStepPos),
                            compiler.getStepLocalName(firstStepPos));
  }
  initPredicateInfo(compiler, firstStepPos);
}
 
Example #4
Source File: WalkerFactory.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Analyze a step and give information about it's predicates.  Right now this
 * just returns true or false if the step has a predicate.
 *
 * @param compiler non-null reference to compiler object that has processed
 *                 the XPath operations into an opcode map.
 * @param opPos The opcode position for the step.
 * @param stepType The type of step, one of OP_GROUP, etc.
 *
 * @return true if step has a predicate.
 *
 * @throws javax.xml.transform.TransformerException
 */
static boolean analyzePredicate(Compiler compiler, int opPos, int stepType)
        throws javax.xml.transform.TransformerException
{

  int argLen;

  switch (stepType)
  {
  case OpCodes.OP_VARIABLE :
  case OpCodes.OP_EXTFUNCTION :
  case OpCodes.OP_FUNCTION :
  case OpCodes.OP_GROUP :
    argLen = compiler.getArgLength(opPos);
    break;
  default :
    argLen = compiler.getArgLengthOfStep(opPos);
  }

  int pos = compiler.getFirstPredicateOpPos(opPos);
  int nPredicates = compiler.countPredicates(pos);

  return (nPredicates > 0) ? true : false;
}
 
Example #5
Source File: PredicatedNodeTest.java    From jdk1.8-source-analysis with Apache License 2.0 6 votes vote down vote up
/**
 * Init predicate info.
 *
 * @param compiler The Compiler object that has information about this
 *                 walker in the op map.
 * @param opPos The op code position of this location step.
 *
 * @throws javax.xml.transform.TransformerException
 */
protected void initPredicateInfo(Compiler compiler, int opPos)
        throws javax.xml.transform.TransformerException
{

  int pos = compiler.getFirstPredicateOpPos(opPos);

  if(pos > 0)
  {
    m_predicates = compiler.getCompiledPredicates(pos);
    if(null != m_predicates)
    {
      for(int i = 0; i < m_predicates.length; i++)
      {
              m_predicates[i].exprSetParent(this);
      }
    }
  }
}
 
Example #6
Source File: PredicatedNodeTest.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Init predicate info.
 *
 * @param compiler The Compiler object that has information about this
 *                 walker in the op map.
 * @param opPos The op code position of this location step.
 *
 * @throws javax.xml.transform.TransformerException
 */
protected void initPredicateInfo(Compiler compiler, int opPos)
        throws javax.xml.transform.TransformerException
{

  int pos = compiler.getFirstPredicateOpPos(opPos);

  if(pos > 0)
  {
    m_predicates = compiler.getCompiledPredicates(pos);
    if(null != m_predicates)
    {
      for(int i = 0; i < m_predicates.length; i++)
      {
              m_predicates[i].exprSetParent(this);
      }
    }
  }
}
 
Example #7
Source File: WalkerFactory.java    From openjdk-8 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Analyze a step and give information about it's predicates.  Right now this
 * just returns true or false if the step has a predicate.
 *
 * @param compiler non-null reference to compiler object that has processed
 *                 the XPath operations into an opcode map.
 * @param opPos The opcode position for the step.
 * @param stepType The type of step, one of OP_GROUP, etc.
 *
 * @return true if step has a predicate.
 *
 * @throws javax.xml.transform.TransformerException
 */
static boolean analyzePredicate(Compiler compiler, int opPos, int stepType)
        throws javax.xml.transform.TransformerException
{

  int argLen;

  switch (stepType)
  {
  case OpCodes.OP_VARIABLE :
  case OpCodes.OP_EXTFUNCTION :
  case OpCodes.OP_FUNCTION :
  case OpCodes.OP_GROUP :
    argLen = compiler.getArgLength(opPos);
    break;
  default :
    argLen = compiler.getArgLengthOfStep(opPos);
  }

  int pos = compiler.getFirstPredicateOpPos(opPos);
  int nPredicates = compiler.countPredicates(pos);

  return (nPredicates > 0) ? true : false;
}
 
Example #8
Source File: BasicTestIterator.java    From JDKSourceCode1.8 with MIT License 6 votes vote down vote up
/**
 * Create a LocPathIterator object, including creation
 * of step walkers from the opcode list, and call back
 * into the Compiler to create predicate expressions.
 *
 * @param compiler The Compiler which is creating
 * this expression.
 * @param opPos The position of this iterator in the
 * opcode list from the compiler.
 *
 * @throws javax.xml.transform.TransformerException
 */
protected BasicTestIterator(Compiler compiler, int opPos, int analysis)
        throws javax.xml.transform.TransformerException
{
  super(compiler, opPos, analysis, false);

  int firstStepPos = OpMap.getFirstChildPos(opPos);
  int whatToShow = compiler.getWhatToShow(firstStepPos);

  if ((0 == (whatToShow
             & (DTMFilter.SHOW_ATTRIBUTE
             | DTMFilter.SHOW_NAMESPACE
             | DTMFilter.SHOW_ELEMENT
             | DTMFilter.SHOW_PROCESSING_INSTRUCTION)))
             || (whatToShow == DTMFilter.SHOW_ALL))
    initNodeTest(whatToShow);
  else
  {
    initNodeTest(whatToShow, compiler.getStepNS(firstStepPos),
                            compiler.getStepLocalName(firstStepPos));
  }
  initPredicateInfo(compiler, firstStepPos);
}
 
Example #9
Source File: WalkerFactory.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * This method is for building an array of possible levels
 * where the target element(s) could be found for a match.
 * @param lpi The owning location path iterator.
 * @param compiler non-null reference to compiler object that has processed
 *                 the XPath operations into an opcode map.
 * @param stepOpCodePos The opcode position for the step.
 *
 * @return non-null AxesWalker derivative.
 *
 * @throws javax.xml.transform.TransformerException
 * @xsl.usage advanced
 */
static AxesWalker loadOneWalker(
        WalkingIterator lpi, Compiler compiler, int stepOpCodePos)
          throws javax.xml.transform.TransformerException
{

  AxesWalker firstWalker = null;
  int stepType = compiler.getOp(stepOpCodePos);

  if (stepType != OpCodes.ENDOP)
  {

    // m_axesWalkers = new AxesWalker[1];
    // As we unwind from the recursion, create the iterators.
    firstWalker = createDefaultWalker(compiler, stepType, lpi, 0);

    firstWalker.init(compiler, stepOpCodePos, stepType);
  }

  return firstWalker;
}
 
Example #10
Source File: BasicTestIterator.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Create a LocPathIterator object, including creation
 * of step walkers from the opcode list, and call back
 * into the Compiler to create predicate expressions.
 *
 * @param compiler The Compiler which is creating
 * this expression.
 * @param opPos The position of this iterator in the
 * opcode list from the compiler.
 *
 * @throws javax.xml.transform.TransformerException
 */
protected BasicTestIterator(Compiler compiler, int opPos, int analysis)
        throws javax.xml.transform.TransformerException
{
  super(compiler, opPos, analysis, false);

  int firstStepPos = OpMap.getFirstChildPos(opPos);
  int whatToShow = compiler.getWhatToShow(firstStepPos);

  if ((0 == (whatToShow
             & (DTMFilter.SHOW_ATTRIBUTE
             | DTMFilter.SHOW_NAMESPACE
             | DTMFilter.SHOW_ELEMENT
             | DTMFilter.SHOW_PROCESSING_INSTRUCTION)))
             || (whatToShow == DTMFilter.SHOW_ALL))
    initNodeTest(whatToShow);
  else
  {
    initNodeTest(whatToShow, compiler.getStepNS(firstStepPos),
                            compiler.getStepLocalName(firstStepPos));
  }
  initPredicateInfo(compiler, firstStepPos);
}
 
Example #11
Source File: PredicatedNodeTest.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Init predicate info.
 *
 * @param compiler The Compiler object that has information about this
 *                 walker in the op map.
 * @param opPos The op code position of this location step.
 *
 * @throws javax.xml.transform.TransformerException
 */
protected void initPredicateInfo(Compiler compiler, int opPos)
        throws javax.xml.transform.TransformerException
{

  int pos = compiler.getFirstPredicateOpPos(opPos);

  if(pos > 0)
  {
    m_predicates = compiler.getCompiledPredicates(pos);
    if(null != m_predicates)
    {
      for(int i = 0; i < m_predicates.length; i++)
      {
              m_predicates[i].exprSetParent(this);
      }
    }
  }
}
 
Example #12
Source File: WalkerFactory.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * This method is for building an array of possible levels
 * where the target element(s) could be found for a match.
 * @param lpi The owning location path iterator.
 * @param compiler non-null reference to compiler object that has processed
 *                 the XPath operations into an opcode map.
 * @param stepOpCodePos The opcode position for the step.
 *
 * @return non-null AxesWalker derivative.
 *
 * @throws javax.xml.transform.TransformerException
 * @xsl.usage advanced
 */
static AxesWalker loadOneWalker(
        WalkingIterator lpi, Compiler compiler, int stepOpCodePos)
          throws javax.xml.transform.TransformerException
{

  AxesWalker firstWalker = null;
  int stepType = compiler.getOp(stepOpCodePos);

  if (stepType != OpCodes.ENDOP)
  {

    // m_axesWalkers = new AxesWalker[1];
    // As we unwind from the recursion, create the iterators.
    firstWalker = createDefaultWalker(compiler, stepType, lpi, 0);

    firstWalker.init(compiler, stepOpCodePos, stepType);
  }

  return firstWalker;
}
 
Example #13
Source File: XPath.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Construct an XPath object.
 *
 * (Needs review -sc) This method initializes an XPathParser/
 * Compiler and compiles the expression.
 * @param exprString The XPath expression.
 * @param locator The location of the expression, may be null.
 * @param prefixResolver A prefix resolver to use to resolve prefixes to
 *                       namespace URIs.
 * @param type one of {@link #SELECT} or {@link #MATCH}.
 * @param errorListener The error listener, or null if default should be used.
 *
 * @throws javax.xml.transform.TransformerException if syntax or other error.
 */
public XPath(
        String exprString, SourceLocator locator,
        PrefixResolver prefixResolver, int type,
        ErrorListener errorListener, FunctionTable aTable)
          throws javax.xml.transform.TransformerException
{
  m_funcTable = aTable;
  if(null == errorListener)
    errorListener = new com.sun.org.apache.xml.internal.utils.DefaultErrorHandler();

  m_patternString = exprString;

  XPathParser parser = new XPathParser(errorListener, locator);
  Compiler compiler = new Compiler(errorListener, locator, m_funcTable);

  if (SELECT == type)
    parser.initXPath(compiler, exprString, prefixResolver);
  else if (MATCH == type)
    parser.initMatchPattern(compiler, exprString, prefixResolver);
  else
    throw new RuntimeException(XSLMessages.createXPATHMessage(
          XPATHErrorResources.ER_CANNOT_DEAL_XPATH_TYPE,
          new Object[]{Integer.toString(type)}));
          //"Can not deal with XPath type: " + type);

  // System.out.println("----------------");
  Expression expr = compiler.compile(0);

  // System.out.println("expr: "+expr);
  this.setExpression(expr);

  if((null != locator) && locator instanceof ExpressionNode)
  {
      expr.exprSetParent((ExpressionNode)locator);
  }

}
 
Example #14
Source File: OneStepIteratorForward.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Create a OneStepIterator object.
 *
 * @param compiler A reference to the Compiler that contains the op map.
 * @param opPos The position within the op map, which contains the
 * location path expression for this itterator.
 *
 * @throws javax.xml.transform.TransformerException
 */
OneStepIteratorForward(Compiler compiler, int opPos, int analysis)
        throws javax.xml.transform.TransformerException
{
  super(compiler, opPos, analysis);
  int firstStepPos = OpMap.getFirstChildPos(opPos);

  m_axis = WalkerFactory.getAxisFromStep(compiler, firstStepPos);

}
 
Example #15
Source File: WalkerFactory.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
static boolean isProximateInnerExpr(Compiler compiler, int opPos)
{
  int op = compiler.getOp(opPos);
  int innerExprOpPos = opPos+2;
  switch(op)
  {
    case OpCodes.OP_ARGUMENT:
      if(isProximateInnerExpr(compiler, innerExprOpPos))
        return true;
      break;
    case OpCodes.OP_VARIABLE:
    case OpCodes.OP_NUMBERLIT:
    case OpCodes.OP_LITERAL:
    case OpCodes.OP_LOCATIONPATH:
      break; // OK
    case OpCodes.OP_FUNCTION:
      boolean isProx = functionProximateOrContainsProximate(compiler, opPos);
      if(isProx)
        return true;
      break;
    case OpCodes.OP_GT:
    case OpCodes.OP_GTE:
    case OpCodes.OP_LT:
    case OpCodes.OP_LTE:
    case OpCodes.OP_EQUALS:
      int leftPos = OpMap.getFirstChildPos(op);
      int rightPos = compiler.getNextOpPos(leftPos);
      isProx = isProximateInnerExpr(compiler, leftPos);
      if(isProx)
        return true;
      isProx = isProximateInnerExpr(compiler, rightPos);
      if(isProx)
        return true;
      break;
    default:
      return true; // be conservative...
  }
  return false;
}
 
Example #16
Source File: XPath.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Construct an XPath object.
 *
 * (Needs review -sc) This method initializes an XPathParser/
 * Compiler and compiles the expression.
 * @param exprString The XPath expression.
 * @param locator The location of the expression, may be null.
 * @param prefixResolver A prefix resolver to use to resolve prefixes to
 *                       namespace URIs.
 * @param type one of {@link #SELECT} or {@link #MATCH}.
 * @param errorListener The error listener, or null if default should be used.
 *
 * @throws javax.xml.transform.TransformerException if syntax or other error.
 */
public XPath(
        String exprString, SourceLocator locator,
        PrefixResolver prefixResolver, int type,
        ErrorListener errorListener, FunctionTable aTable)
          throws javax.xml.transform.TransformerException
{
  m_funcTable = aTable;
  if(null == errorListener)
    errorListener = new com.sun.org.apache.xml.internal.utils.DefaultErrorHandler();

  m_patternString = exprString;

  XPathParser parser = new XPathParser(errorListener, locator);
  Compiler compiler = new Compiler(errorListener, locator, m_funcTable);

  if (SELECT == type)
    parser.initXPath(compiler, exprString, prefixResolver);
  else if (MATCH == type)
    parser.initMatchPattern(compiler, exprString, prefixResolver);
  else
    throw new RuntimeException(XSLMessages.createXPATHMessage(
          XPATHErrorResources.ER_CANNOT_DEAL_XPATH_TYPE,
          new Object[]{Integer.toString(type)}));
          //"Can not deal with XPath type: " + type);

  // System.out.println("----------------");
  Expression expr = compiler.compileExpression(0);

  // System.out.println("expr: "+expr);
  this.setExpression(expr);

  if((null != locator) && locator instanceof ExpressionNode)
  {
      expr.exprSetParent((ExpressionNode)locator);
  }

}
 
Example #17
Source File: XPath.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Construct an XPath object.
 *
 * (Needs review -sc) This method initializes an XPathParser/
 * Compiler and compiles the expression.
 * @param exprString The XPath expression.
 * @param locator The location of the expression, may be null.
 * @param prefixResolver A prefix resolver to use to resolve prefixes to
 *                       namespace URIs.
 * @param type one of {@link #SELECT} or {@link #MATCH}.
 * @param errorListener The error listener, or null if default should be used.
 *
 * @throws javax.xml.transform.TransformerException if syntax or other error.
 */
public XPath(
        String exprString, SourceLocator locator,
        PrefixResolver prefixResolver, int type,
        ErrorListener errorListener, FunctionTable aTable)
          throws javax.xml.transform.TransformerException
{
  m_funcTable = aTable;
  if(null == errorListener)
    errorListener = new com.sun.org.apache.xml.internal.utils.DefaultErrorHandler();

  m_patternString = exprString;

  XPathParser parser = new XPathParser(errorListener, locator);
  Compiler compiler = new Compiler(errorListener, locator, m_funcTable);

  if (SELECT == type)
    parser.initXPath(compiler, exprString, prefixResolver);
  else if (MATCH == type)
    parser.initMatchPattern(compiler, exprString, prefixResolver);
  else
    throw new RuntimeException(XSLMessages.createXPATHMessage(
          XPATHErrorResources.ER_CANNOT_DEAL_XPATH_TYPE,
          new Object[]{Integer.toString(type)}));
          //"Can not deal with XPath type: " + type);

  // System.out.println("----------------");
  Expression expr = compiler.compile(0);

  // System.out.println("expr: "+expr);
  this.setExpression(expr);

  if((null != locator) && locator instanceof ExpressionNode)
  {
      expr.exprSetParent((ExpressionNode)locator);
  }

}
 
Example #18
Source File: OneStepIteratorForward.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Create a OneStepIterator object.
 *
 * @param compiler A reference to the Compiler that contains the op map.
 * @param opPos The position within the op map, which contains the
 * location path expression for this itterator.
 *
 * @throws javax.xml.transform.TransformerException
 */
OneStepIteratorForward(Compiler compiler, int opPos, int analysis)
        throws javax.xml.transform.TransformerException
{
  super(compiler, opPos, analysis);
  int firstStepPos = OpMap.getFirstChildPos(opPos);

  m_axis = WalkerFactory.getAxisFromStep(compiler, firstStepPos);

}
 
Example #19
Source File: OneStepIteratorForward.java    From JDKSourceCode1.8 with MIT License 5 votes vote down vote up
/**
 * Create a OneStepIterator object.
 *
 * @param compiler A reference to the Compiler that contains the op map.
 * @param opPos The position within the op map, which contains the
 * location path expression for this itterator.
 *
 * @throws javax.xml.transform.TransformerException
 */
OneStepIteratorForward(Compiler compiler, int opPos, int analysis)
        throws javax.xml.transform.TransformerException
{
  super(compiler, opPos, analysis);
  int firstStepPos = OpMap.getFirstChildPos(opPos);

  m_axis = WalkerFactory.getAxisFromStep(compiler, firstStepPos);

}
 
Example #20
Source File: XPath.java    From JDKSourceCode1.8 with MIT License 5 votes vote down vote up
/**
 * Construct an XPath object.
 *
 * (Needs review -sc) This method initializes an XPathParser/
 * Compiler and compiles the expression.
 * @param exprString The XPath expression.
 * @param locator The location of the expression, may be null.
 * @param prefixResolver A prefix resolver to use to resolve prefixes to
 *                       namespace URIs.
 * @param type one of {@link #SELECT} or {@link #MATCH}.
 * @param errorListener The error listener, or null if default should be used.
 *
 * @throws javax.xml.transform.TransformerException if syntax or other error.
 */
public XPath(
        String exprString, SourceLocator locator,
        PrefixResolver prefixResolver, int type,
        ErrorListener errorListener, FunctionTable aTable)
          throws javax.xml.transform.TransformerException
{
  m_funcTable = aTable;
  if(null == errorListener)
    errorListener = new com.sun.org.apache.xml.internal.utils.DefaultErrorHandler();

  m_patternString = exprString;

  XPathParser parser = new XPathParser(errorListener, locator);
  Compiler compiler = new Compiler(errorListener, locator, m_funcTable);

  if (SELECT == type)
    parser.initXPath(compiler, exprString, prefixResolver);
  else if (MATCH == type)
    parser.initMatchPattern(compiler, exprString, prefixResolver);
  else
    throw new RuntimeException(XSLMessages.createXPATHMessage(
          XPATHErrorResources.ER_CANNOT_DEAL_XPATH_TYPE,
          new Object[]{Integer.toString(type)}));
          //"Can not deal with XPath type: " + type);

  // System.out.println("----------------");
  Expression expr = compiler.compile(0);

  // System.out.println("expr: "+expr);
  this.setExpression(expr);

  if((null != locator) && locator instanceof ExpressionNode)
  {
      expr.exprSetParent((ExpressionNode)locator);
  }

}
 
Example #21
Source File: WalkerFactory.java    From jdk1.8-source-analysis with Apache License 2.0 5 votes vote down vote up
static boolean isProximateInnerExpr(Compiler compiler, int opPos)
{
  int op = compiler.getOp(opPos);
  int innerExprOpPos = opPos+2;
  switch(op)
  {
    case OpCodes.OP_ARGUMENT:
      if(isProximateInnerExpr(compiler, innerExprOpPos))
        return true;
      break;
    case OpCodes.OP_VARIABLE:
    case OpCodes.OP_NUMBERLIT:
    case OpCodes.OP_LITERAL:
    case OpCodes.OP_LOCATIONPATH:
      break; // OK
    case OpCodes.OP_FUNCTION:
      boolean isProx = functionProximateOrContainsProximate(compiler, opPos);
      if(isProx)
        return true;
      break;
    case OpCodes.OP_GT:
    case OpCodes.OP_GTE:
    case OpCodes.OP_LT:
    case OpCodes.OP_LTE:
    case OpCodes.OP_EQUALS:
      int leftPos = OpMap.getFirstChildPos(op);
      int rightPos = compiler.getNextOpPos(leftPos);
      isProx = isProximateInnerExpr(compiler, leftPos);
      if(isProx)
        return true;
      isProx = isProximateInnerExpr(compiler, rightPos);
      if(isProx)
        return true;
      break;
    default:
      return true; // be conservative...
  }
  return false;
}
 
Example #22
Source File: OneStepIterator.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Create a OneStepIterator object.
 *
 * @param compiler A reference to the Compiler that contains the op map.
 * @param opPos The position within the op map, which contains the
 * location path expression for this itterator.
 *
 * @throws javax.xml.transform.TransformerException
 */
OneStepIterator(Compiler compiler, int opPos, int analysis)
        throws javax.xml.transform.TransformerException
{
  super(compiler, opPos, analysis);
  int firstStepPos = OpMap.getFirstChildPos(opPos);

  m_axis = WalkerFactory.getAxisFromStep(compiler, firstStepPos);

}
 
Example #23
Source File: WalkerFactory.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
static boolean isProximateInnerExpr(Compiler compiler, int opPos)
{
  int op = compiler.getOp(opPos);
  int innerExprOpPos = opPos+2;
  switch(op)
  {
    case OpCodes.OP_ARGUMENT:
      if(isProximateInnerExpr(compiler, innerExprOpPos))
        return true;
      break;
    case OpCodes.OP_VARIABLE:
    case OpCodes.OP_NUMBERLIT:
    case OpCodes.OP_LITERAL:
    case OpCodes.OP_LOCATIONPATH:
      break; // OK
    case OpCodes.OP_FUNCTION:
      boolean isProx = functionProximateOrContainsProximate(compiler, opPos);
      if(isProx)
        return true;
      break;
    case OpCodes.OP_GT:
    case OpCodes.OP_GTE:
    case OpCodes.OP_LT:
    case OpCodes.OP_LTE:
    case OpCodes.OP_EQUALS:
      int leftPos = OpMap.getFirstChildPos(op);
      int rightPos = compiler.getNextOpPos(leftPos);
      isProx = isProximateInnerExpr(compiler, leftPos);
      if(isProx)
        return true;
      isProx = isProximateInnerExpr(compiler, rightPos);
      if(isProx)
        return true;
      break;
    default:
      return true; // be conservative...
  }
  return false;
}
 
Example #24
Source File: OneStepIteratorForward.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Create a OneStepIterator object.
 *
 * @param compiler A reference to the Compiler that contains the op map.
 * @param opPos The position within the op map, which contains the
 * location path expression for this itterator.
 *
 * @throws javax.xml.transform.TransformerException
 */
OneStepIteratorForward(Compiler compiler, int opPos, int analysis)
        throws javax.xml.transform.TransformerException
{
  super(compiler, opPos, analysis);
  int firstStepPos = OpMap.getFirstChildPos(opPos);

  m_axis = WalkerFactory.getAxisFromStep(compiler, firstStepPos);

}
 
Example #25
Source File: WalkerFactory.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
static boolean isProximateInnerExpr(Compiler compiler, int opPos)
{
  int op = compiler.getOp(opPos);
  int innerExprOpPos = opPos+2;
  switch(op)
  {
    case OpCodes.OP_ARGUMENT:
      if(isProximateInnerExpr(compiler, innerExprOpPos))
        return true;
      break;
    case OpCodes.OP_VARIABLE:
    case OpCodes.OP_NUMBERLIT:
    case OpCodes.OP_LITERAL:
    case OpCodes.OP_LOCATIONPATH:
      break; // OK
    case OpCodes.OP_FUNCTION:
      boolean isProx = functionProximateOrContainsProximate(compiler, opPos);
      if(isProx)
        return true;
      break;
    case OpCodes.OP_GT:
    case OpCodes.OP_GTE:
    case OpCodes.OP_LT:
    case OpCodes.OP_LTE:
    case OpCodes.OP_EQUALS:
      int leftPos = OpMap.getFirstChildPos(op);
      int rightPos = compiler.getNextOpPos(leftPos);
      isProx = isProximateInnerExpr(compiler, leftPos);
      if(isProx)
        return true;
      isProx = isProximateInnerExpr(compiler, rightPos);
      if(isProx)
        return true;
      break;
    default:
      return true; // be conservative...
  }
  return false;
}
 
Example #26
Source File: WalkerFactory.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
static boolean functionProximateOrContainsProximate(Compiler compiler,
                                                    int opPos)
{
  int endFunc = opPos + compiler.getOp(opPos + 1) - 1;
  opPos = OpMap.getFirstChildPos(opPos);
  int funcID = compiler.getOp(opPos);
  //  System.out.println("funcID: "+funcID);
  //  System.out.println("opPos: "+opPos);
  //  System.out.println("endFunc: "+endFunc);
  switch(funcID)
  {
    case FunctionTable.FUNC_LAST:
    case FunctionTable.FUNC_POSITION:
      return true;
    default:
      opPos++;
      int i = 0;
      for (int p = opPos; p < endFunc; p = compiler.getNextOpPos(p), i++)
      {
        int innerExprOpPos = p+2;
        int argOp = compiler.getOp(innerExprOpPos);
        boolean prox = isProximateInnerExpr(compiler, innerExprOpPos);
        if(prox)
          return true;
      }

  }
  return false;
}
 
Example #27
Source File: OneStepIterator.java    From JDKSourceCode1.8 with MIT License 5 votes vote down vote up
/**
 * Create a OneStepIterator object.
 *
 * @param compiler A reference to the Compiler that contains the op map.
 * @param opPos The position within the op map, which contains the
 * location path expression for this itterator.
 *
 * @throws javax.xml.transform.TransformerException
 */
OneStepIterator(Compiler compiler, int opPos, int analysis)
        throws javax.xml.transform.TransformerException
{
  super(compiler, opPos, analysis);
  int firstStepPos = OpMap.getFirstChildPos(opPos);

  m_axis = WalkerFactory.getAxisFromStep(compiler, firstStepPos);

}
 
Example #28
Source File: WalkerFactory.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
/**
 * This method is for building an array of possible levels
 * where the target element(s) could be found for a match.
 * @param lpi The owning location path iterator object.
 * @param compiler non-null reference to compiler object that has processed
 *                 the XPath operations into an opcode map.
 * @param stepOpCodePos The opcode position for the step.
 * @param stepIndex The top-level step index withing the iterator.
 *
 * @return non-null AxesWalker derivative.
 *
 * @throws javax.xml.transform.TransformerException
 * @xsl.usage advanced
 */
static AxesWalker loadWalkers(
        WalkingIterator lpi, Compiler compiler, int stepOpCodePos, int stepIndex)
          throws javax.xml.transform.TransformerException
{

  int stepType;
  AxesWalker firstWalker = null;
  AxesWalker walker, prevWalker = null;

  int analysis = analyze(compiler, stepOpCodePos, stepIndex);

  while (OpCodes.ENDOP != (stepType = compiler.getOp(stepOpCodePos)))
  {
    walker = createDefaultWalker(compiler, stepOpCodePos, lpi, analysis);

    walker.init(compiler, stepOpCodePos, stepType);
    walker.exprSetParent(lpi);

    // walker.setAnalysis(analysis);
    if (null == firstWalker)
    {
      firstWalker = walker;
    }
    else
    {
      prevWalker.setNextWalker(walker);
      walker.setPrevWalker(prevWalker);
    }

    prevWalker = walker;
    stepOpCodePos = compiler.getNextStepPos(stepOpCodePos);

    if (stepOpCodePos < 0)
      break;
  }

  return firstWalker;
}
 
Example #29
Source File: OneStepIteratorForward.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Create a OneStepIterator object.
 *
 * @param compiler A reference to the Compiler that contains the op map.
 * @param opPos The position within the op map, which contains the
 * location path expression for this itterator.
 *
 * @throws javax.xml.transform.TransformerException
 */
OneStepIteratorForward(Compiler compiler, int opPos, int analysis)
        throws javax.xml.transform.TransformerException
{
  super(compiler, opPos, analysis);
  int firstStepPos = OpMap.getFirstChildPos(opPos);

  m_axis = WalkerFactory.getAxisFromStep(compiler, firstStepPos);

}
 
Example #30
Source File: OneStepIteratorForward.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Create a OneStepIterator object.
 *
 * @param compiler A reference to the Compiler that contains the op map.
 * @param opPos The position within the op map, which contains the
 * location path expression for this itterator.
 *
 * @throws javax.xml.transform.TransformerException
 */
OneStepIteratorForward(Compiler compiler, int opPos, int analysis)
        throws javax.xml.transform.TransformerException
{
  super(compiler, opPos, analysis);
  int firstStepPos = OpMap.getFirstChildPos(opPos);

  m_axis = WalkerFactory.getAxisFromStep(compiler, firstStepPos);

}