oscript.data
Class Function.FunctionData

java.lang.Object
  extended byoscript.data.Function.FunctionData
All Implemented Interfaces:
java.io.Externalizable, java.io.Serializable
Enclosing class:
Function

public static final class Function.FunctionData
extends java.lang.Object
implements java.io.Externalizable

In order to keep function instances more lightweight, the values that will be the same for any instance of a function representing the same portion of the parse tree have been split out into this class, in order to be shared between different function instances.

See Also:
Serialized Form

Field Summary
 boolean hasFxnInScope
          A hint from the parser about whether scope storage can be allocated from the stack, which can only be done if there are no functions declared within this function
 NodeEvaluator program
          The node-evaluator for evaluating the body of this function.
 
Constructor Summary
Function.FunctionData()
           
Function.FunctionData(int id, int[] argIds, boolean varargs, NodeEvaluator exprList, NodeEvaluator program, NodeEvaluator sprogram, boolean hasVarInScope, boolean hasFxnInScope, Value comment)
          Class Constructor.
 
Method Summary
 void addArgs(FunctionScope fxnScope, MemberTable args)
          A helper to populate a fxn-scope with args
 Value getName()
           
 MemberTable mapArgs(MemberTable args)
          Map arguments to a function into the member-table which is used for a function scope.
 void readExternal(java.io.ObjectInput in)
          Derived class that implements Externalizable must call this if it overrides it.
 void writeExternal(java.io.ObjectOutput out)
          Derived class that implements Externalizable must call this if it overrides it.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

program

public NodeEvaluator program
The node-evaluator for evaluating the body of this function.

only public for StackFrame


hasFxnInScope

public boolean hasFxnInScope
A hint from the parser about whether scope storage can be allocated from the stack, which can only be done if there are no functions declared within this function

only public for StackFrame

Constructor Detail

Function.FunctionData

public Function.FunctionData(int id,
                             int[] argIds,
                             boolean varargs,
                             NodeEvaluator exprList,
                             NodeEvaluator program,
                             NodeEvaluator sprogram,
                             boolean hasVarInScope,
                             boolean hasFxnInScope,
                             Value comment)
Class Constructor.

Parameters:
id - the id of the symbol that maps to the member, ie. it's name
argIds - array of argument ids and attributes
varargs - is this a function that can take a variable number of args?
exprList - expressions to evaluate to get args to superFxn or null if superFxn is null
program - the body of the function
sprogram - the static body of the function, or null
hasVarInScope - whether one or more vars/functions are declared in the function body's scope... this is a hint from the parser to tell us if we can avoid creating a scope object at runtime
hasFxnInScope - whether one or more functions are enclosed by this function body's scope... this is a hint from the parser to tell us if we can allocate scope storage from the stack
comment - html formatted comment generated from javadoc comment in src file, or null

Function.FunctionData

public Function.FunctionData()
Method Detail

readExternal

public void readExternal(java.io.ObjectInput in)
                  throws java.io.IOException,
                         java.lang.ClassNotFoundException
Derived class that implements Externalizable must call this if it overrides it. It should override it to save/restore it's own state.

Specified by:
readExternal in interface java.io.Externalizable
Throws:
java.io.IOException
java.lang.ClassNotFoundException

writeExternal

public void writeExternal(java.io.ObjectOutput out)
                   throws java.io.IOException
Derived class that implements Externalizable must call this if it overrides it. It should override it to save/restore it's own state.

Specified by:
writeExternal in interface java.io.Externalizable
Throws:
java.io.IOException

mapArgs

public final MemberTable mapArgs(MemberTable args)
Map arguments to a function into the member-table which is used for a function scope. Since the compiler ensures that the function parameters map to idx 0 thru n in the function-scope, all this has to do is collapse the var-arg parameter (if present) into a single array, and if there is a function within this function's body copy into new table.. This also ensures that the correct number of parameters is passed to the function. This is used instead of addArgs(oscript.data.FunctionScope, oscript.util.MemberTable) when calling as a function.

XXX this could be used in case of constructor scope, by stripping out private parameters... maybe

Parameters:
args - the input arguments
Returns:

addArgs

public final void addArgs(FunctionScope fxnScope,
                          MemberTable args)
A helper to populate a fxn-scope with args


getName

public Value getName()