Changeset 28f3a19 for src/SynTree
- Timestamp:
- Jun 27, 2018, 3:28:41 PM (6 years ago)
- Branches:
- new-env, with_gc
- Children:
- b21c77a
- Parents:
- 0182bfa (diff), 63238a4 (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:
-
- 13 edited
Legend:
- Unmodified
- Added
- Removed
-
src/SynTree/BasicType.cc
r0182bfa r28f3a19 55 55 case DoubleImaginary: 56 56 case LongDoubleImaginary: 57 case Float80: 58 case Float128: 57 59 return false; 58 60 case NUMBER_OF_BASIC_TYPES: -
src/SynTree/Declaration.cc
r0182bfa r28f3a19 92 92 } 93 93 94 94 95 // Local Variables: // 95 96 // tab-width: 4 // -
src/SynTree/Declaration.h
r0182bfa r28f3a19 83 83 Expression *asmName; 84 84 std::list< Attribute * > attributes; 85 bool isDeleted = false; 85 86 86 87 DeclarationWithType( const std::string &name, Type::StorageClasses scs, LinkageSpec::Spec linkage, const std::list< Attribute * > & attributes, Type::FuncSpecifiers fs ); -
src/SynTree/Expression.cc
r0182bfa r28f3a19 640 640 641 641 642 DefaultArgExpr::DefaultArgExpr( Expression * expr ) : expr( expr ) { 643 assert( expr->result ); 644 result = expr->result->clone(); 645 } 646 DefaultArgExpr::DefaultArgExpr( const DefaultArgExpr & other ) : Expression( other ), expr( maybeClone( other.expr ) ) {} 647 648 void DefaultArgExpr::print( std::ostream & os, Indenter indent ) const { 649 os << "Default Argument Expression" << std::endl << indent+1; 650 expr->print( os, indent+1 ); 651 } 652 653 GenericExpr::Association::Association( Type * type, Expression * expr ) : type( type ), expr( expr ), isDefault( false ) {} 654 GenericExpr::Association::Association( Expression * expr ) : type( nullptr ), expr( expr ), isDefault( true ) {} 655 GenericExpr::Association::Association( const Association & other ) : type( maybeClone( other.type ) ), expr( maybeClone( other.expr ) ), isDefault( other.isDefault ) {} 656 657 GenericExpr::GenericExpr( Expression * control, const std::list<Association> & assoc ) : Expression(), control( control ), associations( assoc ) {} 658 GenericExpr::GenericExpr( const GenericExpr & other ) : Expression(other), control( maybeClone( other.control ) ), associations( other.associations ) {} 659 GenericExpr::~GenericExpr() {} 660 661 void GenericExpr::print( std::ostream & os, Indenter indent ) const { 662 os << "C11 _Generic Expression" << std::endl << indent+1; 663 control->print( os, indent+1 ); 664 os << std::endl << indent+1 << "... with associations: " << std::endl; 665 for ( const Association & assoc : associations ) { 666 os << indent+1; 667 if (assoc.isDefault) { 668 os << "... default: "; 669 assoc.expr->print( os, indent+1 ); 670 } else { 671 os << "... type: "; 672 assoc.type->print( os, indent+1 ); 673 os << std::endl << indent+1 << "... expression: "; 674 assoc.expr->print( os, indent+1 ); 675 os << std::endl; 676 } 677 os << std::endl; 678 } 679 } 680 642 681 // Local Variables: // 643 682 // tab-width: 4 // -
src/SynTree/Expression.h
r0182bfa r28f3a19 833 833 }; 834 834 835 /// expression wrapping the use of a default argument - should never make it past the resolver. 836 class DefaultArgExpr : public Expression { 837 public: 838 Expression * expr; 839 840 DefaultArgExpr( Expression * expr ); 841 DefaultArgExpr( const DefaultArgExpr & other ); 842 843 virtual DefaultArgExpr * clone() const { return new DefaultArgExpr( * this ); } 844 virtual void accept( Visitor & v ) { v.visit( this ); } 845 virtual Expression * acceptMutator( Mutator & m ) { return m.mutate( this ); } 846 virtual void print( std::ostream & os, Indenter indent = {} ) const; 847 }; 848 849 /// C11 _Generic expression 850 class GenericExpr : public Expression { 851 public: 852 struct Association { 853 Type * type = nullptr; 854 Expression * expr = nullptr; 855 bool isDefault = false; 856 857 Association( Type * type, Expression * expr ); 858 Association( Expression * expr ); 859 Association( const Association & other ); 860 Association & operator=( const Association & other ) = delete; // at the moment this isn't used, and I don't want to implement it 861 }; 862 863 Expression * control; 864 std::list<Association> associations; 865 866 GenericExpr( Expression * control, const std::list<Association> & assoc ); 867 GenericExpr( const GenericExpr & other ); 868 ~GenericExpr(); 869 870 virtual GenericExpr * clone() const { return new GenericExpr( * this ); } 871 virtual void accept( Visitor & v ) { v.visit( this ); } 872 virtual Expression * acceptMutator( Mutator & m ) { return m.mutate( this ); } 873 virtual void print( std::ostream & os, Indenter indent = {} ) const; 874 }; 875 835 876 // Local Variables: // 836 877 // tab-width: 4 // -
src/SynTree/Mutator.h
r0182bfa r28f3a19 93 93 virtual Expression * mutate( InitExpr * initExpr ) = 0; 94 94 virtual Expression * mutate( DeletedExpr * delExpr ) = 0; 95 virtual Expression * mutate( DefaultArgExpr * argExpr ) = 0; 96 virtual Expression * mutate( GenericExpr * genExpr ) = 0; 95 97 96 98 virtual Type * mutate( VoidType * basicType ) = 0; -
src/SynTree/ReferenceToType.cc
r0182bfa r28f3a19 46 46 47 47 namespace { 48 void doLookup( const std::list< Declaration * > &members, const std::string &name, std::list< Declaration* > &foundDecls ) {49 for ( std::list< Declaration* >::const_iterator i = members.begin(); i != members.end(); ++i) {50 if ( (*i)->get_name()== name ) {51 foundDecls.push_back( *i);48 void doLookup( const std::list< Declaration * > & members, const std::string & name, std::list< Declaration* > & foundDecls ) { 49 for ( Declaration * decl : members ) { 50 if ( decl->name == name ) { 51 foundDecls.push_back( decl ); 52 52 } // if 53 53 } // for … … 56 56 57 57 StructInstType::StructInstType( const Type::Qualifiers & tq, StructDecl * baseStruct, const std::list< Attribute * > & attributes ) : 58 Parent( tq, baseStruct-> get_name(), attributes ), baseStruct( baseStruct ) {}58 Parent( tq, baseStruct->name, attributes ), baseStruct( baseStruct ) {} 59 59 60 60 std::string StructInstType::typeString() const { return "struct"; } … … 80 80 void StructInstType::lookup( const std::string &name, std::list< Declaration* > &foundDecls ) const { 81 81 assert( baseStruct ); 82 doLookup( baseStruct-> get_members(), name, foundDecls );82 doLookup( baseStruct->members, name, foundDecls ); 83 83 } 84 84 … … 99 99 100 100 UnionInstType::UnionInstType( const Type::Qualifiers & tq, UnionDecl * baseUnion, const std::list< Attribute * > & attributes ) : 101 Parent( tq, baseUnion-> get_name(), attributes ), baseUnion( baseUnion ) {}101 Parent( tq, baseUnion->name, attributes ), baseUnion( baseUnion ) {} 102 102 103 103 std::string UnionInstType::typeString() const { return "union"; } … … 123 123 void UnionInstType::lookup( const std::string &name, std::list< Declaration* > &foundDecls ) const { 124 124 assert( baseUnion ); 125 doLookup( baseUnion-> get_members(), name, foundDecls );125 doLookup( baseUnion->members, name, foundDecls ); 126 126 } 127 127 -
src/SynTree/Statement.cc
r0182bfa r28f3a19 208 208 } 209 209 210 WhileStmt::WhileStmt( Expression *condition, Statement *body, bool isDoWhile ):211 Statement(), condition( condition), body( body), i sDoWhile( isDoWhile) {210 WhileStmt::WhileStmt( Expression *condition, Statement *body, std::list< Statement * > & initialization, bool isDoWhile ): 211 Statement(), condition( condition), body( body), initialization( initialization ), isDoWhile( isDoWhile) { 212 212 } 213 213 -
src/SynTree/Statement.h
r0182bfa r28f3a19 213 213 Expression *condition; 214 214 Statement *body; 215 std::list<Statement *> initialization; 215 216 bool isDoWhile; 216 217 217 218 WhileStmt( Expression *condition, 218 Statement *body, bool isDoWhile = false );219 Statement *body, std::list<Statement *> & initialization, bool isDoWhile = false ); 219 220 WhileStmt( const WhileStmt &other ); 220 221 -
src/SynTree/SynTree.h
r0182bfa r28f3a19 101 101 class InitExpr; 102 102 class DeletedExpr; 103 class DefaultArgExpr; 104 class GenericExpr; 103 105 104 106 class Type; -
src/SynTree/Type.cc
r0182bfa r28f3a19 10 10 // Created On : Mon May 18 07:44:20 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Mon Sep 25 15:16:32 201713 // Update Count : 3 812 // Last Modified On : Fri Jun 22 10:17:19 2018 13 // Update Count : 39 14 14 // 15 15 #include "Type.h" … … 24 24 using namespace std; 25 25 26 const char *BasicType::typeNames[ BasicType::NUMBER_OF_BASIC_TYPES] = {26 const char *BasicType::typeNames[] = { 27 27 "_Bool", 28 28 "char", … … 48 48 "__int128", 49 49 "unsigned __int128", 50 "__float80", 51 "__float128" 50 52 }; 53 static_assert( 54 sizeof(BasicType::typeNames)/sizeof(BasicType::typeNames[0]) == BasicType::NUMBER_OF_BASIC_TYPES, 55 "Each basic type name should have a corresponding kind enum value" 56 ); 51 57 52 58 Type::Type( const Qualifiers &tq, const std::list< Attribute * > & attributes ) : tq( tq ), attributes( attributes ) {} … … 58 64 59 65 // These must remain in the same order as the corresponding bit fields. 60 const char * Type::FuncSpecifiersNames[] = { "inline", " fortran", "_Noreturn" };66 const char * Type::FuncSpecifiersNames[] = { "inline", "_Noreturn", "fortran" }; 61 67 const char * Type::StorageClassesNames[] = { "extern", "static", "auto", "register", "_Thread_local" }; 62 68 const char * Type::QualifiersNames[] = { "const", "restrict", "volatile", "lvalue", "mutex", "_Atomic" }; -
src/SynTree/Type.h
r0182bfa r28f3a19 230 230 SignedInt128, 231 231 UnsignedInt128, 232 Float80, 233 Float128, 232 234 NUMBER_OF_BASIC_TYPES 233 235 } kind; -
src/SynTree/Visitor.h
r0182bfa r28f3a19 95 95 virtual void visit( InitExpr * initExpr ) = 0; 96 96 virtual void visit( DeletedExpr * delExpr ) = 0; 97 virtual void visit( DefaultArgExpr * argExpr ) = 0; 98 virtual void visit( GenericExpr * genExpr ) = 0; 97 99 98 100 virtual void visit( VoidType * basicType ) = 0;
Note: See TracChangeset
for help on using the changeset viewer.