Skip to content
This repository was archived by the owner on Jul 12, 2024. It is now read-only.

Adapt namespacing to Scala.js core conventions. #127

Merged
merged 12 commits into from
May 14, 2024

Conversation

sjrd
Copy link
Collaborator

@sjrd sjrd commented May 12, 2024

No description provided.

@sjrd sjrd force-pushed the adapt-namespacing-to-core-conventions branch from 11d24cf to d8bc76e Compare May 12, 2024 13:06
@sjrd sjrd requested review from tanishiking May 12, 2024 13:07
Copy link
Owner

@tanishiking tanishiking left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thank you very much for well-explained commit messages!

Comment on lines +349 to +350
* ¹ We use the Unicode character `⟦` to represent two consecutive `[` characters in order
* not to confuse Scaladoc.
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤣

sjrd added 12 commits May 14, 2024 13:50
Everything in the package is "Wasm". This file is specifically
about the module structure, as described in
https://webassembly.github.io/gc/core/syntax/modules.html
We put everything from `Modules.scala` inside `object Modules`, and
everything from `Instructions.scala` inside `object Instructions`.
So that `FunctionBuilder` does not need to know about IR Trees.
Import Wasm types as `watpe` (similar to `irtpe` or `jstpe`, which
we use in the JS backend and the compiler backend).

Import IR elements without namespacing.
In the CoreWasmLib, we manipulate IR types and names, but not trees,
so we import the former two without namespacing.

We produce a lot of Wasm types and instructions, so those are
imported without namespacing either.

This is similar to the import strategy of the `CoreJSLib` in the
JS backend.
The Preprocessor never manipulates any WebAssembly things, so we
can import IR things without namespace.
The competition is a bit tight, but WasmContext manipulates more IR
concepts than Wasm contexts. Therefore, we import IR things without
namespace, and Wasm things under short namespaces. We use `wa`,
`watpe`, `wamod` and `wanme` by analogy to the compiler backend and
JS backend conventions, which use `js` and `jsnme`.
The choice of what to import with or without namespace is the same
as the `Emitter` in the JS backend.

IR trees are only required in `genStartFunction`, so we confine
their imports there. Arguably `genStartFunction` conceptually
belongs more to `ClassEmitter` than `Emitter`.
The choice of what to import with or without namespace is the same
as the `ClassEmitter` in the JS backend.
The choice of what to import with or without namespace is the same
as the `FunctionEmitter` in the JS backend.
Now that everything is properly namespaced, we do not need this
artificial namespacing in the class names.
@sjrd sjrd force-pushed the adapt-namespacing-to-core-conventions branch from d8bc76e to 5287949 Compare May 14, 2024 11:51
@sjrd sjrd merged commit 489b870 into tanishiking:main May 14, 2024
1 check passed
@sjrd sjrd deleted the adapt-namespacing-to-core-conventions branch May 14, 2024 11:58
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants