public class SimpleCompiler extends Cookable implements ISimpleCompiler
SimpleCompiler object, proceed as described for ISimpleCompiler.
Alternatively, a number of "convenience constructors" exist that execute the described steps
instantly.| Modifier and Type | Field and Description |
|---|---|
protected boolean |
debugLines |
protected boolean |
debugSource |
protected boolean |
debugVars |
BOOT_CLASS_LOADER, SYSTEM_PROPERTY_SOURCE_DEBUGGING_DIR, SYSTEM_PROPERTY_SOURCE_DEBUGGING_ENABLE| Constructor and Description |
|---|
SimpleCompiler() |
SimpleCompiler(Scanner scanner,
ClassLoader optionalParentClassLoader)
Equivalent to
|
SimpleCompiler(String fileName)
Equivalent to
|
SimpleCompiler(String optionalFileName,
InputStream is)
Equivalent to
|
SimpleCompiler(String optionalFileName,
Reader in)
Equivalent to
|
| Modifier and Type | Method and Description |
|---|---|
protected void |
assertNotCooked()
Throw an
IllegalStateException if this Cookable is already cooked. |
protected Java.Type[] |
classesToTypes(Location location,
Class[] classes)
|
protected Java.Type |
classToType(Location location,
Class optionalClass)
|
protected ClassLoader |
compileToClassLoader(Java.CompilationUnit compilationUnit)
Compile the given compilation unit.
|
void |
cook(Java.CompilationUnit compilationUnit)
Cook this compilation unit directly.
|
void |
cook(Scanner scanner) |
void |
cook(String optionalFileName,
Reader r)
Reads, scans, parses and compiles Java tokens from the given
Reader. |
boolean |
equals(Object o)
Two
SimpleCompilers are regarded equal iff
Both are objects of the same class (e.g. |
ClassLoader |
getClassLoader()
Returns a
ClassLoader object through which the previously compiled classes can be accessed. |
int |
hashCode() |
static void |
main(String[] args) |
void |
setDebuggingInformation(boolean debugSource,
boolean debugLines,
boolean debugVars)
Determines what kind of debugging information is included in the generates classes.
|
void |
setParentClassLoader(ClassLoader optionalParentClassLoader)
The "parent class loader" is used to load referenced classes.
|
void |
setParentClassLoader(ClassLoader optionalParentClassLoader,
Class[] auxiliaryClasses)
Allow references to the classes loaded through this parent class loader
(@see
setParentClassLoader(ClassLoader)), plus the extra
auxiliaryClasses. |
protected void |
setUpClassLoaders()
Initializes
classLoader and iClassLoader from the configured
parentClassLoader and optionalAuxiliaryClasses. |
cook, cook, cook, cook, cook, cook, cook, cookFile, cookFile, cookFile, cookFile, readStringprotected boolean debugSource
protected boolean debugLines
protected boolean debugVars
public SimpleCompiler(String optionalFileName, Reader in) throws IOException, CompileException
SimpleCompiler sc = new SimpleCompiler(); sc.cook(optionalFileName, in);
IOExceptionCompileExceptionSimpleCompiler(),
Cookable.cook(String, Reader)public SimpleCompiler(String optionalFileName, InputStream is) throws IOException, CompileException
SimpleCompiler sc = new SimpleCompiler(); sc.cook(optionalFileName, is);
IOExceptionCompileExceptionSimpleCompiler(),
Cookable.cook(String, InputStream)public SimpleCompiler(String fileName) throws IOException, CompileException
SimpleCompiler sc = new SimpleCompiler(); sc.cook(fileName);
IOExceptionCompileExceptionSimpleCompiler(),
Cookable.cookFile(String)public SimpleCompiler(Scanner scanner, ClassLoader optionalParentClassLoader) throws IOException, CompileException
SimpleCompiler sc = new SimpleCompiler(); sc.setParentClassLoader(optionalParentClassLoader); sc.cook(scanner);
public SimpleCompiler()
public void setParentClassLoader(ClassLoader optionalParentClassLoader)
ICookableSystem.getSystemClassLoader() |
The running JVM's class path |
Thread.currentThread().getContextClassLoader() or null |
The class loader effective for the invoking thread |
ICookable.BOOT_CLASS_LOADER |
The running JVM's boot class path |
setParentClassLoader in interface ICookablepublic void setParentClassLoader(ClassLoader optionalParentClassLoader, Class[] auxiliaryClasses)
setParentClassLoader(ClassLoader)), plus the extra
auxiliaryClasses.
Notice that the auxiliaryClasses must either be loadable through the
optionalParentClassLoader (in which case they have no effect), or
no class with the same name must be loadable through the
optionalParentClassLoader.
public void setDebuggingInformation(boolean debugSource,
boolean debugLines,
boolean debugVars)
ICookablesetDebuggingInformation in interface ICookablepublic final void cook(String optionalFileName, Reader r) throws CompileException, IOException
ICookableReader.cook in interface ICookablecook in class CookableoptionalFileName - Used when reporting errors and warnings.CompileExceptionIOExceptionpublic void cook(Scanner scanner) throws CompileException, IOException
CompileExceptionIOExceptionpublic void cook(Java.CompilationUnit compilationUnit) throws CompileException
Cookable.cook(java.lang.String, java.io.Reader)CompileExceptionprotected final void setUpClassLoaders()
classLoader and iClassLoader from the configured
parentClassLoader and optionalAuxiliaryClasses. These are needed by
classToType(Location, Class) and friends which are used when creating the AST.public ClassLoader getClassLoader()
ISimpleCompilerClassLoader object through which the previously compiled classes can be accessed. This ClassLoader can be used for subsequent ISimpleCompilers in order to compile compilation units that use
types (e.g. declare derived types) declared in the previous one.
This method must only be called after exactly on of the ICookable.cook(String, java.io.Reader) methods was called.
getClassLoader in interface ISimpleCompilerpublic boolean equals(Object o)
SimpleCompilers are regarded equal iff
ScriptEvaluators)
ByteArrayClassLoader.equals(Object)
protected final ClassLoader compileToClassLoader(Java.CompilationUnit compilationUnit) throws CompileException
compilationUnit - The parsed compilation unitClassLoader into which the compiled classes were definedCompileExceptionprotected void assertNotCooked()
IllegalStateException if this Cookable is already cooked.Copyright © 2001–2013. All rights reserved.