codesimian
Class CompileAndExecInnerCsFile

java.lang.Object
  extended by codesimian.CS<CSGeneric>
      extended by codesimian.DefaultCS
          extended by codesimian.CompileAndExecInnerCsFile
All Implemented Interfaces:
CodeSimian

public class CompileAndExecInnerCsFile
extends DefaultCS

gets the bytes of an inner file, compiles it, then pretends to be the compiled output forever. WARNING: If you write code containing a compileAndExecInnerCsFile, compile it, and convert it back to code, the second code will be bigger than the first because it contains the old file contents instead of dynamicly loading it by file name.

TODO: build a GUI wrapper to solve this problem... This code does not work: window(compileAndExecInnerCsFile('cs/anyfileofnonwindowjavaawtcomponent.cs')) It doesnt work because the window gets the java.awt.Component value of the compileAndExecInnerCsFile before the string filename is added to it. Therefore compileAndExecInnerCsFile should immediately return an empty wrapper and fill in the wrapper exactly when the filename is given, but that has the problem of maybe the filename's chars arent all there yet. Its a repeat of the same problem. However if its an S object, the compiler hack of creating it all at once is used. I dont want to depend on hacks. Find a simpler way to make the following code work: window(compileAndExecInnerCsFile('cs/anyfileofnonwindowjavaawtcomponent.cs')) I could check each filename as the filename is built 1 letter at a time to see if each is a valid inner file name, but that has the problem of shorter filenames possibly being a subset of longer filenames, and the problem of requiring a listener be added to the filename object, and listeners are not part of codesimians current design, but it can be hacked through the PROXY objects.


Field Summary
static java.lang.String fileNameSuffix
           
 
Fields inherited from class codesimian.CS
DESCRIPTION, END, EXECPROXY, HEAP, JAVACODE, MYFUEL, NAME, NEWINSTANCE, NULL, PARENT, PARSEPRIORITY, PREV, TESTER, THIS
 
Constructor Summary
CompileAndExecInnerCsFile()
           
 
Method Summary
 java.lang.String description()
          a short description of this CS, shorter than the javadoc, but long enough to tell what the params are for.
 double DForProxy()
          Execute this CS and cast to double.
static CS getAndCompileInternalCsFile(java.lang.String internalFileName, CS compiler)
          returns null if file not found or code cant be compiled.
 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()".
 java.lang.Object LForProxy(java.lang.Class type)
          the default implementation can use many Class parameters.
 int maxP()
          Maximum quantity of Params
 int minP()
          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.
static CS newInitializedFunction(CS parametersAndFunctionBody, int parameterQuantity)
          Example: newInitializedFunction( codesimian code: +(2#two 3#three 4#four three), 2 ) 2#two and both 3#threes are replaced, and the + becomes the function body.
 CS P(int index)
          WARNING: if add CSs then delete them, they are still in the param[] array and can be returned in this function, despite them being out of valid range: index at least countP().
 
Methods inherited from class codesimian.DefaultCS
B, C, countP, decrementMyFuel, deleteP, F, fuel, getExec, getObject, heap, I, indexP, indexPName, insertB, insertC, insertD, insertF, insertI, insertJ, insertL, insertL, insertL1, insertP, insertS, insertZ, J, javaCode, LForProxy, 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, setP, 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

fileNameSuffix

public static final java.lang.String fileNameSuffix
See Also:
Constant Field Values
Constructor Detail

CompileAndExecInnerCsFile

public CompileAndExecInnerCsFile()
Method Detail

DForProxy

public double DForProxy()
Description copied from class: CS
Execute this CS and cast to double.

D() and DForProxy() are the 2 most important functions in CS. They execute this CS. All other execute functions, by default, return DForProxy cast to their own type.

For example, J() calls the proxy which calls JForProxy() which calls DForProxy(). D() calls the proxy which calls DForProxy().

By default, all other primitive EXECUTE functions defer to D.
Functions that EXECUTE this CS: L(Class) L(int,Class,int) Z() B() C() S() I() J() F() D() V()

Specified by:
DForProxy in class DefaultCS

LForProxy

public java.lang.Object LForProxy(java.lang.Class type)
Description copied from class: DefaultCS
the default implementation can use many Class parameters. If you override but do not know what to return, return super.LForProxy(Class). All EXEC objects must override L(Class) the same way they override D(), reversed.

TODO: add ability to return List, or should I make every CS be a list?

Overrides:
LForProxy in class DefaultCS
See Also:
execProxy(), setExecProxy(CS)

P

public CS P(int index)
Description copied from class: DefaultCS
WARNING: if add CSs then delete them, they are still in the param[] array and can be returned in this function, despite them being out of valid range: index at least countP().

Overrides:
P in class DefaultCS
Parameters:
index - range 0 (or neg?) to countP()-1 inclusive
See Also:
CS.heap()

keyword

public java.lang.String keyword()
Description copied from class: DefaultCS
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()".
Default: Returns class name, minus package name (and its dots), and change the first letter to lowercase.

For example, CS.MaxParams does not override keyword(), which returns "maxP".

Overrides:
keyword in class DefaultCS
See Also:
CS.parent(), CS.newInstance(), CS.name()

getAndCompileInternalCsFile

public static CS getAndCompileInternalCsFile(java.lang.String internalFileName,
                                             CS compiler)
                                      throws CodesimianCompileException
returns null if file not found or code cant be compiled.

Throws:
CodesimianCompileException

newInitializedFunction

public static CS newInitializedFunction(CS parametersAndFunctionBody,
                                        int parameterQuantity)
Example: newInitializedFunction( codesimian code: +(2#two 3#three 4#four three), 2 ) 2#two and both 3#threes are replaced, and the + becomes the function body.


minP

public int minP()
Description copied from class: DefaultCS
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.

Overrides:
minP in class DefaultCS

maxP

public int maxP()
Description copied from class: CS
Maximum quantity of Params

Overrides:
maxP in class CS

description

public java.lang.String description()
Description copied from class: CS
a short description of this CS, shorter than the javadoc, but long enough to tell what the params are for. Example use: in automatically generated webpages for CodeSimian. Example: "returns sum of all params" for Add.

Overrides:
description in class DefaultCS