Revert "Eval errors are now correctly spanned"
This reverts commit 2f5b954b7c
.
This commit is contained in:
parent
975655a96e
commit
7a275556c7
|
@ -355,10 +355,7 @@ impl ExecEnv {
|
||||||
}
|
}
|
||||||
|
|
||||||
let stmts = crate::parser::Parser::new(&code).init()?;
|
let stmts = crate::parser::Parser::new(&code).init()?;
|
||||||
self.eval_stmts(&stmts).map_err(|x| Error {
|
self.eval_stmts(&stmts)?;
|
||||||
span: span.clone(),
|
|
||||||
..x
|
|
||||||
})?;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Ok(())
|
Ok(())
|
||||||
|
|
|
@ -93,16 +93,11 @@ impl Value {
|
||||||
Value::Abool(a) => a as _,
|
Value::Abool(a) => a as _,
|
||||||
Value::Bool(b) => b as _,
|
Value::Bool(b) => b as _,
|
||||||
Value::Functio(func) => match func {
|
Value::Functio(func) => match func {
|
||||||
// Compares lengths of functions:
|
|
||||||
// BfFunctio - Sum of lengths of instructions and length of tape
|
|
||||||
// AbleFunctio - Sum of argument count and body length
|
|
||||||
// Eval - Length of input code
|
|
||||||
|
|
||||||
Functio::BfFunctio {
|
Functio::BfFunctio {
|
||||||
instructions,
|
instructions,
|
||||||
tape_len,
|
tape_len,
|
||||||
} => (instructions.len() + tape_len) as _,
|
} => (instructions.len() + tape_len) as _,
|
||||||
Functio::AbleFunctio { params, body } => (params.len() + format!("{:?}", body).len()) as _,
|
Functio::AbleFunctio { params, body } => (params.len() + body.len()) as _,
|
||||||
Functio::Eval(s) => s.len() as _,
|
Functio::Eval(s) => s.len() as _,
|
||||||
},
|
},
|
||||||
Value::Int(i) => i,
|
Value::Int(i) => i,
|
||||||
|
@ -366,7 +361,32 @@ impl PartialOrd for Value {
|
||||||
Value::Int(i) => Some(i.cmp(&other.into_i32())),
|
Value::Int(i) => Some(i.cmp(&other.into_i32())),
|
||||||
Value::Bool(b) => Some(b.cmp(&other.into_bool())),
|
Value::Bool(b) => Some(b.cmp(&other.into_bool())),
|
||||||
Value::Abool(a) => a.partial_cmp(&other.into_abool()),
|
Value::Abool(a) => a.partial_cmp(&other.into_abool()),
|
||||||
Value::Functio(_) => self.clone().into_i32().partial_cmp(&other.into_i32()),
|
Value::Functio(f) => {
|
||||||
|
// Compares lengths of functions:
|
||||||
|
// BfFunctio - Sum of lengths of instructions and length of tape
|
||||||
|
// AbleFunctio - Sum of argument count and body length
|
||||||
|
// Eval - Length of input code
|
||||||
|
|
||||||
|
let selfl = match f {
|
||||||
|
Functio::BfFunctio {
|
||||||
|
instructions,
|
||||||
|
tape_len,
|
||||||
|
} => instructions.len() + tape_len,
|
||||||
|
Functio::AbleFunctio { params, body } => params.len() + body.len(),
|
||||||
|
Functio::Eval(s) => s.len(),
|
||||||
|
};
|
||||||
|
|
||||||
|
let otherl = match other.into_functio() {
|
||||||
|
Functio::BfFunctio {
|
||||||
|
instructions,
|
||||||
|
tape_len,
|
||||||
|
} => instructions.len() + tape_len,
|
||||||
|
Functio::AbleFunctio { params, body } => params.len() + body.len(),
|
||||||
|
Functio::Eval(s) => s.len(),
|
||||||
|
};
|
||||||
|
|
||||||
|
Some(selfl.cmp(&otherl))
|
||||||
|
}
|
||||||
Value::Cart(c) => Some(c.len().cmp(&other.into_cart().len())),
|
Value::Cart(c) => Some(c.len().cmp(&other.into_cart().len())),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue