public abstract class AbstractCompiler extends java.lang.Object implements SourceExcerptProvider
Modifier and Type | Class and Description |
---|---|
(package private) static class |
AbstractCompiler.ConfigContext
Represents the different contexts for which the compiler could have
distinct configurations.
|
(package private) static class |
AbstractCompiler.LifeCycleStage |
SourceExcerptProvider.ExcerptFormatter, SourceExcerptProvider.SourceExcerpt
Modifier and Type | Field and Description |
---|---|
(package private) boolean |
needsEs6DartRuntime |
(package private) boolean |
needsEs6Runtime |
(package private) static DiagnosticType |
READ_ERROR |
private AbstractCompiler.LifeCycleStage |
stage |
Constructor and Description |
---|
AbstractCompiler() |
Modifier and Type | Method and Description |
---|---|
(package private) abstract void |
addChangeHandler(CodeChangeHandler handler)
Register a listener for code change events.
|
(package private) abstract void |
addComments(java.lang.String filename,
java.util.List<Comment> comments) |
(package private) abstract void |
addToDebugLog(java.lang.String message)
Logs a message under a central logger.
|
(package private) abstract void |
afterPass(java.lang.String passName)
Will be called after each pass finishes.
|
(package private) abstract boolean |
areNodesEqualForInlining(Node n1,
Node n2)
Are the nodes equal for the purpose of inlining?
If type aware optimizations are on, type equality is checked.
|
(package private) abstract void |
beforePass(java.lang.String passName)
Will be called before each pass runs.
|
(package private) abstract Node |
ensureLibraryInjected(java.lang.String resourceName,
boolean normalizeAndUniquifyNames)
The subdir js/ contains libraries of code that we inject
at compile-time only if requested by this function.
|
(package private) abstract void |
forwardDeclareType(java.lang.String typeName) |
abstract CodingConvention |
getCodingConvention()
Gets the current coding convention.
|
(package private) abstract java.util.List<Comment> |
getComments(java.lang.String filename)
Returns all the comments from the given file.
|
(package private) abstract CssRenamingMap |
getCssRenamingMap()
Gets the CssRenamingMap.
|
(package private) abstract com.google.common.collect.ImmutableMap<java.lang.String,Node> |
getDefaultDefineValues()
Gets a map of default @define values.
|
(package private) abstract ErrorReporter |
getDefaultErrorReporter()
Gets a default error reporter for injecting into Rhino.
|
(package private) abstract CheckLevel |
getErrorLevel(JSError error) |
abstract ErrorManager |
getErrorManager()
Gets the error manager.
|
(package private) abstract java.util.Set<java.lang.String> |
getExternProperties()
Gets the names of the properties defined in externs or null if
GatherExternProperties pass was not run yet.
|
(package private) abstract GlobalVarReferenceMap |
getGlobalVarReferences()
This can be used to get the list of all references to all global variables
based on all previous calls to
updateGlobalVarReferences . |
(package private) abstract java.lang.Iterable<TypeValidator.TypeMismatch> |
getImplicitInterfaceUses()
Gets all types that are used implicitly as a
matching structural interface type.
|
abstract CompilerInput |
getInput(InputId inputId)
Looks up an input (possibly an externs input) by input id.
|
(package private) abstract java.util.List<CompilerInput> |
getInputsInOrder()
Gets the inputs in the order in which they are being processed.
|
(package private) abstract Node |
getJsRoot()
Returns the root of the source tree, ignoring externs
|
(package private) abstract CompilerOptions.LanguageMode |
getLanguageMode()
The language mode of the current root node.
|
(package private) abstract java.lang.String |
getLastPassName()
Gets the last pass name set by setProgress.
|
(package private) AbstractCompiler.LifeCycleStage |
getLifeCycleStage() |
(package private) abstract JSModuleGraph |
getModuleGraph()
Gets the module graph.
|
(package private) abstract Node |
getNodeForCodeInsertion(JSModule module)
Gets a suitable SCRIPT node to serve as a parent for code insertion.
|
(package private) abstract CompilerOptions |
getOptions() |
(package private) abstract Config |
getParserConfig(AbstractCompiler.ConfigContext context)
Returns the parser configuration for the specified context.
|
abstract double |
getProgress() |
abstract ReverseAbstractInterpreter |
getReverseAbstractInterpreter()
Get an interpreter for type analysis.
|
(package private) abstract Node |
getRoot()
Returns the root node of the AST, which includes both externs and source.
|
(package private) abstract SimpleDefinitionFinder |
getSimpleDefinitionFinder()
Used by three passes that run in sequence (optimize-returns,
optimize-parameters, remove-unused-variables), to avoid having them
recompute it independently.
|
(package private) abstract SourceFile |
getSourceFileByName(java.lang.String sourceName)
Looks up a source file by name.
|
(package private) abstract GlobalTypeInfo |
getSymbolTable()
Used only by the new type inference
|
(package private) abstract CompilerInput |
getSynthesizedExternsInput() |
(package private) abstract CompilerInput |
getSynthesizedExternsInputAtEnd() |
abstract TypedScope |
getTopScope()
Gets the top scope.
|
(package private) abstract ScopeCreator |
getTypedScopeCreator()
Gets a memoized scope creator with type information.
|
abstract TypeIRegistry |
getTypeIRegistry() |
(package private) abstract java.lang.Iterable<TypeValidator.TypeMismatch> |
getTypeMismatches()
Gets the central registry of type violations.
|
abstract JSTypeRegistry |
getTypeRegistry()
Gets a central registry of type information from the compiled JS.
|
(package private) abstract TypeValidator |
getTypeValidator()
Only used by passes in the old type checker.
|
(package private) abstract com.google.common.base.Supplier<java.lang.String> |
getUniqueNameIdSupplier()
Generates unique ids.
|
(package private) abstract boolean |
hasHaltingErrors() |
(package private) abstract boolean |
hasRegExpGlobalReferences() |
(package private) abstract boolean |
hasScopeChanged(Node n)
True iff a function changed since the last time a pass was run
|
(package private) abstract boolean |
isIdeMode()
Returns true if compiling in IDE mode.
|
(package private) abstract Node |
parseSyntheticCode(java.lang.String code)
Parses code for injecting.
|
(package private) abstract Node |
parseSyntheticCode(java.lang.String filename,
java.lang.String code)
Parses code for injecting, and associate it with a given source file.
|
(package private) abstract Node |
parseTestCode(java.lang.String code)
Parses code for testing.
|
(package private) abstract void |
prepareAst(Node root)
Normalizes the types of AST nodes in the given tree, and
annotates any nodes to which the coding convention applies so that passes
can read the annotations instead of using the coding convention.
|
(package private) abstract void |
process(CompilerPass pass)
Runs a given compiler-pass by calling its
process() method. |
(package private) abstract void |
removeChangeHandler(CodeChangeHandler handler)
Remove a listener for code change events.
|
abstract void |
report(JSError error)
Report an error or warning.
|
(package private) abstract void |
reportChangeToEnclosingScope(Node n)
Passes that do cross-scope modifications use this (eg, InlineVariables)
|
abstract void |
reportCodeChange()
Report code changes.
|
(package private) abstract void |
setCssRenamingMap(CssRenamingMap map)
Sets the CssRenamingMap.
|
(package private) abstract void |
setDefaultDefineValues(com.google.common.collect.ImmutableMap<java.lang.String,Node> values)
Stores a map of default @define values.
|
(package private) abstract void |
setExternProperties(java.util.Set<java.lang.String> externProperties)
Sets the names of the properties defined in externs.
|
(package private) abstract void |
setHasRegExpGlobalReferences(boolean references)
Set if RegExp global properties are used.
|
(package private) abstract void |
setLanguageMode(CompilerOptions.LanguageMode mode) |
(package private) void |
setLifeCycleStage(AbstractCompiler.LifeCycleStage stage)
Set the current life-cycle state.
|
(package private) abstract void |
setProgress(double progress,
java.lang.String lastPassName)
Sets the progress percentage as well as the name of the last pass that
ran (if available).
|
(package private) abstract void |
setScope(Node n)
Let the PhaseOptimizer know which scope a pass is currently analyzing
|
(package private) abstract void |
setSimpleDefinitionFinder(SimpleDefinitionFinder defFinder) |
(package private) abstract void |
setSymbolTable(GlobalTypeInfo symbolTable) |
(package private) abstract void |
throwInternalError(java.lang.String msg,
java.lang.Exception cause)
Report an internal error.
|
abstract java.lang.String |
toSource(Node root)
Prints a node to source code.
|
(package private) abstract void |
updateGlobalVarReferences(java.util.Map<Var,ReferenceCollectingCallback.ReferenceCollection> refMapPatch,
Node collectionRoot)
Updates the list of references for variables in global scope.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
getSourceLine, getSourceMapping, getSourceRegion
static final DiagnosticType READ_ERROR
boolean needsEs6Runtime
boolean needsEs6DartRuntime
private AbstractCompiler.LifeCycleStage stage
abstract void beforePass(java.lang.String passName)
abstract void afterPass(java.lang.String passName)
public abstract CompilerInput getInput(InputId inputId)
abstract SourceFile getSourceFileByName(java.lang.String sourceName)
abstract JSModuleGraph getModuleGraph()
abstract java.util.List<CompilerInput> getInputsInOrder()
AbstractCompilerRunner
.public abstract JSTypeRegistry getTypeRegistry()
public abstract TypeIRegistry getTypeIRegistry()
abstract void forwardDeclareType(java.lang.String typeName)
abstract ScopeCreator getTypedScopeCreator()
public abstract TypedScope getTopScope()
public abstract void report(JSError error)
abstract void throwInternalError(java.lang.String msg, java.lang.Exception cause)
public abstract CodingConvention getCodingConvention()
public abstract void reportCodeChange()
abstract void addToDebugLog(java.lang.String message)
abstract void setCssRenamingMap(CssRenamingMap map)
abstract CssRenamingMap getCssRenamingMap()
abstract Node getNodeForCodeInsertion(JSModule module)
module
contains any inputs, the returned node will be the SCRIPT
node corresponding to its first input. If module
is empty, on the
other hand, then the returned node will be the first SCRIPT node in a
non-empty module that module
depends on (the deepest one possible).module
- A module. If null, will return the first SCRIPT node of all
modules.abstract TypeValidator getTypeValidator()
abstract java.lang.Iterable<TypeValidator.TypeMismatch> getTypeMismatches()
abstract java.lang.Iterable<TypeValidator.TypeMismatch> getImplicitInterfaceUses()
abstract GlobalTypeInfo getSymbolTable()
abstract void setSymbolTable(GlobalTypeInfo symbolTable)
abstract SimpleDefinitionFinder getSimpleDefinitionFinder()
abstract void setSimpleDefinitionFinder(SimpleDefinitionFinder defFinder)
abstract Node parseSyntheticCode(java.lang.String code)
abstract Node parseSyntheticCode(java.lang.String filename, java.lang.String code)
abstract Node parseTestCode(java.lang.String code)
public abstract java.lang.String toSource(Node root)
abstract ErrorReporter getDefaultErrorReporter()
public abstract ReverseAbstractInterpreter getReverseAbstractInterpreter()
AbstractCompiler.LifeCycleStage getLifeCycleStage()
abstract com.google.common.base.Supplier<java.lang.String> getUniqueNameIdSupplier()
abstract boolean hasHaltingErrors()
abstract void addChangeHandler(CodeChangeHandler handler)
abstract void removeChangeHandler(CodeChangeHandler handler)
abstract void setScope(Node n)
abstract Node getJsRoot()
abstract boolean hasScopeChanged(Node n)
abstract void reportChangeToEnclosingScope(Node n)
abstract boolean isIdeMode()
abstract Config getParserConfig(AbstractCompiler.ConfigContext context)
abstract void prepareAst(Node root)
public abstract ErrorManager getErrorManager()
void setLifeCycleStage(AbstractCompiler.LifeCycleStage stage)
abstract boolean areNodesEqualForInlining(Node n1, Node n2)
abstract void setHasRegExpGlobalReferences(boolean references)
references
- Whether there are references to the RegExp global object
properties.abstract boolean hasRegExpGlobalReferences()
abstract CheckLevel getErrorLevel(JSError error)
abstract void process(CompilerPass pass)
process()
method.pass
- The pass to be run.abstract Node getRoot()
abstract CompilerOptions getOptions()
abstract CompilerOptions.LanguageMode getLanguageMode()
CompilerOptions
before transpilation happens, and
match the languageOut field after transpilation.abstract void setLanguageMode(CompilerOptions.LanguageMode mode)
abstract void updateGlobalVarReferences(java.util.Map<Var,ReferenceCollectingCallback.ReferenceCollection> refMapPatch, Node collectionRoot)
refMapPatch
- Maps each variable to all of its references; may contain
references collected from the whole AST or only a SCRIPT sub-tree.collectionRoot
- The root of sub-tree in which reference collection
has been done. This should either be a SCRIPT node (if collection is
done on a single file) or it is assumed that collection is on full AST.abstract GlobalVarReferenceMap getGlobalVarReferences()
updateGlobalVarReferences
.abstract CompilerInput getSynthesizedExternsInput()
abstract CompilerInput getSynthesizedExternsInputAtEnd()
public abstract double getProgress()
abstract java.lang.String getLastPassName()
abstract void setProgress(double progress, @Nullable java.lang.String lastPassName)
progress
- A precentage expressed as a double in the range [0, 1].
Use -1 if you just want to set the last pass name.abstract Node ensureLibraryInjected(java.lang.String resourceName, boolean normalizeAndUniquifyNames)
resourceName
- The name of the library. For example, if "base" is
is specified, then we load js/base.jsnormalizeAndUniquifyNames
- Whether to normalize the library code and make
names unique.abstract void setExternProperties(java.util.Set<java.lang.String> externProperties)
externProperties
- The set of property names defined in externs.abstract java.util.Set<java.lang.String> getExternProperties()
abstract void addComments(java.lang.String filename, java.util.List<Comment> comments)
abstract java.util.List<Comment> getComments(java.lang.String filename)
abstract void setDefaultDefineValues(com.google.common.collect.ImmutableMap<java.lang.String,Node> values)
abstract com.google.common.collect.ImmutableMap<java.lang.String,Node> getDefaultDefineValues()