basic function calls, still with bugs!
This commit is contained in:
parent
22d1ceb3e8
commit
681176282c
|
@ -286,9 +286,9 @@ fn get_builtin(name: &str, arity: usize) -> Option<Op> {
|
||||||
pub struct Compiler {
|
pub struct Compiler {
|
||||||
pub chunk: Chunk,
|
pub chunk: Chunk,
|
||||||
pub bindings: Vec<Binding>,
|
pub bindings: Vec<Binding>,
|
||||||
scope_depth: isize,
|
pub scope_depth: isize,
|
||||||
match_depth: usize,
|
pub match_depth: usize,
|
||||||
stack_depth: usize,
|
pub stack_depth: usize,
|
||||||
pub spans: Vec<SimpleSpan>,
|
pub spans: Vec<SimpleSpan>,
|
||||||
pub nodes: Vec<&'static Ast>,
|
pub nodes: Vec<&'static Ast>,
|
||||||
pub ast: &'static Ast,
|
pub ast: &'static Ast,
|
||||||
|
@ -837,10 +837,8 @@ impl Compiler {
|
||||||
// visit all the args
|
// visit all the args
|
||||||
// then store them
|
// then store them
|
||||||
// then call the function
|
// then call the function
|
||||||
for (register_slot, arg) in args.iter().enumerate() {
|
for arg in args {
|
||||||
self.visit(arg);
|
self.visit(arg);
|
||||||
self.emit_op(Op::StoreAt);
|
|
||||||
self.emit_byte(register_slot);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
self.emit_op(Op::PushBinding);
|
self.emit_op(Op::PushBinding);
|
||||||
|
@ -982,7 +980,7 @@ impl Compiler {
|
||||||
Some(compiler) => compiler,
|
Some(compiler) => compiler,
|
||||||
None => {
|
None => {
|
||||||
let mut compiler = Compiler::new(clause, self.name, self.src);
|
let mut compiler = Compiler::new(clause, self.name, self.src);
|
||||||
compiler.emit_op(Op::Load);
|
// compiler.emit_op(Op::Load);
|
||||||
compiler.stack_depth += arity;
|
compiler.stack_depth += arity;
|
||||||
compiler.scope_depth += 1;
|
compiler.scope_depth += 1;
|
||||||
compiler.emit_op(Op::ResetMatch);
|
compiler.emit_op(Op::ResetMatch);
|
||||||
|
|
|
@ -78,7 +78,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 = "
|
||||||
(1, 2, 3)
|
fn foo (_) -> [1, 2, 3]
|
||||||
|
|
||||||
|
foo (1)
|
||||||
";
|
";
|
||||||
run(src);
|
run(src);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user