/* ** Yab2Cpp ** ** Transpiler by Samuel D. Crow ** ** Based on Yab ** */ #include "yab2cpp.h" #include "runtime/runtime.h" /* static initializers */ unordered_map > label::lookup; unsigned int label::nextID=START; /* base class of all the code structure types */ codeType::codeType(enum CODES t) { this->type=t; if (TRACE) { indent(); logfile << "Entering " << CODETYPES[t]; } ++indentLevel; } codeType::~codeType() { --indentLevel; if (TRACE) { indent(); logfile << "Leaving " << CODETYPES[this->getType()]; } } /* label definitions and helper routines */ label *label::find(string &s) { unordered_map >lookup; auto ret=label::lookup.find(s); return(ret==label::lookup.end()?nullptr:ret->second.get()); } void label::dumpLabels() { varNames << "Global Labels\n" << endl; for(auto iter=lookup.begin(); iter!=lookup.end(); ++iter) { varNames << "label " << iter->first << " has ID " << iter->second->getID() << endl ; } } void label::generateEnd() { output_cpp << "state=EXIT;\nbreak;\n"; } void label::generateJumpTo() { output_cpp << "state=" << this->getID() << ";\nbreak;\n"; } /* pass this as second parameter to generateOnNTo or generateOnNSub */ unsigned int label::generateOnNSkip(list