-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Initial infrastructure and hello world for the Scala.js back-end. #1126
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
Conversation
I am not sure whether you would consider this for inclusion in the repo, at this point. But I figured it was in a good enough state to suggest it. In any case, I would very much like comments on the general aspect. Please tell me if I'm doing anything stupid at this point. It might be interesting to compare this with the scalac implementation at https://github.com/scala-js/scala-js/tree/master/compiler/src/main/scala/org/scalajs/core/compiler I guess all of @odersky @DarkDimius @smarter might be interested in having a look at this, if not all the details. |
I followed most of the code. Ideologically it looks good to me. I'd be curious to see how much different would be handling of |
f08f000
to
70e6665
Compare
Rebased. I saved the earlier comments at sjrd@57c1b1c |
@DarkDimius I added a commit moving I am not sure if the new situation is desirable. But in any case the required changes highlight that, in master, |
/rebuild |
Are OOMs in partest CI common? Or are the failures in fact not spurious? |
I'm getting them too so it's probably not your fault, we're just steadily using more and more memory, you can try increasing https://github.com/lampepfl/dotty/blob/master/project/Build.scala#L11 and see if it helps. |
It appears to have helped, indeed. So, from my side, I'm happy with this PR the way it is. I guess it deserves a real review, now. |
…ctor. Dotty treats trait and class constructors as returning the class. But scalac uses Unit for the return type of trait init methods.
When a concrete val is mixed in from a Scala2 trait, a setter is generated, which is called by the `$init$` method. Since the assignment in this setter is not done in the constructor, it is nonsensical for the field to be immutable. This commit sets the Mutable flag on such fields. It only applies for vals coming from Scala2 traits. vals coming from Dotty traits are kept immutable.
The Scala.js back-end can be enabled with the `-scalajs` command-line option. Currently, it adds one phase to the pipeline, which emits .sjsir files from trees. A sandbox project `sjsSandbox`, in `sandbox/scalajs/`, can be used to easily test Scala.js compilation. One can run the `main()` method of the `hello.world` object with > sjsSandbox/run The back-end only contains the bare mimimum to compile the hello world application in the sandbox. Anything else will blow up (for example, primitive method calls). It is a work-in-progress.
This required the ability to instantiate a different `Platform` depending on settings, which, in turn, required to defer the initialization of `ContextBase.platform`.
This guarantees that we can bootstrap dotty without depending on the binaries of scalajs-ir compiled by another Scala compiler.
@DarkDimius Following our conversation from this afternoon, I have added a commit addressing your concern about the bootstrap'ability of scalajs-ir. Instead of depending on the compiled artifacts, the build now depends on the sources and compiles them as part of dotty. In bootstrap tests, they are therefore part of the compilation of dotty by itself. |
As for testability, something we could do would be to simply add a CI command |
@sjrd, for testability, I leave this for you to decide. Please tell me if you wish to add it to CI. |
Initial infrastructure and hello world for the Scala.js back-end.
Thanks!
I think it would be worth it, yes. |
How long do the tests take? |
|
OK then, add it :). |
The Scala.js back-end can be enabled with the
-scalajs
command-line option. Currently, it adds one phase to the pipeline, which emits .sjsir files from trees.A sandbox project
sjsSandbox
, insandbox/scalajs/
, can be used to easily test Scala.js compilation. One can run themain()
method of thehello.world
object withThe back-end only contains the bare mimimum to compile the hello world application in the sandbox. Anything else will blow up (for example, primitive method calls). It is a work-in-progress.