-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Make
inline
forget inlined defs and use strict parser to save memory.
- Loading branch information
1 parent
823b174
commit 9b4c8b9
Showing
2 changed files
with
45 additions
and
27 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
When we have a theory with many definitions that are used exactly one | ||
(after having been declared), then we might want to eliminate these definitions | ||
by inlining them, so that the signature during type checking remains small. | ||
|
||
For this, we have to traverse our theory file twice: | ||
first to find out which definitions are used exactly once, and | ||
second to eliminate these definitions and to inline them. | ||
|
||
The first step is done by `symcount`. | ||
It actually counts for every constant how often it is used. | ||
A count of 0 means that the constant was declared, but never used. | ||
|
||
cargo run --release --example symcount -- in.dk > in.symcount | ||
|
||
To get those constants that are used exactly once, we use some UNIX magic: | ||
|
||
grep "^1[^0-9]" in.symcount | sed 's/^1.//' > in.inline | ||
|
||
Finally, we use `inline`. | ||
To save memory, this will forget any definition that has been inlined once, | ||
so you currently cannot use this to inline definitions that are used more than once! | ||
|
||
cargo run --release --example inline -- in.dk in.inline > in.inlined.dk |
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