Separate the IR evaluator, add an interesting stack-breaking case.
This commit is contained in:
@@ -15,7 +15,7 @@ impl ConstantType {
|
||||
match self {
|
||||
ConstantType::Void => &[],
|
||||
ConstantType::I8 | ConstantType::I16 | ConstantType::I32 | ConstantType::I64 => {
|
||||
&[("+", 2), ("-", 1), ("-", 2), ("*", 2), ("/", 2)]
|
||||
&[("+", 2), ("negate", 1), ("-", 2), ("*", 2), ("/", 2)]
|
||||
}
|
||||
ConstantType::U8 | ConstantType::U16 | ConstantType::U32 | ConstantType::U64 => {
|
||||
&[("+", 2), ("-", 2), ("*", 2), ("/", 2)]
|
||||
|
||||
@@ -146,7 +146,8 @@ impl Expression {
|
||||
|
||||
Value::Primitive(name) if name == "print" => {
|
||||
if let [Expression::Reference(_, name)] = &args[..] {
|
||||
let value = Expression::Reference(loc.clone(), name.clone()).eval(stdout, env)?;
|
||||
let value = Expression::Reference(loc.clone(), name.clone())
|
||||
.eval(stdout, env)?;
|
||||
let value = match value {
|
||||
Value::Number(x) => Value::U64(x),
|
||||
x => x,
|
||||
@@ -156,7 +157,10 @@ impl Expression {
|
||||
stdout.push_str(&addendum);
|
||||
Ok(Value::Void)
|
||||
} else {
|
||||
panic!("Non-reference/non-singleton argument to 'print': {:?}", args);
|
||||
panic!(
|
||||
"Non-reference/non-singleton argument to 'print': {:?}",
|
||||
args
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user