| java.lang.Object org.mozilla.javascript.optimizer.ClassCompiler
ClassCompiler | public class ClassCompiler (Code) | | Generates class files from script sources.
since 1.5 Release 5
author: Igor Bukanov |
Constructor Summary | |
public | ClassCompiler(CompilerEnvirons compilerEnv) Construct ClassCompiler that uses the specified compiler environment
when generating classes. |
ClassCompiler | public ClassCompiler(CompilerEnvirons compilerEnv)(Code) | | Construct ClassCompiler that uses the specified compiler environment
when generating classes.
|
compileToClassFiles | public Object[] compileToClassFiles(String source, String sourceLocation, int lineno, String mainClassName)(Code) | | Compile JavaScript source into one or more Java class files.
The first compiled class will have name mainClassName.
If the results of
ClassCompiler.getTargetExtends() or
ClassCompiler.getTargetImplements() are not null, then the first compiled
class will extend the specified super class and implement
specified interfaces.
array where elements with even indexes specifies class nameand the following odd index gives class file body as byte[]array. The initial element of the array always holdsmainClassName and array[1] holds its byte code. |
getTargetExtends | public Class getTargetExtends()(Code) | | Get the class that the generated target will extend.
|
getTargetImplements | public Class[] getTargetImplements()(Code) | | Get the interfaces that the generated target will implement.
|
makeAuxiliaryClassName | protected String makeAuxiliaryClassName(String mainClassName, String auxMarker)(Code) | | Build class name for a auxiliary class generated by compiler.
If the compiler needs to generate extra classes beyond the main class,
it will call this function to build the auxiliary class name.
The default implementation simply appends auxMarker to mainClassName
but this can be overridden.
|
setMainMethodClass | public void setMainMethodClass(String className)(Code) | | Set the class name to use for main method implementation.
The class must have a method matching
public static void main(Script sc, String[] args), it will be
called when main(String[] args) is called in the generated
class. The class name should be fully qulified name and include the
package name like in org.foo.Bar.
|
setTargetExtends | public void setTargetExtends(Class extendsClass)(Code) | | Set the class that the generated target will extend.
Parameters: extendsClass - the class it extends |
setTargetImplements | public void setTargetImplements(Class[] implementsClasses)(Code) | | Set the interfaces that the generated target will implement.
Parameters: implementsClasses - an array of Class objects, one for eachinterface the target will extend |
|
|