public interface ICodeGenerator
Modifier and Type | Interface and Description |
---|---|
static interface |
ICodeGenerator.IConstantValue
|
Modifier and Type | Method and Description |
---|---|
MethodInfo |
createMethodInfo(LexicalScope scope,
FunctionNode func,
Name alternate_name)
Creates a MethodInfo specifying the signature of a method
declared by a FunctionNode.
|
MethodInfo |
createMethodInfoWithDefaultArgumentValues(LexicalScope scope,
FunctionNode func)
Creates a MethodInfo specifying the signature of a method
declared by a FunctionNode, and adds in the information for any
default argument values.
|
ABCBytesRequestResult |
generate(ExecutorService executorService,
boolean useParallelCodegen,
String synthetic_name_prefix,
IASNode root_node,
ICompilerProject project,
boolean inInvisibleCompilationUnit,
Map<String,String> encodedDebugFiles)
Generate an ABC file equivalent to the input syntax tree.
|
ABCBytesRequestResult |
generate(String synthetic_name_prefix,
IASNode root_node,
ICompilerProject project)
Generate an ABC file equivalent to the input syntax tree.
|
ICodeGenerator.IConstantValue |
generateConstantValue(IASNode subtree,
ICompilerProject project)
Helper method to expose the constant folding code to clients outside of the burm, such
as org.apache.flex.compiler.internal.as.definitions.ConstantDefinition.
|
MethodInfo |
generateFunction(FunctionNode func,
LexicalScope enclosing_scope,
InstructionList instance_init_insns,
Name alternateName)
Generate code for a function declaration, and put its initialization code
on the relevant instruction list.
|
GenerateFunctionInParallelResult |
generateFunctionInParallel(ExecutorService executorService,
FunctionNode func,
LexicalScope enclosing_scope)
Generate code for a function declaration, using a background thread
provided by the specified
ExecutorService . |
InstructionList |
generateInstructions(IASNode subtree,
int goal_state,
LexicalScope scope)
Translate an AST into ABC instructions.
|
void |
generateMethodBodyForFunction(MethodInfo mi,
IASNode node,
LexicalScope enclosing_scope,
InstructionList instance_init_insns)
Helper method used by
generateFunction() (and also by
generateEventHandler() in MXMLDocumentDirectiveProcessor). |
void |
generateMXMLDataBindingGetterFunction(MethodInfo mi,
List<IExpressionNode> nodes,
LexicalScope enclosing_scope)
Helper method used by databinding codegen to emit an anonymous function
based on a list of
IExpressionNode 's. |
void |
generateMXMLDataBindingSetterFunction(MethodInfo mi,
IExpressionNode setterExpression,
LexicalScope enclosing_scope)
Helper method used by mxml databinding codegen to emit an anonymous
function used by an mxml data binding destination function.
|
Object |
reduceSubtree(IASNode subtree,
LexicalScope scope,
int goal)
Reduce an AST to its equivalent ABC structures.
|
ABCBytesRequestResult generate(String synthetic_name_prefix, IASNode root_node, ICompilerProject project) throws InterruptedException
synthetic_name_prefix
- Prefix to prepend to all synthetic namesroot_node
- the root of the syntax tree.project
- ICompilerProject
whose symbol table is used to
resolve references to definitions.InterruptedException
ABCBytesRequestResult generate(ExecutorService executorService, boolean useParallelCodegen, String synthetic_name_prefix, IASNode root_node, ICompilerProject project, boolean inInvisibleCompilationUnit, Map<String,String> encodedDebugFiles) throws InterruptedException
executorService
- ExecutorService
used by the code generator
when parallel code generation is enabled.useParallelCodegen
- If true, some method bodies are generated in
background threads. If false all method bodies are generated on the
calling thread.synthetic_name_prefix
- Prefix to prepend to all synthetic namesroot_node
- the root of the syntax tree.project
- ICompilerProject
whose symbol table is used to
resolve references to definitions.inInvisibleCompilationUnit
- Indicates whether or not we are
generating code for an
IInvisibleCompilationUnit
.encodedDebugFiles
- - a mapping between the absolute path of a file, and the
encoded path that is used by OP_debugfileInterruptedException
InstructionList generateInstructions(IASNode subtree, int goal_state, LexicalScope scope)
subtree
- - the CM subtree.goal_state
- - the desired goal state.
One of the nonterminal states in CmcEmitter,
or 0 if you're feeling lucky and are willing
to accept whatever instruction sequence the
BURM decides is optimal.scope
- - the active lexical scope.MethodInfo generateFunction(FunctionNode func, LexicalScope enclosing_scope, InstructionList instance_init_insns, Name alternateName)
func
- the function declaration node.enclosing_scope
- the lexical scope in which the function was
defined.instance_init_insns
- a list of instance initialization instructions
collected outside a constructor body that must be included in the
constructor.MethodInfo
created for the function.GenerateFunctionInParallelResult generateFunctionInParallel(ExecutorService executorService, FunctionNode func, LexicalScope enclosing_scope)
ExecutorService
.executorService
- ExecutorService
used to do work in other
threads.func
- the function declaration node.enclosing_scope
- the lexical scope in which the function was
defined.GenerateFunctionInParallelResult
which can be used to
wait for code generation of the specified function to complete and to
extract the MethodInfo
created for the specified function. The
MethodInfo
may be extracted immediately after this method
completes ( you don't have to wait for code generation of the specified
function complete ).void generateMXMLDataBindingSetterFunction(MethodInfo mi, IExpressionNode setterExpression, LexicalScope enclosing_scope)
If the expression node is a.b.c, this method will generate a funtion whose source would look something like this:
function (arg:*):void { a.b.c = arg; }
mi
- - the MethodInfo describing the signaturesetterExpression
- IExpressionNode
that is the destination
expression of a mxml data binding.enclosing_scope
- LexicalScope
for the class initializer
that encloses the function being generated.void generateMXMLDataBindingGetterFunction(MethodInfo mi, List<IExpressionNode> nodes, LexicalScope enclosing_scope)
IExpressionNode
's. This method emits a
function that contains code that evaluates each expression in the list
and adds the expressions together with ABCConstants.OP_add
.mi
- - the MethodInfo describing the signaturenodes
- - a List
of IExpressionNode
's to be
codegen'd.enclosing_scope
- LexicalScope
for the class initializer
that encloses the function being generated.MethodInfo createMethodInfo(LexicalScope scope, FunctionNode func, Name alternate_name)
func
- - A FunctionNode representing a method declaration.MethodInfo createMethodInfoWithDefaultArgumentValues(LexicalScope scope, FunctionNode func)
func
- - A FunctionNode representing a method declaration.void generateMethodBodyForFunction(MethodInfo mi, IASNode node, LexicalScope enclosing_scope, InstructionList instance_init_insns)
generateFunction()
(and also by
generateEventHandler()
in MXMLDocumentDirectiveProcessor).mi
- - the MethodInfo describing the signaturenode
- - the FunctionNode or MXMLEventSpecifierNode.enclosing_scope
- - the lexical scope
in which the handler method is autogenerated.instance_init_insns
- - a list of instance
initialization instructions collected outside
a constructor body that must be included in the
constructor.ICodeGenerator.IConstantValue generateConstantValue(IASNode subtree, ICompilerProject project)
subtree
- the tree to generate a constant value forproject
- the project to use to evaluate the treeObject reduceSubtree(IASNode subtree, LexicalScope scope, int goal) throws Exception
subtree
- - the root of the AST subtree.
May be null, in which case this routine returns null.scope
- - the active LexicalScope.goal
- - the BURM's goal state. One of the CmcEmitter.__foo_NT constants.Exception
- from the BURM if the computation didn't succeed or was interrupted.Copyright © 2016 The Apache Software Foundation. All rights reserved.