mirror of
https://github.com/roc-lang/roc.git
synced 2025-09-27 13:59:08 +00:00
print all the relevant info
This commit is contained in:
parent
e7f3c6f281
commit
e44a8a9eed
17 changed files with 308 additions and 12 deletions
|
@ -615,10 +615,12 @@ fn deep_copy_expr_help<C: CopyEnv>(env: &mut C, copied: &mut Vec<Variable>, expr
|
|||
loc_condition,
|
||||
loc_continuation,
|
||||
variable,
|
||||
symbol,
|
||||
} => Dbg {
|
||||
loc_condition: Box::new(loc_condition.map(|e| go_help!(e))),
|
||||
loc_continuation: Box::new(loc_continuation.map(|e| go_help!(e))),
|
||||
variable: sub!(*variable),
|
||||
symbol: *symbol,
|
||||
},
|
||||
|
||||
TypedHole(v) => TypedHole(sub!(*v)),
|
||||
|
|
|
@ -244,6 +244,7 @@ pub enum Expr {
|
|||
loc_condition: Box<Loc<Expr>>,
|
||||
loc_continuation: Box<Loc<Expr>>,
|
||||
variable: Variable,
|
||||
symbol: Symbol,
|
||||
},
|
||||
|
||||
/// Rendered as empty box in editor
|
||||
|
@ -260,6 +261,14 @@ pub struct ExpectLookup {
|
|||
pub ability_info: Option<SpecializationId>,
|
||||
}
|
||||
|
||||
#[derive(Clone, Copy, Debug)]
|
||||
pub struct DbgLookup {
|
||||
pub symbol: Symbol,
|
||||
pub var: Variable,
|
||||
pub region: Region,
|
||||
pub ability_info: Option<SpecializationId>,
|
||||
}
|
||||
|
||||
impl Expr {
|
||||
pub fn category(&self) -> Category {
|
||||
match self {
|
||||
|
@ -1039,6 +1048,33 @@ pub fn canonicalize_expr<'a>(
|
|||
output,
|
||||
)
|
||||
}
|
||||
ast::Expr::Dbg(condition, continuation) => {
|
||||
let mut output = Output::default();
|
||||
|
||||
let (loc_condition, output1) =
|
||||
canonicalize_expr(env, var_store, scope, condition.region, &condition.value);
|
||||
|
||||
let (loc_continuation, output2) = canonicalize_expr(
|
||||
env,
|
||||
var_store,
|
||||
scope,
|
||||
continuation.region,
|
||||
&continuation.value,
|
||||
);
|
||||
|
||||
output.union(output1);
|
||||
output.union(output2);
|
||||
|
||||
(
|
||||
Dbg {
|
||||
loc_condition: Box::new(loc_condition),
|
||||
loc_continuation: Box::new(loc_continuation),
|
||||
variable: var_store.fresh(),
|
||||
symbol: scope.gen_unique_symbol(),
|
||||
},
|
||||
output,
|
||||
)
|
||||
}
|
||||
ast::Expr::If(if_thens, final_else_branch) => {
|
||||
let mut branches = Vec::with_capacity(if_thens.len());
|
||||
let mut output = Output::default();
|
||||
|
@ -1838,6 +1874,7 @@ pub fn inline_calls(var_store: &mut VarStore, expr: Expr) -> Expr {
|
|||
loc_condition,
|
||||
loc_continuation,
|
||||
variable,
|
||||
symbol,
|
||||
} => {
|
||||
let loc_condition = Loc {
|
||||
region: loc_condition.region,
|
||||
|
@ -1853,6 +1890,7 @@ pub fn inline_calls(var_store: &mut VarStore, expr: Expr) -> Expr {
|
|||
loc_condition: Box::new(loc_condition),
|
||||
loc_continuation: Box::new(loc_continuation),
|
||||
variable,
|
||||
symbol,
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2582,9 +2620,10 @@ impl Declarations {
|
|||
})
|
||||
}
|
||||
|
||||
pub fn expects(&self) -> VecMap<Region, Vec<ExpectLookup>> {
|
||||
pub fn expects(&self) -> ExpectCollector {
|
||||
let mut collector = ExpectCollector {
|
||||
expects: VecMap::default(),
|
||||
dbgs: VecMap::default(),
|
||||
};
|
||||
|
||||
let var = Variable::EMPTY_RECORD;
|
||||
|
@ -2617,7 +2656,7 @@ impl Declarations {
|
|||
}
|
||||
}
|
||||
|
||||
collector.expects
|
||||
collector
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2897,8 +2936,9 @@ fn toplevel_expect_to_inline_expect_help(mut loc_expr: Loc<Expr>, has_effects: b
|
|||
loc_expr
|
||||
}
|
||||
|
||||
struct ExpectCollector {
|
||||
expects: VecMap<Region, Vec<ExpectLookup>>,
|
||||
pub struct ExpectCollector {
|
||||
pub expects: VecMap<Region, Vec<ExpectLookup>>,
|
||||
pub dbgs: VecMap<Symbol, DbgLookup>,
|
||||
}
|
||||
|
||||
impl crate::traverse::Visitor for ExpectCollector {
|
||||
|
@ -2917,6 +2957,21 @@ impl crate::traverse::Visitor for ExpectCollector {
|
|||
self.expects
|
||||
.insert(loc_condition.region, lookups_in_cond.to_vec());
|
||||
}
|
||||
Expr::Dbg {
|
||||
loc_condition,
|
||||
variable,
|
||||
symbol,
|
||||
..
|
||||
} => {
|
||||
let lookup = DbgLookup {
|
||||
symbol: *symbol,
|
||||
var: *variable,
|
||||
region: loc_condition.region,
|
||||
ability_info: None,
|
||||
};
|
||||
|
||||
self.dbgs.insert(*symbol, lookup);
|
||||
}
|
||||
_ => (),
|
||||
}
|
||||
|
||||
|
|
|
@ -3,7 +3,9 @@ use crate::annotation::{canonicalize_annotation, AnnotationFor};
|
|||
use crate::def::{canonicalize_defs, Def};
|
||||
use crate::effect_module::HostedGeneratedFunctions;
|
||||
use crate::env::Env;
|
||||
use crate::expr::{ClosureData, Declarations, ExpectLookup, Expr, Output, PendingDerives};
|
||||
use crate::expr::{
|
||||
ClosureData, DbgLookup, Declarations, ExpectLookup, Expr, Output, PendingDerives,
|
||||
};
|
||||
use crate::pattern::{BindingsFromPattern, Pattern};
|
||||
use crate::scope::Scope;
|
||||
use bumpalo::Bump;
|
||||
|
@ -131,6 +133,7 @@ pub struct Module {
|
|||
pub rigid_variables: RigidVariables,
|
||||
pub abilities_store: PendingAbilitiesStore,
|
||||
pub loc_expects: VecMap<Region, Vec<ExpectLookup>>,
|
||||
pub loc_dbgs: VecMap<Symbol, DbgLookup>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Default)]
|
||||
|
@ -153,6 +156,7 @@ pub struct ModuleOutput {
|
|||
pub pending_derives: PendingDerives,
|
||||
pub scope: Scope,
|
||||
pub loc_expects: VecMap<Region, Vec<ExpectLookup>>,
|
||||
pub loc_dbgs: VecMap<Symbol, DbgLookup>,
|
||||
}
|
||||
|
||||
fn validate_generate_with<'a>(
|
||||
|
@ -776,7 +780,7 @@ pub fn canonicalize_module_defs<'a>(
|
|||
}
|
||||
}
|
||||
|
||||
let loc_expects = declarations.expects();
|
||||
let collected = declarations.expects();
|
||||
|
||||
ModuleOutput {
|
||||
scope,
|
||||
|
@ -789,7 +793,8 @@ pub fn canonicalize_module_defs<'a>(
|
|||
problems: env.problems,
|
||||
symbols_from_requires,
|
||||
pending_derives,
|
||||
loc_expects,
|
||||
loc_expects: collected.expects,
|
||||
loc_dbgs: collected.dbgs,
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -358,6 +358,14 @@ pub fn desugar_expr<'a>(arena: &'a Bump, loc_expr: &'a Loc<Expr<'a>>) -> &'a Loc
|
|||
region: loc_expr.region,
|
||||
})
|
||||
}
|
||||
Dbg(condition, continuation) => {
|
||||
let desugared_condition = &*arena.alloc(desugar_expr(arena, condition));
|
||||
let desugared_continuation = &*arena.alloc(desugar_expr(arena, continuation));
|
||||
arena.alloc(Loc {
|
||||
value: Dbg(desugared_condition, desugared_continuation),
|
||||
region: loc_expr.region,
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -291,6 +291,7 @@ pub fn walk_expr<V: Visitor>(visitor: &mut V, expr: &Expr, var: Variable) {
|
|||
variable,
|
||||
loc_condition,
|
||||
loc_continuation,
|
||||
symbol: _,
|
||||
} => {
|
||||
visitor.visit_expr(&loc_condition.value, loc_condition.region, *variable);
|
||||
visitor.visit_expr(
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue