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.
MYFUEL -
Static variable in class codesimian.Compile
a TOKEN preceding an integer specifying the myFuel() for some CS being compiled,
like +#fifteen$5(3 fifteen) which becomes +#fifteen$0(3 fifteen) after increasing its value to 15 by 3s.
Or it could be simpler: ask$3("I refuse to ask this more than 3 times" OK)
An efficient and flexible decimal NUMBER, with one instance var: double.
N is EFFICIENT because you can get/set its value directly as a public instance var.
Its FLEXIBLE because the param system can also be used to get/set its value.
List of 0 or more CSs (my params).
Executing a NothingList returns countP() and does NOTHING to the params.
This list is a place to store CSs, not to compute anything about them.
This class became almost obsolete when CS stopped being a subclass of Number,
although CS still can be cast to Number, but often the dynamic properties are lost.
Returns a Const from the constant-pool whose
value equals the char with index 'charIndex' in the string.
Returns null if charIndex is invalid therefore causes: IndexOutOfBoundsException.
All new CSs should set their options to the same options as I have.
For example: Num n = new Num(3.7); n.setRoot( CS.peekOptions().getRoot() );
But you do not have to do that,
because setOptions() should do it automatically (not implemented yet 5/05).
RandomNeurons are random because they select only some of their edges (in list in param0)
to do calculations with, and randomly select a different subset of edges each execution.
same as reflect(Object[]) except the array is 1 smaller, and all indexs are 1 lower,
and the first element which was taken out is String name,
This function is useful because it can use the
same array as java.lang.reflect.Method.invoke(Object[]);
Name should equal java.lang.reflect.Method.getName() of some Java function (Method).
Removes and returns the oldest 'numBytes' bytes,
or all remaining bytes if not that many exist,
or null if no bytes exist.
Will split an array added by add() if necessary.
For each parameter of 'method', before each invoke(), true if the CS in param[] with the same index
should create an Object like Boolean, Integer, etc and replace the Object in methodParams[] with it.
sameCSConsecutively(list(3 4 5#x x x 89 x x) 2) returns 3 because its 3 consecutive x's.
sameCSConsecutively(list(3 4 5#x x x 89 x x) 6) returns 2 because its 2 consecutive x's.
sameCSConsecutively(list(3 4 5#x x x 89 x x) 1) returns 1 because its 1 consecutive 4.
Always returns at least 1.
Vertical and/or horizontal scrollbars automatically appear around P(0)
when P(0) becomes too large to be completely viewed in its current part of the screen.
(An unusual function for a subclass of CS (Add) to override.)
Modifies or sets this Add's params to try to have n's value.
Executes this Add to get its current value,
then adds the difference to (if nothing interferes) set its value to n's value.
Like the other SetX functions, param0 is target and param1 is source.
param1 is cast to Object and param0 is set using that Object's runtime type.
To set using an interface instead of a class, execute using SetL.L(Class interfaceName).
window is any JFrame *
public boolean setObject(Object window){
if (window==null || !(window instanceof JFrame)) return false;
for (int p=0; psetObject(Object) -
Method in class codesimian.ButtonCS
If classType's type is java.lang.Class, then the fuzzy-type this JavaType
recognizes is CSs whose getObject() returns an object with that Class type.
If classType's type is not java.lang.Class,
then sets the object to classType.getClass() instead.
When countP() increases, rebuildInNextExec becomes true,
and the next DForProxy() calls encapsulate(the last param) therefore decreasing countP() by 1.
true if the number of iterations is known immediately when the loop starts
In this java example: for (int i=0; i
...end is checked once at the start of the loop.
Its value remains constant after that.
error: without this function, theres still a lot of these error messages when CodeSimian starts, caused by CS.start():
error: Static.optionsStack is null.
same as java.lang.String.split(String regularExpressionDelimiter),
but copied here so applets (on the internet) can use it
without complaining about security of dynamic method calls.
Returns a new CS (with no parameters, add them!) described by the String.
Examples: "3.45" "sin" "*" "+$4".
Not allowed: "+$4(3.45 sine(7))" "3.45 +$4 sine(7)" because its multiple CSs.
should i override decompile() also? or is that private?
8/06 I'm overriding toString() because I think Constants are getting printed in code
as their name BEFORE they are given that name in that code.
this 1 CS, no paranthesis, possibly with modifiers.
Example: +$3#nameOfThisPlus
toString() might have returned (for that same example): +$3#nameOfThisPlus(1 2$7 *(3 4))
catch(user-specified-type catchMe)
CATCHes some arbitrary subclass of Throwable.
If that subclass is Exception or Throwable, use the other more-efficient subclasses.
This subclass is slower because it uses a dynamic type.
a 2-dimensional view of objects of the following form:
object.P(0) is a list of objects to view.
object.P(1) is a list of numbers that represent view options.
Same as reflect(Object[]) except the array is 1 bigger, and returnAndNameAndParameters[0]
is replaced by the return-value of the reflected function being called, and all indexs are 1 higher.