Skip to content

Commit

Permalink
Revert Remove inlining_strategy from CompilerConfig (#6081) (#6095)
Browse files Browse the repository at this point in the history
  • Loading branch information
maciektr authored Jul 30, 2024
1 parent 5881b09 commit 1b747da
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 9 deletions.
7 changes: 5 additions & 2 deletions crates/bin/cairo-compile/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,11 @@ fn main() -> anyhow::Result<()> {

let sierra_program = compile_cairo_project_at_path(
&args.path,
args.inlining_strategy.into(),
CompilerConfig { replace_ids: args.replace_ids, ..CompilerConfig::default() },
CompilerConfig {
replace_ids: args.replace_ids,
inlining_strategy: args.inlining_strategy.into(),
..CompilerConfig::default()
},
)?;

match args.output {
Expand Down
12 changes: 5 additions & 7 deletions crates/cairo-lang-compiler/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,9 @@ pub struct CompilerConfig<'c> {
/// Replaces sierra ids with human-readable ones.
pub replace_ids: bool,

/// Disables inlining functions.
pub inlining_strategy: InliningStrategy,

/// The name of the allowed libfuncs list to use in compilation.
/// If None the default list of audited libfuncs will be used.
pub allowed_libfuncs_list_name: Option<String>,
Expand All @@ -60,11 +63,10 @@ pub struct CompilerConfig<'c> {
/// * `Err(anyhow::Error)` - Compilation failed.
pub fn compile_cairo_project_at_path(
path: &Path,
inlining_strategy: InliningStrategy,
compiler_config: CompilerConfig<'_>,
) -> Result<Program> {
let mut db = RootDatabase::builder()
.with_inlining_strategy(inlining_strategy)
.with_inlining_strategy(compiler_config.inlining_strategy)
.detect_corelib()
.build()?;
let main_crate_ids = setup_project(&mut db, path)?;
Expand All @@ -82,13 +84,9 @@ pub fn compile_cairo_project_at_path(
/// * `Err(anyhow::Error)` - Compilation failed.
pub fn compile(
project_config: ProjectConfig,
inlining_strategy: InliningStrategy,
compiler_config: CompilerConfig<'_>,
) -> Result<Program> {
let mut db = RootDatabase::builder()
.with_project_config(project_config.clone())
.with_inlining_strategy(inlining_strategy)
.build()?;
let mut db = RootDatabase::builder().with_project_config(project_config.clone()).build()?;
let main_crate_ids = get_main_crate_ids_from_project(&mut db, &project_config);

compile_prepared_db_program(&mut db, main_crate_ids, compiler_config)
Expand Down
2 changes: 2 additions & 0 deletions crates/cairo-lang-starknet/src/test_utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ use cairo_lang_compiler::project::ProjectConfig;
use cairo_lang_compiler::CompilerConfig;
use cairo_lang_filesystem::db::FilesGroup;
use cairo_lang_filesystem::ids::Directory;
use cairo_lang_lowering::utils::InliningStrategy;
use cairo_lang_starknet_classes::allowed_libfuncs::BUILTIN_ALL_LIBFUNCS_LIST;
use cairo_lang_starknet_classes::contract_class::ContractClass;
use cairo_lang_test_utils::test_lock;
Expand Down Expand Up @@ -83,6 +84,7 @@ pub fn get_test_contract(example_file_name: &str) -> ContractClass {
allowed_libfuncs_list_name: Some(BUILTIN_ALL_LIBFUNCS_LIST.to_string()),
diagnostics_reporter,
add_statements_functions: false,
inlining_strategy: InliningStrategy::Default,
},
)
.expect("compile_path failed")
Expand Down

0 comments on commit 1b747da

Please sign in to comment.