// BEGIN mycpp output #include "gc_heap.h" using gc_heap::Alloc; using gc_heap::kZeroMask; using gc_heap::StackRoots; #include "my_runtime.h" #include "mylib2.h" using gc_heap::NewStr; using gc_heap::NewList; using gc_heap::NewDict; GLOBAL_STR(str0, "yo"); namespace test_cast { // forward declare class ColorOutput; } // forward declare namespace test_cast namespace test_cast { // declare class ColorOutput : public gc_heap::Obj { public: ColorOutput(mylib::Writer* f); void WriteRaw(Tuple2* raw); Tuple2 GetRaw(); mylib::Writer* f; int num_chars; DISALLOW_COPY_AND_ASSIGN(ColorOutput) }; void run_tests(); void run_benchmarks(); } // declare namespace test_cast namespace test_cast { // define ColorOutput::ColorOutput(mylib::Writer* f) : gc_heap::Obj(Tag::FixedSize, kZeroMask, sizeof(ColorOutput)) { this->f = f; this->num_chars = 0; } void ColorOutput::WriteRaw(Tuple2* raw) { Str* s = nullptr; int num_chars; StackRoots _roots({&raw, &s}); Tuple2* tup0 = raw; s = tup0->at0(); num_chars = tup0->at1(); this->f->write(s); this->num_chars += num_chars; } Tuple2 ColorOutput::GetRaw() { mylib::BufWriter* f = static_cast(this->f); return (Tuple2(f->getvalue(), this->num_chars)); } void run_tests() { mylib::BufWriter* f = nullptr; test_cast::ColorOutput* out = nullptr; Str* s = nullptr; int num_chars; StackRoots _roots({&f, &out, &s}); f = Alloc(); out = Alloc(f); out->WriteRaw((Alloc>(str0, 2))); Tuple2 tup1 = out->GetRaw(); s = tup1.at0(); num_chars = tup1.at1(); print(s); } void run_benchmarks() { throw Alloc(); } } // define namespace test_cast