implement multiterm synthetic expressions
This commit is contained in:
parent
fc245348b4
commit
c497b90a16
|
@ -860,8 +860,27 @@ impl Compiler {
|
|||
_ => unreachable!(),
|
||||
}
|
||||
// TODO: implement longer synthetic expressions
|
||||
for term in rest {
|
||||
todo!()
|
||||
for (term, _) in rest {
|
||||
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) => {
|
||||
|
|
11
src/main.rs
11
src/main.rs
|
@ -76,16 +76,9 @@ pub fn run(src: &'static str) {
|
|||
pub fn main() {
|
||||
env::set_var("RUST_BACKTRACE", "1");
|
||||
let src = "
|
||||
fn foo () -> {
|
||||
let x = :foo
|
||||
let y = :bar
|
||||
(x, y)
|
||||
}
|
||||
fn foo () -> fn () -> fn () -> #{:foo :bar}
|
||||
|
||||
let a = foo ()
|
||||
let b = foo ()
|
||||
|
||||
(a, b)
|
||||
foo () () () :foo
|
||||
";
|
||||
run(src);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user