Changeset ecae5860
- Timestamp:
- Jun 1, 2018, 7:53:43 PM (7 years ago)
- Branches:
- ADT, aaron-thesis, arm-eh, ast-experimental, cleanup-dtors, deferred_resn, demangler, enum, forall-pointer-decay, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr, new-env, no_list, persistent-indexer, pthread-emulation, qualifiedEnum, with_gc
- Children:
- adb6a4f1
- Parents:
- b368dd8
- Location:
- src
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
src/Parser/TypedefTable.cc
rb368dd8 recae5860 10 10 // Created On : Sat May 16 15:20:13 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Wed May 30 18:04:38 201813 // Update Count : 1 4812 // Last Modified On : Fri Jun 1 16:54:18 2018 13 // Update Count : 155 14 14 // 15 15 … … 54 54 void TypedefTable::makeTypedef( const string & name ) { 55 55 if ( ! typedefTable.exists( name ) ) { 56 typedefTable.addToEnclosingScope( name, TYPEDEFname /*, "MTD"*/);56 typedefTable.addToEnclosingScope( name, TYPEDEFname, "MTD" ); 57 57 } // if 58 58 } // TypedefTable::makeTypedef 59 59 60 void TypedefTable::addToScope( const std::string & identifier, int kind /*, const char * locn*/) {60 void TypedefTable::addToScope( const std::string & identifier, int kind, const char * locn __attribute__((unused)) ) { 61 61 auto scope = kindTable.currentScope(); 62 debugPrint( cerr << "Adding at " /* << locn */<< " " << identifier << " as kind " << kind << " scope " << scope << endl );62 debugPrint( cerr << "Adding at " << locn << " " << identifier << " as kind " << kind << " scope " << scope << endl ); 63 63 auto ret = kindTable.insertAt( scope, identifier, kind ); 64 64 if ( ! ret.second ) ret.first->second = kind; // exists => update 65 65 } // TypedefTable::addToScope 66 66 67 void TypedefTable::addToEnclosingScope( const std::string & identifier, int kind /*, const char * locn*/) {67 void TypedefTable::addToEnclosingScope( const std::string & identifier, int kind, const char * locn __attribute__((unused)) ) { 68 68 assert( kindTable.currentScope() >= 1 ); 69 69 auto scope = kindTable.currentScope() - 1; 70 debugPrint( cerr << "Adding 2 at " /* << locn */<< " " << identifier << " as kind " << kind << " scope " << scope << endl );70 debugPrint( cerr << "Adding+1 at " << locn << " " << identifier << " as kind " << kind << " scope " << scope << endl ); 71 71 auto ret = kindTable.insertAt( scope, identifier, kind ); 72 72 if ( ! ret.second ) ret.first->second = kind; // exists => update -
src/Parser/TypedefTable.h
rb368dd8 recae5860 10 10 // Created On : Sat May 16 15:24:36 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Wed May 30 17:02:49201813 // Update Count : 8 212 // Last Modified On : Thu May 31 23:23:47 2018 13 // Update Count : 83 14 14 // 15 15 … … 32 32 void changeKind( const std::string & identifier, int kind ); 33 33 void makeTypedef( const std::string & name ); 34 void addToScope( const std::string & identifier, int kind /*, const char **/);35 void addToEnclosingScope( const std::string & identifier, int kind /*, const char */);34 void addToScope( const std::string & identifier, int kind, const char * ); 35 void addToEnclosingScope( const std::string & identifier, int kind, const char * ); 36 36 37 37 void enterScope(); -
src/Parser/parser.yy
rb368dd8 recae5860 10 10 // Created On : Sat Sep 1 20:22:55 2001 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Thu May 31 15:11:40201813 // Update Count : 34 4412 // Last Modified On : Fri Jun 1 17:59:57 2018 13 // Update Count : 3476 14 14 // 15 15 … … 304 304 %type<en> enumerator_value_opt 305 305 306 %type<decl> exception_declaration external_definition external_definition_list external_definition_list_ opt306 %type<decl> exception_declaration external_definition external_definition_list external_definition_list_no_pop_push external_definition_list_opt 307 307 308 308 %type<decl> field_declaration field_declaration_list_opt field_declarator_opt field_declaring_list … … 644 644 // semantics checks, e.g., ++3, 3--, *3, &&3 645 645 | constant 646 { $$ = $1; }647 646 | string_literal 648 647 { $$ = new ExpressionNode( $1 ); } … … 988 987 { $$ = new StatementNode( build_if( $3, $5, $7 ) ); } 989 988 ; 990 991 989 992 990 if_control_expression: … … 1383 1381 cfa_function_declaration: // CFA 1384 1382 cfa_function_specifier 1385 { $$ = $1; }1386 1383 | type_qualifier_list cfa_function_specifier 1387 1384 { $$ = $2->addQualifiers( $1 ); } … … 1440 1437 TYPEDEF cfa_variable_specifier 1441 1438 { 1442 typedefTable.addToEnclosingScope( *$2->name, TYPEDEFname /*, "1"*/);1439 typedefTable.addToEnclosingScope( *$2->name, TYPEDEFname, "1" ); 1443 1440 $$ = $2->addTypedef(); 1444 1441 } 1445 1442 | TYPEDEF cfa_function_specifier 1446 1443 { 1447 typedefTable.addToEnclosingScope( *$2->name, TYPEDEFname /*, "2"*/);1444 typedefTable.addToEnclosingScope( *$2->name, TYPEDEFname, "2" ); 1448 1445 $$ = $2->addTypedef(); 1449 1446 } 1450 1447 | cfa_typedef_declaration pop ',' push no_attr_identifier 1451 1448 { 1452 typedefTable.addToEnclosingScope( *$5, TYPEDEFname /*, "3"*/);1449 typedefTable.addToEnclosingScope( *$5, TYPEDEFname, "3" ); 1453 1450 $$ = $1->appendList( $1->cloneType( $5 ) ); 1454 1451 } … … 1461 1458 TYPEDEF type_specifier declarator 1462 1459 { 1463 typedefTable.addToEnclosingScope( *$3->name, TYPEDEFname /*, "4"*/);1460 typedefTable.addToEnclosingScope( *$3->name, TYPEDEFname, "4" ); 1464 1461 $$ = $3->addType( $2 )->addTypedef(); 1465 1462 } 1466 1463 | typedef_declaration pop ',' push declarator 1467 1464 { 1468 typedefTable.addToEnclosingScope( *$5->name, TYPEDEFname /*, "5"*/);1465 typedefTable.addToEnclosingScope( *$5->name, TYPEDEFname, "5" ); 1469 1466 $$ = $1->appendList( $1->cloneBaseType( $5 )->addTypedef() ); 1470 1467 } 1471 1468 | type_qualifier_list TYPEDEF type_specifier declarator // remaining OBSOLESCENT (see 2 ) 1472 1469 { 1473 typedefTable.addToEnclosingScope( *$4->name, TYPEDEFname /*, "6"*/);1470 typedefTable.addToEnclosingScope( *$4->name, TYPEDEFname, "6" ); 1474 1471 $$ = $4->addType( $3 )->addQualifiers( $1 )->addTypedef(); 1475 1472 } 1476 1473 | type_specifier TYPEDEF declarator 1477 1474 { 1478 typedefTable.addToEnclosingScope( *$3->name, TYPEDEFname /*, "7"*/);1475 typedefTable.addToEnclosingScope( *$3->name, TYPEDEFname, "7" ); 1479 1476 $$ = $3->addType( $1 )->addTypedef(); 1480 1477 } 1481 1478 | type_specifier TYPEDEF type_qualifier_list declarator 1482 1479 { 1483 typedefTable.addToEnclosingScope( *$4->name, TYPEDEFname /*, "8"*/);1480 typedefTable.addToEnclosingScope( *$4->name, TYPEDEFname, "8" ); 1484 1481 $$ = $4->addQualifiers( $1 )->addTypedef()->addType( $1 ); 1485 1482 } … … 1937 1934 { $$ = nullptr; } 1938 1935 | bit_subrange_size 1939 { $$ = $1; }1940 1936 ; 1941 1937 … … 2187 2183 type_parameter_list: // CFA 2188 2184 type_parameter 2189 { $$ = $1; }2190 2185 | type_parameter_list ',' type_parameter 2191 2186 { $$ = $1->appendList( $3 ); } … … 2201 2196 type_parameter: // CFA 2202 2197 type_class no_attr_identifier_or_type_name 2203 { typedefTable.addToScope( *$2, TYPEDEFname /*, "9"*/); }2198 { typedefTable.addToScope( *$2, TYPEDEFname, "9" ); } 2204 2199 type_initializer_opt assertion_list_opt 2205 2200 { $$ = DeclarationNode::newTypeParam( $1, $2 )->addTypeInitializer( $4 )->addAssertions( $5 ); } … … 2270 2265 no_attr_identifier_or_type_name 2271 2266 { 2272 typedefTable.addToEnclosingScope( *$1, TYPEDEFname /*, "10"*/);2267 typedefTable.addToEnclosingScope( *$1, TYPEDEFname, "10" ); 2273 2268 $$ = DeclarationNode::newTypeDecl( $1, 0 ); 2274 2269 } 2275 2270 | no_attr_identifier_or_type_name '(' type_parameter_list ')' 2276 2271 { 2277 typedefTable.addToEnclosingScope( *$1, TYPEGENname /*, "11"*/);2272 typedefTable.addToEnclosingScope( *$1, TYPEGENname, "11" ); 2278 2273 $$ = DeclarationNode::newTypeDecl( $1, $3 ); 2279 2274 } … … 2330 2325 ; 2331 2326 2327 // SKULLDUGGERY: Declarations in extern "X" and distribution need to be added to the current lexical scope. 2328 // However, external_definition_list creates a new scope around each external_definition, but the pop loses all the 2329 // types in the extern "X" and distribution at the end of the block. This version of external_definition_list does 2330 2331 // not do push/pop for declarations at the level of the extern "X" and distribution block. Any recursive uses of 2332 // external_definition_list within the extern "X" and distribution block correctly pushes/pops for that scope level. 2333 external_definition_list_no_pop_push: 2334 external_definition 2335 | external_definition_list_no_pop_push 2336 { forall = xxx; } 2337 external_definition 2338 { $$ = $1 ? $1->appendList( $3 ) : $3; } 2339 ; 2340 2332 2341 external_definition_list_opt: 2333 2342 // empty 2334 2343 { $$ = nullptr; } 2335 | external_definition_list 2344 | external_definition_list_no_pop_push 2336 2345 ; 2337 2346 … … 2339 2348 declaration 2340 2349 | external_function_definition 2350 | EXTENSION external_definition // GCC, multiple __extension__ allowed, meaning unknown 2351 { 2352 distExt( $2 ); // mark all fields in list 2353 $$ = $2; 2354 } 2341 2355 | ASM '(' string_literal ')' ';' // GCC, global assembler statement 2342 2356 { … … 2348 2362 linkage = LinkageSpec::linkageUpdate( yylloc, linkage, $2 ); 2349 2363 } 2350 // SKULLDUGGERY: Declarations in extern "X" need to be added to the current lexical scope. However, 2351 // external_definition_list_opt creates a new scope that loses the types at the end of the extern block. The 2352 // correction is a pop/push (reverse order) to undo the push/pop from external_definition_list_opt. This 2353 // trick works for nested extern "X"s, as each one undoes itself in the nesting. 2354 '{' pop external_definition_list_opt push '}' 2364 '{' external_definition_list_opt '}' 2355 2365 { 2356 2366 linkage = linkageStack.top(); 2357 2367 linkageStack.pop(); 2358 $$ = $6; 2359 } 2360 | EXTENSION external_definition // GCC, multiple __extension__ allowed, meaning unknown 2361 { 2362 distExt( $2 ); // mark all fields in list 2363 $$ = $2; 2368 $$ = $5; 2364 2369 } 2365 2370 | type_qualifier_list 2366 2371 { if ( $1->type->forall ) xxx = forall = true; } // remember generic type 2367 '{' external_definition_list push '}'// CFA, namespace2372 '{' external_definition_list_opt '}' // CFA, namespace 2368 2373 { 2369 2374 for ( DeclarationNode * iter = $4; iter != nullptr; iter = (DeclarationNode *)iter->get_next() ) { … … 2378 2383 | declaration_qualifier_list 2379 2384 { if ( $1->type->forall ) xxx = forall = true; } // remember generic type 2380 '{' external_definition_list '}'// CFA, namespace2385 '{' external_definition_list_opt '}' // CFA, namespace 2381 2386 { 2382 2387 for ( DeclarationNode * iter = $4; iter != nullptr; iter = (DeclarationNode *)iter->get_next() ) { … … 2394 2399 if ( $2->type->forall ) xxx = forall = true; // remember generic type 2395 2400 } 2396 '{' external_definition_list '}'// CFA, namespace2401 '{' external_definition_list_opt '}' // CFA, namespace 2397 2402 { 2398 2403 for ( DeclarationNode * iter = $5; iter != nullptr; iter = (DeclarationNode *)iter->get_next() ) { … … 2715 2720 typedef 2716 2721 // hide type name in enclosing scope by variable name 2717 { typedefTable.addToEnclosingScope( *$1->name, IDENTIFIER /*, "ID"*/); }2722 { typedefTable.addToEnclosingScope( *$1->name, IDENTIFIER, "ID" ); } 2718 2723 | '(' paren_type ')' 2719 2724 { $$ = $2; } -
src/libcfa/stdlib
rb368dd8 recae5860 10 10 // Created On : Thu Jan 28 17:12:35 2016 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Wed May 16 07:53:10201813 // Update Count : 30 012 // Last Modified On : Fri Jun 1 19:52:52 2018 13 // Update Count : 302 14 14 // 15 15 … … 67 67 return posix_memalign( (void **)ptr, align, sizeof(T) ); // C posix_memalign 68 68 } // posix_memalign 69 70 71 // Cforall dynamic allocation 69 } // distribution 70 71 // Cforall dynamic allocation 72 static inline forall( dtype T | sized(T) ) { 72 73 extern "C" { void * memset( void * dest, int c, size_t size ); } // use default C routine for void * 73 74
Note: See TracChangeset
for help on using the changeset viewer.