public class ABCGenerator extends Object implements ICodeGenerator
Modifier and Type | Class and Description |
---|---|
static class |
ABCGenerator.ConstantValue
|
ICodeGenerator.IConstantValue
Constructor and Description |
---|
ABCGenerator() |
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 alternate_name)
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.
|
InstructionList |
generateInstructions(IASNode subtree,
int goal_state,
LexicalScope scope,
InstructionList instance_init_insns)
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.
|
static ICodeGeneratorFactory |
getABCGeneratorFactory()
Get an ICodeGeneratorFactory that will always return the same ABCGenerator instance
|
Object |
reduceSubtree(IASNode subtree,
LexicalScope scope,
int goal)
Reduce an AST to its equivalent ABC structures.
|
public ABCBytesRequestResult generate(String synthetic_name_prefix, IASNode root_node, ICompilerProject project) throws InterruptedException
ICodeGenerator
generate
in interface ICodeGenerator
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
public ABCBytesRequestResult generate(ExecutorService executorService, boolean useParallelCodegen, String synthetic_name_prefix, IASNode root_node, ICompilerProject project, boolean inInvisibleCompilationUnit, Map<String,String> encodedDebugFiles) throws InterruptedException
ICodeGenerator
generate
in interface ICodeGenerator
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
public InstructionList generateInstructions(IASNode subtree, int goal_state, LexicalScope scope)
generateInstructions
in interface ICodeGenerator
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.public InstructionList generateInstructions(IASNode subtree, int goal_state, LexicalScope scope, InstructionList instance_init_insns)
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.instance_init_insns
- - a list of instance
initialization instructions collected outside
a constructor body that must be included in the
constructor.public MethodInfo generateFunction(FunctionNode func, LexicalScope enclosing_scope, InstructionList instance_init_insns, Name alternate_name)
Post condition: if instance_init_insns is not null then the method will have been processed as and marked as a constructor.
generateFunction
in interface ICodeGenerator
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.public GenerateFunctionInParallelResult generateFunctionInParallel(ExecutorService executorService, FunctionNode func, LexicalScope enclosing_scope)
ExecutorService
.generateFunctionInParallel
in interface ICodeGenerator
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 ).public void generateMethodBodyForFunction(MethodInfo mi, IASNode node, LexicalScope enclosing_scope, InstructionList instance_init_insns)
generateFunction()
(and also by
generateEventHandler()
in MXMLDocumentDirectiveProcessor).generateMethodBodyForFunction
in interface ICodeGenerator
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.public 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; }
generateMXMLDataBindingSetterFunction
in interface ICodeGenerator
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.public 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
.generateMXMLDataBindingGetterFunction
in interface ICodeGenerator
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.public MethodInfo createMethodInfo(LexicalScope scope, FunctionNode func, Name alternate_name)
createMethodInfo
in interface ICodeGenerator
func
- - A FunctionNode representing a method declaration.public MethodInfo createMethodInfoWithDefaultArgumentValues(LexicalScope scope, FunctionNode func)
createMethodInfoWithDefaultArgumentValues
in interface ICodeGenerator
func
- - A FunctionNode representing a method declaration.public ICodeGenerator.IConstantValue generateConstantValue(IASNode subtree, ICompilerProject project)
generateConstantValue
in interface ICodeGenerator
subtree
- the tree to generate a constant value forproject
- the project to use to evaluate the treepublic Object reduceSubtree(IASNode subtree, LexicalScope scope, int goal) throws Exception
reduceSubtree
in interface ICodeGenerator
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.public static ICodeGeneratorFactory getABCGeneratorFactory()
Copyright © 2016 The Apache Software Foundation. All rights reserved.