Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move compiler-related stuff to a new compiler module #1144

Merged
merged 25 commits into from
Jan 16, 2021

Conversation

alexarchambault
Copy link
Collaborator

@alexarchambault alexarchambault commented Jan 14, 2021

This subsumes #1135. The core idea of this PR consists in moving any compiler- or parsing-related logic to a new compiler module, that we can rewrite for Scala 3 later on.

Thanks to the 2.13 / 3 compatibility, we can just rewrite this compiler module in Scala 3 in a first time, and run it alongside the other modules compiled for 2.13, to get Scala 3 support. This is done on this branch (I'm about to add details about what it can and cannot do in its README).

This PR also adds a new compiler-interface module, defining a few compiler- and parsing-related traits, and has interp and repl depend on those traits rather than on the classes of compiler. This ensures we don't inadvertently depend on concrete scalac or fastparse definitions or compiler internals from interp and repl, which would hamper substituting compiler targetting Scala 3 to compiler targetting Scala 2.13 at runtime.

In more detail, the commits in this PR successively:

  • do minimal refactorings that help subsequent developments,
  • add a new compiler module and move code to it,
  • add a new compiler-interface module, with mostly just traits,
  • implement the traits of compiler-interface in compiler,
  • rely on compiler-interface rather than compiler in interp, then in repl.

Commit-by-commit:

@alexarchambault alexarchambault force-pushed the compiler-module branch 5 times, most recently from f64902f to c417431 Compare January 14, 2021 19:13
That makes it easier later on to extract an interface for CompilerLifecycleManager
A simple Option is enough, and that makes for a cleaner
interface for CompilerLifecycleManager later on.
Having it rely on Frame from ammonite.repl.api, rather than a concrete
Frame implementation, makes it easier to extract an interface for
CompilerLifecycleManager later on.
…and remove Compiler.parse

This allows to strip the Compiler public API of references to
scala.tools.nsc. Later on, makes it easier to extract an interface
for Compiler.
This makes it more straightforward to extract an API for parsing
later on.
Just like the previous commit, this facilitates extracting an API
for parsing later on.
@lihaoyi
Copy link
Member

lihaoyi commented Jan 16, 2021

Looks good to me, feel free to merge whenever

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants