Changeset 19858f6 for src/SynTree
- Timestamp:
- Oct 4, 2019, 9:59:01 AM (6 years ago)
- Branches:
- ADT, arm-eh, ast-experimental, enum, forall-pointer-decay, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr, pthread-emulation, qualifiedEnum
- Children:
- 65e10b2
- Parents:
- 970141d (diff), 73fad25 (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/SynTree
- Files:
-
- 2 deleted
- 10 edited
-
AddressExpr.cc (modified) (1 diff)
-
ApplicationExpr.cc (modified) (2 diffs)
-
ArrayType.cc (modified) (1 diff)
-
CommaExpr.cc (modified) (2 diffs)
-
Expression.cc (modified) (16 diffs)
-
Expression.h (modified) (1 diff)
-
TopLvalue.cc (deleted)
-
TopLvalue.h (deleted)
-
TupleExpr.cc (modified) (3 diffs)
-
Type.cc (modified) (1 diff)
-
Type.h (modified) (4 diffs)
-
module.mk (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
src/SynTree/AddressExpr.cc
r970141d r19858f6 53 53 } // if 54 54 } 55 // result of & is never an lvalue56 get_result()->set_lvalue( false );57 55 } 58 56 } -
src/SynTree/ApplicationExpr.cc
r970141d r19858f6 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 … … 77 78 78 79 bool ApplicationExpr::get_lvalue() const { 79 return result->get_lvalue(); 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; 80 86 } 81 87 -
src/SynTree/ArrayType.cc
r970141d r19858f6 26 26 ArrayType::ArrayType( const Type::Qualifiers &tq, Type *base, Expression *dimension, bool isVarLen, bool isStatic, const std::list< Attribute * > & attributes ) 27 27 : Type( tq, attributes ), base( base ), dimension( dimension ), isVarLen( isVarLen ), isStatic( isStatic ) { 28 base->set_lvalue( false );29 28 } 30 29 -
src/SynTree/CommaExpr.cc
r970141d r19858f6 23 23 CommaExpr::CommaExpr( Expression *arg1, Expression *arg2 ) 24 24 : Expression(), arg1( arg1 ), arg2( arg2 ) { 25 // xxx - result of a comma expression is never an lvalue, so should set lvalue26 // to false on all result types. Actually doing this causes some strange things27 // to happen in later passes (particularly, Specialize, Lvalue, and Box). This needs to be looked into.28 25 set_result( maybeClone( arg2->get_result() ) ); 29 // get_type->set_isLvalue( false );30 26 } 31 27 … … 40 36 41 37 bool CommaExpr::get_lvalue() const { 42 // xxx - as above, shouldn't be an lvalue but that information is used anyways. 43 return result->get_lvalue(); 38 // This is wrong by C, but the current implementation uses it. 39 // (ex: Specialize, Lvalue and Box) 40 return arg2->get_lvalue(); 44 41 } 45 42 -
src/SynTree/Expression.cc
r970141d r19858f6 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 … … 64 65 65 66 bool Expression::get_lvalue() const { 66 assert( !result->get_lvalue() );67 67 return false; 68 68 } … … 115 115 assert( var->get_type() ); 116 116 Type * type = var->get_type()->clone(); 117 type->set_lvalue( true );118 117 119 118 // xxx - doesn't quite work yet - get different alternatives with the same cost … … 125 124 // long long int value; 126 125 // if ( decl->valueOf( var, value ) ) { 127 // type->set_lvalue( false ); 126 // type->set_lvalue( false ); // Would have to move to get_lvalue. 128 127 // } 129 128 // } … … 140 139 141 140 bool VariableExpr::get_lvalue() const { 142 return result->get_lvalue(); 141 // It isn't always an lvalue, but it is never an rvalue. 142 return true; 143 143 } 144 144 … … 277 277 278 278 bool CastExpr::get_lvalue() const { 279 return result->get_lvalue(); 279 // This is actually wrong by C, but it works with our current set-up. 280 return arg->get_lvalue(); 280 281 } 281 282 … … 360 361 } 361 362 363 bool UntypedMemberExpr::get_lvalue() const { 364 return aggregate->get_lvalue(); 365 } 366 362 367 void UntypedMemberExpr::print( std::ostream & os, Indenter indent ) const { 363 368 os << "Untyped Member Expression, with field: " << std::endl << indent+1; … … 378 383 sub.apply( res ); 379 384 result = res; 380 result->set_lvalue( true );381 385 result->get_qualifiers() |= aggregate->result->get_qualifiers(); 382 386 } … … 392 396 393 397 bool MemberExpr::get_lvalue() const { 394 assert( result->get_lvalue() );398 // This is actually wrong by C, but it works with our current set-up. 395 399 return true; 396 400 } … … 427 431 // if references are still allowed in the AST, dereference returns a reference 428 432 ret->set_result( new ReferenceType( Type::Qualifiers(), ret->get_result() ) ); 429 } else {430 // references have been removed, in which case dereference returns an lvalue of the base type.431 ret->result->set_lvalue( true );432 433 } 433 434 } … … 447 448 448 449 bool UntypedExpr::get_lvalue() const { 449 return result->get_lvalue(); 450 // from src/GenPoly/Lvalue.cc: isIntrinsicReference 451 static std::set<std::string> lvalueFunctions = { "*?", "?[?]" }; 452 std::string fname = InitTweak::getFunctionName( const_cast< UntypedExpr * >( this ) ); 453 return lvalueFunctions.count(fname); 450 454 } 451 455 … … 510 514 511 515 bool ConditionalExpr::get_lvalue() const { 512 return result->get_lvalue();516 return false; 513 517 } 514 518 … … 570 574 571 575 bool ConstructorExpr::get_lvalue() const { 572 return result->get_lvalue();576 return false; 573 577 } 574 578 … … 582 586 CompoundLiteralExpr::CompoundLiteralExpr( Type * type, Initializer * initializer ) : initializer( initializer ) { 583 587 assert( type && initializer ); 584 type->set_lvalue( true );585 588 set_result( type ); 586 589 } … … 593 596 594 597 bool CompoundLiteralExpr::get_lvalue() const { 595 assert( result->get_lvalue() );596 598 return true; 597 599 } … … 648 650 } 649 651 bool StmtExpr::get_lvalue() const { 650 return result->get_lvalue();652 return false; 651 653 } 652 654 void StmtExpr::print( std::ostream & os, Indenter indent ) const { -
src/SynTree/Expression.h
r970141d r19858f6 275 275 virtual ~UntypedMemberExpr(); 276 276 277 bool get_lvalue() const final; 278 277 279 Expression * get_member() const { return member; } 278 280 void set_member( Expression * newValue ) { member = newValue; } -
src/SynTree/TupleExpr.cc
r970141d r19858f6 58 58 59 59 bool TupleExpr::get_lvalue() const { 60 return result->get_lvalue();60 return false; 61 61 } 62 62 … … 71 71 assertf( type->size() > index, "TupleIndexExpr index out of bounds: tuple size %d, requested index %d in expr %s", type->size(), index, toString( tuple ).c_str() ); 72 72 set_result( (*std::next( type->get_types().begin(), index ))->clone() ); 73 // like MemberExpr, TupleIndexExpr is always an lvalue74 get_result()->set_lvalue( true );75 73 } 76 74 … … 83 81 84 82 bool TupleIndexExpr::get_lvalue() const { 85 assert( result->get_lvalue() ); 86 return true; 83 return tuple->get_lvalue(); 87 84 } 88 85 -
src/SynTree/Type.cc
r970141d r19858f6 85 85 const char * Type::FuncSpecifiersNames[] = { "inline", "_Noreturn", "fortran" }; 86 86 const char * Type::StorageClassesNames[] = { "extern", "static", "auto", "register", "_Thread_local" }; 87 const char * Type::QualifiersNames[] = { "const", "restrict", "volatile", " lvalue", "mutex", "_Atomic" };87 const char * Type::QualifiersNames[] = { "const", "restrict", "volatile", "mutex", "_Atomic" }; 88 88 89 89 Type * Type::stripDeclarator() { -
src/SynTree/Type.h
r970141d r19858f6 102 102 }; // StorageClasses 103 103 104 enum { Const = 1 << 0, Restrict = 1 << 1, Volatile = 1 << 2, Lvalue = 1 << 3, Mutex = 1 << 4, Atomic = 1 << 5, NumTypeQualifier = 6};104 enum { Const = 1 << 0, Restrict = 1 << 1, Volatile = 1 << 2, Mutex = 1 << 3, Atomic = 1 << 4, NumTypeQualifier = 5 }; 105 105 static const char * QualifiersNames[]; 106 106 union Qualifiers { 107 enum { Mask = ~ (Restrict | Lvalue)};107 enum { Mask = ~Restrict }; 108 108 unsigned int val; 109 109 struct { … … 111 111 bool is_restrict : 1; 112 112 bool is_volatile : 1; 113 bool is_lvalue : 1;114 113 bool is_mutex : 1; 115 114 bool is_atomic : 1; … … 153 152 bool get_volatile() const { return tq.is_volatile; } 154 153 bool get_restrict() const { return tq.is_restrict; } 155 bool get_lvalue() const { return tq.is_lvalue; }156 154 bool get_mutex() const { return tq.is_mutex; } 157 155 bool get_atomic() const { return tq.is_atomic; } … … 159 157 void set_volatile( bool newValue ) { tq.is_volatile = newValue; } 160 158 void set_restrict( bool newValue ) { tq.is_restrict = newValue; } 161 void set_lvalue( bool newValue ) { tq.is_lvalue = newValue; }162 159 void set_mutex( bool newValue ) { tq.is_mutex = newValue; } 163 160 void set_atomic( bool newValue ) { tq.is_atomic = newValue; } -
src/SynTree/module.mk
r970141d r19858f6 49 49 SynTree/TypeSubstitution.cc \ 50 50 SynTree/Attribute.cc \ 51 SynTree/DeclReplacer.cc \ 52 SynTree/TopLvalue.cc 51 SynTree/DeclReplacer.cc 53 52 54 53 SRC += $(SRC_SYNTREE)
Note:
See TracChangeset
for help on using the changeset viewer.