Skip to content

Commit

Permalink
fix: Print closures as name: value using debug information
Browse files Browse the repository at this point in the history
  • Loading branch information
Marwes committed Jan 22, 2017
1 parent cf67386 commit 880e600
Showing 1 changed file with 13 additions and 6 deletions.
19 changes: 13 additions & 6 deletions vm/src/value.rs
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,6 @@ enum Prec {
}
use self::Prec::*;


pub struct ValuePrinter<'a> {
pub typ: &'a ArcType,
pub env: &'a TypeEnv,
Expand Down Expand Up @@ -341,11 +340,19 @@ impl<'a, 't> InternalPrinter<'a, 't> {
}
Value::Closure(ref closure) => {
chain![arena;
"{",
arena.concat(closure.upvars.iter().map(|field| {
arena.text(format!("{:?}", field))
})),
"}"
"<",
arena.text(closure.function.name.declared_name().to_string()),
arena.concat(closure.upvars.iter().zip(&closure.function.debug_info.upvars)
.map(|(field, info)| {
chain![arena;
arena.space(),
info.name.clone(),
":",
arena.space(),
self.p(&info.typ, Top).pretty(*field)
]
}).intersperse(arena.text(","))),
">"
]
}
Value::Array(ref array) => {
Expand Down

0 comments on commit 880e600

Please sign in to comment.