Add a new subclass of Exec at any time.
For any subDesc where subDesc.equals(subclassInstance.getClassDescription()),
Exec.getSubclass(subDesc) returns subclassInstance.getClass().
If myFuel == ALWAYS_CALCULATE (default),
and Options.costAvailable is big enough,
D() always calculates DForProxy() instead of returning the previous value.
Returns a number proportional to the approximate total DEPENDENCE between
the bayes-node (my param0), its childs, and between each child and each other child.
get more bytes from byteMaker if count is less than this *
private int minCount = -1;
public final int minCount(){ return minCount; }
/** how many bytes to get from byteMaker at a time *
private int byteMakerIncrement = -1;
public final int byteMakerIncrement(){ return byteMakerIncrement; }
/** where to get bytes from when needed *
private ByteMaker byteMaker = null;
public final ByteMaker byteMaker(){ return byteMaker; }
Converts a sequence
(that often has duplicate objects)
of CS objects
(that probably do not have enough params)
to a tree or graph-shape of CS objects,
where each CS object has a valid quantity of params,
assuming your parenthesis (example: Compile.LPAREN) allow that.
Returns size of conditional-probability table in param1,
which is EXPONENTIALLY bigger than quantity of child nodes
and anything else in this BayesNode.
Returns true if this CS has permission to execute, and consumes 1 exec permission.
If myFuel is at least 1, decrements it and returns true.
Or if myFuel == ALWAYS_CALCULATE, returns true but does not decrement.
Else returns false.
Does not call DForProxy().
WARNING: if returns false, could have deleted but not moved other params down 1 index.
WARNING: if duplicates not allowed, can not slide params down 1 index the standard way, returns false.
deletes a char from the string and returns a Const from the constant-pool with its value *
public CS deleteP(int index){
if (index < 0 || countP() <= index){
String t = text.getText();
text.setText(
t.substring(0, index) +
t.substring(index+1, t.length())
);
if (index < execPosition) execPosition--;
return Const.pool( (double) t.charAt(index) );
}
return null;
}
If param1 is out of range -1 to 1, it is modified (zig-zagged) to be in that range
zigZag(-1 to 1) = same
zigZag(-1.4) = -.6
zigZag(1.3) = .7
zigZag(.2+4*anyInteger) = .2
Invokes a java Method with parameters methodParams[], after (optionally, if replace[x]) replacing some
of methodParameters[] with CSs from param[] or Numbers with their DForProxy() values
like "new Integer(CS.intValue())".
Tries to convert each param CS to types in this order:
P(index).getObject() object, P(index) subclass of CS, primitive type int boolean etc.
returns 1 (else -1) if param0 can be cast to (or is) one of these java-types:
the Class object returned by my getObject(), or
the java-type of param1.getObject().
Returns 0 if ClassCastException from (Class) getObject().
=Recurse2(list(x 1 2) list(y 0 3 2))
is the same as
x.P(1).setP( 2, y.P(0).P(3).P(2) )
so the first list's countP() must be at least 2,
and the second list's countP() must be at least 1.
CS execMe = this.P(0);
Normally returns execMe.DForProxy(), but returns execMe.prevD() if:
-- execMe.myFuel() <= 0
If execMe is executed, CHANGES:
-- sets execMe's prevExec to value of execMe.DForProxy()
-- decrements execMe.myFuel (unless it equals CS.ALWAYS_CALCULATE)
This class automatically generated by Exec.javaCode(null, true, false, false, true)
CS execMe = this.P(0);
Normally returns execMe.DForProxy(), but returns execMe.prevD() if either of:
-- execMe.myFuel() <= 0
-- execMe.fuel().D() <= 0.0
If execMe is executed, CHANGES:
-- sets execMe's prevExec to value of execMe.DForProxy()
-- decrements execMe.myFuel (unless it equals CS.ALWAYS_CALCULATE)
-- decreases execMe.fuel() by execMe.cost()
This class automatically generated by Exec.javaCode(null, true, true, false, true)
CS execMe = this.P(0);
Normally returns execMe.DForProxy(), but returns execMe.prevD() if any of:
-- execMe.myFuel() <= 0
-- execMe.fuel().D() <= 0.0
-- execMe.DForProxy() returns NaN, infinity, or -infinity.
If execMe is executed, CHANGES:
-- sets execMe's prevExec to value of execMe.DForProxy()
-- decrements execMe.myFuel (unless it equals CS.ALWAYS_CALCULATE)
-- decreases execMe.fuel() by execMe.cost()
This class automatically generated by Exec.javaCode(null, true, true, true, true)
CS execMe = this.P(0);
Normally returns execMe.DForProxy(), but returns execMe.prevD() if any of:
-- execMe.myFuel() <= 0
-- execMe.fuel().D() <= 0.0
-- execMe.DForProxy() returns NaN, infinity, or -infinity.
If execMe is executed, CHANGES:
-- decrements execMe.myFuel (unless it equals CS.ALWAYS_CALCULATE)
-- decreases execMe.fuel() by execMe.cost() WARNING: Sometimes returns prevExec, but never sets it. PrevExec might always be 0.
This class automatically generated by Exec.javaCode(null, true, true, true, false)
CS execMe = this.P(0);
Normally returns execMe.DForProxy(), but returns execMe.prevD() if either of:
-- execMe.myFuel() <= 0
-- execMe.fuel().D() <= 0.0
If execMe is executed, CHANGES:
-- decrements execMe.myFuel (unless it equals CS.ALWAYS_CALCULATE)
-- decreases execMe.fuel() by execMe.cost() WARNING: Sometimes returns prevExec, but never sets it. PrevExec might always be 0.
This class automatically generated by Exec.javaCode(null, true, true, false, false)
CS execMe = this.P(0);
Normally returns execMe.DForProxy(), but returns execMe.prevD() if either of:
-- execMe.myFuel() <= 0
-- execMe.DForProxy() returns NaN, infinity, or -infinity.
If execMe is executed, CHANGES:
-- sets execMe's prevExec to value of execMe.DForProxy()
-- decrements execMe.myFuel (unless it equals CS.ALWAYS_CALCULATE)
This class automatically generated by Exec.javaCode(null, true, false, true, true)
CS execMe = this.P(0);
Normally returns execMe.DForProxy(), but returns execMe.prevD() if either of:
-- execMe.myFuel() <= 0
-- execMe.DForProxy() returns NaN, infinity, or -infinity.
If execMe is executed, CHANGES:
-- decrements execMe.myFuel (unless it equals CS.ALWAYS_CALCULATE) WARNING: Sometimes returns prevExec, but never sets it. PrevExec might always be 0.
This class automatically generated by Exec.javaCode(null, true, false, true, false)
CS execMe = this.P(0);
Normally returns execMe.DForProxy(), but returns execMe.prevD() if:
-- execMe.myFuel() <= 0
If execMe is executed, CHANGES:
-- decrements execMe.myFuel (unless it equals CS.ALWAYS_CALCULATE) WARNING: Sometimes returns prevExec, but never sets it. PrevExec might always be 0.
This class automatically generated by Exec.javaCode(null, true, false, false, false)
CS execMe = this.P(0);
Normally returns execMe.DForProxy(), but returns execMe.prevD() if:
-- execMe.fuel().D() <= 0.0
If execMe is executed, CHANGES:
-- sets execMe's prevExec to value of execMe.DForProxy()
-- decreases execMe.fuel() by execMe.cost()
This class automatically generated by Exec.javaCode(null, false, true, false, true)
CS execMe = this.P(0);
Normally returns execMe.DForProxy(), but returns execMe.prevD() if either of:
-- execMe.fuel().D() <= 0.0
-- execMe.DForProxy() returns NaN, infinity, or -infinity.
If execMe is executed, CHANGES:
-- sets execMe's prevExec to value of execMe.DForProxy()
-- decreases execMe.fuel() by execMe.cost()
This class automatically generated by Exec.javaCode(null, false, true, true, true)
CS execMe = this.P(0);
Normally returns execMe.DForProxy(), but returns execMe.prevD() if either of:
-- execMe.fuel().D() <= 0.0
-- execMe.DForProxy() returns NaN, infinity, or -infinity.
If execMe is executed, CHANGES:
-- decreases execMe.fuel() by execMe.cost() WARNING: Sometimes returns prevExec, but never sets it. PrevExec might always be 0.
This class automatically generated by Exec.javaCode(null, false, true, true, false)
CS execMe = this.P(0);
Normally returns execMe.DForProxy(), but returns execMe.prevD() if:
-- execMe.fuel().D() <= 0.0
If execMe is executed, CHANGES:
-- decreases execMe.fuel() by execMe.cost() WARNING: Sometimes returns prevExec, but never sets it. PrevExec might always be 0.
This class automatically generated by Exec.javaCode(null, false, true, false, false)
CS execMe = this.P(0);
Normally returns execMe.DForProxy(), but returns execMe.prevD() if:
-- execMe.DForProxy() returns NaN, infinity, or -infinity.
If execMe is executed, CHANGES:
-- sets execMe's prevExec to value of execMe.DForProxy()
This class automatically generated by Exec.javaCode(null, false, false, true, true)
CS execMe = this.P(0);
Normally returns execMe.DForProxy(), but returns execMe.prevD() if:
-- execMe.DForProxy() returns NaN, infinity, or -infinity. WARNING: Sometimes returns prevExec, but never sets it. PrevExec might always be 0.
This class automatically generated by Exec.javaCode(null, false, false, true, false)
CS execMe = this.P(0);
If execMe is executed, CHANGES:
-- sets execMe's prevExec to value of execMe.DForProxy() WARNING: Sets prevExec, but never returns or uses it.
If you do not prevD() externally, this wastes cpu time.
This class automatically generated by Exec.javaCode(SetPrevExecButNeverUseIt, false, false, false, true)
EXECPROXY -
Static variable in class codesimian.CS
someCS.P(CS.EXECPROXY) should return someCS.getExec(),
and optionally someCS.setP(CS.EXECPROXY,x) (or other SET functions) should call someCS.setExec(x),
but if the SET functions dont do that, they should return false in that case.
same as ByteArrayInputStream except ByteArrayInputStream.count can be set by a function,
which causes more and more bytes to be available, without changing the byte[] array.
Returns the system time, as the number of seconds since the start of 1970,
probably only accurate to a few milliseconds because of hardware limits,
and never accurate to less than 1 millisecond because of software limits.
The file must contain my own email input format:
$$$startNewEmail
$$$spam .87
$$$subject email subject here
$$$text non-subject text here
Put newlines wherever you want.
Returns this Num's value, like D(), but does not do everything D() does.
You could also call DForProxy() which does the same thing here,
but you should only do that if your execHacker()==true.
A window that asks the user for CodeSimian code, compiles it,
relays error messages to the user, and gives the finished error-free code
to the HumanTypesCommand object.
IndependentCS is used to avoid DEPENDENCY CYCLES when creating the first few CSs.
If you add a new function to CS but not override in IndependentCS, you might create a dependency cycle.
Sorts the values in the double[] array of a child InterpretText,
and returns an array containing values equally spread between 0.0 and 1,
but in the same order they were before sorting.
Execute this CS and cast to long.
Most subclasses should override JForProxy() instead of J(), or neither. WARNING: by default, like the other execute functions, J() calls D() and casts to J's type.
long is the only primitive type that double has problems with.
double maps to long correctly for all values between at least -(2^51) and 2^51 - 1.
Past that, accuracy is less than integer precision.
using this CS as the root, returns this CS and its children recursively
as a String of JAVA CODE that often (but not always) does the same thing as executing this root CS.
This will work with the basic operators like + / * - and probably a few others,
but complex CSs will have to override this function to specify how to translate itself into Java code
in combination with its children and descendent CSs.
since NothingList doesnt execute its contents and only returns the quantity of things it contains,
javaCode(CS) returns the String of a number, the current quantity.
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()".
common keys have type Class (try to cast to that type),
Number (return something from index Number.intValue()),
or String (return something with that name, often has an int index too)
same as L(Class) except only uses a subset of param indexs.
Like many other L functions, allows optimizations of converting CSs to specific Object types.
Example: new S("abcdefg").L(2,String.class,3) returns "cde".
the boolean loop condition, or max number of loops, is checked ONCE when the loop starts.
DForProxy(){
double end = param1;
for (double param0 = 0; param0 < end; param0++) param2;
return last value of param2;
}
param0: iteration var.
LOOP with no iteration var.
DForProxy(){
double end = param0;
for (double i = 0; i < end; i++) param1;
return last value of param1;
}
param0: max value of iteration var.
param1: loop body.
Check value of param0 once, and repeat execution of param1 that many times.
If value of param0 changes during that loop, it is not noticed.
LPAREN -
Static variable in class codesimian.Compile
4/06 OBSOLETE JAVADOC, BUT STILL A LITTLE USEFUL...
LPAREN and RPAREN should be part of output of Lex and part
of input to Parse if you use paranthesis.
For DForProxy().
Minimum number of parameters in param[] needed to call DForProxy().
Defines which indexs of param[] DForProxy() can use.
Functions with a different number of parameters must override this.
OVERRIDE THIS FUNCTION IF EXEC USES A DIFFERENT NUMBER OF PARAMETERS.
Default is 1.