gc<Chunk> ExprCompiler::compile(Module* module, FnExpr& function) { compile(module, function.resolved().maxLocals(), NULL, function.pattern(), NULL, function.body()); // TODO(bob): Is this the right error? // If we get here, the argument didn't match the function's signature so // throw a NoMethodError. write(-1, OP_BUILT_IN, 3, 0); write(-1, OP_THROW, 0); chunk_->bind(maxSlots_, function.resolved().closures().count()); return chunk_; }
void ExprCompiler::visit(FnExpr& expr, int dest) { // TODO(bob): Handle closures. ExprCompiler compiler(compiler_); gc<Chunk> chunk = compiler.compile(module_, expr); int index = chunk_->addChunk(chunk); write(expr, OP_FUNCTION, index, dest); compileClosures(expr.pos(), expr.resolved()); }
void Resolver::visit(FnExpr& expr, int dummy) { // Resolve the function itself. resolve(compiler_, module_, this, &expr.resolved(), false, NULL, expr.pattern(), NULL, expr.body()); }