예제 #1
0
  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());
  }
예제 #2
0
  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_;
  }
예제 #3
0
파일: Resolver.cpp 프로젝트: relrod/magpie
 void Resolver::visit(FnExpr& expr, int dummy)
 {
   // Resolve the function itself.
   resolve(compiler_, module_, this, &expr.resolved(), false,
           NULL, expr.pattern(), NULL, expr.body());
 }