Package org.mozilla.javascript.optimizer
Class Codegen
- java.lang.Object
- 
- org.mozilla.javascript.optimizer.Codegen
 
- 
- 
Constructor SummaryConstructors Constructor Description Codegen()
 - 
Method SummaryAll Methods Instance Methods Concrete Methods Modifier and Type Method Description voidcaptureStackInfo(RhinoException ex)Capture stack information from the given exception.java.lang.Objectcompile(CompilerEnvirons compilerEnv, ScriptNode tree, java.lang.String encodedSource, boolean returnFunction)Compile the script or function from intermediate representation tree into an executable form.byte[]compileToClassFile(CompilerEnvirons compilerEnv, java.lang.String mainClassName, ScriptNode scriptOrFn, java.lang.String encodedSource, boolean returnFunction)FunctioncreateFunctionObject(Context cx, Scriptable scope, java.lang.Object bytecode, java.lang.Object staticSecurityDomain)Create a function object.ScriptcreateScriptObject(java.lang.Object bytecode, java.lang.Object staticSecurityDomain)Create a script object.java.lang.StringgetPatchedStack(RhinoException ex, java.lang.String nativeStackTrace)Given a native stack trace, patch it with script-specific source and line informationjava.util.List<java.lang.String>getScriptStack(RhinoException ex)Get the script stack for the given exceptionjava.lang.StringgetSourcePositionFromStack(Context cx, int[] linep)Get the source position information by examining the stack.voidsetEvalScriptFlag(Script script)Mark the given script to indicate it was created by a call to eval() or to a Function constructor.voidsetMainMethodClass(java.lang.String className)
 
- 
- 
- 
Method Detail- 
captureStackInfopublic void captureStackInfo(RhinoException ex) Description copied from interface:EvaluatorCapture stack information from the given exception.- Specified by:
- captureStackInfoin interface- Evaluator
- Parameters:
- ex- an exception thrown during execution
 
 - 
getSourcePositionFromStackpublic java.lang.String getSourcePositionFromStack(Context cx, int[] linep) Description copied from interface:EvaluatorGet the source position information by examining the stack.- Specified by:
- getSourcePositionFromStackin interface- Evaluator
- Parameters:
- cx- Context
- linep- Array object of length >= 1; getSourcePositionFromStack will assign the line number to linep[0].
- Returns:
- the name of the file or other source container
 
 - 
getPatchedStackpublic java.lang.String getPatchedStack(RhinoException ex, java.lang.String nativeStackTrace) Description copied from interface:EvaluatorGiven a native stack trace, patch it with script-specific source and line information- Specified by:
- getPatchedStackin interface- Evaluator
- Parameters:
- ex- exception
- nativeStackTrace- the native stack trace
- Returns:
- patched stack trace
 
 - 
getScriptStackpublic java.util.List<java.lang.String> getScriptStack(RhinoException ex) Description copied from interface:EvaluatorGet the script stack for the given exception- Specified by:
- getScriptStackin interface- Evaluator
- Parameters:
- ex- exception from execution
- Returns:
- list of strings for the stack trace
 
 - 
setEvalScriptFlagpublic void setEvalScriptFlag(Script script) Description copied from interface:EvaluatorMark the given script to indicate it was created by a call to eval() or to a Function constructor.- Specified by:
- setEvalScriptFlagin interface- Evaluator
- Parameters:
- script- script to mark as from eval
 
 - 
compilepublic java.lang.Object compile(CompilerEnvirons compilerEnv, ScriptNode tree, java.lang.String encodedSource, boolean returnFunction) Description copied from interface:EvaluatorCompile the script or function from intermediate representation tree into an executable form.- Specified by:
- compilein interface- Evaluator
- Parameters:
- compilerEnv- Compiler environment
- tree- parse tree
- encodedSource- encoding of the source code for decompilation
- returnFunction- if true, compiling a function
- Returns:
- an opaque object that can be passed to either createFunctionObject or createScriptObject, depending on the value of returnFunction
 
 - 
createScriptObjectpublic Script createScriptObject(java.lang.Object bytecode, java.lang.Object staticSecurityDomain) Description copied from interface:EvaluatorCreate a script object.- Specified by:
- createScriptObjectin interface- Evaluator
- Parameters:
- bytecode- opaque object returned by compile
- staticSecurityDomain- security domain
- Returns:
- Script object that can be evaluated
 
 - 
createFunctionObjectpublic Function createFunctionObject(Context cx, Scriptable scope, java.lang.Object bytecode, java.lang.Object staticSecurityDomain) Description copied from interface:EvaluatorCreate a function object.- Specified by:
- createFunctionObjectin interface- Evaluator
- Parameters:
- cx- Current context
- scope- scope of the function
- bytecode- opaque object returned by compile
- staticSecurityDomain- security domain
- Returns:
- Function object that can be called
 
 - 
compileToClassFilepublic byte[] compileToClassFile(CompilerEnvirons compilerEnv, java.lang.String mainClassName, ScriptNode scriptOrFn, java.lang.String encodedSource, boolean returnFunction) 
 - 
setMainMethodClasspublic void setMainMethodClass(java.lang.String className) 
 
- 
 
-