public class BindingCodeGenUtils extends Object
Modifier and Type | Field and Description |
---|---|
static boolean |
doLog |
Modifier and Type | Method and Description |
---|---|
static InstructionList |
fireInitialBindings()
enumerate all the bindings we have created for this class, and execute each
of them so that initial values get assigned to binding targets.
|
static void |
generateGetter(IABCVisitor emitter,
InstructionList ret,
List<IExpressionNode> expressions,
LexicalScope enclosing_scope)
emits the code for anonymous getter function, then adds to the instruction list for instantiating one onto the stack
|
static MethodInfo |
generatePropertyGetterFunction(IABCVisitor emitter,
ICompilerProject project,
ASScope scope)
generate this function: function(propertyName:String):* { return
target[propertyName]; } where target == "this"
|
static void |
generateSetter(InstructionList ret,
IExpressionNode expression,
LexicalScope enclosing_scope)
emits the code for anonymous setter function, then adds to the instruction list for instantiating one onto the stack
|
static void |
log(InstructionList insns,
String s) |
static void |
log(String s) |
static void |
makeBinding(InstructionList insns,
FlexProject project,
String destStr,
String srcString,
InstructionList methodInstr)
generate code to instantiate a binding object.
|
static void |
makeFunctionWatcher(InstructionList insns,
FlexProject project,
IABCVisitor emitter,
String functionName,
List<String> eventNames,
List<BindingInfo> bindingInfo,
IExpressionNode[] params)
Generates the ABC to instantiate a FunctionReturnWatcher
* VM context:
on entry: nothing on stack
local1 = this.
|
static void |
makeParameterFunction(IABCVisitor emitter,
InstructionList ret,
IExpressionNode[] params)
Generated the "parameter function" required by the FunctionReturnWatcher
constructor.
|
static void |
makePropertyWatcher(boolean makeStaticWatcher,
InstructionList insns,
String propertyName,
List<String> eventNames,
List<BindingInfo> bindingInfo,
MethodInfo propertyGetterFunction,
FlexProject project)
Generates the ABC to instantiate a PropertyWatcher
Can only generate one special case:
single event (Constructor actually takes an array of events. we could easily add that
no property getter function (we use null)
Note that we are passing in references to BindingInfo.
|
static void |
makeXMLWatcher(InstructionList insns,
String propertyName,
List<BindingInfo> bindingInfo,
FlexProject project)
Generate instructions to instantiate an mx.binding.XMLWatcher
|
static void |
trace(InstructionList insns)
debugging function to call "trace"
will use top of stack as string parameter, doesn't change stack depth
|
static void |
trace(InstructionList insns,
String string)
debugging function to all "trace"
|
public static final boolean doLog
public static void generateGetter(IABCVisitor emitter, InstructionList ret, List<IExpressionNode> expressions, LexicalScope enclosing_scope)
ret
- The instruction list being built.expressions
- will be codegened to do the bulk of the getter work
* VM context:
one entry: nothing
exit: new function object for getter on TOSpublic static void generateSetter(InstructionList ret, IExpressionNode expression, LexicalScope enclosing_scope)
ret
- The instruction list being built.expression
- will be codegened to do the bulk of the setter work
* VM context:
one entry: nothing
exit: new function object for getter on TOSpublic static void makeBinding(InstructionList insns, FlexProject project, String destStr, String srcString, InstructionList methodInstr)
insns
- IL to add instructions toproject
- Project we are compiling indestStr
- String representation of the destination expressionsrcString
- String representation of the source expressionmethodInstr
- IL with instructions to put the source function and destination function
on the stack. These will be inserted where they are needed - these will usually
be OP_newfunction, but could be anything that leaves the methods on the stackpublic static void makePropertyWatcher(boolean makeStaticWatcher, InstructionList insns, String propertyName, List<String> eventNames, List<BindingInfo> bindingInfo, MethodInfo propertyGetterFunction, FlexProject project)
public static void makeXMLWatcher(InstructionList insns, String propertyName, List<BindingInfo> bindingInfo, FlexProject project)
insns
- The instruction list being built.propertyName
- The name of a property.bindingInfo
- The binding information for the property.project
- The compiler project.public static void makeFunctionWatcher(InstructionList insns, FlexProject project, IABCVisitor emitter, String functionName, List<String> eventNames, List<BindingInfo> bindingInfo, IExpressionNode[] params)
public static void makeParameterFunction(IABCVisitor emitter, InstructionList ret, IExpressionNode[] params)
This function is like this:
function(): Array { return [param1, param2] };Since that is actually difficult to generate, we are instead generating a simple function that throws an exception that we know will be caught silently by the Flex SDK.
There may be some strange edge cases where this trick won't work, but it will cover the majority of cases BETTER than doing the "right" thing.
emitter
- IABCVisitor
to which generated code is added.ret
- InstructionList
to which code that creates a function
closure for the new parameter function should be added.public static void trace(InstructionList insns, String string)
insns
- The instruction list being built.string
- is a constant string to tracepublic static void trace(InstructionList insns)
insns
- The instruction list being built.public static MethodInfo generatePropertyGetterFunction(IABCVisitor emitter, ICompilerProject project, ASScope scope)
emitter
- The IABCVisitor
that generated code is added to.project
- The ICompilerProject
in which code is being
generated.scope
- The ASScope
that contains the data binding
expression for which a getter is being generated.public static InstructionList fireInitialBindings()
public static void log(String s)
public static void log(InstructionList insns, String s)
Copyright © 2016 The Apache Software Foundation. All rights reserved.