forked from JetBrains/kotlin
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Shorten mangled names and make type/scope/name distinction explicit
Our current mangled names are inconveniently long. I'm working on making them shorter, but it's quite a bit of work; this should make things a bit easier to read without reworking too much.
- Loading branch information
Showing
91 changed files
with
5,611 additions
and
6,089 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
41 changes: 41 additions & 0 deletions
41
...erification/formver.core/src/org/jetbrains/kotlin/formver/names/NameMangling.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
# Name mangling | ||
|
||
There are two hard problems in computer science: | ||
cache invalidation, naming, and off-by-one errors. | ||
|
||
When translating Kotlin to Viper, we need to pick distinct names for objects. | ||
Viper is significantly less forgiving than Kotlin when it comes to shadowing, | ||
so we aim to pick unique names globally. | ||
|
||
We do this by scoping and typing the names: | ||
* Names are given a scope corresponding (roughly) to their scope in the original | ||
Kotlin program. | ||
* Names are given a type based on the kind of thing they refer to. | ||
|
||
Since this typically makes names long, we use abbreviations, or omit the type | ||
and/or scope for the most common cases. | ||
|
||
For scopes: | ||
* `pkg` for package | ||
* `g` for global | ||
* `p` for parameter | ||
* `ln` for local, where `n` is the number of the scope. | ||
|
||
For types: | ||
* `c` for class | ||
* `f` for function | ||
* `d` for domain | ||
* `l` for label | ||
* `a` for anonymous value | ||
* `con` for constructor | ||
* `pp` for property (internal use only) | ||
* `bf` for backing field | ||
* `pg` for property getter | ||
* `ps` for property setter | ||
* `eg` for extension getter | ||
* `es` for extension setter | ||
|
||
There are still holdover (longer) names. | ||
|
||
Ideally, we would like this system to be modular and configurable, dropping | ||
prefixes when they are unused, etc. However, that is WIP. |
Oops, something went wrong.