class GlobalVarReferenceMap extends java.lang.Object implements ReferenceCollectingCallback.ReferenceMap
ReferenceMap
that is specific to global scope
and can be used in different passes. In other words instead of relying on
Var object it relies on the name of the variable. It also supports hot-swap
update of reference map for a specific script.Modifier and Type | Class and Description |
---|---|
(package private) static class |
GlobalVarReferenceMap.GlobalVarRefCleanupPass
A CleanupPass implementation that will replace references to old Syntactic
Global Scopes generated in previous compile runs with references to the
Global Typed Scope.
|
private static class |
GlobalVarReferenceMap.SourceRefRange |
Modifier and Type | Field and Description |
---|---|
private java.util.Map<InputId,java.lang.Integer> |
inputOrder |
private java.util.Map<java.lang.String,ReferenceCollectingCallback.ReferenceCollection> |
refMap |
Constructor and Description |
---|
GlobalVarReferenceMap(java.util.List<CompilerInput> inputs,
java.util.List<CompilerInput> externs) |
Modifier and Type | Method and Description |
---|---|
private GlobalVarReferenceMap.SourceRefRange |
findSourceRefRange(java.util.List<ReferenceCollectingCallback.Reference> refList,
InputId inputId)
Finds the range of references associated to
sourceName . |
ReferenceCollectingCallback.ReferenceCollection |
getReferences(Var var) |
private void |
removeScriptReferences(InputId inputId) |
private void |
replaceReferences(java.lang.String varName,
InputId inputId,
ReferenceCollectingCallback.ReferenceCollection newSourceCollection) |
private void |
resetGlobalVarReferences(java.util.Map<Var,ReferenceCollectingCallback.ReferenceCollection> globalRefMap)
Resets global var reference map with the new provide map.
|
(package private) void |
updateGlobalVarReferences(java.util.Map<Var,ReferenceCollectingCallback.ReferenceCollection> refMapPatch,
Node root)
Updates the internal reference map based on the provided parameters.
|
void |
updateReferencesWithGlobalScope(Scope globalScope) |
private java.util.Map<java.lang.String,ReferenceCollectingCallback.ReferenceCollection> refMap
private final java.util.Map<InputId,java.lang.Integer> inputOrder
GlobalVarReferenceMap(java.util.List<CompilerInput> inputs, java.util.List<CompilerInput> externs)
inputs
- The ordered list of all inputs for the compiler.public ReferenceCollectingCallback.ReferenceCollection getReferences(Var var)
getReferences
in interface ReferenceCollectingCallback.ReferenceMap
private void resetGlobalVarReferences(java.util.Map<Var,ReferenceCollectingCallback.ReferenceCollection> globalRefMap)
globalRefMap
- The reference map result of a
ReferenceCollectingCallback
pass collected from the whole AST.void updateGlobalVarReferences(java.util.Map<Var,ReferenceCollectingCallback.ReferenceCollection> refMapPatch, Node root)
scriptRoot
is not SCRIPT, it basically replaces the internal map
with the new one, otherwise it replaces all the information associated to
the given script.refMapPatch
- The reference map result of a
ReferenceCollectingCallback
pass which might be collected from
the whole AST or just a sub-tree associated to a SCRIPT node.root
- AST sub-tree root on which reference collection was done.private void removeScriptReferences(InputId inputId)
private void replaceReferences(java.lang.String varName, InputId inputId, ReferenceCollectingCallback.ReferenceCollection newSourceCollection)
private GlobalVarReferenceMap.SourceRefRange findSourceRefRange(java.util.List<ReferenceCollectingCallback.Reference> refList, InputId inputId)
sourceName
. Note that
even if there is no sourceName references the returned information can be
used to decide where to insert new sourceName refs.public void updateReferencesWithGlobalScope(Scope globalScope)
globalScope
- a new Global Scope to replace the scope of references
with.