From 86146ae7f462db0fb40d6142ead764d389228d23 Mon Sep 17 00:00:00 2001 From: microproofs Date: Sat, 13 Jan 2024 23:21:25 -0500 Subject: [PATCH] adding codegen traces --- crates/aiken-lsp/src/server/lsp_project.rs | 11 +++++++--- crates/aiken-project/src/lib.rs | 24 ++++++++++++++++------ crates/aiken-project/src/options.rs | 1 + crates/aiken/src/cmd/blueprint/address.rs | 2 +- crates/aiken/src/cmd/blueprint/hash.rs | 2 +- crates/aiken/src/cmd/blueprint/policy.rs | 2 +- crates/aiken/src/cmd/build.rs | 9 ++++++-- crates/aiken/src/cmd/check.rs | 8 +++++++- 8 files changed, 44 insertions(+), 15 deletions(-) diff --git a/crates/aiken-lsp/src/server/lsp_project.rs b/crates/aiken-lsp/src/server/lsp_project.rs index 4c58a79d..4c40367a 100644 --- a/crates/aiken-lsp/src/server/lsp_project.rs +++ b/crates/aiken-lsp/src/server/lsp_project.rs @@ -32,9 +32,14 @@ impl LspProject { pub fn compile(&mut self) -> Result<(), Vec> { let checkpoint = self.project.checkpoint(); - let result = self - .project - .check(true, None, false, false, Tracing::NoTraces); + let result = self.project.check( + true, + None, + false, + false, + Tracing::NoTraces, + Tracing::NoTraces, + ); self.project.restore(checkpoint); diff --git a/crates/aiken-project/src/lib.rs b/crates/aiken-project/src/lib.rs index 06d88164..1ac2a935 100644 --- a/crates/aiken-project/src/lib.rs +++ b/crates/aiken-project/src/lib.rs @@ -151,10 +151,16 @@ where self.defined_modules = checkpoint.defined_modules; } - pub fn build(&mut self, uplc: bool, tracing: Tracing) -> Result<(), Vec> { + pub fn build( + &mut self, + uplc: bool, + tracing: Tracing, + code_gen_tracing: Tracing, + ) -> Result<(), Vec> { let options = Options { code_gen_mode: CodeGenMode::Build(uplc), tracing, + code_gen_tracing, }; self.compile(options) @@ -210,9 +216,11 @@ where verbose: bool, exact_match: bool, tracing: Tracing, + code_gen_tracing: Tracing, ) -> Result<(), Vec> { let options = Options { tracing, + code_gen_tracing, code_gen_mode: if skip_tests { CodeGenMode::NoOp } else { @@ -282,7 +290,7 @@ where &self.functions, &self.data_types, &self.module_types, - options.tracing.into(), + options.code_gen_tracing.into(), ); let blueprint = Blueprint::new(&self.config, &self.checked_modules, &mut generator) @@ -311,8 +319,12 @@ where verbose, exact_match, } => { - let tests = - self.collect_tests(verbose, match_tests, exact_match, options.tracing.into())?; + let tests = self.collect_tests( + verbose, + match_tests, + exact_match, + options.code_gen_tracing.into(), + )?; if !tests.is_empty() { self.event_listener.handle_event(Event::RunningTests); @@ -675,7 +687,7 @@ where verbose: bool, match_tests: Option>, exact_match: bool, - tracing: bool, + code_gen_tracing: bool, ) -> Result, Error> { let mut scripts = Vec::new(); let mut testable_validators = Vec::new(); @@ -778,7 +790,7 @@ where &self.functions, &self.data_types, &self.module_types, - tracing, + code_gen_tracing, ); for (module_name, testable_validator) in &testable_validators { diff --git a/crates/aiken-project/src/options.rs b/crates/aiken-project/src/options.rs index 2da0d13d..2d147604 100644 --- a/crates/aiken-project/src/options.rs +++ b/crates/aiken-project/src/options.rs @@ -3,6 +3,7 @@ use aiken_lang::ast::Tracing; pub struct Options { pub code_gen_mode: CodeGenMode, pub tracing: Tracing, + pub code_gen_tracing: Tracing, } pub enum CodeGenMode { diff --git a/crates/aiken/src/cmd/blueprint/address.rs b/crates/aiken/src/cmd/blueprint/address.rs index dab00111..18889e8f 100644 --- a/crates/aiken/src/cmd/blueprint/address.rs +++ b/crates/aiken/src/cmd/blueprint/address.rs @@ -36,7 +36,7 @@ pub fn exec( ) -> miette::Result<()> { with_project(directory.as_deref(), false, |p| { if rebuild { - p.build(false, Tracing::NoTraces)?; + p.build(false, Tracing::NoTraces, Tracing::NoTraces)?; } let title = module.as_ref().map(|m| { diff --git a/crates/aiken/src/cmd/blueprint/hash.rs b/crates/aiken/src/cmd/blueprint/hash.rs index b19a00f3..4dbf10f7 100644 --- a/crates/aiken/src/cmd/blueprint/hash.rs +++ b/crates/aiken/src/cmd/blueprint/hash.rs @@ -31,7 +31,7 @@ pub fn exec( ) -> miette::Result<()> { with_project(directory.as_deref(), false, |p| { if rebuild { - p.build(false, Tracing::NoTraces)?; + p.build(false, Tracing::NoTraces, Tracing::NoTraces)?; } let title = module.as_ref().map(|m| { diff --git a/crates/aiken/src/cmd/blueprint/policy.rs b/crates/aiken/src/cmd/blueprint/policy.rs index 4bb14f15..1d7fc536 100644 --- a/crates/aiken/src/cmd/blueprint/policy.rs +++ b/crates/aiken/src/cmd/blueprint/policy.rs @@ -31,7 +31,7 @@ pub fn exec( ) -> miette::Result<()> { with_project(directory.as_deref(), false, |p| { if rebuild { - p.build(false, Tracing::NoTraces)?; + p.build(false, Tracing::NoTraces, Tracing::NoTraces)?; } let title = module.as_ref().map(|m| { diff --git a/crates/aiken/src/cmd/build.rs b/crates/aiken/src/cmd/build.rs index 40eb3fe0..2ac1e44d 100644 --- a/crates/aiken/src/cmd/build.rs +++ b/crates/aiken/src/cmd/build.rs @@ -22,6 +22,10 @@ pub struct Args { /// Do not remove traces when generating code #[clap(short, long)] keep_traces: bool, + + /// Add code gen traces when generating code + #[clap(short, long)] + code_gen_traces: bool, } pub fn exec( @@ -31,15 +35,16 @@ pub fn exec( watch, uplc, keep_traces, + code_gen_traces, }: Args, ) -> miette::Result<()> { let result = if watch { watch_project(directory.as_deref(), watch::default_filter, 500, |p| { - p.build(uplc, keep_traces.into()) + p.build(uplc, keep_traces.into(), code_gen_traces.into()) }) } else { with_project(directory.as_deref(), deny, |p| { - p.build(uplc, keep_traces.into()) + p.build(uplc, keep_traces.into(), code_gen_traces.into()) }) }; diff --git a/crates/aiken/src/cmd/check.rs b/crates/aiken/src/cmd/check.rs index ba05299c..2b1f21ca 100644 --- a/crates/aiken/src/cmd/check.rs +++ b/crates/aiken/src/cmd/check.rs @@ -37,6 +37,10 @@ pub struct Args { /// Remove traces when generating code (including tests) #[clap(long)] no_traces: bool, + + /// Remove code gen traces when generating code (including tests) + #[clap(long)] + no_code_gen_traces: bool, } pub fn exec( @@ -48,8 +52,8 @@ pub fn exec( match_tests, exact_match, no_traces, + no_code_gen_traces, watch, - .. }: Args, ) -> miette::Result<()> { let result = if watch { @@ -60,6 +64,7 @@ pub fn exec( debug, exact_match, (!no_traces).into(), + (!no_code_gen_traces).into(), ) }) } else { @@ -70,6 +75,7 @@ pub fn exec( debug, exact_match, (!no_traces).into(), + (!no_code_gen_traces).into(), ) }) };