adding codegen traces

This commit is contained in:
microproofs 2024-01-13 23:21:25 -05:00 committed by KtorZ
parent 81e29539c8
commit 86146ae7f4
No known key found for this signature in database
GPG Key ID: 33173CB6F77F4277
8 changed files with 44 additions and 15 deletions

View File

@ -32,9 +32,14 @@ impl LspProject {
pub fn compile(&mut self) -> Result<(), Vec<ProjectError>> { pub fn compile(&mut self) -> Result<(), Vec<ProjectError>> {
let checkpoint = self.project.checkpoint(); let checkpoint = self.project.checkpoint();
let result = self let result = self.project.check(
.project true,
.check(true, None, false, false, Tracing::NoTraces); None,
false,
false,
Tracing::NoTraces,
Tracing::NoTraces,
);
self.project.restore(checkpoint); self.project.restore(checkpoint);

View File

@ -151,10 +151,16 @@ where
self.defined_modules = checkpoint.defined_modules; self.defined_modules = checkpoint.defined_modules;
} }
pub fn build(&mut self, uplc: bool, tracing: Tracing) -> Result<(), Vec<Error>> { pub fn build(
&mut self,
uplc: bool,
tracing: Tracing,
code_gen_tracing: Tracing,
) -> Result<(), Vec<Error>> {
let options = Options { let options = Options {
code_gen_mode: CodeGenMode::Build(uplc), code_gen_mode: CodeGenMode::Build(uplc),
tracing, tracing,
code_gen_tracing,
}; };
self.compile(options) self.compile(options)
@ -210,9 +216,11 @@ where
verbose: bool, verbose: bool,
exact_match: bool, exact_match: bool,
tracing: Tracing, tracing: Tracing,
code_gen_tracing: Tracing,
) -> Result<(), Vec<Error>> { ) -> Result<(), Vec<Error>> {
let options = Options { let options = Options {
tracing, tracing,
code_gen_tracing,
code_gen_mode: if skip_tests { code_gen_mode: if skip_tests {
CodeGenMode::NoOp CodeGenMode::NoOp
} else { } else {
@ -282,7 +290,7 @@ where
&self.functions, &self.functions,
&self.data_types, &self.data_types,
&self.module_types, &self.module_types,
options.tracing.into(), options.code_gen_tracing.into(),
); );
let blueprint = Blueprint::new(&self.config, &self.checked_modules, &mut generator) let blueprint = Blueprint::new(&self.config, &self.checked_modules, &mut generator)
@ -311,8 +319,12 @@ where
verbose, verbose,
exact_match, exact_match,
} => { } => {
let tests = let tests = self.collect_tests(
self.collect_tests(verbose, match_tests, exact_match, options.tracing.into())?; verbose,
match_tests,
exact_match,
options.code_gen_tracing.into(),
)?;
if !tests.is_empty() { if !tests.is_empty() {
self.event_listener.handle_event(Event::RunningTests); self.event_listener.handle_event(Event::RunningTests);
@ -675,7 +687,7 @@ where
verbose: bool, verbose: bool,
match_tests: Option<Vec<String>>, match_tests: Option<Vec<String>>,
exact_match: bool, exact_match: bool,
tracing: bool, code_gen_tracing: bool,
) -> Result<Vec<Script>, Error> { ) -> Result<Vec<Script>, Error> {
let mut scripts = Vec::new(); let mut scripts = Vec::new();
let mut testable_validators = Vec::new(); let mut testable_validators = Vec::new();
@ -778,7 +790,7 @@ where
&self.functions, &self.functions,
&self.data_types, &self.data_types,
&self.module_types, &self.module_types,
tracing, code_gen_tracing,
); );
for (module_name, testable_validator) in &testable_validators { for (module_name, testable_validator) in &testable_validators {

View File

@ -3,6 +3,7 @@ use aiken_lang::ast::Tracing;
pub struct Options { pub struct Options {
pub code_gen_mode: CodeGenMode, pub code_gen_mode: CodeGenMode,
pub tracing: Tracing, pub tracing: Tracing,
pub code_gen_tracing: Tracing,
} }
pub enum CodeGenMode { pub enum CodeGenMode {

View File

@ -36,7 +36,7 @@ pub fn exec(
) -> miette::Result<()> { ) -> miette::Result<()> {
with_project(directory.as_deref(), false, |p| { with_project(directory.as_deref(), false, |p| {
if rebuild { if rebuild {
p.build(false, Tracing::NoTraces)?; p.build(false, Tracing::NoTraces, Tracing::NoTraces)?;
} }
let title = module.as_ref().map(|m| { let title = module.as_ref().map(|m| {

View File

@ -31,7 +31,7 @@ pub fn exec(
) -> miette::Result<()> { ) -> miette::Result<()> {
with_project(directory.as_deref(), false, |p| { with_project(directory.as_deref(), false, |p| {
if rebuild { if rebuild {
p.build(false, Tracing::NoTraces)?; p.build(false, Tracing::NoTraces, Tracing::NoTraces)?;
} }
let title = module.as_ref().map(|m| { let title = module.as_ref().map(|m| {

View File

@ -31,7 +31,7 @@ pub fn exec(
) -> miette::Result<()> { ) -> miette::Result<()> {
with_project(directory.as_deref(), false, |p| { with_project(directory.as_deref(), false, |p| {
if rebuild { if rebuild {
p.build(false, Tracing::NoTraces)?; p.build(false, Tracing::NoTraces, Tracing::NoTraces)?;
} }
let title = module.as_ref().map(|m| { let title = module.as_ref().map(|m| {

View File

@ -22,6 +22,10 @@ pub struct Args {
/// Do not remove traces when generating code /// Do not remove traces when generating code
#[clap(short, long)] #[clap(short, long)]
keep_traces: bool, keep_traces: bool,
/// Add code gen traces when generating code
#[clap(short, long)]
code_gen_traces: bool,
} }
pub fn exec( pub fn exec(
@ -31,15 +35,16 @@ pub fn exec(
watch, watch,
uplc, uplc,
keep_traces, keep_traces,
code_gen_traces,
}: Args, }: Args,
) -> miette::Result<()> { ) -> miette::Result<()> {
let result = if watch { let result = if watch {
watch_project(directory.as_deref(), watch::default_filter, 500, |p| { 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 { } else {
with_project(directory.as_deref(), deny, |p| { with_project(directory.as_deref(), deny, |p| {
p.build(uplc, keep_traces.into()) p.build(uplc, keep_traces.into(), code_gen_traces.into())
}) })
}; };

View File

@ -37,6 +37,10 @@ pub struct Args {
/// Remove traces when generating code (including tests) /// Remove traces when generating code (including tests)
#[clap(long)] #[clap(long)]
no_traces: bool, no_traces: bool,
/// Remove code gen traces when generating code (including tests)
#[clap(long)]
no_code_gen_traces: bool,
} }
pub fn exec( pub fn exec(
@ -48,8 +52,8 @@ pub fn exec(
match_tests, match_tests,
exact_match, exact_match,
no_traces, no_traces,
no_code_gen_traces,
watch, watch,
..
}: Args, }: Args,
) -> miette::Result<()> { ) -> miette::Result<()> {
let result = if watch { let result = if watch {
@ -60,6 +64,7 @@ pub fn exec(
debug, debug,
exact_match, exact_match,
(!no_traces).into(), (!no_traces).into(),
(!no_code_gen_traces).into(),
) )
}) })
} else { } else {
@ -70,6 +75,7 @@ pub fn exec(
debug, debug,
exact_match, exact_match,
(!no_traces).into(), (!no_traces).into(),
(!no_code_gen_traces).into(),
) )
}) })
}; };