void DonutClosureObject::bootstrap(Handler<Heap> const& heap, Handler<Source> const& src, unsigned int const& closureIndex, Handler<Object> const& scope) { const_cast<Handler<Source>&>(this->src_) = src; const_cast<unsigned int&>(this->index_) = closureIndex; const_cast<Handler<Closure>&>(this->asm_) = src->getClosure(closureIndex); if(scope){ this->set(heap, "__scope__", scope); } }
TEST_F(DonutParserTest, DotTest) { Handler<Source> code = Parser::fromString("func(zux){test.aux=1;};", "<MEM>", 0)->parseProgram(); ASSERT_EQ(2, code->numClosure()); Handler<Closure> clos = code->getEntrypoint(); ASSERT_EQ(0, clos->arglist().size()); ASSERT_LT(0, clos->instlist().size()); Handler<Closure> another = code->getClosure((code->getEntrypointID()+1)%2); ASSERT_EQ(1, another->arglist().size()); ASSERT_LT(0, another->instlist().size()); }