- Timestamp:
- Feb 7, 2019, 1:18:27 PM (5 years ago)
- Branches:
- (u'spielwiese', '2a584933abf2a2d3082034c7586d38bb6de1a30a')
- Children:
- 098784114c00a08a4d18cf392c0f2411aa0d007ed669f7b103e531e130535f2141dd1d77cfa31a81
- Parents:
- 54b24c79febc0e79ee3f9c6a86b7c4d505c69a43
- Location:
- ppcc/src
- Files:
-
- 1 added
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
ppcc/src/parser.cc
r54b24c raa4d31 1 1 #include "adlib/lib.h" 2 2 #include "adlib/map.h" 3 #include "adlib/set.h" 3 4 #include "pplex.h" 4 5 … … 18 19 static Dict *class_vars; 19 20 static Dict *class_types; 21 static StrSet *type_prefix_set; 22 static Dict *namespaced; 20 23 21 24 enum DeclType { … … 37 40 GCVar(class_vars, new Dict()); 38 41 GCVar(class_types, new Dict()); 42 GCVar(type_prefix_set, new StrSet()); 43 type_prefix_set->add(S("class")); 44 type_prefix_set->add(S("struct")); 45 type_prefix_set->add(S("typedef")); 46 // special treatment for some gfanlib variables for now. 47 GCVar(namespaced, new Dict()); 48 namespaced->add(S("MVMachineIntegerOverflow"), S("gfan")); 49 namespaced->add(S("lpSolver"), S("gfan")); 39 50 }); 40 51 … … 244 255 } 245 256 if ((is_class && !is_extern) || init_start >= 0) { 246 if (is_toplevel) 257 if (is_toplevel) { 247 258 init_list->add(var_name); 259 } 248 260 Token var_init = Token(SymGen, var_name->clone()->add("__INIT__")); 249 261 parser->emit(static_token); … … 262 274 parser->init_count++; 263 275 parser->emit(Token(SymGen, S( 264 " staticpSingular_register_init_var(void *, void *, long);"276 "void pSingular_register_init_var(void *, void *, long);" 265 277 "class %s__CONSTR__ {\n" 266 " %s__CONSTR__() {\n"278 " public: %s__CONSTR__() {\n" 267 279 " pSingular_register_init_var(&%s, &%s__INIT__, sizeof(%s));\n" 268 280 " }\n" … … 281 293 Token &token = output->at(i); 282 294 if (token.sym == SymIdent && class_vars->contains(token.str)) { 283 token.str = class_vars->at(token.str); 295 Int j = i-1; 296 while (j >= 0 && TEST(SymsWS | BIT(SymAst), output->at(j).sym)) 297 j--; 298 if (j < 0 || !type_prefix_set->contains(output->at(j).str)) 299 token.str = class_vars->at(token.str); 284 300 } 285 301 } … … 318 334 if (class_vars->contains(var_name)) { 319 335 Str *type = class_types->at(var_name); 336 if (namespaced->contains(var_name)) { 337 type = namespaced->at(var_name)->clone()->add("::")->add(type); 338 var_name = namespaced->at(var_name)->clone()->add("::")->add(var_name); 339 } 320 340 init_part->add(S( 321 341 " %s = (%c *)pSingular_alloc_var((long)sizeof(%c));\n" … … 374 394 Int var_pos = -1, var_start = -1, var_end = -1; 375 395 var_start = parser->current_pos(); 376 parser->skip_while(SymsTypePrefix | BIT(SymWS) );396 parser->skip_while(SymsTypePrefix | BIT(SymWS) | BIT(SymClass)); 377 397 if (TEST(SymsEndDecl | BIT(SymLBrkt), parser->current_sym())) { 378 398 // We are one symbol past the initial variable identifier. … … 481 501 if (toplevel->len() > 0) 482 502 toplevel->pop(); 503 tl = 0; 483 504 parser->advance(); 484 505 break; -
ppcc/src/ppcc.cc
r54b24c raa4d31 160 160 void TestOutputExecutable() { 161 161 if (mode == LINK) { 162 Str *path = S("factory/threadsupport.cc"); 163 for (Int i = 0; i < 4; i++) { 164 if (FileStat(path)) { 165 ExtraArgs->add(path); 166 return; 167 } 168 path = S("../")->add(path); 162 if (Output && FileExtension(Output)->len() != 0) { 163 return; 164 } 165 Str *path = DirName(ProgramPath()); 166 if (path) { 167 path->add("/../Singular/threadsupport.cc"); 168 path = NormalizePath(path); 169 } 170 if (path && FileStat(path)) { 171 ExtraArgs->add(path); 172 } else { 173 PrintLn(path); 174 Error("cannot locate ppcc directory"); 169 175 } 170 176 }
Note: See TracChangeset
for help on using the changeset viewer.