|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcodesimian.CS<CSGeneric>
codesimian.DefaultCS
codesimian.Function
public class Function
This class allows trees of CSs to be used a little more like hard-coded functions.
You dont have to copy the tree to have 2 instances of that tree with a few CSs in them different.
Instead, make 2 Function's and let them both wrap the tree, and change only the CSs in the tree
whose parameters are the parameters of this Function.
OBSOLETE TEXT:
Its first parameter is the root of the CS that this is a wrapper-class for.
You can set that param, but if you try to get it, you will instead get an Err (subclass of Num)
with the value of getEncapsulated().prevD(). That is to protect the tree from being modified.
getEncapsulated() is not a typo. Its how to get the real param0. You cant get it from P(0).
Its ok to overwrite the tree with setP(countP(),newTree),
because this Function will change to use that new tree,
but if P(countP()) were allowed to return the real param0,
it would not be possible to hide the tree
from CSs who use this Function.
For evolution of CodeSimian code, most Functions should have at least 2 parameters,
so they'll have at least 1 parameter thats actually used as a parameter.
Nested Class Summary | |
---|---|
static class |
Function.ParamProxy
The Function class encapsulates a tree/graph of CSs. |
Field Summary | |
---|---|
protected CS |
encapsulated
|
protected CS[] |
functionContents
includes all contained CSs except the parameters, and CSs that will be replaced. |
protected Function.ParamProxy[] |
paramChanges
paramChanges.length == countP() |
protected boolean |
rebuildInNextExec
Returns true if the next time DForProxy() runs, it should call encapsulate(getEncapsulated()) and set this boolean to false. |
Fields inherited from class codesimian.CS |
---|
DESCRIPTION, END, EXECPROXY, HEAP, JAVACODE, MYFUEL, NAME, NEWINSTANCE, NULL, PARENT, PARSEPRIORITY, PREV, TESTER, THIS |
Constructor Summary | |
---|---|
Function()
|
Method Summary | |
---|---|
boolean |
deleteP(int index)
deleting not yet allowed |
double |
DForProxy()
Execute this CS and cast to double. |
void |
encapsulate(CS encapsulateMe)
Sets the CS that this Function is a wrapper for. |
CS |
getEncapsulated()
Returuns the root of the tree (or graph) of CSs that this Function is a wrapper-class for. |
boolean |
insertP(int index,
CS insertMe)
inserting not yet allowed |
java.lang.String |
keyword()
For the CodeSimian language as a String. CodeSimian language keyword, like "+" "*" "max" ">" etc. Override this function if you want to specify a keyword other than how I derive them from the class name, like + for Add. Some CSs might never be intended to be used in the language by their keyword. The best example (4/05) is Num, because it is used in the language like "3.4" instead of "num()". |
int |
maxP()
Maximum quantity of Params |
CS |
P(int index)
Works normally except if index==countP(), 1 higher than the max valid index, returns getEncapsulated() |
void |
prepareFunctionContentsForNextExecution()
|
boolean |
setP(int index,
CS setTo)
When countP() increases, rebuildInNextExec becomes true, and the next DForProxy() calls encapsulate(the last param) therefore decreasing countP() by 1. |
Methods inherited from class codesimian.DefaultCS |
---|
B, C, countP, decrementMyFuel, description, F, fuel, getExec, getObject, heap, I, indexP, indexPName, insertB, insertC, insertD, insertF, insertI, insertJ, insertL, insertL, insertL1, insertS, insertZ, J, javaCode, LForProxy, LForProxy, minP, myFuel, name, newInstance, objectToCS, objectToCSArray, objectToCSArray, prevD, prevL, PType, S, setB, setC, setCountP, setD, setD, setExec, setF, setFuel, setI, setJ, setL, setL, setL, setL1, setMyFuel, setName, setObject, setPrevExec, setPType, setS, setZ, start, toString, V, Z |
Methods inherited from class codesimian.CS |
---|
addB, addC, addD, addF, addI, addJ, addL, addP, addP, addP, addP, addP, addS, addZ, BForProxy, CForProxy, clone, cost, D, deleteP, FForProxy, GETB, GETC, GETD, GETF, GETI, GETJ, GETL, GETS, GETZ, IForProxy, isIllusion, JForProxy, L, L, L, L, L, maxD, minD, overwrites, parent, parsePriority, PB, PC, PD, PF, PI, PJ, PL, prevB, prevC, prevF, prevI, prevJ, prevS, prevZ, proxyOf, PS, PZ, reflect, reflect, reflect6, setB, SETB, setC, SETC, setCost, SETD, setDescription, setF, SETF, setHeap, setI, SETI, setJ, SETJ, SETL, setL, setL, setParent, setParsePriority, setProxyOf, setS, SETS, setTester, setZ, SETZ, SForProxy, tester, toJavaCode, VForProxy, voidReflect, ZForProxy |
Methods inherited from class java.lang.Object |
---|
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
protected Function.ParamProxy[] paramChanges
protected CS[] functionContents
protected CS encapsulated
protected boolean rebuildInNextExec
Constructor Detail |
---|
public Function()
Method Detail |
---|
public double DForProxy()
CS
DForProxy
in class DefaultCS
public void prepareFunctionContentsForNextExecution()
public int maxP()
CS
maxP
in class CS
public java.lang.String keyword()
DefaultCS
keyword
in class DefaultCS
CS.parent()
,
CS.newInstance()
,
CS.name()
public boolean setP(int index, CS setTo)
setP
in class DefaultCS
public CS P(int index)
P
in class DefaultCS
index
- range 0 (or neg?) to countP()-1 inclusiveCS.heap()
public boolean insertP(int index, CS insertMe)
insertP
in class DefaultCS
public boolean deleteP(int index)
deleteP
in class DefaultCS
public void encapsulate(CS encapsulateMe)
public CS getEncapsulated()
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |