Use sources instead of parsed package #1362
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
When splitting up the compiler I noticed that there is an internal structure for storing parsed files called
sources
.sources
is very similar to the structure I addedParsedPackage
used to split the parse and compile phases apart. I joined these two into one sharedSources
structure to save some moving of information around and complexity.These changes should not affect functionality. It is a refactor to simplify and organize how data prior to the Archives is stored.
After this change: Build will load all the packages needed for a project into
Sources
. The rootSources
is passed intoCompile
where theSources
will be sorted, type checked, etc before being compiled into JS.In following tickets the
Sources
sorting, type checking, and the creation of therootCtx
will be moved out ofCompile
so that they can be performed on allSources
at the same time, thus allowing generic information to be passed across package boundaries.This is related to #1013 and #1270
Changes
errorList
into its own package (errorList.ErrorList
) so that it can be used by more packages by itself.JSFile
into its own package (jsFile.JSFile
).JSFilesFromDir
method from build/context.go into thejsFile
package since it relates toJSFile
.sources
into its own package (sources.Sources
) so that it can be used by both thebuild
andcompiler
packages.packageImporter
used bySources
into two parts to reduce dependencies:packageImporter
that useserrorList
to collect any errors that occurred.ImportContext
asImport
since the cached packages and archives were already onImportContext
.ImportContext
already had anImport
method, I renamed it toImportArchive
so thatImport
onImportContext
implementsgo/types.Importer
but allows us to still import an archive.GoLinkname
into its own package (linkname.GoLinkname
) so that thesources
package can use it.GoLinknameSet
andParseGoLinknames
so that they can be used bycompiler
.errorAt
intolinkname
since it was only being used byGoLinkname
at this moment.ParsedPackage
withSources
sinceSources
already existed with nearly everything inParsedPackage
.Imports
method toUnresolvedImports
when moving that method toSources
.Dir string
andJSFiles []jsFile.JSFile
fields that were missing fromSources
but needed byParsedPackage
.Sources
, e.g. "at this point the sources haven't been sorted".compiler/package.go#Compile
to take the rootSources
instead of parts from aParsedPackage
and remove the original creation of theSources
that was done first thing inCompile
(after some error handling stuff).