- Timestamp:
- Sep 27, 2019, 3:35:46 PM (6 years ago)
- Branches:
- ADT, arm-eh, ast-experimental, enum, forall-pointer-decay, jacob/cs343-translation, master, new-ast, new-ast-unique-expr, pthread-emulation, qualifiedEnum
- Children:
- 90ce35aa
- Parents:
- 8e1467d (diff), 849720f (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the(diff)
links above to see all the changes relative to each parent. - Location:
- src
- Files:
-
- 2 added
- 42 edited
Legend:
- Unmodified
- Added
- Removed
-
src/AST/Convert.cpp
r8e1467d r4a60488 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 … … 2688 2688 ); 2689 2689 } 2690 2691 virtual void visit( const AttrExpr * ) override final {2692 assertf( false, "AttrExpr deprecated in new AST." );2693 }2694 2690 }; 2695 2691 -
src/AST/porting.md
r8e1467d r4a60488 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/BasicTypes-gen.cc
r8e1467d r4a60488 295 295 // cout << code.str(); 296 296 297 297 298 // TEMPORARY DURING CHANGE OVER 299 #define TypeAST TOP_SRCDIR "src/AST/Type.hpp" 300 resetInput( file, TypeAST, buffer, code, str ); 301 302 if ( (start = str.find( STARTMK )) == string::npos ) Abort( "start", TypeAST ); 303 start += sizeof( STARTMK ); // includes newline 304 code << str.substr( 0, start ); 305 306 code << "\t" << BYMK << endl; 307 code << "\tenum Kind {" << endl; 308 for ( int r = 0; r < NUMBER_OF_BASIC_TYPES; r += 1 ) { 309 code << "\t\t" << graph[r].name << "," << endl; 310 } // for 311 code << "\t\tNUMBER_OF_BASIC_TYPES" << endl; 312 code << "\t} kind;" << endl; 313 code << "\t"; // indentation for end marker 314 315 if ( (start = str.find( ENDMK, start + 1 )) == string::npos ) Abort( "end", TypeAST ); 316 code << str.substr( start ); 317 318 output( file, TypeAST, code ); 319 // cout << code.str(); 320 321 298 322 #define ConversionCost TOP_SRCDIR "src/ResolvExpr/ConversionCost.cc" 299 323 resetInput( file, ConversionCost, buffer, code, str ); … … 310 334 code << right << setw(30) << graph[c].type << left; 311 335 } else if ( graph[c].rank != graph[c + 2].rank ) { 312 code << string( 10, ' ' ) << setw(25) << graph[c].type << setw(25) <<graph[c + 1].type;336 code << string( 10, ' ' ) << setw(25) << graph[c].type << graph[c + 1].type; 313 337 c += 1; 314 338 } else { 315 code << setw(20) << graph[c].type << setw(20) << graph[c + 1].type << setw(20) <<graph[c + 2].type;339 code << setw(20) << graph[c].type << setw(20) << graph[c + 1].type << graph[c + 2].type; 316 340 c += 2; 317 341 } // if … … 328 352 code << "\t" << BYMK << endl; 329 353 code << "\tstatic const int costMatrix[BasicType::NUMBER_OF_BASIC_TYPES][BasicType::NUMBER_OF_BASIC_TYPES] = { // path length from root to node" << endl 330 << "\t\t/* ";354 << "\t\t/* "; 331 355 for ( int r = 0; r < NUMBER_OF_BASIC_TYPES; r += 1 ) { // titles 332 356 code << setw(5) << graph[r].abbrev; … … 334 358 code << " */" << endl; 335 359 for ( int r = 0; r < NUMBER_OF_BASIC_TYPES; r += 1 ) { // costs 336 code << "\t\t/* " << setw(6) << graph[r].abbrev << "*/ {";360 code << "\t\t/* " << setw(6) << graph[r].abbrev << " */ {"; 337 361 for ( int c = 0; c < NUMBER_OF_BASIC_TYPES; c += 1 ) { 338 362 code << setw(4) << costMatrix[r][c] << ","; … … 353 377 code << "\t" << BYMK << endl; 354 378 code << "\tstatic const int signMatrix[BasicType::NUMBER_OF_BASIC_TYPES][BasicType::NUMBER_OF_BASIC_TYPES] = { // number of sign changes in safe conversion" << endl 355 << "\t\t/* ";379 << "\t\t/* "; 356 380 for ( int r = 0; r < NUMBER_OF_BASIC_TYPES; r += 1 ) { // titles 357 381 code << setw(5) << graph[r].abbrev; … … 359 383 code << " */" << endl; 360 384 for ( int r = 0; r < NUMBER_OF_BASIC_TYPES; r += 1 ) { // costs 361 code << "\t\t/* " << setw(6) << graph[r].abbrev << "*/ {";385 code << "\t\t/* " << setw(6) << graph[r].abbrev << " */ {"; 362 386 for ( int c = 0; c < NUMBER_OF_BASIC_TYPES; c += 1 ) { 363 387 code << setw(4) << signMatrix[r][c] << ","; … … 395 419 code << "*/" << endl; 396 420 for ( int r = 0; r < NUMBER_OF_BASIC_TYPES; r += 1 ) { // costs 397 code << "\t\t\t\t {\n\t\t/* " << setw(6) << graph[r].abbrev << "*/";421 code << "\t\t\t\t {\n\t\t/* " << setw(6) << graph[r].abbrev << " */"; 398 422 for ( int c = 0; c < NUMBER_OF_BASIC_TYPES; c += 1 ) { 399 423 string s = string{"BT "} + graph[commonTypeMatrix[r][c]].name; -
src/Common/Eval.cc
r8e1467d r4a60488 10 10 // Created On : Mon May 18 07:44:20 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Sun May 6 22:24:16 201813 // Update Count : 4012 // Last Modified On : Wed Jul 24 15:09:06 2019 13 // Update Count : 64 14 14 // 15 15 … … 27 27 bool valid = true; 28 28 29 void previsit( BaseSyntaxNode * ) { visit_children = false; }30 void postvisit( BaseSyntaxNode * ) { valid = false; }29 void previsit( const BaseSyntaxNode * ) { visit_children = false; } 30 void postvisit( const BaseSyntaxNode * ) { valid = false; } 31 31 32 void postvisit( ConstantExpr * expr ) { 32 void postvisit( const SizeofExpr * ) { 33 } 34 35 void postvisit( const ConstantExpr * expr ) { 33 36 value = expr->intValue(); 34 37 } 35 38 36 void postvisit( CastExpr * expr ) {39 void postvisit( const CastExpr * expr ) { 37 40 auto arg = eval(expr->arg); 38 41 valid = arg.second; … … 41 44 } 42 45 43 void postvisit( VariableExpr *expr ) {46 void postvisit( const VariableExpr * const expr ) { 44 47 if ( EnumInstType * inst = dynamic_cast<EnumInstType *>(expr->result) ) { 45 48 if ( EnumDecl * decl = inst->baseEnum ) { … … 52 55 } 53 56 54 void postvisit( ApplicationExpr * expr ) {55 DeclarationWithType * function = InitTweak::getFunction( expr);57 void postvisit( const ApplicationExpr * expr ) { 58 DeclarationWithType * function = InitTweak::getFunction(const_cast<ApplicationExpr *>(expr)); 56 59 if ( ! function || function->linkage != LinkageSpec::Intrinsic ) { valid = false; return; } 57 60 const std::string & fname = function->name; … … 94 97 void postvisit( const ast::ConstantExpr * expr ) { 95 98 value = expr->intValue(); 99 } 100 101 void postvisit( const ast::SizeofExpr * expr ) { 102 if ( expr->expr ) value = eval(expr->expr).first; 103 else if ( expr->type ) value = eval(expr->expr).first; 104 else SemanticError( expr->location, ::toString( "Internal error: SizeofExpr has no expression or type value" ) ); 96 105 } 97 106 … … 145 154 }; 146 155 147 std::pair<long long int, bool> eval( Expression * expr) {156 std::pair<long long int, bool> eval( const Expression * expr) { 148 157 PassVisitor<EvalOld> ev; 149 158 if (expr) { -
src/Common/PassVisitor.h
r8e1467d r4a60488 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
r8e1467d r4a60488 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/Common/utility.h
r8e1467d r4a60488 10 10 // Created On : Mon May 18 07:44:20 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Sun May 6 22:24:16 201813 // Update Count : 4 012 // Last Modified On : Wed Jul 24 14:28:19 2019 13 // Update Count : 41 14 14 // 15 15 … … 483 483 // ----------------------------------------------------------------------------- 484 484 /// evaluates expr as a long long int. If second is false, expr could not be evaluated 485 std::pair<long long int, bool> eval( Expression * expr);485 std::pair<long long int, bool> eval(const Expression * expr); 486 486 487 487 namespace ast { -
src/GenPoly/Box.cc
r8e1467d r4a60488 725 725 if ( ! needsBoxing( param, arg->result, exprTyVars, env ) ) return; 726 726 727 if ( arg-> result->get_lvalue() ) {727 if ( arg->get_lvalue() ) { 728 728 // argument expression may be CFA lvalue, but not C lvalue -- apply generalizedLvalue transformations. 729 729 // if ( VariableExpr * varExpr = dynamic_cast< VariableExpr * >( arg ) ) { -
src/GenPoly/Lvalue.cc
r8e1467d r4a60488 363 363 int diff = depth1 - depth2; 364 364 365 if ( diff > 0 && ! srcType->get_lvalue() ) {365 if ( diff > 0 && ! castExpr->arg->get_lvalue() ) { 366 366 // rvalue to reference conversion -- introduce temporary 367 367 // know that reference depth of cast argument is 0, need to introduce n temporaries for reference depth of n, e.g. … … 407 407 ret = new AddressExpr( ret ); 408 408 } 409 if ( srcType->get_lvalue() && ! ResolvExpr::typesCompatible( srcType, strict_dynamic_cast<ReferenceType *>( destType )->base, SymTab::Indexer() ) ) {409 if ( castExpr->arg->get_lvalue() && ! ResolvExpr::typesCompatible( srcType, strict_dynamic_cast<ReferenceType *>( destType )->base, SymTab::Indexer() ) ) { 410 410 // must keep cast if cast-to type is different from the actual type 411 411 castExpr->arg = ret; -
src/InitTweak/InitTweak.cc
r8e1467d r4a60488 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/Makefile.am
r8e1467d r4a60488 11 11 ## Created On : Sun May 31 08:51:46 2015 12 12 ## Last Modified By : Peter A. Buhr 13 ## Last Modified On : Fri Feb 15 09:44:09201914 ## Update Count : 9 713 ## Last Modified On : Mon Aug 5 12:57:46 2019 14 ## Update Count : 98 15 15 ############################################################################### 16 16 … … 55 55 $(addprefix $(srcdir)/, ResolvExpr/ConversionCost.cc ResolvExpr/CommonType.cc SymTab/ManglerCommon.cc) : $(srcdir)/SynTree/Type.h 56 56 57 $(srcdir)/ SynTree/Type.h: BasicTypes-gen.cc57 $(srcdir)/AST/Type.hpp : BasicTypes-gen.cc 58 58 ${AM_V_GEN}${CXXCOMPILE} $< -o BasicTypes-gen -Wall -Wextra 59 59 @./BasicTypes-gen … … 62 62 # put into lib for now 63 63 cfa_cpplibdir = $(CFA_LIBDIR) 64 cfa_cpplib_PROGRAMS = ../driver/cfa-cpp demangler 64 cfa_cpplib_PROGRAMS = ../driver/cfa-cpp $(DEMANGLER) 65 EXTRA_PROGRAMS = demangler 65 66 ___driver_cfa_cpp_SOURCES = $(SRC) 66 67 ___driver_cfa_cpp_LDADD = -ldl $(LIBPROFILER) $(LIBTCMALLOC) … … 74 75 demangler_LDADD = libdemangle.a -ldl # yywrap 75 76 76 noinst_LIBRARIES = libdemangle.a 77 noinst_LIBRARIES = $(LIBDEMANGLE) 78 EXTRA_LIBRARIES = libdemangle.a 77 79 libdemangle_a_SOURCES = $(SRCDEMANGLE) 78 80 -
src/Makefile.in
r8e1467d r4a60488 141 141 build_triplet = @build@ 142 142 host_triplet = @host@ 143 cfa_cpplib_PROGRAMS = ../driver/cfa-cpp$(EXEEXT) demangler$(EXEEXT) 143 cfa_cpplib_PROGRAMS = ../driver/cfa-cpp$(EXEEXT) $(DEMANGLER) 144 EXTRA_PROGRAMS = demangler$(EXEEXT) 144 145 subdir = src 145 146 ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 … … 231 232 SynTree/Initializer.$(OBJEXT) \ 232 233 SynTree/TypeSubstitution.$(OBJEXT) SynTree/Attribute.$(OBJEXT) \ 233 SynTree/DeclReplacer.$(OBJEXT) 234 SynTree/DeclReplacer.$(OBJEXT) SynTree/TopLvalue.$(OBJEXT) 234 235 am__objects_8 = CompilationState.$(OBJEXT) $(am__objects_1) \ 235 236 $(am__objects_2) Concurrency/Keywords.$(OBJEXT) \ … … 411 412 CCDEPMODE = @CCDEPMODE@ 412 413 CFACC = @CFACC@ 414 CFACC_INSTALL = @CFACC_INSTALL@ 413 415 CFACPP = @CFACPP@ 414 416 CFA_BACKEND_CC = @CFA_BACKEND_CC@ … … 428 430 CYGPATH_W = @CYGPATH_W@ 429 431 DEFS = @DEFS@ 432 DEMANGLER = @DEMANGLER@ 430 433 DEPDIR = @DEPDIR@ 431 434 DLLTOOL = @DLLTOOL@ … … 440 443 FGREP = @FGREP@ 441 444 GREP = @GREP@ 445 HAS_DISTCC = @HAS_DISTCC@ 442 446 HOST_FLAGS = @HOST_FLAGS@ 443 447 INSTALL = @INSTALL@ … … 453 457 LIBCFA_TARGET_DIRS = @LIBCFA_TARGET_DIRS@ 454 458 LIBCFA_TARGET_MAKEFILES = @LIBCFA_TARGET_MAKEFILES@ 459 LIBDEMANGLE = @LIBDEMANGLE@ 455 460 LIBOBJS = @LIBOBJS@ 456 461 LIBS = @LIBS@ … … 693 698 SynTree/TypeSubstitution.cc \ 694 699 SynTree/Attribute.cc \ 695 SynTree/DeclReplacer.cc 700 SynTree/DeclReplacer.cc \ 701 SynTree/TopLvalue.cc 696 702 697 703 … … 705 711 demangler_SOURCES = SymTab/demangler.cc # test driver for the demangler, also useful as a sanity check that libdemangle.a is complete 706 712 demangler_LDADD = libdemangle.a -ldl # yywrap 707 noinst_LIBRARIES = libdemangle.a 713 noinst_LIBRARIES = $(LIBDEMANGLE) 714 EXTRA_LIBRARIES = libdemangle.a 708 715 libdemangle_a_SOURCES = $(SRCDEMANGLE) 709 716 all: $(BUILT_SOURCES) … … 1023 1030 SynTree/DeclReplacer.$(OBJEXT): SynTree/$(am__dirstamp) \ 1024 1031 SynTree/$(DEPDIR)/$(am__dirstamp) 1032 SynTree/TopLvalue.$(OBJEXT): SynTree/$(am__dirstamp) \ 1033 SynTree/$(DEPDIR)/$(am__dirstamp) 1025 1034 Tuples/$(am__dirstamp): 1026 1035 @$(MKDIR_P) Tuples … … 1334 1343 @AMDEP_TRUE@@am__include@ @am__quote@SynTree/$(DEPDIR)/ReferenceType.Po@am__quote@ 1335 1344 @AMDEP_TRUE@@am__include@ @am__quote@SynTree/$(DEPDIR)/Statement.Po@am__quote@ 1345 @AMDEP_TRUE@@am__include@ @am__quote@SynTree/$(DEPDIR)/TopLvalue.Po@am__quote@ 1336 1346 @AMDEP_TRUE@@am__include@ @am__quote@SynTree/$(DEPDIR)/TupleExpr.Po@am__quote@ 1337 1347 @AMDEP_TRUE@@am__include@ @am__quote@SynTree/$(DEPDIR)/TupleType.Po@am__quote@ … … 1667 1677 $(addprefix $(srcdir)/, ResolvExpr/ConversionCost.cc ResolvExpr/CommonType.cc SymTab/ManglerCommon.cc) : $(srcdir)/SynTree/Type.h 1668 1678 1669 $(srcdir)/ SynTree/Type.h: BasicTypes-gen.cc1679 $(srcdir)/AST/Type.hpp : BasicTypes-gen.cc 1670 1680 ${AM_V_GEN}${CXXCOMPILE} $< -o BasicTypes-gen -Wall -Wextra 1671 1681 @./BasicTypes-gen -
src/Parser/DeclarationNode.cc
r8e1467d r4a60488 10 10 // Created On : Sat May 16 12:34:05 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Fri Feb 1 16:49:17201913 // Update Count : 111 312 // Last Modified On : Thu Jul 25 22:17:10 2019 13 // Update Count : 1116 14 14 // 15 15 … … 49 49 const char * DeclarationNode::aggregateNames[] = { "struct", "union", "trait", "coroutine", "monitor", "thread", "NoAggregateNames" }; 50 50 const char * DeclarationNode::typeClassNames[] = { "otype", "dtype", "ftype", "NoTypeClassNames" }; 51 const char * DeclarationNode::builtinTypeNames[] = { "__builtin_va_list", " zero_t", "one_t", "NoBuiltinTypeNames" };51 const char * DeclarationNode::builtinTypeNames[] = { "__builtin_va_list", "__auto_type", "zero_t", "one_t", "NoBuiltinTypeNames" }; 52 52 53 53 UniqueName DeclarationNode::anonymous( "__anonymous" ); … … 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/ExpressionNode.cc
r8e1467d r4a60488 10 10 // Created On : Sat May 16 13:17:07 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Sun Mar 10 16:10:32201913 // Update Count : 97 612 // Last Modified On : Sun Aug 4 20:57:55 2019 13 // Update Count : 978 14 14 // 15 15 … … 109 109 110 110 Expression * build_constantInteger( string & str ) { 111 static const BasicType::Kind kind[2][ 7] = {111 static const BasicType::Kind kind[2][6] = { 112 112 // short (h) must be before char (hh) because shorter type has the longer suffix 113 113 { BasicType::ShortSignedInt, BasicType::SignedChar, BasicType::SignedInt, BasicType::LongSignedInt, BasicType::LongLongSignedInt, BasicType::SignedInt128, }, -
src/Parser/ParseNode.h
r8e1467d r4a60488 10 10 // Created On : Sat May 16 13:28:16 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Mon Apr 15 14:22:39201913 // Update Count : 87 412 // Last Modified On : Thu Jul 25 22:17:10 2019 13 // Update Count : 876 14 14 // 15 15 … … 221 221 enum TypeClass { Otype, Dtype, Ftype, Ttype, NoTypeClass }; 222 222 static const char * typeClassNames[]; 223 enum BuiltinType { Valist, Zero, One, NoBuiltinType };223 enum BuiltinType { Valist, AutoType, Zero, One, NoBuiltinType }; 224 224 static const char * builtinTypeNames[]; 225 225 … … 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
r8e1467d r4a60488 10 10 * Created On : Sat Sep 22 08:58:10 2001 11 11 * Last Modified By : Peter A. Buhr 12 * Last Modified On : Wed May 15 21:25:27 201913 * Update Count : 7 0812 * Last Modified On : Sun Aug 4 20:53:47 2019 13 * Update Count : 719 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 … … 218 214 __attribute__ { KEYWORD_RETURN(ATTRIBUTE); } // GCC 219 215 auto { KEYWORD_RETURN(AUTO); } 216 __auto_type { KEYWORD_RETURN(AUTO_TYPE); } 220 217 basetypeof { KEYWORD_RETURN(BASETYPEOF); } // CFA 221 218 _Bool { KEYWORD_RETURN(BOOL); } // C99 … … 276 273 __inline__ { KEYWORD_RETURN(INLINE); } // GCC 277 274 int { KEYWORD_RETURN(INT); } 275 int128 { KEYWORD_RETURN(INT128); } // CFA 278 276 __int128 { KEYWORD_RETURN(INT128); } // GCC 279 int128{ KEYWORD_RETURN(INT128); } // GCC277 __int128_t { KEYWORD_RETURN(INT128); } // GCC 280 278 __label__ { KEYWORD_RETURN(LABEL); } // GCC 281 279 long { KEYWORD_RETURN(LONG); } … … 292 290 __restrict__ { KEYWORD_RETURN(RESTRICT); } // GCC 293 291 return { KEYWORD_RETURN(RETURN); } 292 /* resume { KEYWORD_RETURN(RESUME); } // CFA */ 294 293 short { KEYWORD_RETURN(SHORT); } 295 294 signed { KEYWORD_RETURN(SIGNED); } … … 300 299 _Static_assert { KEYWORD_RETURN(STATICASSERT); } // C11 301 300 struct { KEYWORD_RETURN(STRUCT); } 301 /* suspend { KEYWORD_RETURN(SUSPEND); } // CFA */ 302 302 switch { KEYWORD_RETURN(SWITCH); } 303 303 thread { KEYWORD_RETURN(THREAD); } // C11 … … 314 314 __typeof__ { KEYWORD_RETURN(TYPEOF); } // GCC 315 315 union { KEYWORD_RETURN(UNION); } 316 __uint128_t { KEYWORD_RETURN(UINT128); } // GCC 316 317 unsigned { KEYWORD_RETURN(UNSIGNED); } 317 318 __builtin_va_list { KEYWORD_RETURN(VALIST); } // GCC … … 333 334 IDENTIFIER_RETURN(); 334 335 } 335 {attr_identifier} { ATTRIBUTE_RETURN(); }336 336 337 337 /* numeric constants */ -
src/Parser/parser.yy
r8e1467d r4a60488 10 10 // Created On : Sat Sep 1 20:22:55 2001 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Sun Jul 14 07:54:30201913 // Update Count : 43 5512 // Last Modified On : Sun Aug 4 21:48:23 2019 13 // Update Count : 4364 14 14 // 15 15 … … 268 268 %token VOID CHAR SHORT INT LONG FLOAT DOUBLE SIGNED UNSIGNED 269 269 %token BOOL COMPLEX IMAGINARY // C99 270 %token INT128 uuFLOAT80 uuFLOAT128// GCC270 %token INT128 UINT128 uuFLOAT80 uuFLOAT128 // GCC 271 271 %token uFLOAT16 uFLOAT32 uFLOAT32X uFLOAT64 uFLOAT64X uFLOAT128 // GCC 272 272 %token ZERO_T ONE_T // CFA 273 273 %token VALIST // GCC 274 %token AUTO_TYPE // GCC 274 275 %token TYPEOF BASETYPEOF LABEL // GCC 275 276 %token ENUM STRUCT UNION … … 288 289 %token<tok> IDENTIFIER QUOTED_IDENTIFIER TYPEDEFname TYPEGENname 289 290 %token<tok> TIMEOUT WOR 290 %token<tok> ATTR_IDENTIFIER ATTR_TYPEDEFname ATTR_TYPEGENname291 291 %token<tok> INTEGERconstant CHARACTERconstant STRINGliteral 292 292 %token<tok> DIRECTIVE … … 312 312 %token ATassign // @= 313 313 314 %type<tok> identifier no_attr_identifier315 %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 316 316 %type<tok> quasi_keyword 317 317 %type<constant> string_literal … … 546 546 ; 547 547 548 no_attr_identifier:548 identifier: 549 549 IDENTIFIER 550 550 | quasi_keyword 551 551 | '@' // CFA 552 552 { Token tok = { new string( DeclarationNode::anonymous.newName() ), yylval.tok.loc }; $$ = tok; } 553 ;554 555 identifier:556 no_attr_identifier557 | ATTR_IDENTIFIER // CFA558 553 ; 559 554 … … 594 589 | '(' comma_expression ')' '`' IDENTIFIER // CFA, postfix call 595 590 { $$ = new ExpressionNode( build_func( new ExpressionNode( build_postfix_name( $5 ) ), $2 ) ); } 596 | type_name '.' no_attr_identifier// CFA, nested type591 | type_name '.' identifier // CFA, nested type 597 592 { SemanticError( yylloc, "Qualified name is currently unimplemented." ); $$ = nullptr; } 598 593 | type_name '.' '[' field_name_list ']' // CFA, nested type / tuple field selector … … 647 642 | postfix_expression '(' argument_expression_list ')' 648 643 { $$ = new ExpressionNode( build_func( $1, $3 ) ); } 649 | postfix_expression '.' no_attr_identifier644 | postfix_expression '.' identifier 650 645 { $$ = new ExpressionNode( build_fieldSel( $1, build_varref( $3 ) ) ); } 651 646 | postfix_expression '.' INTEGERconstant // CFA, tuple index … … 655 650 | postfix_expression '.' '[' field_name_list ']' // CFA, tuple field selector 656 651 { $$ = new ExpressionNode( build_fieldSel( $1, build_tuple( $4 ) ) ); } 657 | postfix_expression ARROW no_attr_identifier652 | postfix_expression ARROW identifier 658 653 { $$ = new ExpressionNode( build_pfieldSel( $1, build_varref( $3 ) ) ); } 659 654 | postfix_expression ARROW INTEGERconstant // CFA, tuple index … … 718 713 | FLOATINGconstant fraction_constants_opt 719 714 { $$ = new ExpressionNode( build_field_name_fraction_constants( build_field_name_FLOATINGconstant( *$1 ), $2 ) ); } 720 | no_attr_identifier fraction_constants_opt715 | identifier fraction_constants_opt 721 716 { 722 717 $$ = new ExpressionNode( build_field_name_fraction_constants( build_varref( $1 ), $2 ) ); … … 776 771 | ALIGNOF '(' type_no_function ')' // GCC, type alignment 777 772 { $$ = new ExpressionNode( new AlignofExpr( maybeMoveBuildType( $3 ) ) ); } 778 | OFFSETOF '(' type_no_function ',' no_attr_identifier ')'773 | OFFSETOF '(' type_no_function ',' identifier ')' 779 774 { $$ = new ExpressionNode( build_offsetOf( $3, build_varref( $5 ) ) ); } 780 | ATTR_IDENTIFIER781 { $$ = new ExpressionNode( new AttrExpr( build_varref( $1 ), maybeMoveBuild< Expression >( (ExpressionNode *)nullptr ) ) ); }782 | ATTR_IDENTIFIER '(' argument_expression ')'783 { $$ = new ExpressionNode( new AttrExpr( build_varref( $1 ), maybeMoveBuild< Expression >( $3 ) ) ); }784 | ATTR_IDENTIFIER '(' type ')'785 { $$ = new ExpressionNode( new AttrExpr( build_varref( $1 ), maybeMoveBuildType( $3 ) ) ); }786 775 ; 787 776 … … 1018 1007 1019 1008 labeled_statement: 1020 // labels cannot be identifiers 0 or 1 or ATTR_IDENTIFIER1009 // labels cannot be identifiers 0 or 1 1021 1010 identifier_or_type_name ':' attribute_list_opt statement 1022 1011 { $$ = $4->add_label( $1, $3 ); } … … 1386 1375 | type_specifier_nobody variable_abstract_declarator 1387 1376 { $$ = $2->addType( $1 ); } 1388 | cfa_abstract_declarator_tuple no_attr_identifier// CFA1377 | cfa_abstract_declarator_tuple identifier // CFA 1389 1378 { $$ = $1->addName( $2 ); } 1390 1379 | cfa_abstract_declarator_tuple // CFA … … 1450 1439 1451 1440 label_list: 1452 no_attr_identifier1441 identifier 1453 1442 { 1454 1443 $$ = new LabelNode(); $$->labels.push_back( *$1 ); 1455 1444 delete $1; // allocated by lexer 1456 1445 } 1457 | label_list ',' no_attr_identifier1446 | label_list ',' identifier 1458 1447 { 1459 1448 $$ = $1; $1->labels.push_back( *$3 ); … … 1500 1489 1501 1490 local_label_list: // GCC, local label 1502 no_attr_identifier_or_type_name1503 | local_label_list ',' no_attr_identifier_or_type_name1491 identifier_or_type_name 1492 | local_label_list ',' identifier_or_type_name 1504 1493 ; 1505 1494 … … 1623 1612 $$ = $2->addTypedef(); 1624 1613 } 1625 | cfa_typedef_declaration pop ',' push no_attr_identifier1614 | cfa_typedef_declaration pop ',' push identifier 1626 1615 { 1627 1616 typedefTable.addToEnclosingScope( *$5, TYPEDEFname, "3" ); … … 1663 1652 typedef_expression: 1664 1653 // GCC, naming expression type: typedef name = exp; gives a name to the type of an expression 1665 TYPEDEF no_attr_identifier '=' assignment_expression1654 TYPEDEF identifier '=' assignment_expression 1666 1655 { 1667 1656 // $$ = DeclarationNode::newName( 0 ); // unimplemented 1668 1657 SemanticError( yylloc, "Typedef expression is currently unimplemented." ); $$ = nullptr; 1669 1658 } 1670 | typedef_expression pop ',' push no_attr_identifier '=' assignment_expression1659 | typedef_expression pop ',' push identifier '=' assignment_expression 1671 1660 { 1672 1661 // $$ = DeclarationNode::newName( 0 ); // unimplemented … … 1837 1826 | INT128 1838 1827 { $$ = DeclarationNode::newBasicType( DeclarationNode::Int128 ); } 1828 | UINT128 1829 { $$ = DeclarationNode::newBasicType( DeclarationNode::Int128 )->addType( DeclarationNode::newSignedNess( DeclarationNode::Unsigned ) ); } 1839 1830 | FLOAT 1840 1831 { $$ = DeclarationNode::newBasicType( DeclarationNode::Float ); } … … 1871 1862 | VALIST // GCC, __builtin_va_list 1872 1863 { $$ = DeclarationNode::newBuiltinType( DeclarationNode::Valist ); } 1864 | AUTO_TYPE 1865 { $$ = DeclarationNode::newBuiltinType( DeclarationNode::AutoType ); } 1873 1866 ; 1874 1867 … … 1912 1905 | BASETYPEOF '(' comma_expression ')' // CFA: basetypeof( a+b ) y; 1913 1906 { $$ = DeclarationNode::newTypeof( $3, true ); } 1914 | ATTR_TYPEGENname '(' type ')' // CFA: e.g., @type( x ) y;1915 { $$ = DeclarationNode::newAttr( $1, $3 ); }1916 | ATTR_TYPEGENname '(' comma_expression ')' // CFA: e.g., @type( a+b ) y;1917 { $$ = DeclarationNode::newAttr( $1, $3 ); }1918 1907 | ZERO_T // CFA 1919 1908 { $$ = DeclarationNode::newBuiltinType( DeclarationNode::Zero ); } … … 2024 2013 '{' field_declaration_list_opt '}' type_parameters_opt 2025 2014 { $$ = DeclarationNode::newAggregate( $1, nullptr, $7, $5, true )->addQualifiers( $2 ); } 2026 | aggregate_key attribute_list_opt no_attr_identifier fred2015 | aggregate_key attribute_list_opt identifier fred 2027 2016 { 2028 2017 typedefTable.makeTypedef( *$3, forall || typedefTable.getEnclForall() ? TYPEGENname : TYPEDEFname ); // create typedef … … 2050 2039 2051 2040 aggregate_type_nobody: // struct, union - {...} 2052 aggregate_key attribute_list_opt no_attr_identifier fred2041 aggregate_key attribute_list_opt identifier fred 2053 2042 { 2054 2043 typedefTable.makeTypedef( *$3, forall || typedefTable.getEnclForall() ? TYPEGENname : TYPEDEFname ); … … 2151 2140 cfa_field_declaring_list: // CFA, new style field declaration 2152 2141 // bit-fields are handled by C declarations 2153 cfa_abstract_declarator_tuple no_attr_identifier_or_type_name2142 cfa_abstract_declarator_tuple identifier_or_type_name 2154 2143 { $$ = $1->addName( $2 ); } 2155 | cfa_field_declaring_list ',' no_attr_identifier_or_type_name2144 | cfa_field_declaring_list ',' identifier_or_type_name 2156 2145 { $$ = $1->appendList( $1->cloneType( $3 ) ); } 2157 2146 ; … … 2178 2167 ENUM attribute_list_opt '{' enumerator_list comma_opt '}' 2179 2168 { $$ = DeclarationNode::newEnum( nullptr, $4, true )->addQualifiers( $2 ); } 2180 | ENUM attribute_list_opt no_attr_identifier2169 | ENUM attribute_list_opt identifier 2181 2170 { typedefTable.makeTypedef( *$3 ); } 2182 2171 '{' enumerator_list comma_opt '}' … … 2189 2178 2190 2179 enum_type_nobody: // enum - {...} 2191 ENUM attribute_list_opt no_attr_identifier2180 ENUM attribute_list_opt identifier 2192 2181 { 2193 2182 typedefTable.makeTypedef( *$3 ); … … 2202 2191 2203 2192 enumerator_list: 2204 no_attr_identifier_or_type_name enumerator_value_opt2193 identifier_or_type_name enumerator_value_opt 2205 2194 { $$ = DeclarationNode::newEnumConstant( $1, $2 ); } 2206 | enumerator_list ',' no_attr_identifier_or_type_name enumerator_value_opt2195 | enumerator_list ',' identifier_or_type_name enumerator_value_opt 2207 2196 { $$ = $1->appendList( DeclarationNode::newEnumConstant( $3, $4 ) ); } 2208 2197 ; … … 2312 2301 2313 2302 identifier_list: // K&R-style parameter list => no types 2314 no_attr_identifier2303 identifier 2315 2304 { $$ = DeclarationNode::newName( $1 ); } 2316 | identifier_list ',' no_attr_identifier2305 | identifier_list ',' identifier 2317 2306 { $$ = $1->appendList( DeclarationNode::newName( $3 ) ); } 2318 2307 ; … … 2320 2309 identifier_or_type_name: 2321 2310 identifier 2322 | TYPEDEFname2323 | TYPEGENname2324 ;2325 2326 no_attr_identifier_or_type_name:2327 no_attr_identifier2328 2311 | TYPEDEFname 2329 2312 | TYPEGENname … … 2380 2363 designation: 2381 2364 designator_list ':' // C99, CFA uses ":" instead of "=" 2382 | no_attr_identifier ':'// GCC, field name2365 | identifier ':' // GCC, field name 2383 2366 { $$ = new ExpressionNode( build_varref( $1 ) ); } 2384 2367 ; … … 2392 2375 2393 2376 designator: 2394 '.' no_attr_identifier// C99, field name2377 '.' identifier // C99, field name 2395 2378 { $$ = new ExpressionNode( build_varref( $2 ) ); } 2396 2379 | '[' push assignment_expression pop ']' // C99, single array element … … 2437 2420 2438 2421 type_parameter: // CFA 2439 type_class no_attr_identifier_or_type_name2422 type_class identifier_or_type_name 2440 2423 { typedefTable.addToScope( *$2, TYPEDEFname, "9" ); } 2441 2424 type_initializer_opt assertion_list_opt … … 2470 2453 2471 2454 assertion: // CFA 2472 '|' no_attr_identifier_or_type_name '(' type_list ')'2455 '|' identifier_or_type_name '(' type_list ')' 2473 2456 { $$ = DeclarationNode::newTraitUse( $2, $4 ); } 2474 2457 | '|' '{' push trait_declaration_list pop '}' … … 2507 2490 2508 2491 type_declarator_name: // CFA 2509 no_attr_identifier_or_type_name2492 identifier_or_type_name 2510 2493 { 2511 2494 typedefTable.addToEnclosingScope( *$1, TYPEDEFname, "10" ); 2512 2495 $$ = DeclarationNode::newTypeDecl( $1, 0 ); 2513 2496 } 2514 | no_attr_identifier_or_type_name '(' type_parameter_list ')'2497 | identifier_or_type_name '(' type_parameter_list ')' 2515 2498 { 2516 2499 typedefTable.addToEnclosingScope( *$1, TYPEGENname, "11" ); … … 2520 2503 2521 2504 trait_specifier: // CFA 2522 TRAIT no_attr_identifier_or_type_name '(' type_parameter_list ')' '{' '}'2505 TRAIT identifier_or_type_name '(' type_parameter_list ')' '{' '}' 2523 2506 { $$ = DeclarationNode::newTrait( $2, $4, 0 ); } 2524 | TRAIT no_attr_identifier_or_type_name '(' type_parameter_list ')' '{' push trait_declaration_list pop '}'2507 | TRAIT identifier_or_type_name '(' type_parameter_list ')' '{' push trait_declaration_list pop '}' 2525 2508 { $$ = DeclarationNode::newTrait( $2, $4, $8 ); } 2526 2509 ; -
src/ResolvExpr/AlternativeFinder.cc
r8e1467d r4a60488 9 9 // Author : Richard C. Bilson 10 10 // Created On : Sat May 16 23:52:08 2015 11 // Last Modified By : Peter A. Buhr12 // Last Modified On : Thu Nov 1 21:00:56 201813 // Update Count : 3 511 // Last Modified By : Andrew Beach 12 // Last Modified On : Thu Aug 8 16:35:00 2019 13 // Update Count : 38 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 ); … … 378 377 } 379 378 380 Cost computeConversionCost( Type * actualType, Type * formalType, const SymTab::Indexer &indexer, const TypeEnvironment & env ) { 379 Cost computeConversionCost( Type * actualType, Type * formalType, bool actualIsLvalue, 380 const SymTab::Indexer &indexer, const TypeEnvironment & env ) { 381 381 PRINT( 382 382 std::cerr << std::endl << "converting "; … … 388 388 std::cerr << std::endl; 389 389 ) 390 Cost convCost = conversionCost( actualType, formalType, indexer, env );390 Cost convCost = conversionCost( actualType, formalType, actualIsLvalue, indexer, env ); 391 391 PRINT( 392 392 std::cerr << std::endl << "cost is " << convCost << std::endl; … … 403 403 404 404 Cost computeExpressionConversionCost( Expression *& actualExpr, Type * formalType, const SymTab::Indexer &indexer, const TypeEnvironment & env ) { 405 Cost convCost = computeConversionCost( actualExpr->result, formalType, indexer, env ); 405 Cost convCost = computeConversionCost( 406 actualExpr->result, formalType, actualExpr->get_lvalue(), indexer, env ); 406 407 407 408 // if there is a non-zero conversion cost, ignoring poly cost, then the expression requires conversion. … … 1136 1137 bool isLvalue( Expression *expr ) { 1137 1138 // xxx - recurse into tuples? 1138 return expr->result && ( expr-> result->get_lvalue() || dynamic_cast< ReferenceType * >( expr->result ) );1139 return expr->result && ( expr->get_lvalue() || dynamic_cast< ReferenceType * >( expr->result ) ); 1139 1140 } 1140 1141 … … 1187 1188 assert( toType ); 1188 1189 toType = resolveTypeof( toType, indexer ); 1190 assert(!dynamic_cast<TypeofType *>(toType)); 1189 1191 SymTab::validateType( toType, &indexer ); 1190 1192 adjustExprType( toType, env, indexer ); … … 1213 1215 unify( castExpr->result, alt.expr->result, alt.env, needAssertions, 1214 1216 haveAssertions, openVars, indexer ); 1215 Cost thisCost = castCost( alt.expr->result, castExpr->result, indexer,1216 alt.env );1217 Cost thisCost = castCost( alt.expr->result, castExpr->result, alt.expr->get_lvalue(), 1218 indexer, alt.env ); 1217 1219 PRINT( 1218 1220 std::cerr << "working on cast with result: " << castExpr->result << std::endl; … … 1402 1404 void AlternativeFinder::Finder::postvisit( OffsetPackExpr *offsetPackExpr ) { 1403 1405 alternatives.push_back( Alternative{ offsetPackExpr->clone(), env } ); 1404 }1405 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 1406 } 1470 1407 … … 1706 1643 // xxx - do some inspecting on this line... why isn't result bound to initAlt.type? 1707 1644 1708 Cost thisCost = castCost( alt.expr->result, toType, indexer, newEnv ); 1645 Cost thisCost = castCost( alt.expr->result, toType, alt.expr->get_lvalue(), 1646 indexer, newEnv ); 1709 1647 if ( thisCost != Cost::infinity ) { 1710 1648 // count one safe conversion for each value that is thrown away -
src/ResolvExpr/CastCost.cc
r8e1467d r4a60488 9 9 // Author : Richard C. Bilson 10 10 // Created On : Sun May 17 06:57:43 2015 11 // Last Modified By : Peter A. Buhr12 // Last Modified On : T ue Feb 2 15:34:36 201613 // Update Count : 711 // Last Modified By : Andrew Beach 12 // Last Modified On : Thu Aug 8 16:12:00 2019 13 // Update Count : 8 14 14 // 15 15 … … 37 37 struct CastCost_old : public ConversionCost { 38 38 public: 39 CastCost_old( const Type * dest, const SymTab::Indexer &indexer, const TypeEnvironment &env, CostFunction costFunc ); 39 CastCost_old( const Type * dest, bool srcIsLvalue, 40 const SymTab::Indexer &indexer, const TypeEnvironment &env, CostFunction costFunc ); 40 41 41 42 using ConversionCost::previsit; … … 45 46 }; 46 47 47 Cost castCost( const Type * src, const Type * dest, const SymTab::Indexer &indexer, const TypeEnvironment &env ) { 48 Cost castCost( const Type * src, const Type * dest, bool srcIsLvalue, 49 const SymTab::Indexer &indexer, const TypeEnvironment &env ) { 48 50 if ( const TypeInstType * destAsTypeInst = dynamic_cast< const TypeInstType * >( dest ) ) { 49 51 if ( const EqvClass * eqvClass = env.lookup( destAsTypeInst->name ) ) { 50 52 if ( eqvClass->type ) { 51 return castCost( src, eqvClass->type, indexer, env );53 return castCost( src, eqvClass->type, srcIsLvalue, indexer, env ); 52 54 } else { 53 55 return Cost::infinity; … … 57 59 const TypeDecl * type = strict_dynamic_cast< const TypeDecl * >( namedType ); 58 60 if ( type->base ) { 59 return castCost( src, type->base, indexer, env ) + Cost::safe;61 return castCost( src, type->base, srcIsLvalue, indexer, env ) + Cost::safe; 60 62 } // if 61 63 } // if … … 78 80 } else if ( const ReferenceType * refType = dynamic_cast< const ReferenceType * > ( dest ) ) { 79 81 PRINT( std::cerr << "conversionCost: dest is reference" << std::endl; ) 80 return convertToReferenceCost( src, refType, indexer, env, [](const Type * t1, const Type * t2, const SymTab::Indexer & indexer, const TypeEnvironment & env ) {82 return convertToReferenceCost( src, refType, srcIsLvalue, indexer, env, [](const Type * t1, const Type * t2, const SymTab::Indexer & indexer, const TypeEnvironment & env ) { 81 83 return ptrsCastable( t1, t2, env, indexer ); 82 84 }); 83 85 } else { 84 86 PassVisitor<CastCost_old> converter( 85 dest, indexer, env,86 (Cost (*)( const Type *, const Type *, const SymTab::Indexer &, const TypeEnvironment & ))87 dest, srcIsLvalue, indexer, env, 88 (Cost (*)( const Type *, const Type *, bool, const SymTab::Indexer &, const TypeEnvironment & )) 87 89 castCost ); 88 90 src->accept( converter ); … … 96 98 } 97 99 98 CastCost_old::CastCost_old( const Type * dest, const SymTab::Indexer &indexer, const TypeEnvironment &env, CostFunction costFunc ) 99 : ConversionCost( dest, indexer, env, costFunc ) { 100 CastCost_old::CastCost_old( const Type * dest, bool srcIsLvalue, 101 const SymTab::Indexer &indexer, const TypeEnvironment &env, CostFunction costFunc ) 102 : ConversionCost( dest, srcIsLvalue, indexer, env, costFunc ) { 100 103 } 101 104 … … 106 109 cost = Cost::unsafe; 107 110 } else { 108 cost = conversionCost( basicType, dest, indexer, env );111 cost = conversionCost( basicType, dest, srcIsLvalue, indexer, env ); 109 112 } // if 110 113 } -
src/ResolvExpr/CommonType.cc
r8e1467d r4a60488 190 190 */ 191 191 { 192 /* B */ BT Bool, BT Char, BT SignedChar, BT UnsignedChar, BT ShortSignedInt, BT ShortUnsignedInt,192 /* B */ BT Bool, BT Char, BT SignedChar, BT UnsignedChar, BT ShortSignedInt, BT ShortUnsignedInt, 193 193 BT SignedInt, BT UnsignedInt, BT LongSignedInt, BT LongUnsignedInt, BT LongLongSignedInt, BT LongLongUnsignedInt, 194 194 BT SignedInt128, BT UnsignedInt128, BT uFloat16, BT uFloat16Complex, BT uFloat32, BT uFloat32Complex, … … 198 198 }, 199 199 { 200 /* C */ BT Char, BT Char, BT SignedChar, BT UnsignedChar, BT ShortSignedInt, BT ShortUnsignedInt,200 /* C */ BT Char, BT Char, BT SignedChar, BT UnsignedChar, BT ShortSignedInt, BT ShortUnsignedInt, 201 201 BT SignedInt, BT UnsignedInt, BT LongSignedInt, BT LongUnsignedInt, BT LongLongSignedInt, BT LongLongUnsignedInt, 202 202 BT SignedInt128, BT UnsignedInt128, BT uFloat16, BT uFloat16Complex, BT uFloat32, BT uFloat32Complex, … … 206 206 }, 207 207 { 208 /* SC */ BT SignedChar, BT SignedChar, BT SignedChar, BT UnsignedChar, BT ShortSignedInt, BT ShortUnsignedInt,208 /* SC */ BT SignedChar, BT SignedChar, BT SignedChar, BT UnsignedChar, BT ShortSignedInt, BT ShortUnsignedInt, 209 209 BT SignedInt, BT UnsignedInt, BT LongSignedInt, BT LongUnsignedInt, BT LongLongSignedInt, BT LongLongUnsignedInt, 210 210 BT SignedInt128, BT UnsignedInt128, BT uFloat16, BT uFloat16Complex, BT uFloat32, BT uFloat32Complex, … … 214 214 }, 215 215 { 216 /* UC */ BT UnsignedChar, BT UnsignedChar, BT UnsignedChar, BT UnsignedChar, BT ShortSignedInt, BT ShortUnsignedInt,216 /* UC */ BT UnsignedChar, BT UnsignedChar, BT UnsignedChar, BT UnsignedChar, BT ShortSignedInt, BT ShortUnsignedInt, 217 217 BT SignedInt, BT UnsignedInt, BT LongSignedInt, BT LongUnsignedInt, BT LongLongSignedInt, BT LongLongUnsignedInt, 218 218 BT SignedInt128, BT UnsignedInt128, BT uFloat16, BT uFloat16Complex, BT uFloat32, BT uFloat32Complex, … … 222 222 }, 223 223 { 224 /* SI */ BT ShortSignedInt, BT ShortSignedInt, BT ShortSignedInt, BT ShortSignedInt, BT ShortSignedInt, BT ShortUnsignedInt,224 /* SI */ BT ShortSignedInt, BT ShortSignedInt, BT ShortSignedInt, BT ShortSignedInt, BT ShortSignedInt, BT ShortUnsignedInt, 225 225 BT SignedInt, BT UnsignedInt, BT LongSignedInt, BT LongUnsignedInt, BT LongLongSignedInt, BT LongLongUnsignedInt, 226 226 BT SignedInt128, BT UnsignedInt128, BT uFloat16, BT uFloat16Complex, BT uFloat32, BT uFloat32Complex, … … 230 230 }, 231 231 { 232 /* SUI */ BT ShortUnsignedInt, BT ShortUnsignedInt, BT ShortUnsignedInt, BT ShortUnsignedInt, BT ShortUnsignedInt, BT ShortUnsignedInt,232 /* SUI */ BT ShortUnsignedInt, BT ShortUnsignedInt, BT ShortUnsignedInt, BT ShortUnsignedInt, BT ShortUnsignedInt, BT ShortUnsignedInt, 233 233 BT SignedInt, BT UnsignedInt, BT LongSignedInt, BT LongUnsignedInt, BT LongLongSignedInt, BT LongLongUnsignedInt, 234 234 BT SignedInt128, BT UnsignedInt128, BT uFloat16, BT uFloat16Complex, BT uFloat32, BT uFloat32Complex, … … 238 238 }, 239 239 { 240 /* I */ BT SignedInt, BT SignedInt, BT SignedInt, BT SignedInt, BT SignedInt, BT SignedInt,240 /* I */ BT SignedInt, BT SignedInt, BT SignedInt, BT SignedInt, BT SignedInt, BT SignedInt, 241 241 BT SignedInt, BT UnsignedInt, BT LongSignedInt, BT LongUnsignedInt, BT LongLongSignedInt, BT LongLongUnsignedInt, 242 242 BT SignedInt128, BT UnsignedInt128, BT uFloat16, BT uFloat16Complex, BT uFloat32, BT uFloat32Complex, … … 246 246 }, 247 247 { 248 /* UI */ BT UnsignedInt, BT UnsignedInt, BT UnsignedInt, BT UnsignedInt, BT UnsignedInt, BT UnsignedInt,248 /* UI */ BT UnsignedInt, BT UnsignedInt, BT UnsignedInt, BT UnsignedInt, BT UnsignedInt, BT UnsignedInt, 249 249 BT UnsignedInt, BT UnsignedInt, BT LongSignedInt, BT LongUnsignedInt, BT LongLongSignedInt, BT LongLongUnsignedInt, 250 250 BT SignedInt128, BT UnsignedInt128, BT uFloat16, BT uFloat16Complex, BT uFloat32, BT uFloat32Complex, … … 254 254 }, 255 255 { 256 /* LI */ BT LongSignedInt, BT LongSignedInt, BT LongSignedInt, BT LongSignedInt, BT LongSignedInt, BT LongSignedInt,256 /* LI */ BT LongSignedInt, BT LongSignedInt, BT LongSignedInt, BT LongSignedInt, BT LongSignedInt, BT LongSignedInt, 257 257 BT LongSignedInt, BT LongSignedInt, BT LongSignedInt, BT LongUnsignedInt, BT LongLongSignedInt, BT LongLongUnsignedInt, 258 258 BT SignedInt128, BT UnsignedInt128, BT uFloat16, BT uFloat16Complex, BT uFloat32, BT uFloat32Complex, … … 262 262 }, 263 263 { 264 /* LUI */ BT LongUnsignedInt, BT LongUnsignedInt, BT LongUnsignedInt, BT LongUnsignedInt, BT LongUnsignedInt, BT LongUnsignedInt,264 /* LUI */ BT LongUnsignedInt, BT LongUnsignedInt, BT LongUnsignedInt, BT LongUnsignedInt, BT LongUnsignedInt, BT LongUnsignedInt, 265 265 BT LongUnsignedInt, BT LongUnsignedInt, BT LongUnsignedInt, BT LongUnsignedInt, BT LongLongSignedInt, BT LongLongUnsignedInt, 266 266 BT SignedInt128, BT UnsignedInt128, BT uFloat16, BT uFloat16Complex, BT uFloat32, BT uFloat32Complex, … … 270 270 }, 271 271 { 272 /* LLI */ BT LongLongSignedInt, BT LongLongSignedInt, BT LongLongSignedInt, BT LongLongSignedInt, BT LongLongSignedInt, BT LongLongSignedInt,272 /* LLI */ BT LongLongSignedInt, BT LongLongSignedInt, BT LongLongSignedInt, BT LongLongSignedInt, BT LongLongSignedInt, BT LongLongSignedInt, 273 273 BT LongLongSignedInt, BT LongLongSignedInt, BT LongLongSignedInt, BT LongLongSignedInt, BT LongLongSignedInt, BT LongLongUnsignedInt, 274 274 BT SignedInt128, BT UnsignedInt128, BT uFloat16, BT uFloat16Complex, BT uFloat32, BT uFloat32Complex, … … 278 278 }, 279 279 { 280 /* LLUI */ BT LongLongUnsignedInt, BT LongLongUnsignedInt, BT LongLongUnsignedInt, BT LongLongUnsignedInt, BT LongLongUnsignedInt, BT LongLongUnsignedInt,280 /* LLUI */ BT LongLongUnsignedInt, BT LongLongUnsignedInt, BT LongLongUnsignedInt, BT LongLongUnsignedInt, BT LongLongUnsignedInt, BT LongLongUnsignedInt, 281 281 BT LongLongUnsignedInt, BT LongLongUnsignedInt, BT LongLongUnsignedInt, BT LongLongUnsignedInt, BT LongLongUnsignedInt, BT LongLongUnsignedInt, 282 282 BT SignedInt128, BT UnsignedInt128, BT uFloat16, BT uFloat16Complex, BT uFloat32, BT uFloat32Complex, … … 286 286 }, 287 287 { 288 /* IB */ BT SignedInt128, BT SignedInt128, BT SignedInt128, BT SignedInt128, BT SignedInt128, BT SignedInt128,288 /* IB */ BT SignedInt128, BT SignedInt128, BT SignedInt128, BT SignedInt128, BT SignedInt128, BT SignedInt128, 289 289 BT SignedInt128, BT SignedInt128, BT SignedInt128, BT SignedInt128, BT SignedInt128, BT SignedInt128, 290 290 BT SignedInt128, BT UnsignedInt128, BT uFloat16, BT uFloat16Complex, BT uFloat32, BT uFloat32Complex, … … 294 294 }, 295 295 { 296 /* UIB */ BT UnsignedInt128, BT UnsignedInt128, BT UnsignedInt128, BT UnsignedInt128, BT UnsignedInt128, BT UnsignedInt128,296 /* UIB */ BT UnsignedInt128, BT UnsignedInt128, BT UnsignedInt128, BT UnsignedInt128, BT UnsignedInt128, BT UnsignedInt128, 297 297 BT UnsignedInt128, BT UnsignedInt128, BT UnsignedInt128, BT UnsignedInt128, BT UnsignedInt128, BT UnsignedInt128, 298 298 BT UnsignedInt128, BT UnsignedInt128, BT uFloat16, BT uFloat16Complex, BT uFloat32, BT uFloat32Complex, … … 302 302 }, 303 303 { 304 /* _FH */ BT uFloat16, BT uFloat16, BT uFloat16, BT uFloat16, BT uFloat16, BT uFloat16,304 /* _FH */ BT uFloat16, BT uFloat16, BT uFloat16, BT uFloat16, BT uFloat16, BT uFloat16, 305 305 BT uFloat16, BT uFloat16, BT uFloat16, BT uFloat16, BT uFloat16, BT uFloat16, 306 306 BT uFloat16, BT uFloat16, BT uFloat16, BT uFloat16Complex, BT uFloat32, BT uFloat32Complex, … … 310 310 }, 311 311 { 312 /* _FH */ BT uFloat16Complex, BT uFloat16Complex, BT uFloat16Complex, BT uFloat16Complex, BT uFloat16Complex, BT uFloat16Complex,312 /* _FH */ BT uFloat16Complex, BT uFloat16Complex, BT uFloat16Complex, BT uFloat16Complex, BT uFloat16Complex, BT uFloat16Complex, 313 313 BT uFloat16Complex, BT uFloat16Complex, BT uFloat16Complex, BT uFloat16Complex, BT uFloat16Complex, BT uFloat16Complex, 314 314 BT uFloat16Complex, BT uFloat16Complex, BT uFloat16Complex, BT uFloat16Complex, BT uFloat32Complex, BT uFloat32Complex, … … 318 318 }, 319 319 { 320 /* _F */ BT uFloat32, BT uFloat32, BT uFloat32, BT uFloat32, BT uFloat32, BT uFloat32,320 /* _F */ BT uFloat32, BT uFloat32, BT uFloat32, BT uFloat32, BT uFloat32, BT uFloat32, 321 321 BT uFloat32, BT uFloat32, BT uFloat32, BT uFloat32, BT uFloat32, BT uFloat32, 322 322 BT uFloat32, BT uFloat32, BT uFloat32, BT uFloat32Complex, BT uFloat32, BT uFloat32Complex, … … 326 326 }, 327 327 { 328 /* _FC */ BT uFloat32Complex, BT uFloat32Complex, BT uFloat32Complex, BT uFloat32Complex, BT uFloat32Complex, BT uFloat32Complex,328 /* _FC */ BT uFloat32Complex, BT uFloat32Complex, BT uFloat32Complex, BT uFloat32Complex, BT uFloat32Complex, BT uFloat32Complex, 329 329 BT uFloat32Complex, BT uFloat32Complex, BT uFloat32Complex, BT uFloat32Complex, BT uFloat32Complex, BT uFloat32Complex, 330 330 BT uFloat32Complex, BT uFloat32Complex, BT uFloat32Complex, BT uFloat32Complex, BT uFloat32Complex, BT uFloat32Complex, … … 334 334 }, 335 335 { 336 /* F */ BT Float, BT Float, BT Float, BT Float, BT Float, BT Float,336 /* F */ BT Float, BT Float, BT Float, BT Float, BT Float, BT Float, 337 337 BT Float, BT Float, BT Float, BT Float, BT Float, BT Float, 338 338 BT Float, BT Float, BT Float, BT FloatComplex, BT Float, BT FloatComplex, … … 342 342 }, 343 343 { 344 /* FC */ BT FloatComplex, BT FloatComplex, BT FloatComplex, BT FloatComplex, BT FloatComplex, BT FloatComplex,344 /* FC */ BT FloatComplex, BT FloatComplex, BT FloatComplex, BT FloatComplex, BT FloatComplex, BT FloatComplex, 345 345 BT FloatComplex, BT FloatComplex, BT FloatComplex, BT FloatComplex, BT FloatComplex, BT FloatComplex, 346 346 BT FloatComplex, BT FloatComplex, BT FloatComplex, BT FloatComplex, BT FloatComplex, BT FloatComplex, … … 350 350 }, 351 351 { 352 /* _FX */ BT uFloat32x, BT uFloat32x, BT uFloat32x, BT uFloat32x, BT uFloat32x, BT uFloat32x,352 /* _FX */ BT uFloat32x, BT uFloat32x, BT uFloat32x, BT uFloat32x, BT uFloat32x, BT uFloat32x, 353 353 BT uFloat32x, BT uFloat32x, BT uFloat32x, BT uFloat32x, BT uFloat32x, BT uFloat32x, 354 354 BT uFloat32x, BT uFloat32x, BT uFloat32x, BT uFloat32xComplex, BT uFloat32x, BT uFloat32xComplex, … … 358 358 }, 359 359 { 360 /* _FXC */ BT uFloat32xComplex, BT uFloat32xComplex, BT uFloat32xComplex, BT uFloat32xComplex, BT uFloat32xComplex, BT uFloat32xComplex,360 /* _FXC */ BT uFloat32xComplex, BT uFloat32xComplex, BT uFloat32xComplex, BT uFloat32xComplex, BT uFloat32xComplex, BT uFloat32xComplex, 361 361 BT uFloat32xComplex, BT uFloat32xComplex, BT uFloat32xComplex, BT uFloat32xComplex, BT uFloat32xComplex, BT uFloat32xComplex, 362 362 BT uFloat32xComplex, BT uFloat32xComplex, BT uFloat32xComplex, BT uFloat32xComplex, BT uFloat32xComplex, BT uFloat32xComplex, … … 366 366 }, 367 367 { 368 /* FD */ BT uFloat64, BT uFloat64, BT uFloat64, BT uFloat64, BT uFloat64, BT uFloat64,368 /* FD */ BT uFloat64, BT uFloat64, BT uFloat64, BT uFloat64, BT uFloat64, BT uFloat64, 369 369 BT uFloat64, BT uFloat64, BT uFloat64, BT uFloat64, BT uFloat64, BT uFloat64, 370 370 BT uFloat64, BT uFloat64, BT uFloat64, BT uFloat64Complex, BT uFloat64, BT uFloat64Complex, … … 374 374 }, 375 375 { 376 /* _FDC */ BT uFloat64Complex, BT uFloat64Complex, BT uFloat64Complex, BT uFloat64Complex, BT uFloat64Complex, BT uFloat64Complex,376 /* _FDC */ BT uFloat64Complex, BT uFloat64Complex, BT uFloat64Complex, BT uFloat64Complex, BT uFloat64Complex, BT uFloat64Complex, 377 377 BT uFloat64Complex, BT uFloat64Complex, BT uFloat64Complex, BT uFloat64Complex, BT uFloat64Complex, BT uFloat64Complex, 378 378 BT uFloat64Complex, BT uFloat64Complex, BT uFloat64Complex, BT uFloat64Complex, BT uFloat64Complex, BT uFloat64Complex, … … 382 382 }, 383 383 { 384 /* D */ BT Double, BT Double, BT Double, BT Double, BT Double, BT Double,384 /* D */ BT Double, BT Double, BT Double, BT Double, BT Double, BT Double, 385 385 BT Double, BT Double, BT Double, BT Double, BT Double, BT Double, 386 386 BT Double, BT Double, BT Double, BT DoubleComplex, BT Double, BT DoubleComplex, … … 390 390 }, 391 391 { 392 /* DC */ BT DoubleComplex, BT DoubleComplex, BT DoubleComplex, BT DoubleComplex, BT DoubleComplex, BT DoubleComplex,392 /* DC */ BT DoubleComplex, BT DoubleComplex, BT DoubleComplex, BT DoubleComplex, BT DoubleComplex, BT DoubleComplex, 393 393 BT DoubleComplex, BT DoubleComplex, BT DoubleComplex, BT DoubleComplex, BT DoubleComplex, BT DoubleComplex, 394 394 BT DoubleComplex, BT DoubleComplex, BT DoubleComplex, BT DoubleComplex, BT DoubleComplex, BT DoubleComplex, … … 398 398 }, 399 399 { 400 /* F80X */ BT uFloat64x, BT uFloat64x, BT uFloat64x, BT uFloat64x, BT uFloat64x, BT uFloat64x,400 /* F80X */ BT uFloat64x, BT uFloat64x, BT uFloat64x, BT uFloat64x, BT uFloat64x, BT uFloat64x, 401 401 BT uFloat64x, BT uFloat64x, BT uFloat64x, BT uFloat64x, BT uFloat64x, BT uFloat64x, 402 402 BT uFloat64x, BT uFloat64x, BT uFloat64x, BT uFloat64xComplex, BT uFloat64x, BT uFloat64xComplex, … … 406 406 }, 407 407 { 408 /* _FDXC */ BT uFloat64xComplex, BT uFloat64xComplex, BT uFloat64xComplex, BT uFloat64xComplex, BT uFloat64xComplex, BT uFloat64xComplex,408 /* _FDXC */ BT uFloat64xComplex, BT uFloat64xComplex, BT uFloat64xComplex, BT uFloat64xComplex, BT uFloat64xComplex, BT uFloat64xComplex, 409 409 BT uFloat64xComplex, BT uFloat64xComplex, BT uFloat64xComplex, BT uFloat64xComplex, BT uFloat64xComplex, BT uFloat64xComplex, 410 410 BT uFloat64xComplex, BT uFloat64xComplex, BT uFloat64xComplex, BT uFloat64xComplex, BT uFloat64xComplex, BT uFloat64xComplex, … … 414 414 }, 415 415 { 416 /* F80*/ BT uuFloat80, BT uuFloat80, BT uuFloat80, BT uuFloat80, BT uuFloat80, BT uuFloat80,416 /* F80 */ BT uuFloat80, BT uuFloat80, BT uuFloat80, BT uuFloat80, BT uuFloat80, BT uuFloat80, 417 417 BT uuFloat80, BT uuFloat80, BT uuFloat80, BT uuFloat80, BT uuFloat80, BT uuFloat80, 418 418 BT uuFloat80, BT uuFloat80, BT uuFloat80, BT uFloat64xComplex, BT uuFloat80, BT uFloat64xComplex, … … 422 422 }, 423 423 { 424 /* _FB */ BT uFloat128, BT uFloat128, BT uFloat128, BT uFloat128, BT uFloat128, BT uFloat128,424 /* _FB */ BT uFloat128, BT uFloat128, BT uFloat128, BT uFloat128, BT uFloat128, BT uFloat128, 425 425 BT uFloat128, BT uFloat128, BT uFloat128, BT uFloat128, BT uFloat128, BT uFloat128, 426 426 BT uFloat128, BT uFloat128, BT uFloat128, BT uFloat128Complex, BT uFloat128, BT uFloat128Complex, … … 430 430 }, 431 431 { 432 /* _FLDC */ BT uFloat128Complex, BT uFloat128Complex, BT uFloat128Complex, BT uFloat128Complex, BT uFloat128Complex, BT uFloat128Complex,432 /* _FLDC */ BT uFloat128Complex, BT uFloat128Complex, BT uFloat128Complex, BT uFloat128Complex, BT uFloat128Complex, BT uFloat128Complex, 433 433 BT uFloat128Complex, BT uFloat128Complex, BT uFloat128Complex, BT uFloat128Complex, BT uFloat128Complex, BT uFloat128Complex, 434 434 BT uFloat128Complex, BT uFloat128Complex, BT uFloat128Complex, BT uFloat128Complex, BT uFloat128Complex, BT uFloat128Complex, … … 438 438 }, 439 439 { 440 /* FB */ BT uuFloat128, BT uuFloat128, BT uuFloat128, BT uuFloat128, BT uuFloat128, BT uuFloat128,440 /* FB */ BT uuFloat128, BT uuFloat128, BT uuFloat128, BT uuFloat128, BT uuFloat128, BT uuFloat128, 441 441 BT uuFloat128, BT uuFloat128, BT uuFloat128, BT uuFloat128, BT uuFloat128, BT uuFloat128, 442 442 BT uuFloat128, BT uuFloat128, BT uuFloat128, BT uFloat128Complex, BT uuFloat128, BT uFloat128Complex, … … 446 446 }, 447 447 { 448 /* LD */ BT LongDouble, BT LongDouble, BT LongDouble, BT LongDouble, BT LongDouble, BT LongDouble,448 /* LD */ BT LongDouble, BT LongDouble, BT LongDouble, BT LongDouble, BT LongDouble, BT LongDouble, 449 449 BT LongDouble, BT LongDouble, BT LongDouble, BT LongDouble, BT LongDouble, BT LongDouble, 450 450 BT LongDouble, BT LongDouble, BT LongDouble, BT LongDoubleComplex, BT LongDouble, BT LongDoubleComplex, … … 454 454 }, 455 455 { 456 /* LDC */ BT LongDoubleComplex, BT LongDoubleComplex, BT LongDoubleComplex, BT LongDoubleComplex, BT LongDoubleComplex, BT LongDoubleComplex,456 /* LDC */ BT LongDoubleComplex, BT LongDoubleComplex, BT LongDoubleComplex, BT LongDoubleComplex, BT LongDoubleComplex, BT LongDoubleComplex, 457 457 BT LongDoubleComplex, BT LongDoubleComplex, BT LongDoubleComplex, BT LongDoubleComplex, BT LongDoubleComplex, BT LongDoubleComplex, 458 458 BT LongDoubleComplex, BT LongDoubleComplex, BT LongDoubleComplex, BT LongDoubleComplex, BT LongDoubleComplex, BT LongDoubleComplex, … … 462 462 }, 463 463 { 464 /* _FBX */ BT uFloat128x, BT uFloat128x, BT uFloat128x, BT uFloat128x, BT uFloat128x, BT uFloat128x,464 /* _FBX */ BT uFloat128x, BT uFloat128x, BT uFloat128x, BT uFloat128x, BT uFloat128x, BT uFloat128x, 465 465 BT uFloat128x, BT uFloat128x, BT uFloat128x, BT uFloat128x, BT uFloat128x, BT uFloat128x, 466 466 BT uFloat128x, BT uFloat128x, BT uFloat128x, BT uFloat128xComplex, BT uFloat128x, BT uFloat128xComplex, -
src/ResolvExpr/ConversionCost.cc
r8e1467d r4a60488 46 46 #endif 47 47 48 Cost conversionCost( const Type * src, const Type * dest, const SymTab::Indexer &indexer, const TypeEnvironment &env ) { 48 Cost conversionCost( const Type * src, const Type * dest, bool srcIsLvalue, 49 const SymTab::Indexer &indexer, const TypeEnvironment &env ) { 49 50 if ( const TypeInstType * destAsTypeInst = dynamic_cast< const TypeInstType * >( dest ) ) { 50 51 PRINT( std::cerr << "type inst " << destAsTypeInst->name; ) 51 52 if ( const EqvClass * eqvClass = env.lookup( destAsTypeInst->name ) ) { 52 53 if ( eqvClass->type ) { 53 return conversionCost( src, eqvClass->type, indexer, env );54 return conversionCost( src, eqvClass->type, srcIsLvalue, indexer, env ); 54 55 } else { 55 56 return Cost::infinity; … … 61 62 assert( type ); 62 63 if ( type->base ) { 63 return conversionCost( src, type->base, indexer, env ) + Cost::safe; 64 return conversionCost( src, type->base, srcIsLvalue, indexer, env ) 65 + Cost::safe; 64 66 } // if 65 67 } // if … … 81 83 } else if ( const ReferenceType * refType = dynamic_cast< const ReferenceType * > ( dest ) ) { 82 84 PRINT( std::cerr << "conversionCost: dest is reference" << std::endl; ) 83 return convertToReferenceCost( src, refType, indexer, env, [](const Type * const t1, const Type * t2, const SymTab::Indexer &, const TypeEnvironment & env ){85 return convertToReferenceCost( src, refType, srcIsLvalue, indexer, env, [](const Type * const t1, const Type * t2, const SymTab::Indexer &, const TypeEnvironment & env ){ 84 86 return ptrsAssignable( t1, t2, env ); 85 87 }); 86 88 } else { 87 89 PassVisitor<ConversionCost> converter( 88 dest, indexer, env,89 (Cost (*)(const Type *, const Type *, const SymTab::Indexer&, const TypeEnvironment&))90 dest, srcIsLvalue, indexer, env, 91 (Cost (*)(const Type *, const Type *, bool, const SymTab::Indexer&, const TypeEnvironment&)) 90 92 conversionCost ); 91 93 src->accept( converter ); … … 98 100 } 99 101 100 Cost convertToReferenceCost( const Type * src, const Type * dest, int diff, const SymTab::Indexer & indexer, const TypeEnvironment & env, PtrsFunction func ) { 102 static Cost convertToReferenceCost( const Type * src, const Type * dest, bool srcIsLvalue, 103 int diff, const SymTab::Indexer & indexer, const TypeEnvironment & env, PtrsFunction func ) { 101 104 PRINT( std::cerr << "convert to reference cost... diff " << diff << " " << src << " / " << dest << std::endl; ) 102 105 if ( diff > 0 ) { 103 106 // TODO: document this 104 Cost cost = convertToReferenceCost( strict_dynamic_cast< const ReferenceType * >( src )->base, dest, diff-1, indexer, env, func ); 107 Cost cost = convertToReferenceCost( 108 strict_dynamic_cast< const ReferenceType * >( src )->base, dest, srcIsLvalue, 109 diff-1, indexer, env, func ); 105 110 cost.incReference(); 106 111 return cost; 107 112 } else if ( diff < -1 ) { 108 113 // TODO: document this 109 Cost cost = convertToReferenceCost( src, strict_dynamic_cast< const ReferenceType * >( dest )->base, diff+1, indexer, env, func ); 114 Cost cost = convertToReferenceCost( 115 src, strict_dynamic_cast< const ReferenceType * >( dest )->base, srcIsLvalue, 116 diff+1, indexer, env, func ); 110 117 cost.incReference(); 111 118 return cost; … … 138 145 PRINT( std::cerr << "reference to rvalue conversion" << std::endl; ) 139 146 PassVisitor<ConversionCost> converter( 140 dest, indexer, env,141 (Cost (*)(const Type *, const Type *, const SymTab::Indexer&, const TypeEnvironment&))147 dest, srcIsLvalue, indexer, env, 148 (Cost (*)(const Type *, const Type *, bool, const SymTab::Indexer&, const TypeEnvironment&)) 142 149 conversionCost ); 143 150 src->accept( converter ); … … 150 157 if ( typesCompatibleIgnoreQualifiers( src, destAsRef->base, indexer, env ) ) { 151 158 PRINT( std::cerr << "converting compatible base type" << std::endl; ) 152 if ( src ->get_lvalue()) {159 if ( srcIsLvalue ) { 153 160 PRINT( 154 161 std::cerr << "lvalue to reference conversion" << std::endl; … … 178 185 } 179 186 180 Cost convertToReferenceCost( const Type * src, const ReferenceType * dest, const SymTab::Indexer & indexer, const TypeEnvironment & env, PtrsFunction func ) { 187 Cost convertToReferenceCost( const Type * src, const ReferenceType * dest, bool srcIsLvalue, 188 const SymTab::Indexer & indexer, const TypeEnvironment & env, PtrsFunction func ) { 181 189 int sdepth = src->referenceDepth(), ddepth = dest->referenceDepth(); 182 Cost cost = convertToReferenceCost( src, dest, s depth-ddepth, indexer, env, func );190 Cost cost = convertToReferenceCost( src, dest, srcIsLvalue, sdepth-ddepth, indexer, env, func ); 183 191 PRINT( std::cerr << "convertToReferenceCost result: " << cost << std::endl; ) 184 192 return cost; 185 193 } 186 194 187 ConversionCost::ConversionCost( const Type * dest, const SymTab::Indexer &indexer, const TypeEnvironment &env, CostFunction costFunc )188 : dest( dest ), indexer( indexer ), cost( Cost::infinity ), env( env ), costFunc( costFunc ) {195 ConversionCost::ConversionCost( const Type * dest, bool srcIsLvalue, const SymTab::Indexer &indexer, const TypeEnvironment &env, CostFunction costFunc ) 196 : dest( dest ), srcIsLvalue( srcIsLvalue ), indexer( indexer ), cost( Cost::infinity ), env( env ), costFunc( costFunc ) { 189 197 } 190 198 … … 217 225 // GENERATED BY BasicTypes-gen.cc 218 226 static const int costMatrix[BasicType::NUMBER_OF_BASIC_TYPES][BasicType::NUMBER_OF_BASIC_TYPES] = { // path length from root to node 219 /* B C SC UC SI SUI I UI LI LUI LLI LLUI IB UIB _FH _FH _F _FC F FC _FX _FXC FD _FDC D DC F80X_FDXC F80 _FB_FLDC FB LD LDC _FBX_FLDXC */220 /* B */ { 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13, 14, 14, 15, 15, 16, 17, 16, 18, 17, },221 /* C */ { -1, 0, 1, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13, 14, 14, 15, 16, 15, 17, 16, },222 /* SC */ { -1, -1, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13, 14, 14, 15, 16, 15, 17, 16, },223 /* UC */ { -1, -1, -1, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13, 14, 14, 15, 16, 15, 17, 16, },224 /* SI */ { -1, -1, -1, -1, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13, 14, 15, 14, 16, 15, },225 /* SUI */ { -1, -1, -1, -1, -1, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13, 14, 15, 14, 16, 15, },226 /* I */ { -1, -1, -1, -1, -1, -1, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 14, 13, 15, 14, },227 /* UI */ { -1, -1, -1, -1, -1, -1, -1, 0, 1, 1, 2, 2, 3, 3, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 14, 13, 15, 14, },228 /* LI */ { -1, -1, -1, -1, -1, -1, -1, -1, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 13, 12, 14, 13, },229 /* LUI */ { -1, -1, -1, -1, -1, -1, -1, -1, -1, 0, 1, 1, 2, 2, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 13, 12, 14, 13, },230 /* LLI */ { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 12, 11, 13, 12, },231 /* LLUI */ { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 0, 1, 1, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 12, 11, 13, 12, },232 /* IB */ { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 11, 10, 12, 11, },233 /* UIB */ { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 0, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 11, 10, 12, 11, },234 /* _FH */ { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 10, 9, 11, 10, },235 /* _FH */ { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 0, -1, 1, -1, 2, -1, 3, -1, 4, -1, 5, -1, 6, -1, -1, 7, -1, -1, 8, -1, 9, },236 /* _F */ { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 9, 8, 10, 9, },237 /* _FC */ { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 0, -1, 1, -1, 2, -1, 3, -1, 4, -1, 5, -1, -1, 6, -1, -1, 7, -1, 8, },238 /* F */ { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 8, 7, 9, 8, },239 /* FC */ { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 0, -1, 1, -1, 2, -1, 3, -1, 4, -1, -1, 5, -1, -1, 6, -1, 7, },240 /* _FX */ { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 7, 6, 8, 7, },241 /* _FXC */ { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 0, -1, 1, -1, 2, -1, 3, -1, -1, 4, -1, -1, 5, -1, 6, },242 /* FD */ { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 6, 5, 7, 6, },243 /* _FDC */ { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 0, -1, 1, -1, 2, -1, -1, 3, -1, -1, 4, -1, 5, },244 /* D */ { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 0, 1, 1, 2, 2, 3, 3, 4, 5, 4, 6, 5, },245 /* DC */ { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 0, -1, 1, -1, -1, 2, -1, -1, 3, -1, 4, },246 /* F80X */ { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 0, 1, 1, 2, 2, 3, 4, 3, 5, 4, },247 /* _FDXC */ { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 0, -1, -1, 1, -1, -1, 2, -1, 3, },248 /* F80*/ { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 1, 0, 1, 2, 2, 3, 3, 4, 4, },249 /* _FB */ { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 0, 1, 1, 2, 2, 3, 3, },250 /* _FLDC */ { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 0, -1, -1, 1, -1, 2, },251 /* FB */ { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 1, 0, 1, 2, 2, 3, },252 /* LD */ { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 0, 1, 1, 2, },253 /* LDC */ { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 0, -1, 1, },254 /* _FBX */ { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 0, 1, },227 /* B C SC UC SI SUI I UI LI LUI LLI LLUI IB UIB _FH _FH _F _FC F FC _FX _FXC FD _FDC D DC F80X_FDXC F80 _FB_FLDC FB LD LDC _FBX_FLDXC */ 228 /* B */ { 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13, 14, 14, 15, 15, 16, 17, 16, 18, 17, }, 229 /* C */ { -1, 0, 1, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13, 14, 14, 15, 16, 15, 17, 16, }, 230 /* SC */ { -1, -1, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13, 14, 14, 15, 16, 15, 17, 16, }, 231 /* UC */ { -1, -1, -1, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13, 14, 14, 15, 16, 15, 17, 16, }, 232 /* SI */ { -1, -1, -1, -1, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13, 14, 15, 14, 16, 15, }, 233 /* SUI */ { -1, -1, -1, -1, -1, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13, 14, 15, 14, 16, 15, }, 234 /* I */ { -1, -1, -1, -1, -1, -1, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 14, 13, 15, 14, }, 235 /* UI */ { -1, -1, -1, -1, -1, -1, -1, 0, 1, 1, 2, 2, 3, 3, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 14, 13, 15, 14, }, 236 /* LI */ { -1, -1, -1, -1, -1, -1, -1, -1, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 13, 12, 14, 13, }, 237 /* LUI */ { -1, -1, -1, -1, -1, -1, -1, -1, -1, 0, 1, 1, 2, 2, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 13, 12, 14, 13, }, 238 /* LLI */ { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 12, 11, 13, 12, }, 239 /* LLUI */ { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 0, 1, 1, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 12, 11, 13, 12, }, 240 /* IB */ { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 11, 10, 12, 11, }, 241 /* UIB */ { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 0, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 11, 10, 12, 11, }, 242 /* _FH */ { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 10, 9, 11, 10, }, 243 /* _FH */ { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 0, -1, 1, -1, 2, -1, 3, -1, 4, -1, 5, -1, 6, -1, -1, 7, -1, -1, 8, -1, 9, }, 244 /* _F */ { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 9, 8, 10, 9, }, 245 /* _FC */ { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 0, -1, 1, -1, 2, -1, 3, -1, 4, -1, 5, -1, -1, 6, -1, -1, 7, -1, 8, }, 246 /* F */ { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 8, 7, 9, 8, }, 247 /* FC */ { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 0, -1, 1, -1, 2, -1, 3, -1, 4, -1, -1, 5, -1, -1, 6, -1, 7, }, 248 /* _FX */ { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 7, 6, 8, 7, }, 249 /* _FXC */ { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 0, -1, 1, -1, 2, -1, 3, -1, -1, 4, -1, -1, 5, -1, 6, }, 250 /* FD */ { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 6, 5, 7, 6, }, 251 /* _FDC */ { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 0, -1, 1, -1, 2, -1, -1, 3, -1, -1, 4, -1, 5, }, 252 /* D */ { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 0, 1, 1, 2, 2, 3, 3, 4, 5, 4, 6, 5, }, 253 /* DC */ { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 0, -1, 1, -1, -1, 2, -1, -1, 3, -1, 4, }, 254 /* F80X */ { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 0, 1, 1, 2, 2, 3, 4, 3, 5, 4, }, 255 /* _FDXC */ { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 0, -1, -1, 1, -1, -1, 2, -1, 3, }, 256 /* F80 */ { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 1, 0, 1, 2, 2, 3, 3, 4, 4, }, 257 /* _FB */ { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 0, 1, 1, 2, 2, 3, 3, }, 258 /* _FLDC */ { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 0, -1, -1, 1, -1, 2, }, 259 /* FB */ { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 1, 0, 1, 2, 2, 3, }, 260 /* LD */ { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 0, 1, 1, 2, }, 261 /* LDC */ { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 0, -1, 1, }, 262 /* _FBX */ { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 0, 1, }, 255 263 /* _FLDXC */ { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 0, }, 256 264 }; // costMatrix … … 265 273 // GENERATED BY BasicTypes-gen.cc 266 274 static const int signMatrix[BasicType::NUMBER_OF_BASIC_TYPES][BasicType::NUMBER_OF_BASIC_TYPES] = { // number of sign changes in safe conversion 267 /* B C SC UC SI SUI I UI LI LUI LLI LLUI IB UIB _FH _FH _F _FC F FC _FX _FXC FD _FDC D DC F80X_FDXC F80 _FB_FLDC FB LD LDC _FBX_FLDXC */268 /* B */ { 0, 0, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, },269 /* C */ { -1, 0, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, },270 /* SC */ { -1, -1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, },271 /* UC */ { -1, -1, -1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, },272 /* SI */ { -1, -1, -1, -1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, },273 /* SUI */ { -1, -1, -1, -1, -1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, },274 /* I */ { -1, -1, -1, -1, -1, -1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, },275 /* UI */ { -1, -1, -1, -1, -1, -1, -1, 0, 1, 0, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, },276 /* LI */ { -1, -1, -1, -1, -1, -1, -1, -1, 0, 1, 0, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, },277 /* LUI */ { -1, -1, -1, -1, -1, -1, -1, -1, -1, 0, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, },278 /* LLI */ { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 0, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, },279 /* LLUI */ { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, },280 /* IB */ { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, },281 /* UIB */ { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, },282 /* _FH */ { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, },283 /* _FH */ { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 0, -1, 0, -1, 0, -1, 0, -1, 0, -1, 0, -1, 0, -1, -1, 0, -1, -1, 0, -1, 0, },284 /* _F */ { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, },285 /* _FC */ { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 0, -1, 0, -1, 0, -1, 0, -1, 0, -1, 0, -1, -1, 0, -1, -1, 0, -1, 0, },286 /* F */ { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, },287 /* FC */ { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 0, -1, 0, -1, 0, -1, 0, -1, 0, -1, -1, 0, -1, -1, 0, -1, 0, },288 /* _FX */ { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, },289 /* _FXC */ { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 0, -1, 0, -1, 0, -1, 0, -1, -1, 0, -1, -1, 0, -1, 0, },290 /* FD */ { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, },291 /* _FDC */ { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 0, -1, 0, -1, 0, -1, -1, 0, -1, -1, 0, -1, 0, },292 /* D */ { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, },293 /* DC */ { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 0, -1, 0, -1, -1, 0, -1, -1, 0, -1, 0, },294 /* F80X */ { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, },295 /* _FDXC */ { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 0, -1, -1, 0, -1, -1, 0, -1, 0, },296 /* F80*/ { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 0, 0, 0, 0, 0, 0, 0, 0, 0, },297 /* _FB */ { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 0, 0, 0, 0, 0, 0, 0, },298 /* _FLDC */ { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 0, -1, -1, 0, -1, 0, },299 /* FB */ { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 0, 0, 0, 0, 0, 0, },300 /* LD */ { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 0, 0, 0, 0, },301 /* LDC */ { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 0, -1, 0, },302 /* _FBX */ { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 0, 0, },275 /* B C SC UC SI SUI I UI LI LUI LLI LLUI IB UIB _FH _FH _F _FC F FC _FX _FXC FD _FDC D DC F80X_FDXC F80 _FB_FLDC FB LD LDC _FBX_FLDXC */ 276 /* B */ { 0, 0, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, }, 277 /* C */ { -1, 0, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, }, 278 /* SC */ { -1, -1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, }, 279 /* UC */ { -1, -1, -1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, }, 280 /* SI */ { -1, -1, -1, -1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, }, 281 /* SUI */ { -1, -1, -1, -1, -1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, }, 282 /* I */ { -1, -1, -1, -1, -1, -1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, }, 283 /* UI */ { -1, -1, -1, -1, -1, -1, -1, 0, 1, 0, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, }, 284 /* LI */ { -1, -1, -1, -1, -1, -1, -1, -1, 0, 1, 0, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, }, 285 /* LUI */ { -1, -1, -1, -1, -1, -1, -1, -1, -1, 0, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, }, 286 /* LLI */ { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 0, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, }, 287 /* LLUI */ { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, }, 288 /* IB */ { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, }, 289 /* UIB */ { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, }, 290 /* _FH */ { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, }, 291 /* _FH */ { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 0, -1, 0, -1, 0, -1, 0, -1, 0, -1, 0, -1, 0, -1, -1, 0, -1, -1, 0, -1, 0, }, 292 /* _F */ { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, }, 293 /* _FC */ { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 0, -1, 0, -1, 0, -1, 0, -1, 0, -1, 0, -1, -1, 0, -1, -1, 0, -1, 0, }, 294 /* F */ { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, }, 295 /* FC */ { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 0, -1, 0, -1, 0, -1, 0, -1, 0, -1, -1, 0, -1, -1, 0, -1, 0, }, 296 /* _FX */ { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, }, 297 /* _FXC */ { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 0, -1, 0, -1, 0, -1, 0, -1, -1, 0, -1, -1, 0, -1, 0, }, 298 /* FD */ { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, }, 299 /* _FDC */ { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 0, -1, 0, -1, 0, -1, -1, 0, -1, -1, 0, -1, 0, }, 300 /* D */ { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, }, 301 /* DC */ { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 0, -1, 0, -1, -1, 0, -1, -1, 0, -1, 0, }, 302 /* F80X */ { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, }, 303 /* _FDXC */ { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 0, -1, -1, 0, -1, -1, 0, -1, 0, }, 304 /* F80 */ { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 0, 0, 0, 0, 0, 0, 0, 0, 0, }, 305 /* _FB */ { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 0, 0, 0, 0, 0, 0, 0, }, 306 /* _FLDC */ { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 0, -1, -1, 0, -1, 0, }, 307 /* FB */ { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 0, 0, 0, 0, 0, 0, }, 308 /* LD */ { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 0, 0, 0, 0, }, 309 /* LDC */ { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 0, -1, 0, }, 310 /* _FBX */ { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 0, 0, }, 303 311 /* _FLDXC */ { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 0, }, 304 312 }; // signMatrix … … 371 379 // recursively compute conversion cost from T1 to T2. 372 380 // cv can be safely dropped because of 'implicit dereference' behavior. 373 cost = costFunc( refType->base, dest, indexer, env );381 cost = costFunc( refType->base, dest, srcIsLvalue, indexer, env ); 374 382 if ( refType->base->tq == dest->tq ) { 375 383 cost.incReference(); // prefer exact qualifiers … … 403 411 static Type::Qualifiers q; 404 412 static BasicType integer( q, BasicType::SignedInt ); 405 cost = costFunc( &integer, dest, indexer, env ); // safe if dest >= int413 cost = costFunc( &integer, dest, srcIsLvalue, indexer, env ); // safe if dest >= int 406 414 if ( cost < Cost::unsafe ) { 407 415 cost.incSafe(); … … 413 421 void ConversionCost::postvisit( const TypeInstType * inst ) { 414 422 if ( const EqvClass * eqvClass = env.lookup( inst->name ) ) { 415 cost = costFunc( eqvClass->type, dest, indexer, env );423 cost = costFunc( eqvClass->type, dest, srcIsLvalue, indexer, env ); 416 424 } else if ( const TypeInstType * destAsInst = dynamic_cast< const TypeInstType * >( dest ) ) { 417 425 if ( inst->name == destAsInst->name ) { … … 423 431 assert( type ); 424 432 if ( type->base ) { 425 cost = costFunc( type->base, dest, indexer, env ) + Cost::safe;433 cost = costFunc( type->base, dest, srcIsLvalue, indexer, env ) + Cost::safe; 426 434 } // if 427 435 } // if … … 434 442 std::list< Type * >::const_iterator destIt = destAsTuple->types.begin(); 435 443 while ( srcIt != tupleType->types.end() && destIt != destAsTuple->types.end() ) { 436 Cost newCost = costFunc( * srcIt++, * destIt++, indexer, env );444 Cost newCost = costFunc( * srcIt++, * destIt++, srcIsLvalue, indexer, env ); 437 445 if ( newCost == Cost::infinity ) { 438 446 return; … … 534 542 } 535 543 536 Cost convertToReferenceCost( const ast::Type * src, const ast::Type * dst, int diff,537 const ast::SymbolTable & symtab, const ast::TypeEnvironment & env,544 static Cost convertToReferenceCost( const ast::Type * src, const ast::Type * dst, 545 int diff, const ast::SymbolTable & symtab, const ast::TypeEnvironment & env, 538 546 NumCostCalculation func ) { 539 547 if ( 0 < diff ) { -
src/ResolvExpr/ConversionCost.h
r8e1467d r4a60488 10 10 // Created On : Sun May 17 09:37:28 2015 11 11 // Last Modified By : Andrew Beach 12 // Last Modified On : Mon Jun 24 10:00:00 201913 // Update Count : 512 // Last Modified On : Thu Aug 8 16:13:00 2019 13 // Update Count : 6 14 14 // 15 15 … … 33 33 class TypeEnvironment; 34 34 35 typedef std::function<Cost(const Type *, const Type *, const SymTab::Indexer &, const TypeEnvironment &)> CostFunction; 35 typedef std::function<Cost(const Type *, const Type *, bool, 36 const SymTab::Indexer &, const TypeEnvironment &)> CostFunction; 37 36 38 struct ConversionCost : public WithShortCircuiting { 37 39 public: 38 ConversionCost( const Type * dest, const SymTab::Indexer &indexer, const TypeEnvironment &env, CostFunction ); 40 ConversionCost( const Type * dest, bool srcIsLvalue, 41 const SymTab::Indexer &indexer, const TypeEnvironment &env, CostFunction ); 39 42 40 43 Cost get_cost() const { return cost; } … … 59 62 protected: 60 63 const Type * dest; 64 bool srcIsLvalue; 61 65 const SymTab::Indexer &indexer; 62 66 Cost cost; … … 66 70 67 71 typedef std::function<int(const Type *, const Type *, const SymTab::Indexer &, const TypeEnvironment &)> PtrsFunction; 68 Cost convertToReferenceCost( const Type * src, const ReferenceType * dest, const SymTab::Indexer & indexer, const TypeEnvironment & env, PtrsFunction func ); 72 Cost convertToReferenceCost( const Type * src, const ReferenceType * dest, bool srcIsLvalue, 73 const SymTab::Indexer & indexer, const TypeEnvironment & env, PtrsFunction func ); 69 74 70 75 // Some function pointer types, differ in return type. -
src/ResolvExpr/ResolveAssertions.cc
r8e1467d r4a60488 9 9 // Author : Aaron B. Moss 10 10 // Created On : Fri Oct 05 13:46:00 2018 11 // Last Modified By : Peter A. Buhr12 // Last Modified On : Wed Jul 10 16:10:37201913 // Update Count : 211 // Last Modified By : Andrew Beach 12 // Last Modified On : Thu Aug 8 16:47:00 2019 13 // Update Count : 3 14 14 // 15 15 … … 156 156 for ( const auto& assn : x.assns ) { 157 157 // compute conversion cost from satisfying decl to assertion 158 assert( !assn.match.adjType->get_lvalue() ); 158 159 k += computeConversionCost( 159 assn.match.adjType, assn.decl->get_type(), indexer, x.env );160 assn.match.adjType, assn.decl->get_type(), false, indexer, x.env ); 160 161 161 162 // mark vars+specialization cost on function-type assertions -
src/ResolvExpr/Unify.cc
r8e1467d r4a60488 9 9 // Author : Richard C. Bilson 10 10 // Created On : Sun May 17 12:27:10 2015 11 // Last Modified By : A aron B. Moss12 // Last Modified On : Mon Jun 18 11:58:00 201813 // Update Count : 4 311 // Last Modified By : Andrew Beach 12 // Last Modified On : Wed Sep 4 10:00:00 2019 13 // Update Count : 44 14 14 // 15 15 … … 274 274 #endif 275 275 if ( ( common = commonType( type1, type2, widen.first, widen.second, indexer, env, openVars ) ) ) { 276 common-> get_qualifiers() = tq1 | tq2;276 common->tq = tq1.unify( tq2 ); 277 277 #ifdef DEBUG 278 278 std::cerr << "unifyInexact: common type is "; … … 291 291 if ( ( tq1 > tq2 || widen.first ) && ( tq2 > tq1 || widen.second ) ) { 292 292 common = type1->clone(); 293 common-> get_qualifiers() = tq1 | tq2;293 common->tq = tq1.unify( tq2 ); 294 294 result = true; 295 295 } else { … … 298 298 } else { 299 299 common = type1->clone(); 300 common-> get_qualifiers() = tq1 | tq2;300 common->tq = tq1.unify( tq2 ); 301 301 result = true; 302 302 } // if -
src/ResolvExpr/typeops.h
r8e1467d r4a60488 9 9 // Author : Richard C. Bilson 10 10 // Created On : Sun May 17 07:28:22 2015 11 // Last Modified By : Peter A. Buhr12 // Last Modified On : Fri Feb 8 09:30:34201913 // Update Count : 411 // Last Modified By : Andrew Beach 12 // Last Modified On : Thu Aug 8 16:36:00 2019 13 // Update Count : 5 14 14 // 15 15 … … 80 80 81 81 // in CastCost.cc 82 Cost castCost( const Type * src, const Type * dest, const SymTab::Indexer & indexer, const TypeEnvironment & env ); 82 Cost castCost( const Type * src, const Type * dest, bool srcIsLvalue, 83 const SymTab::Indexer & indexer, const TypeEnvironment & env ); 83 84 Cost castCost( 84 85 const ast::Type * src, const ast::Type * dst, const ast::SymbolTable & symtab, … … 86 87 87 88 // in ConversionCost.cc 88 Cost conversionCost( const Type * src, const Type * dest, const SymTab::Indexer & indexer, const TypeEnvironment & env ); 89 Cost conversionCost( const Type * src, const Type * dest, bool srcIsLvalue, 90 const SymTab::Indexer & indexer, const TypeEnvironment & env ); 89 91 Cost conversionCost( 90 92 const ast::Type * src, const ast::Type * dst, const ast::SymbolTable & symtab, … … 92 94 93 95 // in AlternativeFinder.cc 94 Cost computeConversionCost( Type * actualType, Type * formalType, 96 Cost computeConversionCost( Type * actualType, Type * formalType, bool actualIsLvalue, 95 97 const SymTab::Indexer & indexer, const TypeEnvironment & env ); 96 98 -
src/SymTab/Demangle.cc
r8e1467d r4a60488 9 9 // Author : Rob Schluntz 10 10 // Created On : Thu Jul 19 12:52:41 2018 11 // Last Modified By : Rob Schluntz12 // Last Modified On : T hu Jul 19 12:54:35 201813 // Update Count : 211 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Tue Jul 30 13:46:33 2019 13 // Update Count : 3 14 14 // 15 15 … … 313 313 typeString = "_Atomic " + typeString; 314 314 } // if 315 if ( type->get_lvalue() ) {316 // when not generating C code, print lvalue for debugging.317 typeString = "lvalue " + typeString;318 }319 315 } 320 316 } -
src/SymTab/Mangler.cc
r8e1467d r4a60488 10 10 // Created On : Sun May 17 21:40:29 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Mon Sep 25 15:49:26 201713 // Update Count : 2 312 // Last Modified On : Tue Jul 30 13:46:10 2019 13 // Update Count : 26 14 14 // 15 15 #include "Mangler.h" … … 377 377 mangleName << Encoding::qualifiers.at(Type::Mutex); 378 378 } // if 379 if ( type->get_lvalue() ) {380 // mangle based on whether the type is lvalue, so that the resolver can differentiate lvalues and rvalues381 mangleName << Encoding::qualifiers.at(Type::Lvalue);382 }383 384 379 if ( inFunctionType ) { 385 380 // turn off inFunctionType so that types can be differentiated for nested qualifiers … … 724 719 mangleName << Encoding::qualifiers.at(Type::Mutex); 725 720 } // if 726 if ( type->is_lvalue() ) {727 // mangle based on whether the type is lvalue, so that the resolver can differentiate lvalues and rvalues728 mangleName << Encoding::qualifiers.at(Type::Lvalue);729 }730 731 721 if ( inFunctionType ) { 732 722 // turn off inFunctionType so that types can be differentiated for nested qualifiers -
src/SymTab/Validate.cc
r8e1467d r4a60488 9 9 // Author : Richard C. Bilson 10 10 // Created On : Sun May 17 21:50:04 2015 11 // Last Modified By : Peter A. Buhr12 // Last Modified On : Mon Aug 28 13:47:23 201713 // Update Count : 3 5911 // Last Modified By : Andrew Beach 12 // Last Modified On : Wed Aug 7 6:42:00 2019 13 // Update Count : 360 14 14 // 15 15 … … 81 81 #include "SynTree/Label.h" // for operator==, Label 82 82 #include "SynTree/Mutator.h" // for Mutator 83 #include "SynTree/TopLvalue.h" // for assertTopLvalue, clearInnerLvalue 83 84 #include "SynTree/Type.h" // for Type, TypeInstType, EnumInstType 84 85 #include "SynTree/TypeSubstitution.h" // for TypeSubstitution … … 308 309 PassVisitor<FixQualifiedTypes> fixQual; 309 310 311 assertTopLvalue( translationUnit ); 310 312 { 311 313 Stats::Heap::newPass("validate-A"); … … 316 318 acceptAll( translationUnit, epc ); // must happen before VerifyCtorDtorAssign, because void return objects should not exist; before LinkReferenceToTypes_old because it is an indexer and needs correct types for mangling 317 319 } 320 assertTopLvalue( translationUnit ); 318 321 { 319 322 Stats::Heap::newPass("validate-B"); 320 323 Stats::Time::BlockGuard guard("validate-B"); 324 assertTopLvalue( translationUnit ); 321 325 Stats::Time::TimeBlock("Link Reference To Types", [&]() { 322 326 acceptAll( translationUnit, lrt ); // must happen before autogen, because sized flag needs to propagate to generated functions 323 327 }); 328 clearInnerLvalue( translationUnit ); 329 assertTopLvalue( translationUnit ); 324 330 Stats::Time::TimeBlock("Fix Qualified Types", [&]() { 325 331 mutateAll( translationUnit, fixQual ); // must happen after LinkReferenceToTypes_old, because aggregate members are accessed 326 332 }); 333 assertTopLvalue( translationUnit ); 327 334 Stats::Time::TimeBlock("Hoist Structs", [&]() { 328 335 HoistStruct::hoistStruct( translationUnit ); // must happen after EliminateTypedef, so that aggregate typedefs occur in the correct order 329 336 }); 337 assertTopLvalue( translationUnit ); 330 338 Stats::Time::TimeBlock("Eliminate Typedefs", [&]() { 331 339 EliminateTypedef::eliminateTypedef( translationUnit ); // 332 340 }); 333 341 } 342 assertTopLvalue( translationUnit ); 334 343 { 335 344 Stats::Heap::newPass("validate-C"); … … 340 349 InitTweak::fixReturnStatements( translationUnit ); // must happen before autogen 341 350 } 351 assertTopLvalue( translationUnit ); 342 352 { 343 353 Stats::Heap::newPass("validate-D"); 344 354 Stats::Time::BlockGuard guard("validate-D"); 355 assertTopLvalue( translationUnit ); 345 356 Stats::Time::TimeBlock("Apply Concurrent Keywords", [&]() { 346 357 Concurrency::applyKeywords( translationUnit ); 347 358 }); 359 clearInnerLvalue( translationUnit ); 360 assertTopLvalue( translationUnit ); 348 361 Stats::Time::TimeBlock("Forall Pointer Decay", [&]() { 349 362 acceptAll( translationUnit, fpd ); // must happen before autogenerateRoutines, after Concurrency::applyKeywords because uniqueIds must be set on declaration before resolution 350 363 }); 364 assertTopLvalue( translationUnit ); 351 365 Stats::Time::TimeBlock("Hoist Control Declarations", [&]() { 352 366 ControlStruct::hoistControlDecls( translationUnit ); // hoist initialization out of for statements; must happen before autogenerateRoutines 353 367 }); 368 assertTopLvalue( translationUnit ); 354 369 Stats::Time::TimeBlock("Generate Autogen routines", [&]() { 355 370 autogenerateRoutines( translationUnit ); // moved up, used to be below compoundLiteral - currently needs EnumAndPointerDecay_old 356 371 }); 357 } 372 clearInnerLvalue( translationUnit ); 373 } 374 assertTopLvalue( translationUnit ); 358 375 { 359 376 Stats::Heap::newPass("validate-E"); 360 377 Stats::Time::BlockGuard guard("validate-E"); 378 assertTopLvalue( translationUnit ); 361 379 Stats::Time::TimeBlock("Implement Mutex Func", [&]() { 362 380 Concurrency::implementMutexFuncs( translationUnit ); 363 381 }); 382 clearInnerLvalue( translationUnit ); 383 assertTopLvalue( translationUnit ); 364 384 Stats::Time::TimeBlock("Implement Thread Start", [&]() { 365 385 Concurrency::implementThreadStarter( translationUnit ); 366 386 }); 387 assertTopLvalue( translationUnit ); 367 388 Stats::Time::TimeBlock("Compound Literal", [&]() { 368 389 mutateAll( translationUnit, compoundliteral ); 369 390 }); 391 assertTopLvalue( translationUnit ); 370 392 Stats::Time::TimeBlock("Resolve With Expressions", [&]() { 371 393 ResolvExpr::resolveWithExprs( translationUnit ); // must happen before FixObjectType because user-code is resolved and may contain with variables 372 394 }); 373 } 395 clearInnerLvalue( translationUnit ); 396 } 397 assertTopLvalue( translationUnit ); 374 398 { 375 399 Stats::Heap::newPass("validate-F"); 376 400 Stats::Time::BlockGuard guard("validate-F"); 401 assertTopLvalue( translationUnit ); 377 402 Stats::Time::TimeBlock("Fix Object Type", [&]() { 378 403 FixObjectType::fix( translationUnit ); 379 404 }); 405 assertTopLvalue( translationUnit ); 380 406 Stats::Time::TimeBlock("Array Length", [&]() { 381 407 ArrayLength::computeLength( translationUnit ); 382 408 }); 409 clearInnerLvalue( translationUnit ); 410 assertTopLvalue( translationUnit ); 383 411 Stats::Time::TimeBlock("Find Special Declarations", [&]() { 384 412 Validate::findSpecialDecls( translationUnit ); 385 413 }); 414 assertTopLvalue( translationUnit ); 386 415 Stats::Time::TimeBlock("Fix Label Address", [&]() { 387 416 mutateAll( translationUnit, labelAddrFixer ); 388 417 }); 418 assertTopLvalue( translationUnit ); 389 419 Stats::Time::TimeBlock("Handle Attributes", [&]() { 390 420 Validate::handleAttributes( translationUnit ); 391 421 }); 392 422 } 423 assertTopLvalue( translationUnit ); 393 424 } 394 425 -
src/SynTree/AddressExpr.cc
r8e1467d r4a60488 42 42 AddressExpr::AddressExpr( Expression *arg ) : Expression(), arg( arg ) { 43 43 if ( arg->result ) { 44 if ( arg-> result->get_lvalue() ) {44 if ( arg->get_lvalue() ) { 45 45 // lvalue, retains all layers of reference and gains a pointer inside the references 46 46 set_result( addrType( arg->result ) ); -
src/SynTree/ApplicationExpr.cc
r8e1467d r4a60488 9 9 // Author : Richard C. Bilson 10 10 // Created On : Mon May 18 07:44:20 2015 11 // Last Modified By : Rob Schluntz12 // Last Modified On : Tue Apr 26 12:41:06 201613 // Update Count : 411 // Last Modified By : Andrew Beach 12 // Last Modified On : Mon Aug 12 14:28:00 2019 13 // Update Count : 5 14 14 // 15 15 … … 25 25 #include "Declaration.h" // for Declaration 26 26 #include "Expression.h" // for ParamEntry, ApplicationExpr, Expression 27 #include "InitTweak/InitTweak.h" // for getFunction 27 28 #include "ResolvExpr/typeops.h" // for extractResultType 28 29 #include "Type.h" // for Type, PointerType, FunctionType … … 76 77 } 77 78 79 bool ApplicationExpr::get_lvalue() const { 80 // from src/GenPoly/Lvalue.cc: isIntrinsicReference 81 static std::set<std::string> lvalueFunctions = { "*?", "?[?]" }; 82 if ( const DeclarationWithType * func = InitTweak::getFunction( this ) ) { 83 return func->linkage == LinkageSpec::Intrinsic && lvalueFunctions.count(func->name); 84 } 85 return false; 86 } 87 78 88 void ApplicationExpr::print( std::ostream &os, Indenter indent ) const { 79 89 os << "Application of" << std::endl << indent+1; -
src/SynTree/BasicType.cc
r8e1467d r4a60488 10 10 // Created On : Mon May 18 07:44:20 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Thu Jan 31 21:37:36201913 // Update Count : 1 212 // Last Modified On : Sun Aug 4 21:07:44 2019 13 // Update Count : 13 14 14 // 15 15 … … 31 31 bool BasicType::isInteger() const { 32 32 return kind <= UnsignedInt128; 33 #if 034 switch ( kind ) {35 case Bool:36 case Char:37 case SignedChar:38 case UnsignedChar:39 case ShortSignedInt:40 case ShortUnsignedInt:41 case SignedInt:42 case UnsignedInt:43 case LongSignedInt:44 case LongUnsignedInt:45 case LongLongSignedInt:46 case LongLongUnsignedInt:47 case SignedInt128:48 case UnsignedInt128:49 return true;50 case Float:51 case Double:52 case LongDouble:53 case FloatComplex:54 case DoubleComplex:55 case LongDoubleComplex:56 case FloatImaginary:57 case DoubleImaginary:58 case LongDoubleImaginary:59 case Float80:60 case Float128:61 return false;62 case NUMBER_OF_BASIC_TYPES:63 assert( false );64 } // switch65 assert( false );66 return false;67 #endif68 33 } 69 34 -
src/SynTree/CommaExpr.cc
r8e1467d r4a60488 9 9 // Author : Richard C. Bilson 10 10 // Created On : Mon May 18 07:44:20 2015 11 // Last Modified By : Rob Schluntz12 // Last Modified On : Mon May 02 15:19:44201613 // Update Count : 111 // Last Modified By : Andrew Beach 12 // Last Modified On : Mon Arg 12 16:11:00 2016 13 // Update Count : 2 14 14 // 15 15 … … 39 39 } 40 40 41 bool CommaExpr::get_lvalue() const { 42 // This is wrong by C, but the current implementation uses it. 43 return arg2->get_lvalue(); 44 } 45 41 46 void CommaExpr::print( std::ostream &os, Indenter indent ) const { 42 47 os << "Comma Expression:" << std::endl; -
src/SynTree/Expression.cc
r8e1467d r4a60488 9 9 // Author : Richard C. Bilson 10 10 // Created On : Mon May 18 07:44:20 2015 11 // Last Modified By : Peter A. Buhr12 // Last Modified On : T ue Feb 19 18:10:55201913 // Update Count : 6 011 // Last Modified By : Andrew Beach 12 // Last Modified On : Thr Aug 15 13:43:00 2019 13 // Update Count : 64 14 14 // 15 15 … … 19 19 #include <iostream> // for ostream, operator<<, basic_ostream 20 20 #include <list> // for list, _List_iterator, list<>::co... 21 #include <set> // for set 21 22 22 23 #include "Common/utility.h" // for maybeClone, cloneAll, deleteAll … … 63 64 } 64 65 66 bool Expression::get_lvalue() const { 67 return false; 68 } 69 65 70 void Expression::print( std::ostream & os, Indenter indent ) const { 66 71 printInferParams( inferParams, os, indent+1, 0 ); … … 134 139 } 135 140 141 bool VariableExpr::get_lvalue() const { 142 // It isn't always an lvalue, but it is never an rvalue. 143 return true; 144 } 145 136 146 VariableExpr * VariableExpr::functionPointer( FunctionDecl * func ) { 137 147 VariableExpr * funcExpr = new VariableExpr( func ); … … 252 262 } 253 263 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 Expression::print( os, indent );281 }282 283 264 CastExpr::CastExpr( Expression * arg, Type * toType, bool isGenerated ) : arg(arg), isGenerated( isGenerated ) { 284 265 set_result(toType); … … 294 275 CastExpr::~CastExpr() { 295 276 delete arg; 277 } 278 279 bool CastExpr::get_lvalue() const { 280 // This is actually wrong by C, but it works with our current set-up. 281 return arg->get_lvalue(); 296 282 } 297 283 … … 376 362 } 377 363 364 bool UntypedMemberExpr::get_lvalue() const { 365 return aggregate->get_lvalue(); 366 } 367 378 368 void UntypedMemberExpr::print( std::ostream & os, Indenter indent ) const { 379 369 os << "Untyped Member Expression, with field: " << std::endl << indent+1; … … 405 395 // don't delete the member declaration, since it points somewhere else in the tree 406 396 delete aggregate; 397 } 398 399 bool MemberExpr::get_lvalue() const { 400 // This is actually wrong by C, but it works with our current set-up. 401 return true; 407 402 } 408 403 … … 457 452 } 458 453 454 bool UntypedExpr::get_lvalue() const { 455 // from src/GenPoly/Lvalue.cc: isIntrinsicReference 456 static std::set<std::string> lvalueFunctions = { "*?", "?[?]" }; 457 std::string fname = InitTweak::getFunctionName( const_cast< UntypedExpr * >( this ) ); 458 return lvalueFunctions.count(fname); 459 } 459 460 460 461 void UntypedExpr::print( std::ostream & os, Indenter indent ) const { … … 515 516 delete arg2; 516 517 delete arg3; 518 } 519 520 bool ConditionalExpr::get_lvalue() const { 521 return false; 517 522 } 518 523 … … 573 578 } 574 579 580 bool ConstructorExpr::get_lvalue() const { 581 return false; 582 } 583 575 584 void ConstructorExpr::print( std::ostream & os, Indenter indent ) const { 576 585 os << "Constructor Expression: " << std::endl << indent+1; … … 590 599 CompoundLiteralExpr::~CompoundLiteralExpr() { 591 600 delete initializer; 601 } 602 603 bool CompoundLiteralExpr::get_lvalue() const { 604 return true; 592 605 } 593 606 … … 641 654 result = new VoidType( Type::Qualifiers() ); 642 655 } 656 } 657 bool StmtExpr::get_lvalue() const { 658 return false; 643 659 } 644 660 void StmtExpr::print( std::ostream & os, Indenter indent ) const { -
src/SynTree/Expression.h
r8e1467d r4a60488 9 9 // Author : Richard C. Bilson 10 10 // Created On : Mon May 18 07:44:20 2015 11 // Last Modified By : Peter A. Buhr12 // Last Modified On : Mon Feb 18 18:29:51201913 // Update Count : 4911 // Last Modified By : Andrew Beach 12 // Last Modified On : Thr Aug 15 13:46:00 2019 13 // Update Count : 54 14 14 // 15 15 … … 71 71 const Type * get_result() const { return result; } 72 72 void set_result( Type * newValue ) { result = newValue; } 73 virtual bool get_lvalue() const; 73 74 74 75 TypeSubstitution * get_env() const { return env; } … … 98 99 virtual ~ApplicationExpr(); 99 100 101 bool get_lvalue() const final; 102 100 103 Expression * get_function() const { return function; } 101 104 void set_function( Expression * newValue ) { function = newValue; } … … 120 123 UntypedExpr( const UntypedExpr & other ); 121 124 virtual ~UntypedExpr(); 125 126 bool get_lvalue() const final; 122 127 123 128 Expression * get_function() const { return function; } … … 208 213 virtual ~CastExpr(); 209 214 215 bool get_lvalue() const final; 216 210 217 Expression * get_arg() const { return arg; } 211 218 void set_arg( Expression * newValue ) { arg = newValue; } … … 268 275 virtual ~UntypedMemberExpr(); 269 276 277 bool get_lvalue() const final; 278 270 279 Expression * get_member() const { return member; } 271 280 void set_member( Expression * newValue ) { member = newValue; } … … 291 300 virtual ~MemberExpr(); 292 301 302 bool get_lvalue() const final; 303 293 304 DeclarationWithType * get_member() const { return member; } 294 305 void set_member( DeclarationWithType * newValue ) { member = newValue; } … … 313 324 VariableExpr( const VariableExpr & other ); 314 325 virtual ~VariableExpr(); 326 327 bool get_lvalue() const final; 315 328 316 329 DeclarationWithType * get_var() const { return var; } … … 463 476 }; 464 477 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 478 /// LogicalExpr represents a short-circuit boolean expression (&& or ||) 495 479 class LogicalExpr : public Expression { … … 528 512 ConditionalExpr( const ConditionalExpr & other ); 529 513 virtual ~ConditionalExpr(); 514 515 bool get_lvalue() const final; 530 516 531 517 Expression * get_arg1() const { return arg1; } … … 553 539 virtual ~CommaExpr(); 554 540 541 bool get_lvalue() const final; 542 555 543 Expression * get_arg1() const { return arg1; } 556 544 void set_arg1( Expression * newValue ) { arg1 = newValue; } … … 639 627 ~ConstructorExpr(); 640 628 629 bool get_lvalue() const final; 630 641 631 Expression * get_callExpr() const { return callExpr; } 642 632 void set_callExpr( Expression * newValue ) { callExpr = newValue; } … … 657 647 CompoundLiteralExpr( const CompoundLiteralExpr & other ); 658 648 virtual ~CompoundLiteralExpr(); 649 650 bool get_lvalue() const final; 659 651 660 652 Initializer * get_initializer() const { return initializer; } … … 715 707 virtual ~TupleExpr(); 716 708 709 bool get_lvalue() const final; 710 717 711 std::list<Expression*>& get_exprs() { return exprs; } 718 712 … … 733 727 TupleIndexExpr( const TupleIndexExpr & other ); 734 728 virtual ~TupleIndexExpr(); 729 730 bool get_lvalue() const final; 735 731 736 732 Expression * get_tuple() const { return tuple; } … … 782 778 StmtExpr( const StmtExpr & other ); 783 779 virtual ~StmtExpr(); 780 781 bool get_lvalue() const final; 784 782 785 783 CompoundStmt * get_statements() const { return statements; } -
src/SynTree/Mutator.h
r8e1467d r4a60488 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
r8e1467d r4a60488 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/TupleExpr.cc
r8e1467d r4a60488 9 9 // Author : Richard C. Bilson 10 10 // Created On : Mon May 18 07:44:20 2015 11 // Last Modified By : Peter A. Buhr12 // Last Modified On : Fri Mar 17 09:42:29 201713 // Update Count : 311 // Last Modified By : Andrew Beach 12 // Last Modified On : Wed Aug 14 14:34:00 2019 13 // Update Count : 5 14 14 // 15 15 … … 57 57 } 58 58 59 bool TupleExpr::get_lvalue() const { 60 return false; 61 } 62 59 63 void TupleExpr::print( std::ostream &os, Indenter indent ) const { 60 64 os << "Tuple:" << std::endl; … … 76 80 TupleIndexExpr::~TupleIndexExpr() { 77 81 delete tuple; 82 } 83 84 bool TupleIndexExpr::get_lvalue() const { 85 return tuple->get_lvalue(); 78 86 } 79 87 -
src/SynTree/Type.cc
r8e1467d r4a60488 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 : Fri Jul 12 15:48:00201913 // Update Count : 4 411 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Sun Aug 4 21:05:07 2019 13 // Update Count : 45 14 14 // 15 15 #include "Type.h" … … 24 24 using namespace std; 25 25 26 const char *BasicType::typeNames[] = { 27 #if 0 28 "_Bool", 29 "char", 30 "signed char", 31 "unsigned char", 32 "signed short int", 33 "unsigned short int", 34 "signed int", 35 "unsigned int", 36 "signed long int", 37 "unsigned long int", 38 "signed long long int", 39 "unsigned long long int", 40 "float", 41 "double", 42 "long double", 43 "float _Complex", 44 "double _Complex", 45 "long double _Complex", 46 "float _Imaginary", 47 "double _Imaginary", 48 "long double _Imaginary", 49 "__int128", 50 "unsigned __int128", 51 "__float80", 52 "__float128", 53 "_Float16", 54 "_Float32", 55 "_Float32x", 56 "_Float64", 57 "_Float64x", 58 "_Float128", 59 "_Float128x", 60 "_Float16 _Complex", 61 "_Float32 _Complex", 62 "_Float32x _Complex", 63 "_Float64 _Complex", 64 "_Float64x _Complex", 65 "_Float128 _Complex", 66 "_Float128x _Complex", 67 #endif 26 const char * BasicType::typeNames[] = { 68 27 "_Bool", 69 28 "char", … … 107 66 }; 108 67 static_assert( 109 sizeof(BasicType::typeNames) /sizeof(BasicType::typeNames[0]) == BasicType::NUMBER_OF_BASIC_TYPES,68 sizeof(BasicType::typeNames) / sizeof(BasicType::typeNames[0]) == BasicType::NUMBER_OF_BASIC_TYPES, 110 69 "Each basic type name should have a corresponding kind enum value" 111 70 ); … … 152 111 TypeSubstitution Type::genericSubstitution() const { assertf( false, "Non-aggregate type: %s", toCString( this ) ); } 153 112 154 void Type::print( std::ostream & os, Indenter indent ) const {113 void Type::print( std::ostream & os, Indenter indent ) const { 155 114 if ( ! forall.empty() ) { 156 115 os << "forall" << std::endl; -
src/SynTree/Type.h
r8e1467d r4a60488 9 9 // Author : Richard C. Bilson 10 10 // Created On : Mon May 18 07:44:20 2015 11 // Last Modified By : Peter A. Buhr12 // Last Modified On : Thu Feb 14 17:11:24201913 // Update Count : 1 6911 // Last Modified By : Andrew Beach 12 // Last Modified On : Wed Sep 4 09:58:00 2019 13 // Update Count : 170 14 14 // 15 15 … … 131 131 bool operator>( Qualifiers other ) const { return *this != other && *this >= other; } 132 132 BFCommon( Qualifiers, NumTypeQualifier ) 133 134 Qualifiers unify( Qualifiers const & other ) const { 135 int or_flags = Mask & (val | other.val); 136 int and_flags = val & other.val; 137 return Qualifiers( or_flags | and_flags ); 138 } 133 139 }; // Qualifiers 134 140 -
src/SynTree/Visitor.h
r8e1467d r4a60488 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; -
src/SynTree/module.mk
r8e1467d r4a60488 49 49 SynTree/TypeSubstitution.cc \ 50 50 SynTree/Attribute.cc \ 51 SynTree/DeclReplacer.cc 51 SynTree/DeclReplacer.cc \ 52 SynTree/TopLvalue.cc 52 53 53 54 SRC += $(SRC_SYNTREE) -
src/main.cc
r8e1467d r4a60488 10 10 // Created On : Fri May 15 23:12:02 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Wed Jun 5 20:35:13201913 // Update Count : 60 112 // Last Modified On : Fri Aug 23 06:50:08 2019 13 // Update Count : 607 14 14 // 15 15 … … 17 17 #include <execinfo.h> // for backtrace, backtrace_symbols 18 18 #include <getopt.h> // for no_argument, optind, geto... 19 #include <signal.h> // for signal, SIGABRT, SIGSEGV20 19 #include <cassert> // for assertf 21 20 #include <cstdio> // for fopen, FILE, fclose, stdin 22 21 #include <cstdlib> // for exit, free, abort, EXIT_F... 22 #include <csignal> // for signal, SIGABRT, SIGSEGV 23 23 #include <cstring> // for index 24 24 #include <fstream> // for ofstream … … 60 60 #include "ResolvExpr/Resolver.h" // for resolve 61 61 #include "SymTab/Validate.h" // for validate 62 #include "SynTree/TopLvalue.h" // for assertTopLvalue, clearInn... 62 63 #include "SynTree/Declaration.h" // for Declaration 63 64 #include "SynTree/Visitor.h" // for acceptAll 64 65 #include "Tuples/Tuples.h" // for expandMemberTuples, expan... 65 66 #include "Virtual/ExpandCasts.h" // for expandCasts 67 66 68 67 69 using namespace std; … … 95 97 DeclarationNode * parseTree = nullptr; // program parse tree 96 98 99 static bool waiting_for_gdb = false; // flag to set cfa-cpp to wait for gdb on start 100 97 101 static std::string PreludeDirector = ""; 98 102 99 static void parse_cmdline( int argc, char *argv[] , const char *& filename);103 static void parse_cmdline( int argc, char *argv[] ); 100 104 static void parse( FILE * input, LinkageSpec::Spec linkage, bool shouldExit = false ); 101 105 static void dump( list< Declaration * > & translationUnit, ostream & out = cout ); … … 166 170 } // sigAbortHandler 167 171 168 169 172 int main( int argc, char * argv[] ) { 170 173 FILE * input; // use FILE rather than istream because yyin is FILE 171 174 ostream * output = & cout; 172 const char * filename = nullptr;173 175 list< Declaration * > translationUnit; 174 176 … … 182 184 // } // for 183 185 184 parse_cmdline( argc, argv , filename );// process command-line arguments186 parse_cmdline( argc, argv ); // process command-line arguments 185 187 CodeGen::FixMain::setReplaceMain( !nomainp ); 188 189 if ( waiting_for_gdb ) { 190 std::cerr << "Waiting for gdb" << std::endl; 191 std::cerr << "run :" << std::endl; 192 std::cerr << " gdb attach " << getpid() << std::endl; 193 raise(SIGSTOP); 194 } // if 186 195 187 196 try { … … 189 198 if ( optind < argc ) { // any commands after the flags ? => input file name 190 199 input = fopen( argv[ optind ], "r" ); 191 assertf( input, "cannot open %s\n", argv[ optind ] ); 192 // if running cfa-cpp directly, might forget to pass -F option (and really shouldn't have to) 193 if ( filename == nullptr ) filename = argv[ optind ]; 194 // prelude filename comes in differently 195 if ( libcfap ) filename = "prelude.cfa"; 200 assertf( input, "cannot open %s because %s\n", argv[ optind ], strerror( errno ) ); 196 201 optind += 1; 197 202 } else { // no input file name 198 203 input = stdin; 199 // if running cfa-cpp directly, might forget to pass -F option. Since this takes from stdin, pass200 // a fake name along201 if ( filename == nullptr ) filename = "stdin";202 204 } // if 203 205 … … 258 260 Stats::Time::StopBlock(); 259 261 262 //std::cerr << "Post-Parse Check" << std::endl; 263 clearInnerLvalue( translationUnit ); 264 assertTopLvalue( translationUnit ); 265 260 266 // add the assignment statement after the initialization of a type parameter 261 267 PASS( "Validate", SymTab::validate( translationUnit, symtabp ) ); … … 276 282 } // if 277 283 284 assertTopLvalue( translationUnit ); 278 285 PASS( "Fix Labels", ControlStruct::fixLabels( translationUnit ) ); 286 assertTopLvalue( translationUnit ); 279 287 PASS( "Fix Names", CodeGen::fixNames( translationUnit ) ); 288 assertTopLvalue( translationUnit ); 280 289 PASS( "Gen Init", InitTweak::genInit( translationUnit ) ); 290 assertTopLvalue( translationUnit ); 281 291 PASS( "Expand Member Tuples" , Tuples::expandMemberTuples( translationUnit ) ); 292 assertTopLvalue( translationUnit ); 282 293 if ( libcfap ) { 283 294 // generate the bodies of cfa library functions … … 309 320 translationUnit = convert( move( transUnit ) ); 310 321 } 322 311 323 if ( exprp ) { 312 324 dump( translationUnit ); 313 325 return EXIT_SUCCESS; 314 326 } // if 327 328 clearInnerLvalue( translationUnit ); 329 assertTopLvalue( translationUnit ); 315 330 316 331 // fix ObjectDecl - replaces ConstructorInit nodes 317 332 PASS( "Fix Init", InitTweak::fix( translationUnit, buildingLibrary() ) ); 333 clearInnerLvalue( translationUnit ); 334 assertTopLvalue( translationUnit ); 318 335 if ( ctorinitp ) { 319 336 dump ( translationUnit ); … … 322 339 323 340 PASS( "Expand Unique Expr", Tuples::expandUniqueExpr( translationUnit ) ); // xxx - is this the right place for this? want to expand ASAP so tha, sequent passes don't need to worry about double-visiting a unique expr - needs to go after InitTweak::fix so that copy constructed return declarations are reused 341 assertTopLvalue( translationUnit ); 324 342 325 343 PASS( "Translate EHM" , ControlStruct::translateEHM( translationUnit ) ); 344 assertTopLvalue( translationUnit ); 326 345 327 346 PASS( "Gen Waitfor" , Concurrency::generateWaitFor( translationUnit ) ); 347 clearInnerLvalue( translationUnit ); 348 assertTopLvalue( translationUnit ); 328 349 329 350 PASS( "Convert Specializations", GenPoly::convertSpecializations( translationUnit ) ); // needs to happen before tuple types are expanded 351 clearInnerLvalue( translationUnit ); 352 assertTopLvalue( translationUnit ); 330 353 331 354 PASS( "Expand Tuples", Tuples::expandTuples( translationUnit ) ); // xxx - is this the right place for this? 355 assertTopLvalue( translationUnit ); 332 356 333 357 if ( tuplep ) { … … 337 361 338 362 PASS( "Virtual Expand Casts", Virtual::expandCasts( translationUnit ) ); // Must come after translateEHM 363 assertTopLvalue( translationUnit ); 339 364 340 365 PASS( "Instantiate Generics", GenPoly::instantiateGeneric( translationUnit ) ); … … 343 368 return EXIT_SUCCESS; 344 369 } // if 370 clearInnerLvalue( translationUnit ); 371 assertTopLvalue( translationUnit ); 345 372 PASS( "Convert L-Value", GenPoly::convertLvalue( translationUnit ) ); 346 373 clearInnerLvalue( translationUnit ); 374 assertTopLvalue( translationUnit ); 347 375 348 376 if ( bboxp ) { … … 351 379 } // if 352 380 PASS( "Box", GenPoly::box( translationUnit ) ); 381 clearInnerLvalue( translationUnit ); 382 assertTopLvalue( translationUnit ); 353 383 354 384 if ( bcodegenp ) { … … 362 392 363 393 CodeTools::fillLocations( translationUnit ); 394 assertTopLvalue( translationUnit ); 364 395 PASS( "Code Gen", CodeGen::generate( translationUnit, *output, ! genproto, prettycodegenp, true, linemarks ) ); 365 396 … … 412 443 413 444 414 static const char optstring[] = ":hlLmNnpP:S:twW:D: F:";445 static const char optstring[] = ":hlLmNnpP:S:twW:D:"; 415 446 416 447 enum { PreludeDir = 128 }; … … 427 458 { "statistics", required_argument, nullptr, 'S' }, 428 459 { "tree", no_argument, nullptr, 't' }, 460 { "gdb", no_argument, nullptr, 'g' }, 429 461 { "", no_argument, nullptr, 0 }, // -w 430 462 { "", no_argument, nullptr, 0 }, // -W 431 463 { "", no_argument, nullptr, 0 }, // -D 432 { "", no_argument, nullptr, 0 }, // -F433 464 { nullptr, 0, nullptr, 0 } 434 465 }; // long_opts … … 445 476 "<directory> prelude directory for debug/nodebug", // no flag 446 477 "<option-list> enable profiling information:\n counters,heap,time,all,none", // -S 447 "build in tree", // -t 478 "building cfa standard lib", // -t 479 "wait for gdb to attach", // -g 448 480 "", // -w 449 481 "", // -W 450 482 "", // -D 451 "", // -F452 483 }; // description 453 484 … … 484 515 485 516 static void usage( char *argv[] ) { 486 cout << "Usage: " << argv[0] << " options are:" << endl;517 cout << "Usage: " << argv[0] << " [options] [input-file (default stdin)] [output-file (default stdout)], where options are:" << endl; 487 518 int i = 0, j = 1; // j skips starting colon 488 519 for ( ; long_opts[i].name != 0 && optstring[j] != '\0'; i += 1, j += 1 ) { … … 510 541 } // usage 511 542 512 static void parse_cmdline( int argc, char * argv[] , const char *& filename) {543 static void parse_cmdline( int argc, char * argv[] ) { 513 544 opterr = 0; // (global) prevent getopt from printing error messages 514 545 … … 556 587 Stats::parse_params( optarg ); 557 588 break; 558 case 't': // build in tree589 case 't': // building cfa stdlib 559 590 treep = true; 591 break; 592 case 'g': // wait for gdb 593 waiting_for_gdb = true; 560 594 break; 561 595 case 'w': // suppress all warnings, hidden … … 581 615 case 'D': // ignore -Dxxx, forwarded by cpp, hidden 582 616 break; 583 case 'F': // source file-name without suffix, hidden584 filename = optarg;585 break;586 617 case '?': // unknown option 587 618 if ( optopt ) { // short option ?
Note:
See TracChangeset
for help on using the changeset viewer.