com.waveset.expression
Class ExReference

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

public class ExReference
extends ExNode

A node representing a variable or argument reference.


Field Summary
static java.lang.String code_id
           
 
Fields inherited from class com.waveset.expression.ExNode
_bindingCount, _children, _decoration, _parent, trace
 
Constructor Summary
ExReference()
          Build a value node.
ExReference(java.lang.String name)
           
 
Method Summary
 void beginTrace(java.lang.StringBuffer b)
          Overload trace messages since we have literal content.
 void endTrace(java.lang.StringBuffer b)
          Called by ExState to format the end of a trace message for this node.
protected  ExValue evalInternal(ExState state)
          Evalute the reference node.
 ExDefvar getDefvar()
          Get the resolved variable.
 java.lang.String getFunctionName()
          Return the node function name.
 java.lang.String getName()
          Get the name of the reference.
 boolean isExternal()
          Tests to see if this is an external reference.
 boolean isLiteral()
          Overload indicating we have literal content.
 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 setExternal(boolean b)
           
 void setName(java.lang.String s)
           
 void toXml(java.lang.StringBuffer b, int indent)
          Serialize a back to XML.
 
Methods inherited from class com.waveset.expression.ExNode
addChild, addChildren, addCommonAttributes, clearOwner, eval, evalChild, evalChildToObject, evalChildToString, evalToBoolean, evalToInt, evalToObject, evalToString, getBindingCount, getChild, getChildren, getDecoration, getHiddenVariable, getLocation, getOwner, getParent, parseCommonAttributes, removeChild, resolveFunction, resolveVariable, setBindingCount, setChildren, setDecoration, setEnvironment, setLocation, setOwner, setOwner, setParent, toXml, toXml, toXmlAttributes, 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
Constructor Detail

ExReference

public ExReference()
Build a value node.


ExReference

public ExReference(java.lang.String name)
Method Detail

setName

public void setName(java.lang.String s)

setExternal

public void setExternal(boolean b)

parseXml

public void parseXml(org.w3c.dom.Element el)
              throws WavesetException
Parse the XML representation, and flesh out the object. This one is a little more complicated than others as we allow mixed content. Might want this elsewhere, move up to ExNode?

Overrides:
parseXml in class ExNode
Throws:
WavesetException

toXml

public void toXml(java.lang.StringBuffer b,
                  int indent)
Serialize a back to XML. Have to overload the default method since we can more than one tag name.

Overrides:
toXml in class ExNode

postProcess

public void postProcess()
Overload of the ExNode postProcess method. Here we try to resolve our variable reference. This may fail for awhile if we're incrementally building up the environment, and the hasn't been added yet. It may end up being unresolved, which will get caught when its evaluated.

Overrides:
postProcess in class ExNode

getFunctionName

public java.lang.String getFunctionName()
Return the node function name. We support both internal and external reference syntax.

Specified by:
getFunctionName in class ExNode

getName

public java.lang.String getName()
Get the name of the reference.


getDefvar

public ExDefvar getDefvar()
Get the resolved variable.


isExternal

public boolean isExternal()
Tests to see if this is an external reference.


evalInternal

protected ExValue evalInternal(ExState state)
                        throws WavesetException
Evalute the reference node.

If this is resolved to a ExDefvar, we return its value. If it is an external reference, we ask the ExState object to resolve it. If its unresolved we raise an error.

Specified by:
evalInternal in class ExNode
Throws:
WavesetException

isLiteral

public boolean isLiteral()
Overload indicating we have literal content. Set this so we don't get a newline after the start tag.

Overrides:
isLiteral in class ExNode

beginTrace

public void beginTrace(java.lang.StringBuffer b)
Overload trace messages since we have literal content. These are funny, because they're written with literal content, but they may wrap complex evaluations, so we'd really like to have the end tag on a separate line.

We could put the start tag and reference name on one line, indent and allow referenced expressions to trace, then close with the tag on a new line.

Another option would be to put the entire on one line, indent for the referenced expressions, and then close with a line with just the result.

Overrides:
beginTrace in class ExNode

endTrace

public void endTrace(java.lang.StringBuffer b)
Description copied from class: ExNode
Called by ExState to format the end of a trace message for this node. By default, the begin trace mesage looks like an XML end tag, we use the value returned by the abstract getFunctionName method for the element name. Nodes can override this if they have more complicated trace information.

Overrides:
endTrace in class ExNode