// examples/dataflow_testing translated by mycpp // BEGIN mycpp output #include "mycpp/runtime.h" GLOBAL_STR(str0, "key"); GLOBAL_STR(str1, "var"); namespace dataflow_testing { // forward declare class ObjectA; class ObjectB; class ctx_Noop; } // forward declare namespace dataflow_testing namespace dataflow_testing { // declare class ObjectA { public: ObjectA(int a, Tuple2* b); List* list; int a; static constexpr ObjHeader obj_header() { return ObjHeader::ClassScanned(1, sizeof(ObjectA)); } DISALLOW_COPY_AND_ASSIGN(ObjectA) }; class ObjectB { public: ObjectB(); Dict*>* dict; static constexpr ObjHeader obj_header() { return ObjHeader::ClassScanned(1, sizeof(ObjectB)); } DISALLOW_COPY_AND_ASSIGN(ObjectB) }; class ctx_Noop { public: ctx_Noop(); ~ctx_Noop(); DISALLOW_COPY_AND_ASSIGN(ctx_Noop) }; void run_tests(); } // declare namespace dataflow_testing namespace dataflow_testing { // define ObjectA::ObjectA(int a, Tuple2* b) { this->a = a; Tuple2* tup0 = b; x = tup0->at0(); y = tup0->at1(); this->list = NewList(std::initializer_list{(x * y)}); } ObjectB::ObjectB() { this->dict = Alloc*>>(); } ctx_Noop::ctx_Noop() { ; // pass } ctx_Noop::~ctx_Noop() { ; // pass } void run_tests() { dataflow_testing::ObjectA* a = nullptr; dataflow_testing::ObjectB* obj_b = nullptr; dataflow_testing::ObjectA* b = nullptr; dataflow_testing::ObjectA* c = nullptr; dataflow_testing::ObjectA* d = nullptr; List* l = nullptr; a = Alloc(1, (Alloc>(2, 3))); obj_b = Alloc(); obj_b->dict->set(str0, a->list); b = a; try { { // with ctx_Noop ctx{}; c = b; } } catch (AssertionError*) { d = c; } l = NewList(std::initializer_list{nullptr, nullptr, nullptr}); for (int i = 0; i < 3; ++i) { if (os::getenv(str1) != nullptr) { ; // pass } else { l->set(i, b); } } } } // define namespace dataflow_testing int main(int argc, char **argv) { gHeap.Init(); char* b = getenv("BENCHMARK"); if (b && strlen(b)) { // match Python's logic fprintf(stderr, "Benchmarking...\n"); dataflow_testing::run_benchmarks(); } else { dataflow_testing::run_tests(); } gHeap.CleanProcessExit(); }