-
Notifications
You must be signed in to change notification settings - Fork 187
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #459 from sbillig/lowering-context
Move tuple and list expr collection to lowering pass; support lowering of nested tuples
- Loading branch information
Showing
130 changed files
with
411 additions
and
519 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 |
---|---|---|
|
@@ -7,7 +7,6 @@ on: | |
- v* | ||
|
||
pull_request: | ||
branches: [master] | ||
|
||
env: | ||
CARGO_TERM_COLOR: always | ||
|
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
use fe_analyzer::context::Context as AnalyzerContext; | ||
use fe_analyzer::namespace::types::{Array, Tuple}; | ||
use indexmap::IndexSet; | ||
use std::collections::BTreeSet; | ||
|
||
pub struct ModuleContext<'a> { | ||
pub analysis: &'a AnalyzerContext, | ||
|
||
/// Tuples that were used inside of a module, | ||
/// and the generated name of the resulting struct. | ||
pub tuples: IndexSet<Tuple>, | ||
|
||
/// Holds fresh id for [`ModuleContext::make_unique_name`] | ||
fresh_id: u64, | ||
} | ||
|
||
impl<'a> ModuleContext<'a> { | ||
pub fn new(analysis: &'a AnalyzerContext) -> Self { | ||
Self { | ||
analysis, | ||
tuples: IndexSet::new(), | ||
fresh_id: 0, | ||
} | ||
} | ||
|
||
/// Makes a unique name from the given name, keeping it as readable as possible. | ||
pub fn make_unique_name(&mut self, name: &str) -> String { | ||
let id = self.fresh_id; | ||
self.fresh_id += 1; | ||
format!("${}_{}", name, id) | ||
} | ||
} | ||
|
||
// This is contract context, but it's used all over so it has a short name. | ||
pub struct Context<'a, 'b> { | ||
pub module: &'a mut ModuleContext<'b>, | ||
/// List expressions that the contract uses | ||
pub list_expressions: BTreeSet<Array>, | ||
} | ||
|
||
impl<'a, 'b> Context<'a, 'b> { | ||
pub fn new(module: &'a mut ModuleContext<'b>) -> Self { | ||
Self { | ||
module, | ||
list_expressions: BTreeSet::new(), | ||
} | ||
} | ||
} |
Oops, something went wrong.