Search in sources :

Example 1 with VariableSafeAbsRef

use of org.apache.xpath.operations.VariableSafeAbsRef in project robovm by robovm.

the class RedundentExprEliminator method changeToVarRef.

/**
   * Change the expression owned by the owner argument to a variable reference 
   * of the given name.
   * 
   * Warning: For global vars, this function relies on the variable declaration 
   * to which it refers having been added just prior to this function being called,
   * so that the reference index can be determined from the size of the global variables 
   * list minus one.
   * 
   * @param varName The name of the variable which will be referenced.
   * @param owner The owner of the expression which will be replaced by a variable ref.
   * @param paths The paths list that the iterator came from, mainly to determine
   *              if this is a local or global reduction.
   * @param psuedoVarRecipient The element within whose scope the variable is 
   *                           being inserted, possibly a StylesheetRoot.
   */
protected void changeToVarRef(QName varName, ExpressionOwner owner, Vector paths, ElemTemplateElement psuedoVarRecipient) {
    Variable varRef = (paths == m_absPaths) ? new VariableSafeAbsRef() : new Variable();
    varRef.setQName(varName);
    if (paths == m_absPaths) {
        StylesheetRoot root = (StylesheetRoot) psuedoVarRecipient;
        Vector globalVars = root.getVariablesAndParamsComposed();
        // Assume this operation is occuring just after the decl has 
        // been added.
        varRef.setIndex(globalVars.size() - 1);
        varRef.setIsGlobal(true);
    }
    owner.setExpression(varRef);
}
Also used : Variable(org.apache.xpath.operations.Variable) VariableSafeAbsRef(org.apache.xpath.operations.VariableSafeAbsRef) Vector(java.util.Vector)

Example 2 with VariableSafeAbsRef

use of org.apache.xpath.operations.VariableSafeAbsRef in project j2objc by google.

the class RedundentExprEliminator method changeToVarRef.

/**
   * Change the expression owned by the owner argument to a variable reference 
   * of the given name.
   * 
   * Warning: For global vars, this function relies on the variable declaration 
   * to which it refers having been added just prior to this function being called,
   * so that the reference index can be determined from the size of the global variables 
   * list minus one.
   * 
   * @param varName The name of the variable which will be referenced.
   * @param owner The owner of the expression which will be replaced by a variable ref.
   * @param paths The paths list that the iterator came from, mainly to determine
   *              if this is a local or global reduction.
   * @param psuedoVarRecipient The element within whose scope the variable is 
   *                           being inserted, possibly a StylesheetRoot.
   */
protected void changeToVarRef(QName varName, ExpressionOwner owner, Vector paths, ElemTemplateElement psuedoVarRecipient) {
    Variable varRef = (paths == m_absPaths) ? new VariableSafeAbsRef() : new Variable();
    varRef.setQName(varName);
    if (paths == m_absPaths) {
        StylesheetRoot root = (StylesheetRoot) psuedoVarRecipient;
        Vector globalVars = root.getVariablesAndParamsComposed();
        // Assume this operation is occuring just after the decl has 
        // been added.
        varRef.setIndex(globalVars.size() - 1);
        varRef.setIsGlobal(true);
    }
    owner.setExpression(varRef);
}
Also used : Variable(org.apache.xpath.operations.Variable) VariableSafeAbsRef(org.apache.xpath.operations.VariableSafeAbsRef) Vector(java.util.Vector)

Aggregations

Vector (java.util.Vector)2 Variable (org.apache.xpath.operations.Variable)2 VariableSafeAbsRef (org.apache.xpath.operations.VariableSafeAbsRef)2