Changeset ef0a94 in git for ppcc/src/parser.cc
- Timestamp:
- Feb 13, 2019, 5:39:27 PM (5 years ago)
- Branches:
- (u'spielwiese', 'fe61d9c35bf7c61f2b6cbf1b56e25e2f08d536cc')
- Children:
- e26df3f314b9946ffef7f945cbe5c66517600b92
- Parents:
- d669f7b103e531e130535f2141dd1d77cfa31a81
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
ppcc/src/parser.cc
rd669f7 ref0a94 56 56 class Parser : public GC { 57 57 public: 58 TokenList *input, *output ;58 TokenList *input, *output, *prologue; 59 59 SourceFile *source; 60 60 Int pos, marker; … … 66 66 input->add(eof); 67 67 output = new TokenList(); 68 prologue = new TokenList(); 68 69 pos = 0; 69 70 marker = 0; … … 274 275 parser->init_count++; 275 276 parser->emit(Token(SymGen, S( 276 "void pSingular_register_init_var(void *, void *, long);"277 277 "class %s__CONSTR__ {\n" 278 278 " public: %s__CONSTR__() {\n" 279 " pSingular_register_init_var( &%s,&%s__INIT__, sizeof(%s));\n"279 " pSingular_register_init_var((void *)&%s, (void *)&%s__INIT__, sizeof(%s));\n" 280 280 " }\n" 281 281 "} %s__AUX__;\n" … … 286 286 287 287 void EmitEpilogue(Parser *parser) { 288 if ( init_list->len() == 0 && class_vars->count() == 0)288 if (parser->init_count == 0 && init_list->len() == 0 && class_vars->count() == 0) 289 289 return; 290 290 Str *modulename = parser->source->modulename; … … 300 300 } 301 301 } 302 if ( init_list->len() == 0)302 if (parser->init_count == 0 && init_list->len() == 0) 303 303 return; 304 304 Str *init_part; … … 350 350 } 351 351 init_part->add("}\n"); 352 if (parser->init_count) { 353 parser->prologue->add(Token(SymGen, 354 S("static void pSingular_register_init_var(void *, void *, long);\n"))); 355 } 352 356 init_part = init_part->replace_all(S("%n"), S(parser->init_count+1)); 353 357 parser->emit(Token(SymGen, init_part)); … … 512 516 } 513 517 EmitEpilogue(parser); 514 return parser-> output;518 return parser->prologue->clone()->add(parser->output); 515 519 } 516 520 … … 531 535 SourceFile *source = ReadSource(filename, filedata); 532 536 TokenList *tokens = Transform(source); 533 Str *result = new Str(); for (Int i = 0; i < tokens->len(); i++) { 537 Str *result = new Str(); 538 for (Int i = 0; i < tokens->len(); i++) { 534 539 result->add(tokens->at(i).str); 535 540 }
Note: See TracChangeset
for help on using the changeset viewer.