Changeset 4a60488 for src/SynTree
- Timestamp:
- Sep 27, 2019, 3:35:46 PM (5 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/SynTree
- Files:
-
- 2 added
- 13 edited
Legend:
- Unmodified
- Added
- Removed
-
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)
Note: See TracChangeset
for help on using the changeset viewer.