Class AbstractCompiler
- All Implemented Interfaces:
CompilerInputProvider,SourceExcerptProvider
- Direct Known Subclasses:
Compiler
This is an abstract class, so that we can make the methods package-private.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enumWhat point in optimizations we're in.Nested classes/interfaces inherited from interface com.google.javascript.jscomp.SourceExcerptProvider
SourceExcerptProvider.ExcerptFormatter, SourceExcerptProvider.SourceExcerpt -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionabstract voidaddExportedNames(Set<String> exportedVariableNames) Adds exported names to keep track.abstract voidaddInputSourceMap(String name, SourceMapInput sourceMap) Adds aSourceMapInputfor the givensourceFileName, to be used for error reporting and source map combining.abstract voidfinal com.google.javascript.jscomp.AstFactoryReturns a new AstFactory that will add type information to the nodes it creates if and only if type checking has already happened and types have not been converted into colors.final com.google.javascript.jscomp.AstFactoryReturns a new AstFactory that will not add type information, regardless of whether type checking has already happened.com.google.javascript.jscomp.ExpressionDecomposercom.google.javascript.jscomp.ExpressionDecomposercreateExpressionDecomposer(Supplier<String> uniqueNameIdSupplier, com.google.common.collect.ImmutableSet<String> knownConstantFunctions, Scope scope) final LogFilecreateOrReopenIndexedLog(Class<?> owner, String firstNamePart, String... restNameParts) Provides logging access to a file with the specified name, differentiated by the index of the current pass.final LogFilecreateOrReopenLog(Class<?> owner, String firstNamePart, String... restNameParts) Provides logging access to a file with the specified name.Returns a new AstAnalyzer configured correctly to answer questions about Nodes in the AST currently being compiled.abstract StringgetBase64SourceMapContents(String sourceFileName) abstract CodingConventionGets the current coding convention.abstract ColorRegistryGets a central registry of colors from deserialized JS types.abstract IdGeneratorGets the id generator for cross-module motion.abstract com.google.common.collect.ImmutableSet<String> abstract ErrorManagerGets the error manager.Gets the names that have been exported.abstract com.google.common.collect.ImmutableSet<String> Gets the names of the properties defined in externs or null if GatherExternProperties pass was not run yet.abstract CompilerInputLooks up an input (possibly an externs input) by input id.Returns the current life-cycle stage of the AST we're working on.abstract ModuleMapabstract ModuleMetadataMapabstract ReverseAbstractInterpreterGet an interpreter for type analysis.abstract NodegetRoot()Returns the root node of the AST, which includes both externs and source.abstract @Nullable NodegetScriptNode(String filename) abstract @Nullable TypedScopeGets the top scope.abstract booleanGets whether any file needed to transpile any featureabstract Iterable<TypeMismatch> Gets the central registry of type violations.abstract JSTypeRegistryGets a central registry of type information from the compiled JS.abstract booleanWhether the AST has been annotated with optimization colors.abstract booleanReturns whether the typechecking passes have runvoidinitRuntimeLibraryTypedAsts(com.google.common.base.Optional<ColorPool.Builder> colorPoolBuilder) Deserialize runtime libraries from a TypedAST packaged as a JAR resource and reconcile their Colors with the current inputs.final booleanstatic booleanisFillFileName(String fileName) Returns whether a file name was created bycreateFillFileName(java.lang.String).abstract booleanReturns `true` when type checking has run, but the type registry has been cleared.abstract NodeparseSyntheticCode(String filename, String code) Parses code for injecting, and associate it with a given source file.abstract voidReport an error or warning.abstract voidreportAmbiguatePropertiesSummary(Supplier<String> summarySupplier) Used by `AmbiguateProperties` to record a one-line summary of the work it accomplished, if any.abstract voidreportChangeToChangeScope(Node changeScopeRoot) Mark modifications in a scope that is different than the Compiler.currentScope use this (eg, InlineVariables and many others)abstract voidPasses that make modifications in a scope that is different than the Compiler.currentScope use this (eg, InlineVariables and many others)abstract voidreportDisambiguatePropertiesSummary(Supplier<String> summarySupplier) Used by `DisambiguateProperties` to record a one-line summary of the work it accomplished, if any.abstract voidsetAccessorSummary(com.google.javascript.jscomp.AccessorSummary summary) Sets the summary of properties with getters and setters.abstract voidsetAnonymousFunctionNameMap(VariableMap functionMap) Sets the naming map for anonymous functionsabstract voidsetColorRegistry(ColorRegistry registry) Sets the color registryabstract voidsetCssNames(Set<String> newCssNames) Sets the css names found during compilation.abstract voidsetDefineNames(Collection<String> defineNames) Adds @define names to keep track.abstract voidsetIdGeneratorMap(String serializedIdMappings) Sets the id generator for cross-module motion.abstract voidsetInstrumentationMapping(VariableMap instrumentationMapping) Sets the mapping for instrumentation parameter encoding.abstract voidsetModuleMap(ModuleMap moduleMap) abstract voidsetModuleMetadataMap(ModuleMetadataMap moduleMetadataMap) abstract voidsetPropertyMap(VariableMap propertyMap) Sets the property renaming mapabstract voidsetStringMap(VariableMap stringMap) Sets the string replacement mapabstract voidsetVariableMap(VariableMap variableMap) Sets the variable renaming mapabstract StringtoSource()Prints a node to source code.abstract StringPrints a node to source code.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface com.google.javascript.jscomp.SourceExcerptProvider
getSourceLine, getSourceLines, getSourceMapping, getSourceRegion
-
Constructor Details
-
AbstractCompiler
public AbstractCompiler()
-
-
Method Details
-
getInput
Looks up an input (possibly an externs input) by input id. May return null.- Specified by:
getInputin interfaceCompilerInputProvider
-
getScriptNode
-
addExportedNames
Adds exported names to keep track. -
getExportedNames
Gets the names that have been exported. -
setDefineNames
Adds @define names to keep track. -
getDefineNames
-
setVariableMap
Sets the variable renaming map -
setPropertyMap
Sets the property renaming map -
setStringMap
Sets the string replacement map -
setCssNames
Sets the css names found during compilation. -
setInstrumentationMapping
Sets the mapping for instrumentation parameter encoding. -
setIdGeneratorMap
Sets the id generator for cross-module motion. -
getTranspiledFiles
public abstract boolean getTranspiledFiles()Gets whether any file needed to transpile any feature -
getCrossModuleIdGenerator
Gets the id generator for cross-module motion. -
setAnonymousFunctionNameMap
Sets the naming map for anonymous functions -
hasTypeCheckingRun
public abstract boolean hasTypeCheckingRun()Returns whether the typechecking passes have run -
hasOptimizationColors
public abstract boolean hasOptimizationColors()Whether the AST has been annotated with optimization colors. -
isTypeRegistryCleared
public abstract boolean isTypeRegistryCleared()Returns `true` when type checking has run, but the type registry has been cleared.See also `clearJSTypeRegistry()`.
-
getTypeRegistry
Gets a central registry of type information from the compiled JS. -
clearJSTypeRegistry
public abstract void clearJSTypeRegistry() -
getColorRegistry
Gets a central registry of colors from deserialized JS types. -
setColorRegistry
Sets the color registry -
getTopScope
Gets the top scope. -
report
Report an error or warning. -
getCodingConvention
Gets the current coding convention. -
reportChangeToEnclosingScope
Passes that make modifications in a scope that is different than the Compiler.currentScope use this (eg, InlineVariables and many others) -
reportChangeToChangeScope
Mark modifications in a scope that is different than the Compiler.currentScope use this (eg, InlineVariables and many others) -
reportDisambiguatePropertiesSummary
Used by `DisambiguateProperties` to record a one-line summary of the work it accomplished, if any.This information will be included in the tracer mode output, if that is enabled.
-
reportAmbiguatePropertiesSummary
Used by `AmbiguateProperties` to record a one-line summary of the work it accomplished, if any.This information will be included in the tracer mode output, if that is enabled.
-
getTypeMismatches
Gets the central registry of type violations. -
parseSyntheticCode
Parses code for injecting, and associate it with a given source file. -
toSource
Prints a node to source code. -
toSource
Prints a node to source code. -
getReverseAbstractInterpreter
Get an interpreter for type analysis. -
getLifeCycleStage
Returns the current life-cycle stage of the AST we're working on. -
isFillFileName
Returns whether a file name was created bycreateFillFileName(java.lang.String). -
initRuntimeLibraryTypedAsts
public void initRuntimeLibraryTypedAsts(com.google.common.base.Optional<ColorPool.Builder> colorPoolBuilder) Deserialize runtime libraries from a TypedAST packaged as a JAR resource and reconcile their Colors with the current inputs.This method must be called anywhere that Colors are reconciled for application to the AST. Otherwise Color information won't be consistent. `colorPoolBuilder` must be the same builder as used for the other inputs, and the caller retains ownership.
- Parameters:
colorPoolBuilder- if present, includes inferred optimization colors on the deserialized ASTs. If absent, does not include colors.
-
getErrorManager
Gets the error manager. -
getRoot
Returns the root node of the AST, which includes both externs and source. -
getExternProperties
Gets the names of the properties defined in externs or null if GatherExternProperties pass was not run yet. -
addInputSourceMap
Adds aSourceMapInputfor the givensourceFileName, to be used for error reporting and source map combining. -
getBase64SourceMapContents
-
setAccessorSummary
public abstract void setAccessorSummary(com.google.javascript.jscomp.AccessorSummary summary) Sets the summary of properties with getters and setters. -
createAstFactory
public final com.google.javascript.jscomp.AstFactory createAstFactory()Returns a new AstFactory that will add type information to the nodes it creates if and only if type checking has already happened and types have not been converted into colors.Note that the AstFactory will /not/ add colors to the AST if types have been converted into colors. The AstFactory does not understand colors, although color support could certainly be added if it proves useful.
-
createAstFactoryWithoutTypes
public final com.google.javascript.jscomp.AstFactory createAstFactoryWithoutTypes()Returns a new AstFactory that will not add type information, regardless of whether type checking has already happened. -
getAstAnalyzer
Returns a new AstAnalyzer configured correctly to answer questions about Nodes in the AST currently being compiled. -
createDefaultExpressionDecomposer
public com.google.javascript.jscomp.ExpressionDecomposer createDefaultExpressionDecomposer() -
createExpressionDecomposer
-
getModuleMetadataMap
-
setModuleMetadataMap
-
getModuleMap
-
setModuleMap
-
isDebugLoggingEnabled
public final boolean isDebugLoggingEnabled() -
getDebugLogFilterList
-
createOrReopenLog
@MustBeClosed public final LogFile createOrReopenLog(Class<?> owner, String firstNamePart, String... restNameParts) Provides logging access to a file with the specified name. -
createOrReopenIndexedLog
@MustBeClosed public final LogFile createOrReopenIndexedLog(Class<?> owner, String firstNamePart, String... restNameParts) Provides logging access to a file with the specified name, differentiated by the index of the current pass.Indexing helps in separating logs from different pass loops. The filename pattern is "[debug_log_directory]/[owner_name]/([name_part[i]]/){0,n-1}[pass_index]_[name_part[n]]".
-