public class LexicalScope extends Object
Modifier and Type | Class and Description |
---|---|
static class |
LexicalScope.NestingState
The nesting state of a function.
|
protected static class |
LexicalScope.TempManager
Utility class to manage the allocation and merging of temps within
lexical scopes.
|
static class |
LexicalScope.VariableMutability
Mutability settings for a variable declaration.
|
Modifier and Type | Field and Description |
---|---|
static Name |
anyType
The "*" type.
|
static int |
DEBUG_LINE_UNKNOWN
Manifest constant for "debug line number not known."
|
protected MethodBodySemanticChecker |
methodBodySemanticChecker
The semantic checker for this compilation.
|
static Object |
noInitializer
Constant initializer not present.
|
Modifier | Constructor and Description |
---|---|
protected |
LexicalScope()
constructor which should only ever be called
by
GlobalLexicalScope |
protected |
LexicalScope(LexicalScope enclosingFrame)
constructor which is called whenever pushing a new
lexical scope
|
protected |
LexicalScope(LexicalScope enclosingFrame,
boolean mergableTempManager)
constructor which is called whenever pushing a new
lexical scope, and the temps are potentially going
to be shared with enclosing scope.
|
Modifier and Type | Method and Description |
---|---|
void |
addDefaultValue(PooledValue value)
Add a default value to the currently compiling method.
|
protected void |
addHasNexts(Collection<org.apache.flex.compiler.internal.as.codegen.LexicalScope.Hasnext2Wrapper> nexts)
Add a collection of hasnext wrappers to the collection of
hasnexts in this lexical scope.
|
protected void |
addInlinedBindings(Collection<Binding> bindings)
Add a collection of bindings to the collection of inlined bindings
in this lexical scope.
|
void |
addProblem(ICompilerProblem problem)
Add a problem to this code generation phase.
|
void |
addProblems(Collection<ICompilerProblem> problems)
Add a collection of problems to this code generation phase.
|
Binding |
allocateTemp()
Allocate a temporary register.
|
Binding |
allocateTemp(boolean reuse_free)
Allocate a temporary register.
|
void |
declareVariableName(Name n)
Add a variable name to the set of known names.
|
boolean |
emitFile(String candidate) |
boolean |
emitLine(int candidate) |
InstructionList |
findProperty(Binding binding,
boolean useStrict)
Get the property for the specified binding.
|
InstructionList |
findProperty(Name name,
IDefinition def,
boolean useStrict)
Get the property for the specified name.
|
void |
finishClassStaticInitializer(InstructionList cinit_insns)
Finish a class static initializer method.
|
void |
generateBindableGetter(IDefinition bindableVarDef,
Name var_name,
Name backingPropertyName,
Name var_type,
IMetaInfo[] metaTags) |
void |
generateBindableSetter(IDefinition bindableVarDef,
Name var_name,
Name backingPropertyName,
Name var_type,
IMetaInfo[] metaTags) |
Binding |
getBinding(IASNode node,
Name name,
IDefinition def)
Get or create the Binding for a Name and its associated IDefinition.
|
Binding |
getBinding(IDefinition def)
Get or create the Binding for an IDefinition.
|
String |
getDebugFile() |
LexicalScope |
getEnclosingFrame() |
ControlFlowContextManager |
getFlowManager()
Create a ControlFlowContextManager on demand.
|
ICodeGenerator |
getGenerator() |
GlobalLexicalScope |
getGlobalScope() |
protected Collection<org.apache.flex.compiler.internal.as.codegen.LexicalScope.Hasnext2Wrapper> |
getHasNexts() |
boolean |
getInInvisibleCompilationUnit() |
InstructionList |
getInitInstructions() |
IASScope |
getLocalASScope() |
protected Collection<Binding> |
getLocalBindings() |
MethodBodySemanticChecker |
getMethodBodySemanticChecker() |
MethodInfo |
getMethodInfo() |
LexicalScope.NestingState |
getNestingState() |
Vector<Name> |
getParamTypes() |
Collection<ICompilerProblem> |
getProblems() |
ICompilerProject |
getProject() |
InstructionList |
getPropertyValue(Binding binding)
Get the property value for the specified binding.
|
InstructionList |
getPropertyValue(Name name,
IDefinition def)
Get the property value for the specified name.
|
protected Binding |
getThisBinding(IdentifierNode id)
Fetch the Binding that represents "this."
|
void |
initializeTempRegisters(int base)
Give all temporaries a register number.
|
boolean |
insideInlineFunction()
Test whether we are currently inside the scope of a function being inlined.
|
boolean |
isGlobalScope() |
boolean |
isLocalDefinition(IDefinition candidate) |
void |
makeBindableVariable(Binding var,
Name var_type,
IMetaInfo[] metaTags)
Create a bindable property.
|
void |
makeNamespace(Binding ns_binding,
Namespace ns_init)
Declare and define a namespace.
|
void |
makeParameter(IDefinition def,
Name param_type)
Declare an explicit parameter.
|
void |
makeVariable(Binding var)
Create a variable with potential visibility
to nested scopes.
|
void |
makeVariable(Binding var,
Name var_type,
IMetaInfo[] meta_tags)
Create a variable with potential visibility
to nested scopes.
|
void |
makeVariable(Binding var,
Name var_type,
IMetaInfo[] meta_tags,
Object initializer)
Create a variable with potential visibility
to nested scopes.
|
void |
makeVariable(Binding var,
Name var_type,
IMetaInfo[] meta_tags,
Object initializer,
LexicalScope.VariableMutability mutability)
Create a variable with potential visibility
to nested scopes.
|
protected void |
mergeTemps(LexicalScope scopeToMerge)
Merge the temps from the specified lexical scope into this lexical scope.
|
boolean |
needsActivation() |
boolean |
needsArguments() |
boolean |
needsHoistedInitInsns(Name var_name,
boolean has_initializer)
Helper method to determine if a variable binding has already been referenced.
|
boolean |
needsThis() |
LexicalScope |
popFrame()
Pop the current lexical scope.
|
void |
processMetadata(ITraitVisitor tv,
IMetaInfo[] meta_infos)
Metadata management - works on IMetaInfo,
which is a common interface of IMetaTagNode and IMetaTag.
|
LexicalScope |
pushFrame()
Push a new lexical scope.
|
InlineFunctionLexicalScope |
pushInlineFunctionFrame(IASScope containingScope,
boolean storeClassBinding,
FunctionNode functionNode)
Push a new lexical scope for a function being inlined.
|
void |
releaseTemp(Binding temp)
Release a temporary register.
|
void |
resetDebugInfo()
Reset the debug info to initial values.
|
void |
resetMethodInfo()
Reset this scope's MethodInfo to null; called from
a ClassDirectiveProcessor's static initialization
error recovery logic.
|
Binding |
resolveName(IdentifierNode id)
Resolve a name, and return a Binding for it.
|
void |
setDebugFile(String file_name)
Set the debug info file name.
|
void |
setDebugLine(int line_num)
Set the debug info line number.
|
void |
setLocalASScope(IASScope scope)
Set this LexicalScope's corresponding ASScope.
|
void |
setMethodInfo(MethodInfo methodInfo)
sets this scope's MethodInfo,
|
void |
setNeedsActivation()
Turn on thie scope's method's NEED_ACTIVATION flag;
this will cause the AVM to allocate an activation
object when the method is called.
|
void |
setNeedsArguments()
Turn on this scope's method's NEED_ARGUMENTS flag;
this will cause the AVM to allocate an implicit
arguments parameter when the method is called.
|
void |
setNeedsRest()
Turn on this scope's NEED_REST flag.
|
void |
setSetsDxns()
Turn on this scope's SETS_DXNS flag.
|
void |
transferInitializerData()
Transfer information about local initializers from the
scope in which they were declared (the class or instance scope)
to this scope (a constructor).
|
public static final Name anyType
public static final Object noInitializer
public static final int DEBUG_LINE_UNKNOWN
protected MethodBodySemanticChecker methodBodySemanticChecker
protected LexicalScope()
GlobalLexicalScope
protected LexicalScope(LexicalScope enclosingFrame)
enclosingFrame
- the parent frameprotected LexicalScope(LexicalScope enclosingFrame, boolean mergableTempManager)
enclosingFrame
- the parent framepublic void makeVariable(Binding var)
var
- The variable bindingpublic void makeVariable(Binding var, Name var_type, IMetaInfo[] meta_tags)
var
- The variable bindingvar_type
- The Name of the type of the variablemeta_tags
- The metadata on the variablepublic void makeVariable(Binding var, Name var_type, IMetaInfo[] meta_tags, Object initializer)
var
- The variable bindingvar_type
- The Name of the type of the variablemeta_tags
- The metadata on the variableinitializer
- An initializer. null if no initializer. only consts can have an initializerpublic void makeVariable(Binding var, Name var_type, IMetaInfo[] meta_tags, Object initializer, LexicalScope.VariableMutability mutability)
var
- The variable bindingvar_type
- The Name of the type of the variablemeta_tags
- The metadata on the variableinitializer
- An initializer. null if no initializer. only consts can have an initializermutability
- - the caller's desired mutability.public boolean needsHoistedInitInsns(Name var_name, boolean has_initializer)
var_name
- The name for the variablepublic void declareVariableName(Name n)
n
- - the Name to add.public void makeBindableVariable(Binding var, Name var_type, IMetaInfo[] metaTags)
This method must only be called on the thread that started code generation of the syntax tree that contains the bindable variable. This constraint is met today, because we do not generate code for classes in parallel and bindable variables are always be class members.
metaTags
- The IMetaTagsNode representing the metadata nodes for
this definition. If it is null, this method will ask the varDef for the
metadata - some callers of this method will not have an MetaTagsNode in
the AST, and want the metadata from the definitionpublic void generateBindableGetter(IDefinition bindableVarDef, Name var_name, Name backingPropertyName, Name var_type, IMetaInfo[] metaTags)
public void generateBindableSetter(IDefinition bindableVarDef, Name var_name, Name backingPropertyName, Name var_type, IMetaInfo[] metaTags)
public void makeNamespace(Binding ns_binding, Namespace ns_init)
ns_binding
- - the namespace declaration's binding.ns_init
- - the namespace definition's initial AET Namespace. May not be null.public void makeParameter(IDefinition def, Name param_type)
def
- - the parameter's definition.param_type
- - the name of the parameter's type.public void addDefaultValue(PooledValue value)
which is called first.
public boolean needsThis()
public Vector<Name> getParamTypes()
public MethodInfo getMethodInfo()
public void setMethodInfo(MethodInfo methodInfo)
public void resetMethodInfo()
public Binding allocateTemp()
public Binding allocateTemp(boolean reuse_free)
reuse_free
- - re-use a free temp if set.public void releaseTemp(Binding temp)
temp
- - the temp's Binding.allocateTemp()
protected void mergeTemps(LexicalScope scopeToMerge)
scopeToMerge
- the scope containing the temps to mergeprotected void addInlinedBindings(Collection<Binding> bindings)
bindings
- the bindings to addprotected void addHasNexts(Collection<org.apache.flex.compiler.internal.as.codegen.LexicalScope.Hasnext2Wrapper> nexts)
nexts
- the hasnexts to addprotected Collection<org.apache.flex.compiler.internal.as.codegen.LexicalScope.Hasnext2Wrapper> getHasNexts()
protected Collection<Binding> getLocalBindings()
public IASScope getLocalASScope()
public void setLocalASScope(IASScope scope)
public boolean isLocalDefinition(IDefinition candidate)
candidate
- - the IDefinition under examination.public Binding resolveName(IdentifierNode id)
id
- The IdentifierNode you need a Binding forpublic Binding getBinding(IDefinition def)
def
- - the IDefinition.public Binding getBinding(IASNode node, Name name, IDefinition def)
name
- - the name under consideration.def
- - the name's IDefinition.protected Binding getThisBinding(IdentifierNode id)
public InstructionList findProperty(Binding binding, boolean useStrict)
binding
- Binding of the property to finduseStrict
- Use OP_findpropstrictpublic InstructionList findProperty(Name name, IDefinition def, boolean useStrict)
name
- Name of the property to finddef
- Definition of the property to finduseStrict
- Use OP_findpropstrictpublic InstructionList getPropertyValue(Binding binding)
binding
- Binding of the property to findpublic InstructionList getPropertyValue(Name name, IDefinition def)
name
- Name of the property to finddef
- Definition of the property to findpublic LexicalScope getEnclosingFrame()
public void finishClassStaticInitializer(InstructionList cinit_insns)
cinit_insns
- - initialization instructions.
Classes may have ad-hoc static initialization code,
so the content of this list is arbitrary.public void initializeTempRegisters(int base)
public LexicalScope pushFrame()
public InlineFunctionLexicalScope pushInlineFunctionFrame(IASScope containingScope, boolean storeClassBinding, FunctionNode functionNode)
public boolean insideInlineFunction()
public LexicalScope popFrame()
public boolean isGlobalScope()
public final GlobalLexicalScope getGlobalScope()
public boolean needsActivation()
public void setNeedsActivation()
public boolean needsArguments()
public void setNeedsArguments()
public void setNeedsRest()
public void setSetsDxns()
public ControlFlowContextManager getFlowManager()
public void processMetadata(ITraitVisitor tv, IMetaInfo[] meta_infos)
public boolean emitFile(String candidate)
public boolean emitLine(int candidate)
public void setDebugFile(String file_name)
file_name
- - the name to set. May be null.public String getDebugFile()
public void setDebugLine(int line_num)
line_num
- - the line number to set.public void resetDebugInfo()
public LexicalScope.NestingState getNestingState()
public void transferInitializerData()
public ICompilerProject getProject()
public ICodeGenerator getGenerator()
public boolean getInInvisibleCompilationUnit()
IDefinition
's for package/file classes,
interfaces, function's, var's, const's, and namespaces need to be
normalized before comparing them by identity in some semantic checks (
namely the type conversion checks ).
Also, in this case, we must do additional checking to determine
whether an import is valid.public InstructionList getInitInstructions()
public MethodBodySemanticChecker getMethodBodySemanticChecker()
public Collection<ICompilerProblem> getProblems()
public void addProblem(ICompilerProblem problem)
problem
- The ICompilerProblem
to add.public void addProblems(Collection<ICompilerProblem> problems)
problems
- The collection of ICompilerProblem
objects to add.Copyright © 2016 The Apache Software Foundation. All rights reserved.