void MMO_Generator_::_generateFunctionCode (MMO_Function f) { list<string> code; MMO_ImportTable it = f->imports (); for (string i = it->begin (); !it->end (); i = it->next ()) { string addInclude = Util::getInstance ()->packageName (i); if (_includes.find (addInclude) == _includes.end ()) { _includes[addInclude] = addInclude; _writer->write ("#include \"" + addInclude + ".h\"", WR_FUNCTION_HEADER); } } if (f->annotation ()->hasInclude ()) { string addInclude = f->annotation ()->include (); if (_includes.find (addInclude) == _includes.end ()) { _includes[addInclude] = addInclude; _writer->write (addInclude, WR_FUNCTION_HEADER); } } string indent = _writer->indent (1); stringstream buffer; buffer << f->prototype (); _writer->write (&buffer, WR_FUNCTION_CODE); _writer->write ("{", WR_FUNCTION_CODE); _writer->beginBlock (); _printList (f->localDeclarations ()); MMO_StatementTable stt = f->statements (); VarSymbolTable vt = f->varTable (); vt->setPrintEnvironment (VST_FUNCTION); for (MMO_Statement st = stt->begin (); !stt->end (); st = stt->next ()) { list<string> sts = st->print (indent); _printList (st->getVariables ()); code.insert (code.end (), sts.begin (), sts.end ()); } _printList (code); MMO_ArgumentsTable at = f->externalFunctionCalls (); for (MMO_FunctionData fd = at->begin (); !at->end (); fd = at->next ()) { _printList (fd->print (indent)); } _writer->write (f->returnStatement (), WR_FUNCTION_CODE); _writer->endBlock (); _writer->write ("}", WR_FUNCTION_CODE); }
int main(int argc, char* argv[]) { int returned = -1; struct linkedList* q = createLinkedList(3); printf("Checking if the list is empty: %d\n", isEmptyList(q)); printf("Attempting to add to front \n"); addFrontList(q, 1); removeList(q, 1); printf("Checking if the list is empty: %d\n", isEmptyList(q)); addFrontList(q, 2); addFrontList(q, 3); _printList(q); printf("Attempting to add to back \n"); addBackList(q, 4); addBackList(q, 5); addBackList(q, 6); _printList(q); printf("Attempting to print front \n"); printf("%d\n", frontList(q)); printf("Attempting to print back \n"); printf("%d\n", backList(q)); printf("Attempting to remove front \n"); removeFrontList(q); _printList(q); printf("Attempting to remove back \n"); removeBackList(q); _printList(q); printf("Attempting to delete 4 \n"); removeList(q, 4); _printList(q); printf("Attempting to print list \n"); _printList(q); printf("Attempting to confirm contains 5 \n"); returned = containsList(q, 5); if (returned == 1) printf("true \n"); else printf("false \n"); return 0; }
void MMO_Generator_::_generateFunction (MMO_FunctionDefinition f, string fileName) { _printList (f->def ()); }