Skip to content
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

Generate artifacts for all contracts of an ingot #726

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions crates/analyzer/src/namespace/items.rs
Original file line number Diff line number Diff line change
Expand Up @@ -690,9 +690,13 @@ impl ModuleId {
db.module_parent_module(*self)
}

/// All contracts, including duplicates
pub fn all_contracts(&self, db: &dyn AnalyzerDb) -> Rc<[ContractId]> {
db.module_contracts(*self)
/// All contracts, including from submodules and including duplicates
pub fn all_contracts(&self, db: &dyn AnalyzerDb) -> Vec<ContractId> {
self.submodules(db)
.iter()
.flat_map(|module| module.all_contracts(db))
.chain((*db.module_contracts(*self)).to_vec())
.collect::<Vec<_>>()
}

/// Returns the map of ingot deps, built-ins, and the ingot itself as
Expand Down
4 changes: 2 additions & 2 deletions crates/driver/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ fn compile_module_id(
optimize: bool,
) -> Result<CompiledModule, CompileError> {
let mut contracts = IndexMap::default();
for &contract in module_id.all_contracts(db.upcast()).as_ref() {
for contract in module_id.all_contracts(db.upcast()) {
let name = &contract.data(db.upcast()).name;
let abi = db.codegen_abi_contract(contract);
let yul_contract = compile_to_yul(db, contract);
Expand Down Expand Up @@ -144,7 +144,7 @@ fn compile_module_id(
_optimize: bool,
) -> Result<CompiledModule, CompileError> {
let mut contracts = IndexMap::default();
for &contract in module_id.all_contracts(db.upcast()).as_ref() {
for contract in module_id.all_contracts(db.upcast()) {
let name = &contract.data(db.upcast()).name;
let abi = db.codegen_abi_contract(contract);
let yul_contract = compile_to_yul(db, contract);
Expand Down
1 change: 1 addition & 0 deletions newsfragments/726.feature.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Generate artifacts for all contracts of an ingot, not just for contracts that are defined in `main.fe`