implement multiterm synthetic expressions
This commit is contained in:
parent
fc245348b4
commit
c497b90a16
|
@ -860,8 +860,27 @@ impl Compiler {
|
||||||
_ => unreachable!(),
|
_ => unreachable!(),
|
||||||
}
|
}
|
||||||
// TODO: implement longer synthetic expressions
|
// TODO: implement longer synthetic expressions
|
||||||
for term in rest {
|
for (term, _) in rest {
|
||||||
todo!()
|
match term {
|
||||||
|
Keyword(str) => {
|
||||||
|
self.emit_constant(Value::Keyword(str));
|
||||||
|
self.emit_op(Op::GetKey);
|
||||||
|
self.stack_depth -= 1;
|
||||||
|
}
|
||||||
|
Arguments(args) => {
|
||||||
|
self.emit_op(Op::Stash);
|
||||||
|
self.pop();
|
||||||
|
let arity = args.len();
|
||||||
|
for arg in args {
|
||||||
|
self.visit(arg);
|
||||||
|
}
|
||||||
|
self.emit_op(Op::Load);
|
||||||
|
self.emit_op(Op::Call);
|
||||||
|
self.emit_byte(arity);
|
||||||
|
self.stack_depth -= arity;
|
||||||
|
}
|
||||||
|
_ => unreachable!(),
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
When(clauses) => {
|
When(clauses) => {
|
||||||
|
|
11
src/main.rs
11
src/main.rs
|
@ -76,16 +76,9 @@ pub fn run(src: &'static str) {
|
||||||
pub fn main() {
|
pub fn main() {
|
||||||
env::set_var("RUST_BACKTRACE", "1");
|
env::set_var("RUST_BACKTRACE", "1");
|
||||||
let src = "
|
let src = "
|
||||||
fn foo () -> {
|
fn foo () -> fn () -> fn () -> #{:foo :bar}
|
||||||
let x = :foo
|
|
||||||
let y = :bar
|
|
||||||
(x, y)
|
|
||||||
}
|
|
||||||
|
|
||||||
let a = foo ()
|
foo () () () :foo
|
||||||
let b = foo ()
|
|
||||||
|
|
||||||
(a, b)
|
|
||||||
";
|
";
|
||||||
run(src);
|
run(src);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user