Exemplo n.º 1
0
 /**
  * Set the local stack frame. This method is used when creating a Closure to support delayed
  * evaluation of expressions. The "stack frame" is actually on the Java heap, which means it can
  * survive function returns and the like.
  */
 public void setStackFrame(SlotManager map, ValueRepresentation[] variables) {
   stackFrame = new StackFrame(map, variables);
   if (map != null && variables.length != map.getNumberOfVariables()) {
     stackFrame.slots = new ValueRepresentation[map.getNumberOfVariables()];
     System.arraycopy(variables, 0, stackFrame.slots, 0, variables.length);
   }
 }
Exemplo n.º 2
0
 /**
  * Declare a variable. A variable may be declared before an expression referring to it is
  * compiled. Alternatively, a JAXP XPathVariableResolver may be supplied to perform the
  * resolution. A variable that has been explicitly declared is used in preference.
  *
  * @param qname Lexical QName identifying the variable. The namespace prefix, if any, must have
  *     been declared before this method is called, or must be resolvable using the namespace
  *     context.
  * @param initialValue The initial value of the variable. A Java object that can be converted to
  *     an XPath value.
  */
 public Variable declareVariable(String qname, Object initialValue) throws XPathException {
   String prefix;
   String localName;
   try {
     String[] parts = Name.getQNameParts(qname);
     prefix = parts[0];
     localName = parts[1];
   } catch (QNameException err) {
     throw new StaticError("Invalid QName for variable: " + qname);
   }
   String uri = "";
   if (!("".equals(prefix))) {
     uri = getURIForPrefix(prefix);
   }
   Variable var = Variable.make(qname, getConfiguration());
   var.setValue(initialValue);
   int fingerprint = namePool.allocate(prefix, uri, localName) & 0xfffff;
   variables.put(new Integer(fingerprint), var);
   stackFrameMap.allocateSlotNumber(fingerprint);
   return var;
 }
Exemplo n.º 3
0
 /**
  * Create a new stack frame for local variables, using the supplied SlotManager to define the
  * allocation of slots to individual variables
  *
  * @param map the SlotManager for the new stack frame
  */
 public void openStackFrame(SlotManager map) {
   stackFrame = new StackFrame(map, new ValueRepresentation[map.getNumberOfVariables()]);
 }