com.waveset.expression
Class ExDefun

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

public class ExDefun
extends ExNode

The node representation for a <defun> expression, which defines a callable function.

Once defined, the function may be called with a <call> 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
ExDefun()
          Build a defun node.
 
Method Summary
 ExValue call(ExState state, ExNode[] arglist)
          Call a function.
 ExValue eval(ExState state)
          Override ExNode.eval since we don't want the breakpoint to occur here.
protected  ExValue evalInternal(ExState state)
          This implementation does nothing - everything is done within call
 int getArgCount()
          Gets the number of function arguments referenced in the body of this function.
 java.lang.String getFunctionName()
          Gets the node function name.
 java.lang.String getName()
          Gets the name of the function being defined.
 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 setArgCount(int c)
          Sets the number of function arguments referenced in the body of the function.
 void setName(java.lang.String name)
          Set the name.
 void toXmlAttributes(java.lang.StringBuffer b)
          Add attributes to the default XML serialization.
 
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

ExDefun

public ExDefun()
Build a defun node.

Method Detail

getFunctionName

public java.lang.String getFunctionName()
Gets the node function name.

Specified by:
getFunctionName in class ExNode

getName

public java.lang.String getName()
Gets the name of the function being defined.


getArgCount

public int getArgCount()
Gets the number of function arguments referenced in the body of this function.


setArgCount

public void setArgCount(int c)
Sets the number of function arguments referenced in the body of the function.


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)
Add attributes to the default XML serialization.

Overrides:
toXmlAttributes in class ExNode

postProcess

public void postProcess()
Overload of the ExNode postProcess method.

Here we initialize the argCount field, since this will be set as we encounter expressions while traversing our body.

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.

The return value of defun is null. It has the side effect of registering the function 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
This implementation does nothing - everything is done within call

Specified by:
evalInternal in class ExNode
Throws:
WavesetException

call

public ExValue call(ExState state,
                    ExNode[] arglist)
             throws WavesetException
Call a function.

This is called in response to the evaluation of an ExCall node, here is where we evaluation the body of the function.

Throws:
WavesetException