-
Notifications
You must be signed in to change notification settings - Fork 396
Merge the IR node This
into VarRef
, with a magic LocalName
.
#5090
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
9c6d33f
to
30f2bc0
Compare
linker/shared/src/main/scala/org/scalajs/linker/checker/ErrorReporter.scala
Show resolved
Hide resolved
035a4a5
to
dc5febf
Compare
This PR will look better when/if #5092 gets merged first. |
dc5febf
to
29c4439
Compare
Rebased. |
29c4439
to
2202503
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice! Just some comments about details.
linker/shared/src/main/scala/org/scalajs/linker/backend/emitter/FunctionEmitter.scala
Show resolved
Hide resolved
linker/shared/src/main/scala/org/scalajs/linker/checker/ClassDefChecker.scala
Outdated
Show resolved
Hide resolved
linker/shared/src/main/scala/org/scalajs/linker/frontend/optimizer/OptimizerCore.scala
Show resolved
Hide resolved
linker/shared/src/main/scala/org/scalajs/linker/frontend/optimizer/OptimizerCore.scala
Show resolved
Hide resolved
2202503
to
c47cd54
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated.
linker/shared/src/main/scala/org/scalajs/linker/backend/emitter/FunctionEmitter.scala
Show resolved
Hide resolved
linker/shared/src/main/scala/org/scalajs/linker/frontend/optimizer/OptimizerCore.scala
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just one nit RE naming (optional).
copy(thisType = thisType) | ||
withLocal(LocalDef(LocalName.This, thisType, mutable = false)) | ||
|
||
def withMaybeThisType(static: Boolean, thisType: Type): Env = |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: static
should maybe better be called hasThis
here? (or omitThis
).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oops, yes. Fixed. (and rebased just for safety)
linker/shared/src/main/scala/org/scalajs/linker/frontend/optimizer/OptimizerCore.scala
Show resolved
Hide resolved
Everywhere we handle `VarRef`s, we applied the same treatment to `This` nodes. In some places, like in the optimizer's `Binding`s, we also had an additional abstraction to represent either an actual `VarRef` or a `this` value. We now merge `This` as a particular case of `VarRef`. We use a magic `LocalName` that is otherwise invalid, namely `.this`. A variable of that name cannot be declared, either in a `ParamDef` or in a `VarDef`. It is only introduced for receivers, and is always immutable. Several areas of the code get simpler with the merge. The optimizer's `Binding`s is the most obvious example. The `FunctionEmitter`s also benefit from the changes. Other areas get nothing but a reduction of alternatives in pattern matches. `this` values still hold particular meaning in many situations. Therefore, we keep a source compatible constructor/extractor object for `This()`.
c47cd54
to
eac8bf7
Compare
And port the changes that were made to the compiler backend. Most nobably, the changes from the following upstream PRs: * Introduce non-nullable reference types in the IR. scala-js/scala-js#5018 * Opt: Remove useless *Ident indirections in the IR model. scala-js/scala-js#5092 * Merge the IR node This into VarRef, with a magic LocalName. scala-js/scala-js#5090 * Merge several IR nodes into UnaryOp. scala-js/scala-js#5088 * Restrict usages of StoreModule even further. scala-js/scala-js#5059 * Allow Return arg to be a void if the target Labeled is a void. scala-js/scala-js#5074 * Rename NoType to VoidType and print it as "void". scala-js/scala-js#5061
And port the changes that were made to the compiler backend. Most notably, the changes from the following upstream PRs: * Introduce non-nullable reference types in the IR. scala-js/scala-js#5018 * Opt: Remove useless *Ident indirections in the IR model. scala-js/scala-js#5092 * Merge the IR node This into VarRef, with a magic LocalName. scala-js/scala-js#5090 * Merge several IR nodes into UnaryOp. scala-js/scala-js#5088 * Restrict usages of StoreModule even further. scala-js/scala-js#5059 * Allow Return arg to be a void if the target Labeled is a void. scala-js/scala-js#5074 * Rename NoType to VoidType and print it as "void". scala-js/scala-js#5061
And port the changes that were made to the compiler backend. Most notably, the changes from the following upstream PRs: * scala-js/scala-js#5018 * scala-js/scala-js#5092 * scala-js/scala-js#5090 * scala-js/scala-js#5088 * scala-js/scala-js#5059 * scala-js/scala-js#5074 * scala-js/scala-js#5061
Everywhere we handle
VarRef
s, we applied the same treatment toThis
nodes. In some places, like in the optimizer'sBinding
s, we also had an additional abstraction to represent either an actualVarRef
or athis
value.We now merge
This
as a particular case ofVarRef
. We use a magicLocalName
that is otherwise invalid, namely.this
.A variable of that name cannot be declared, either in a
ParamDef
or in aVarDef
. It is only introduced for receivers, and is always immutable.Several areas of the code get simpler with the merge. The optimizer's
Binding
s is the most obvious example. TheFunctionEmitter
s also benefit from the changes. Other areas get nothing but a reduction of alternatives in pattern matches.this
values still hold particular meaning in many situations. Therefore, we keep a source compatible constructor/extractor object forThis()
.The only difference in the eventual output is: