com.waveset.expression
Class ExDefvar

java.lang.Object
  extended bycom.waveset.expression.ExNode
      extended bycom.waveset.expression.ExDefvar
All Implemented Interfaces:
com.sun.idm.debugger.common.Locatable

public class ExDefvar
extends ExNode

The node representation for the <defvar> expression.

Variables are typically used to hold computed values which can then be referenced without repeating the computation. Once defined, variables are referenced with a <ref> expression.

Note that we use the same class to represent function argument declarations made with the <defarg> expression.


Field Summary
static java.lang.String code_id
           
static java.lang.String ELEMENT
          Name of the XML element.
 
Fields inherited from class com.waveset.expression.ExNode
_bindingCount, _children, _decoration, _parent, trace
 
Constructor Summary
ExDefvar()
          Build a defvar node.
 
Method Summary
 ExValue call(ExState state)
          Call a variable.
 ExValue eval(ExState state)
          Override ExNode.eval since we don't want the breakpoint to occur here.
protected  ExValue evalInternal(ExState state)
          Just clears out this binding
 java.lang.String getFunctionName()
          Gets the node function name.
 java.lang.String getName()
          Gets the name of this variable definition.
 int getOrdinal()
          Gets the ordinal number of the variable.
 void parseXml(org.w3c.dom.Element el)
          Parse the XML representation, and flesh out the object.
 void postProcess()
          Overload of the ExNode postProcess method.
 void setName(java.lang.String name)
          Set the name.
 void toXmlAttributes(java.lang.StringBuffer b)
          Add attributes in the start tag of this node.
 
Methods inherited from class com.waveset.expression.ExNode
addChild, addChildren, addCommonAttributes, beginTrace, clearOwner, endTrace, evalChild, evalChildToObject, evalChildToString, evalToBoolean, evalToInt, evalToObject, evalToString, getBindingCount, getChild, getChildren, getDecoration, getHiddenVariable, getLocation, getOwner, getParent, isLiteral, parseCommonAttributes, removeChild, resolveFunction, resolveVariable, setBindingCount, setChildren, setDecoration, setEnvironment, setLocation, setOwner, setOwner, setParent, toXml, toXml, toXml, toXmlChildren
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

code_id

public static final java.lang.String code_id
See Also:
Constant Field Values

ELEMENT

public static final java.lang.String ELEMENT
Name of the XML element. Exposed for the Form parser.

See Also:
Constant Field Values
Constructor Detail

ExDefvar

public ExDefvar()
Build a defvar node.

Method Detail

getFunctionName

public java.lang.String getFunctionName()
Gets the node function name. More complex than most because we use the same node class for two different elements.

Specified by:
getFunctionName in class ExNode

getName

public java.lang.String getName()
Gets the name of this variable definition.


getOrdinal

public int getOrdinal()
Gets the ordinal number of the variable. Assigned during post processing, this is used for fast lookup into the variable binding array.


setName

public void setName(java.lang.String name)
Set the name.


parseXml

public void parseXml(org.w3c.dom.Element el)
              throws WavesetException
Parse the XML representation, and flesh out the object.

Overrides:
parseXml in class ExNode
Throws:
WavesetException

toXmlAttributes

public void toXmlAttributes(java.lang.StringBuffer b)
Description copied from class: ExNode
Add attributes in the start tag of this node. Intended to be overloaded by subclasses.

Overrides:
toXmlAttributes in class ExNode

postProcess

public void postProcess()
Overload of the ExNode postProcess method. Here we assign ordinal numbers to the variables within a block.

Overrides:
postProcess in class ExNode

eval

public ExValue eval(ExState state)
             throws WavesetException
Override ExNode.eval since we don't want the breakpoint to occur here. Rather, we want the breakpoint to happen in the call method. Evalute the variable definition node.

The return value of defvar is null. It has the side effect of registering the definition in the environment.

Actually, the definition happens as a side effect of the postProcess() walk, not during the evaluation of the definition node.

Overrides:
eval in class ExNode
Throws:
WavesetException

evalInternal

protected ExValue evalInternal(ExState state)
                        throws WavesetException
Just clears out this binding

Specified by:
evalInternal in class ExNode
Throws:
WavesetException

call

public ExValue call(ExState state)
             throws WavesetException
Call a variable.

This is called in response to the evaluation of an ExReference node, here is where we evaluate the variable initialization expression. This should only be called once, after which the value will be cached in the binding array for the current scope.

Throws:
WavesetException