Changeset 033ff37
- Timestamp:
- Jul 26, 2019, 6:39:42 AM (5 years ago)
- Branches:
- ADT, arm-eh, ast-experimental, enum, forall-pointer-decay, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr, pthread-emulation, qualifiedEnum
- Children:
- be53b87
- Parents:
- f673c13c
- Files:
-
- 1 deleted
- 15 edited
Legend:
- Unmodified
- Added
- Removed
-
src/AST/Convert.cpp
rf673c13c r033ff37 9 9 // Author : Thierry Delisle 10 10 // Created On : Thu May 09 15::37::05 2019 11 // Last Modified By : Andrew Beach12 // Last Modified On : Mon Jun 17 16:44:00201913 // Update Count : 1 211 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Thu Jul 25 22:21:46 2019 13 // Update Count : 13 14 14 // 15 15 … … 2676 2676 ); 2677 2677 } 2678 2679 virtual void visit( const AttrExpr * ) override final {2680 assertf( false, "AttrExpr deprecated in new AST." );2681 }2682 2678 }; 2683 2679 -
src/AST/porting.md
rf673c13c r033ff37 171 171 * all existing uses assume `type` set if true and don't use `expr` 172 172 173 `AttrExpr`174 * did not port due to feature deprecation (e.g. `expr@attribute`)175 176 173 `LogicalExpr` 177 174 * un-defaulted constructor parameter determining `&&` or `||` -
src/Common/PassVisitor.h
rf673c13c r033ff37 155 155 virtual void visit( OffsetPackExpr * offsetPackExpr ) override final; 156 156 virtual void visit( const OffsetPackExpr * offsetPackExpr ) override final; 157 virtual void visit( AttrExpr * attrExpr ) override final;158 virtual void visit( const AttrExpr * attrExpr ) override final;159 157 virtual void visit( LogicalExpr * logicalExpr ) override final; 160 158 virtual void visit( const LogicalExpr * logicalExpr ) override final; … … 301 299 virtual Expression * mutate( OffsetofExpr * offsetofExpr ) override final; 302 300 virtual Expression * mutate( OffsetPackExpr * offsetPackExpr ) override final; 303 virtual Expression * mutate( AttrExpr * attrExpr ) override final;304 301 virtual Expression * mutate( LogicalExpr * logicalExpr ) override final; 305 302 virtual Expression * mutate( ConditionalExpr * conditionalExpr ) override final; -
src/Common/PassVisitor.impl.h
rf673c13c r033ff37 2302 2302 2303 2303 //-------------------------------------------------------------------------- 2304 // AttrExpr2305 template< typename pass_type >2306 void PassVisitor< pass_type >::visit( AttrExpr * node ) {2307 VISIT_START( node );2308 2309 indexerScopedAccept( node->result, *this );2310 if ( node->get_isType() ) {2311 maybeAccept_impl( node->type, *this );2312 } else {2313 maybeAccept_impl( node->expr, *this );2314 }2315 2316 VISIT_END( node );2317 }2318 2319 template< typename pass_type >2320 void PassVisitor< pass_type >::visit( const AttrExpr * node ) {2321 VISIT_START( node );2322 2323 indexerScopedAccept( node->result, *this );2324 if ( node->get_isType() ) {2325 maybeAccept_impl( node->type, *this );2326 } else {2327 maybeAccept_impl( node->expr, *this );2328 }2329 2330 VISIT_END( node );2331 }2332 2333 template< typename pass_type >2334 Expression * PassVisitor< pass_type >::mutate( AttrExpr * node ) {2335 MUTATE_START( node );2336 2337 indexerScopedMutate( node->env , *this );2338 indexerScopedMutate( node->result, *this );2339 if ( node->get_isType() ) {2340 maybeMutate_impl( node->type, *this );2341 } else {2342 maybeMutate_impl( node->expr, *this );2343 }2344 2345 MUTATE_END( Expression, node );2346 }2347 2348 //--------------------------------------------------------------------------2349 2304 // LogicalExpr 2350 2305 template< typename pass_type > -
src/InitTweak/InitTweak.cc
rf673c13c r033ff37 9 9 // Author : Rob Schluntz 10 10 // Created On : Fri May 13 11:26:36 2016 11 // Last Modified By : Andrew Beach12 // Last Modified On : Fri Jun 19 14:34:00201913 // Update Count : 611 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Thu Jul 25 22:21:48 2019 13 // Update Count : 7 14 14 // 15 15 … … 957 957 void previsit( OffsetofExpr * ) {} 958 958 void previsit( OffsetPackExpr * ) {} 959 void previsit( AttrExpr * ) {}960 959 void previsit( CommaExpr * ) {} 961 960 void previsit( LogicalExpr * ) {} -
src/Parser/DeclarationNode.cc
rf673c13c r033ff37 10 10 // Created On : Sat May 16 12:34:05 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Thu Jul 25 17:13:06201913 // Update Count : 111 512 // Last Modified On : Thu Jul 25 22:17:10 2019 13 // Update Count : 1116 14 14 // 15 15 … … 418 418 return newnode; 419 419 } // DeclarationNode::newBuiltinType 420 421 DeclarationNode * DeclarationNode::newAttr( const string * name, ExpressionNode * expr ) {422 DeclarationNode * newnode = new DeclarationNode;423 newnode->type = nullptr;424 // newnode->attr.name = name;425 newnode->name = name;426 newnode->attr.expr = expr;427 return newnode;428 }429 430 DeclarationNode * DeclarationNode::newAttr( const string * name, DeclarationNode * type ) {431 DeclarationNode * newnode = new DeclarationNode;432 newnode->type = nullptr;433 // newnode->attr.name = name;434 newnode->name = name;435 newnode->attr.type = type;436 return newnode;437 }438 420 439 421 DeclarationNode * DeclarationNode::newAttribute( const string * name, ExpressionNode * expr ) { -
src/Parser/ParseNode.h
rf673c13c r033ff37 10 10 // Created On : Sat May 16 13:28:16 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Thu Jul 25 15:49:51201913 // Update Count : 87 512 // Last Modified On : Thu Jul 25 22:17:10 2019 13 // Update Count : 876 14 14 // 15 15 … … 252 252 static DeclarationNode * newTuple( DeclarationNode * members ); 253 253 static DeclarationNode * newTypeof( ExpressionNode * expr, bool basetypeof = false ); 254 static DeclarationNode * newAttr( const std::string *, ExpressionNode * expr ); // @ attributes255 static DeclarationNode * newAttr( const std::string *, DeclarationNode * type ); // @ attributes256 254 static DeclarationNode * newAttribute( const std::string *, ExpressionNode * expr = nullptr ); // gcc attributes 257 255 static DeclarationNode * newAsmStmt( StatementNode * stmt ); // gcc external asm statement -
src/Parser/lex.ll
rf673c13c r033ff37 10 10 * Created On : Sat Sep 22 08:58:10 2001 11 11 * Last Modified By : Peter A. Buhr 12 * Last Modified On : Thu Jul 25 15:46:05201913 * Update Count : 71 512 * Last Modified On : Thu Jul 25 22:08:32 2019 13 * Update Count : 716 14 14 */ 15 15 … … 59 59 #define QKEYWORD_RETURN(x) RETURN_VAL(x); // quasi-keyword 60 60 #define IDENTIFIER_RETURN() RETURN_VAL( typedefTable.isKind( yytext ) ) 61 #define ATTRIBUTE_RETURN() RETURN_VAL( ATTR_IDENTIFIER )62 61 63 62 #ifdef HAVE_KEYWORDS_FLOATXX // GCC >= 7 => keyword, otherwise typedef … … 92 91 // identifier, GCC: $ in identifier 93 92 identifier ([a-zA-Z_$]|{universal_char})([0-9a-zA-Z_$]|{universal_char})* 94 95 // attribute identifier, GCC: $ in identifier96 attr_identifier "@"{identifier}97 93 98 94 // numeric constants, CFA: '_' in constant … … 336 332 IDENTIFIER_RETURN(); 337 333 } 338 {attr_identifier} { ATTRIBUTE_RETURN(); }339 334 340 335 /* numeric constants */ -
src/Parser/parser.yy
rf673c13c r033ff37 10 10 // Created On : Sat Sep 1 20:22:55 2001 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Thu Jul 25 15:49:52201913 // Update Count : 435 612 // Last Modified On : Thu Jul 25 22:31:38 2019 13 // Update Count : 4359 14 14 // 15 15 … … 289 289 %token<tok> IDENTIFIER QUOTED_IDENTIFIER TYPEDEFname TYPEGENname 290 290 %token<tok> TIMEOUT WOR 291 %token<tok> ATTR_IDENTIFIER ATTR_TYPEDEFname ATTR_TYPEGENname292 291 %token<tok> INTEGERconstant CHARACTERconstant STRINGliteral 293 292 %token<tok> DIRECTIVE … … 313 312 %token ATassign // @= 314 313 315 %type<tok> identifier no_attr_identifier316 %type<tok> identifier_or_type_name no_attr_identifier_or_type_nameattr_name314 %type<tok> identifier 315 %type<tok> identifier_or_type_name attr_name 317 316 %type<tok> quasi_keyword 318 317 %type<constant> string_literal … … 547 546 ; 548 547 549 no_attr_identifier:548 identifier: 550 549 IDENTIFIER 551 550 | quasi_keyword 552 551 | '@' // CFA 553 552 { Token tok = { new string( DeclarationNode::anonymous.newName() ), yylval.tok.loc }; $$ = tok; } 554 ;555 556 identifier:557 no_attr_identifier558 | ATTR_IDENTIFIER // CFA559 553 ; 560 554 … … 595 589 | '(' comma_expression ')' '`' IDENTIFIER // CFA, postfix call 596 590 { $$ = new ExpressionNode( build_func( new ExpressionNode( build_postfix_name( $5 ) ), $2 ) ); } 597 | type_name '.' no_attr_identifier// CFA, nested type591 | type_name '.' identifier // CFA, nested type 598 592 { SemanticError( yylloc, "Qualified name is currently unimplemented." ); $$ = nullptr; } 599 593 | type_name '.' '[' field_name_list ']' // CFA, nested type / tuple field selector … … 648 642 | postfix_expression '(' argument_expression_list ')' 649 643 { $$ = new ExpressionNode( build_func( $1, $3 ) ); } 650 | postfix_expression '.' no_attr_identifier644 | postfix_expression '.' identifier 651 645 { $$ = new ExpressionNode( build_fieldSel( $1, build_varref( $3 ) ) ); } 652 646 | postfix_expression '.' INTEGERconstant // CFA, tuple index … … 656 650 | postfix_expression '.' '[' field_name_list ']' // CFA, tuple field selector 657 651 { $$ = new ExpressionNode( build_fieldSel( $1, build_tuple( $4 ) ) ); } 658 | postfix_expression ARROW no_attr_identifier652 | postfix_expression ARROW identifier 659 653 { $$ = new ExpressionNode( build_pfieldSel( $1, build_varref( $3 ) ) ); } 660 654 | postfix_expression ARROW INTEGERconstant // CFA, tuple index … … 719 713 | FLOATINGconstant fraction_constants_opt 720 714 { $$ = new ExpressionNode( build_field_name_fraction_constants( build_field_name_FLOATINGconstant( *$1 ), $2 ) ); } 721 | no_attr_identifier fraction_constants_opt715 | identifier fraction_constants_opt 722 716 { 723 717 $$ = new ExpressionNode( build_field_name_fraction_constants( build_varref( $1 ), $2 ) ); … … 777 771 | ALIGNOF '(' type_no_function ')' // GCC, type alignment 778 772 { $$ = new ExpressionNode( new AlignofExpr( maybeMoveBuildType( $3 ) ) ); } 779 | OFFSETOF '(' type_no_function ',' no_attr_identifier ')'773 | OFFSETOF '(' type_no_function ',' identifier ')' 780 774 { $$ = new ExpressionNode( build_offsetOf( $3, build_varref( $5 ) ) ); } 781 | ATTR_IDENTIFIER782 { $$ = new ExpressionNode( new AttrExpr( build_varref( $1 ), maybeMoveBuild< Expression >( (ExpressionNode *)nullptr ) ) ); }783 | ATTR_IDENTIFIER '(' argument_expression ')'784 { $$ = new ExpressionNode( new AttrExpr( build_varref( $1 ), maybeMoveBuild< Expression >( $3 ) ) ); }785 | ATTR_IDENTIFIER '(' type ')'786 { $$ = new ExpressionNode( new AttrExpr( build_varref( $1 ), maybeMoveBuildType( $3 ) ) ); }787 775 ; 788 776 … … 1019 1007 1020 1008 labeled_statement: 1021 // labels cannot be identifiers 0 or 1 or ATTR_IDENTIFIER1009 // labels cannot be identifiers 0 or 1 1022 1010 identifier_or_type_name ':' attribute_list_opt statement 1023 1011 { $$ = $4->add_label( $1, $3 ); } … … 1387 1375 | type_specifier_nobody variable_abstract_declarator 1388 1376 { $$ = $2->addType( $1 ); } 1389 | cfa_abstract_declarator_tuple no_attr_identifier// CFA1377 | cfa_abstract_declarator_tuple identifier // CFA 1390 1378 { $$ = $1->addName( $2 ); } 1391 1379 | cfa_abstract_declarator_tuple // CFA … … 1451 1439 1452 1440 label_list: 1453 no_attr_identifier1441 identifier 1454 1442 { 1455 1443 $$ = new LabelNode(); $$->labels.push_back( *$1 ); 1456 1444 delete $1; // allocated by lexer 1457 1445 } 1458 | label_list ',' no_attr_identifier1446 | label_list ',' identifier 1459 1447 { 1460 1448 $$ = $1; $1->labels.push_back( *$3 ); … … 1501 1489 1502 1490 local_label_list: // GCC, local label 1503 no_attr_identifier_or_type_name1504 | local_label_list ',' no_attr_identifier_or_type_name1491 identifier_or_type_name 1492 | local_label_list ',' identifier_or_type_name 1505 1493 ; 1506 1494 … … 1624 1612 $$ = $2->addTypedef(); 1625 1613 } 1626 | cfa_typedef_declaration pop ',' push no_attr_identifier1614 | cfa_typedef_declaration pop ',' push identifier 1627 1615 { 1628 1616 typedefTable.addToEnclosingScope( *$5, TYPEDEFname, "3" ); … … 1664 1652 typedef_expression: 1665 1653 // GCC, naming expression type: typedef name = exp; gives a name to the type of an expression 1666 TYPEDEF no_attr_identifier '=' assignment_expression1654 TYPEDEF identifier '=' assignment_expression 1667 1655 { 1668 1656 // $$ = DeclarationNode::newName( 0 ); // unimplemented 1669 1657 SemanticError( yylloc, "Typedef expression is currently unimplemented." ); $$ = nullptr; 1670 1658 } 1671 | typedef_expression pop ',' push no_attr_identifier '=' assignment_expression1659 | typedef_expression pop ',' push identifier '=' assignment_expression 1672 1660 { 1673 1661 // $$ = DeclarationNode::newName( 0 ); // unimplemented … … 1915 1903 | BASETYPEOF '(' comma_expression ')' // CFA: basetypeof( a+b ) y; 1916 1904 { $$ = DeclarationNode::newTypeof( $3, true ); } 1917 | ATTR_TYPEGENname '(' type ')' // CFA: e.g., @type( x ) y;1918 { $$ = DeclarationNode::newAttr( $1, $3 ); }1919 | ATTR_TYPEGENname '(' comma_expression ')' // CFA: e.g., @type( a+b ) y;1920 { $$ = DeclarationNode::newAttr( $1, $3 ); }1921 1905 | ZERO_T // CFA 1922 1906 { $$ = DeclarationNode::newBuiltinType( DeclarationNode::Zero ); } … … 2027 2011 '{' field_declaration_list_opt '}' type_parameters_opt 2028 2012 { $$ = DeclarationNode::newAggregate( $1, nullptr, $7, $5, true )->addQualifiers( $2 ); } 2029 | aggregate_key attribute_list_opt no_attr_identifier fred2013 | aggregate_key attribute_list_opt identifier fred 2030 2014 { 2031 2015 typedefTable.makeTypedef( *$3, forall || typedefTable.getEnclForall() ? TYPEGENname : TYPEDEFname ); // create typedef … … 2053 2037 2054 2038 aggregate_type_nobody: // struct, union - {...} 2055 aggregate_key attribute_list_opt no_attr_identifier fred2039 aggregate_key attribute_list_opt identifier fred 2056 2040 { 2057 2041 typedefTable.makeTypedef( *$3, forall || typedefTable.getEnclForall() ? TYPEGENname : TYPEDEFname ); … … 2154 2138 cfa_field_declaring_list: // CFA, new style field declaration 2155 2139 // bit-fields are handled by C declarations 2156 cfa_abstract_declarator_tuple no_attr_identifier_or_type_name2140 cfa_abstract_declarator_tuple identifier_or_type_name 2157 2141 { $$ = $1->addName( $2 ); } 2158 | cfa_field_declaring_list ',' no_attr_identifier_or_type_name2142 | cfa_field_declaring_list ',' identifier_or_type_name 2159 2143 { $$ = $1->appendList( $1->cloneType( $3 ) ); } 2160 2144 ; … … 2181 2165 ENUM attribute_list_opt '{' enumerator_list comma_opt '}' 2182 2166 { $$ = DeclarationNode::newEnum( nullptr, $4, true )->addQualifiers( $2 ); } 2183 | ENUM attribute_list_opt no_attr_identifier2167 | ENUM attribute_list_opt identifier 2184 2168 { typedefTable.makeTypedef( *$3 ); } 2185 2169 '{' enumerator_list comma_opt '}' … … 2192 2176 2193 2177 enum_type_nobody: // enum - {...} 2194 ENUM attribute_list_opt no_attr_identifier2178 ENUM attribute_list_opt identifier 2195 2179 { 2196 2180 typedefTable.makeTypedef( *$3 ); … … 2205 2189 2206 2190 enumerator_list: 2207 no_attr_identifier_or_type_name enumerator_value_opt2191 identifier_or_type_name enumerator_value_opt 2208 2192 { $$ = DeclarationNode::newEnumConstant( $1, $2 ); } 2209 | enumerator_list ',' no_attr_identifier_or_type_name enumerator_value_opt2193 | enumerator_list ',' identifier_or_type_name enumerator_value_opt 2210 2194 { $$ = $1->appendList( DeclarationNode::newEnumConstant( $3, $4 ) ); } 2211 2195 ; … … 2315 2299 2316 2300 identifier_list: // K&R-style parameter list => no types 2317 no_attr_identifier2301 identifier 2318 2302 { $$ = DeclarationNode::newName( $1 ); } 2319 | identifier_list ',' no_attr_identifier2303 | identifier_list ',' identifier 2320 2304 { $$ = $1->appendList( DeclarationNode::newName( $3 ) ); } 2321 2305 ; … … 2323 2307 identifier_or_type_name: 2324 2308 identifier 2325 | TYPEDEFname2326 | TYPEGENname2327 ;2328 2329 no_attr_identifier_or_type_name:2330 no_attr_identifier2331 2309 | TYPEDEFname 2332 2310 | TYPEGENname … … 2383 2361 designation: 2384 2362 designator_list ':' // C99, CFA uses ":" instead of "=" 2385 | no_attr_identifier ':'// GCC, field name2363 | identifier ':' // GCC, field name 2386 2364 { $$ = new ExpressionNode( build_varref( $1 ) ); } 2387 2365 ; … … 2395 2373 2396 2374 designator: 2397 '.' no_attr_identifier// C99, field name2375 '.' identifier // C99, field name 2398 2376 { $$ = new ExpressionNode( build_varref( $2 ) ); } 2399 2377 | '[' push assignment_expression pop ']' // C99, single array element … … 2440 2418 2441 2419 type_parameter: // CFA 2442 type_class no_attr_identifier_or_type_name2420 type_class identifier_or_type_name 2443 2421 { typedefTable.addToScope( *$2, TYPEDEFname, "9" ); } 2444 2422 type_initializer_opt assertion_list_opt … … 2473 2451 2474 2452 assertion: // CFA 2475 '|' no_attr_identifier_or_type_name '(' type_list ')'2453 '|' identifier_or_type_name '(' type_list ')' 2476 2454 { $$ = DeclarationNode::newTraitUse( $2, $4 ); } 2477 2455 | '|' '{' push trait_declaration_list pop '}' … … 2510 2488 2511 2489 type_declarator_name: // CFA 2512 no_attr_identifier_or_type_name2490 identifier_or_type_name 2513 2491 { 2514 2492 typedefTable.addToEnclosingScope( *$1, TYPEDEFname, "10" ); 2515 2493 $$ = DeclarationNode::newTypeDecl( $1, 0 ); 2516 2494 } 2517 | no_attr_identifier_or_type_name '(' type_parameter_list ')'2495 | identifier_or_type_name '(' type_parameter_list ')' 2518 2496 { 2519 2497 typedefTable.addToEnclosingScope( *$1, TYPEGENname, "11" ); … … 2523 2501 2524 2502 trait_specifier: // CFA 2525 TRAIT no_attr_identifier_or_type_name '(' type_parameter_list ')' '{' '}'2503 TRAIT identifier_or_type_name '(' type_parameter_list ')' '{' '}' 2526 2504 { $$ = DeclarationNode::newTrait( $2, $4, 0 ); } 2527 | TRAIT no_attr_identifier_or_type_name '(' type_parameter_list ')' '{' push trait_declaration_list pop '}'2505 | TRAIT identifier_or_type_name '(' type_parameter_list ')' '{' push trait_declaration_list pop '}' 2528 2506 { $$ = DeclarationNode::newTrait( $2, $4, $8 ); } 2529 2507 ; -
src/ResolvExpr/AlternativeFinder.cc
rf673c13c r033ff37 10 10 // Created On : Sat May 16 23:52:08 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Thu Nov 1 21:00:56 201813 // Update Count : 3 512 // Last Modified On : Thu Jul 25 22:37:46 2019 13 // Update Count : 37 14 14 // 15 15 … … 79 79 void postvisit( OffsetofExpr * offsetofExpr ); 80 80 void postvisit( OffsetPackExpr * offsetPackExpr ); 81 void postvisit( AttrExpr * attrExpr );82 81 void postvisit( LogicalExpr * logicalExpr ); 83 82 void postvisit( ConditionalExpr * conditionalExpr ); … … 1404 1403 } 1405 1404 1406 namespace {1407 void resolveAttr( SymTab::Indexer::IdData data, const FunctionType * function, Type * argType, const TypeEnvironment &env, AlternativeFinder & finder ) {1408 // assume no polymorphism1409 // assume no implicit conversions1410 assert( function->parameters.size() == 1 );1411 PRINT(1412 std::cerr << "resolvAttr: funcDecl is ";1413 data.id->print( std::cerr );1414 std::cerr << " argType is ";1415 argType->print( std::cerr );1416 std::cerr << std::endl;1417 )1418 const SymTab::Indexer & indexer = finder.get_indexer();1419 AltList & alternatives = finder.get_alternatives();1420 if ( typesCompatibleIgnoreQualifiers( argType, function->parameters.front()->get_type(), indexer, env ) ) {1421 Cost cost = Cost::zero;1422 Expression * newExpr = data.combine( cost );1423 alternatives.push_back( Alternative{1424 new AttrExpr{ newExpr, argType->clone() }, env, OpenVarSet{},1425 AssertionList{}, Cost::zero, cost } );1426 for ( DeclarationWithType * retVal : function->returnVals ) {1427 alternatives.back().expr->result = retVal->get_type()->clone();1428 } // for1429 } // if1430 }1431 }1432 1433 void AlternativeFinder::Finder::postvisit( AttrExpr * attrExpr ) {1434 // assume no 'pointer-to-attribute'1435 NameExpr * nameExpr = dynamic_cast< NameExpr* >( attrExpr->get_attr() );1436 assert( nameExpr );1437 std::list< SymTab::Indexer::IdData > attrList;1438 indexer.lookupId( nameExpr->get_name(), attrList );1439 if ( attrExpr->get_isType() || attrExpr->get_expr() ) {1440 for ( auto & data : attrList ) {1441 const DeclarationWithType * id = data.id;1442 // check if the type is function1443 if ( const FunctionType * function = dynamic_cast< const FunctionType * >( id->get_type() ) ) {1444 // assume exactly one parameter1445 if ( function->parameters.size() == 1 ) {1446 if ( attrExpr->get_isType() ) {1447 resolveAttr( data, function, attrExpr->get_type(), env, altFinder);1448 } else {1449 AlternativeFinder finder( indexer, env );1450 finder.find( attrExpr->get_expr() );1451 for ( AltList::iterator choice = finder.alternatives.begin(); choice != finder.alternatives.end(); ++choice ) {1452 if ( choice->expr->get_result()->size() == 1 ) {1453 resolveAttr(data, function, choice->expr->get_result(), choice->env, altFinder );1454 } // fi1455 } // for1456 } // if1457 } // if1458 } // if1459 } // for1460 } else {1461 for ( auto & data : attrList ) {1462 Cost cost = Cost::zero;1463 Expression * newExpr = data.combine( cost );1464 alternatives.push_back( Alternative{1465 newExpr, env, OpenVarSet{}, AssertionList{}, Cost::zero, cost } );1466 renameTypes( alternatives.back().expr );1467 } // for1468 } // if1469 }1470 1471 1405 void AlternativeFinder::Finder::postvisit( LogicalExpr * logicalExpr ) { 1472 1406 AlternativeFinder firstFinder( indexer, env ); -
src/SynTree/Expression.cc
rf673c13c r033ff37 10 10 // Created On : Mon May 18 07:44:20 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : T ue Feb 19 18:10:55201913 // Update Count : 6 012 // Last Modified On : Thu Jul 25 22:21:48 2019 13 // Update Count : 61 14 14 // 15 15 … … 249 249 os << "Offset pack expression on "; 250 250 type->print(os, indent+1); 251 Expression::print( os, indent );252 }253 254 AttrExpr::AttrExpr( Expression * attr, Expression * expr_ ) :255 Expression(), attr( attr ), expr(expr_), type(0), isType(false) {256 }257 258 AttrExpr::AttrExpr( Expression * attr, Type * type_ ) :259 Expression(), attr( attr ), expr(0), type(type_), isType(true) {260 }261 262 AttrExpr::AttrExpr( const AttrExpr & other ) :263 Expression( other ), attr( maybeClone( other.attr ) ), expr( maybeClone( other.expr ) ), type( maybeClone( other.type ) ), isType( other.isType ) {264 }265 266 AttrExpr::~AttrExpr() {267 delete attr;268 delete expr;269 delete type;270 }271 272 void AttrExpr::print( std::ostream & os, Indenter indent) const {273 os << "Attr ";274 attr->print( os, indent+1);275 if ( isType || expr ) {276 os << "applied to: ";277 if (isType) type->print(os, indent+1);278 else expr->print(os, indent+1);279 } // if280 251 Expression::print( os, indent ); 281 252 } -
src/SynTree/Expression.h
rf673c13c r033ff37 10 10 // Created On : Mon May 18 07:44:20 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Mon Feb 18 18:29:51201913 // Update Count : 4912 // Last Modified On : Thu Jul 25 22:21:44 2019 13 // Update Count : 50 14 14 // 15 15 … … 463 463 }; 464 464 465 /// AttrExpr represents an @attribute expression (like sizeof, but user-defined)466 class AttrExpr : public Expression {467 public:468 Expression * attr;469 Expression * expr;470 Type * type;471 bool isType;472 473 AttrExpr(Expression * attr, Expression * expr );474 AttrExpr( const AttrExpr & other );475 AttrExpr( Expression * attr, Type * type );476 virtual ~AttrExpr();477 478 Expression * get_attr() const { return attr; }479 void set_attr( Expression * newValue ) { attr = newValue; }480 Expression * get_expr() const { return expr; }481 void set_expr( Expression * newValue ) { expr = newValue; }482 Type * get_type() const { return type; }483 void set_type( Type * newValue ) { type = newValue; }484 bool get_isType() const { return isType; }485 void set_isType( bool newValue ) { isType = newValue; }486 487 virtual AttrExpr * clone() const override { return new AttrExpr( * this ); }488 virtual void accept( Visitor & v ) override { v.visit( this ); }489 virtual void accept( Visitor & v ) const override { v.visit( this ); }490 virtual Expression * acceptMutator( Mutator & m ) override { return m.mutate( this ); }491 virtual void print( std::ostream & os, Indenter indent = {} ) const override;492 };493 494 465 /// LogicalExpr represents a short-circuit boolean expression (&& or ||) 495 466 class LogicalExpr : public Expression { -
src/SynTree/Mutator.h
rf673c13c r033ff37 9 9 // Author : Richard C. Bilson 10 10 // Created On : Mon May 18 07:44:20 2015 11 // Last Modified By : Andrew Beach12 // Last Modified On : Mon Jul 24 16:31:00 201713 // Update Count : 1 611 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Thu Jul 25 22:37:46 2019 13 // Update Count : 17 14 14 // 15 15 #pragma once … … 74 74 virtual Expression * mutate( OffsetofExpr * offsetofExpr ) = 0; 75 75 virtual Expression * mutate( OffsetPackExpr * offsetPackExpr ) = 0; 76 virtual Expression * mutate( AttrExpr * attrExpr ) = 0;77 76 virtual Expression * mutate( LogicalExpr * logicalExpr ) = 0; 78 77 virtual Expression * mutate( ConditionalExpr * conditionalExpr ) = 0; -
src/SynTree/SynTree.h
rf673c13c r033ff37 9 9 // Author : Richard C. Bilson 10 10 // Created On : Mon May 18 07:44:20 2015 11 // Last Modified By : Andrew Beach12 // Last Modified On : Mon Jul 24 16:54:00 201713 // Update Count : 1 111 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Thu Jul 25 22:37:45 2019 13 // Update Count : 12 14 14 // 15 15 … … 79 79 class OffsetofExpr; 80 80 class OffsetPackExpr; 81 class AttrExpr;82 81 class LogicalExpr; 83 82 class ConditionalExpr; -
src/SynTree/Visitor.h
rf673c13c r033ff37 9 9 // Author : Richard C. Bilson 10 10 // Created On : Mon May 18 07:44:20 2015 11 // Last Modified By : Andrew Beach12 // Last Modified On : Mon Jul 24 16:28:00 201713 // Update Count : 1 311 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Thu Jul 25 22:21:49 2019 13 // Update Count : 14 14 14 // 15 15 … … 123 123 virtual void visit( OffsetPackExpr * node ) { visit( const_cast<const OffsetPackExpr *>(node) ); } 124 124 virtual void visit( const OffsetPackExpr * offsetPackExpr ) = 0; 125 virtual void visit( AttrExpr * node ) { visit( const_cast<const AttrExpr *>(node) ); }126 virtual void visit( const AttrExpr * attrExpr ) = 0;127 125 virtual void visit( LogicalExpr * node ) { visit( const_cast<const LogicalExpr *>(node) ); } 128 126 virtual void visit( const LogicalExpr * logicalExpr ) = 0;
Note: See TracChangeset
for help on using the changeset viewer.