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>> {
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);

View File

@ -151,10 +151,16 @@ where
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 {
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<Error>> {
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<Vec<String>>,
exact_match: bool,
tracing: bool,
code_gen_tracing: bool,
) -> Result<Vec<Script>, 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 {

View File

@ -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 {

View File

@ -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| {

View File

@ -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| {

View File

@ -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| {

View File

@ -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())
})
};

View File

@ -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(),
)
})
};