Changeset 0720e049 for src/SynTree
- Timestamp:
- Aug 11, 2017, 10:33:37 AM (9 years ago)
- Branches:
- ADT, aaron-thesis, arm-eh, ast-experimental, cleanup-dtors, deferred_resn, demangler, enum, forall-pointer-decay, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr, new-env, no_list, persistent-indexer, pthread-emulation, qualifiedEnum, resolv-new, stuck-waitfor-destruct, with_gc
- Children:
- 54cd58b0
- Parents:
- 3d4b23fa (diff), 59a75cb (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:
-
- 27 edited
-
AddStmtVisitor.h (modified) (2 diffs)
-
AggregateDecl.cc (modified) (2 diffs)
-
ApplicationExpr.cc (modified) (1 diff)
-
Attribute.h (modified) (2 diffs)
-
BaseSyntaxNode.h (modified) (2 diffs)
-
Constant.cc (modified) (2 diffs)
-
Constant.h (modified) (3 diffs)
-
Declaration.cc (modified) (2 diffs)
-
Declaration.h (modified) (19 diffs)
-
Expression.cc (modified) (3 diffs)
-
Expression.h (modified) (64 diffs)
-
Initializer.cc (modified) (2 diffs)
-
Initializer.h (modified) (10 diffs)
-
Label.h (modified) (2 diffs)
-
Mutator.cc (modified) (2 diffs)
-
Mutator.h (modified) (4 diffs)
-
NamedTypeDecl.cc (modified) (2 diffs)
-
Statement.h (modified) (26 diffs)
-
SynTree.h (modified) (3 diffs)
-
Type.cc (modified) (2 diffs)
-
Type.h (modified) (23 diffs)
-
TypeDecl.cc (modified) (2 diffs)
-
TypeExpr.cc (modified) (1 diff)
-
TypeSubstitution.h (modified) (2 diffs)
-
VarExprReplacer.h (modified) (2 diffs)
-
Visitor.cc (modified) (2 diffs)
-
Visitor.h (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
src/SynTree/AddStmtVisitor.h
r3d4b23fa r0720e049 10 10 // Created On : Wed Jun 22 12:05:48 2016 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Tue Jul 12 17:50:32 201613 // Update Count : 812 // Last Modified On : Sat Jul 22 09:51:08 2017 13 // Update Count : 9 14 14 // 15 15 16 #ifndef ADD_STATEMENT_VISITOR_H 17 #define ADD_STATEMENT_VISITOR_H 16 #pragma once 18 17 19 18 #include <list> … … 42 41 }; 43 42 44 #endif // ADD_STATEMENT_VISITOR_H 43 // Local Variables: // 44 // tab-width: 4 // 45 // mode: c++ // 46 // compile-command: "make install" // 47 // End: // -
src/SynTree/AggregateDecl.cc
r3d4b23fa r0720e049 10 10 // Created On : Sun May 17 23:56:39 2015 11 11 // Last Modified By : Andrew Beach 12 // Last Modified On : Tus Jun 27 15:30:00 201713 // Update Count : 2 112 // Last Modified On : Fri Aug 4 14:22:00 2017 13 // Update Count : 22 14 14 // 15 15 … … 40 40 using std::endl; 41 41 42 os << typeString() << " " << get_name(); 43 os << string( indent+2, ' ' ) << "with body " << has_body() << endl; 42 os << typeString() << " " << get_name() << ":"; 43 if ( get_linkage() != LinkageSpec::Cforall ) { 44 os << " " << LinkageSpec::linkageName( get_linkage() ); 45 } // if 46 os << " with body " << has_body() << endl; 44 47 45 48 if ( ! parameters.empty() ) { -
src/SynTree/ApplicationExpr.cc
r3d4b23fa r0720e049 44 44 } 45 45 46 ApplicationExpr::ApplicationExpr( Expression *funcExpr ) : function( funcExpr) {46 ApplicationExpr::ApplicationExpr( Expression *funcExpr, const std::list< Expression * > & argList ) : function( funcExpr ), args( argList ) { 47 47 PointerType *pointer = safe_dynamic_cast< PointerType* >( funcExpr->get_result() ); 48 48 FunctionType *function = safe_dynamic_cast< FunctionType* >( pointer->get_base() ); -
src/SynTree/Attribute.h
r3d4b23fa r0720e049 10 10 // Created On : Mon May 18 07:44:20 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Wed Jan 18 16:27:11201713 // Update Count : 3 812 // Last Modified On : Sat Jul 22 09:54:14 2017 13 // Update Count : 39 14 14 // 15 15 16 #ifndef GCC_ATTRIBUTE_H 17 #define GCC_ATTRIBUTE_H 16 #pragma once 18 17 19 18 #include "SynTree.h" … … 42 41 const std::list< Attribute * > noAttributes; 43 42 44 #endif45 46 43 // Local Variables: // 47 44 // tab-width: 4 // -
src/SynTree/BaseSyntaxNode.h
r3d4b23fa r0720e049 14 14 // 15 15 16 #ifndef BASE_SYNTAX_NODE_H 17 #define BASE_SYNTAX_NODE_H 16 #pragma once 18 17 19 18 #include "Common/utility.h" … … 29 28 }; 30 29 31 #endif // BASE_SYNTAX_NODE_H32 33 30 // Local Variables: // 34 31 // tab-width: 4 // -
src/SynTree/Constant.cc
r3d4b23fa r0720e049 10 10 // Created On : Mon May 18 07:44:20 2015 11 11 // Last Modified By : Andrew Beach 12 // Last Modified On : Thr Jun 22 10:11:00 201713 // Update Count : 2 812 // Last Modified On : Fri Jul 14 14:50:00 2017 13 // Update Count : 29 14 14 // 15 15 … … 46 46 } 47 47 48 Constant Constant::null( Type * ptrtype ) { 49 if ( nullptr == ptrtype ) { 50 ptrtype = new PointerType( 51 Type::Qualifiers(), 52 new VoidType( Type::Qualifiers() ) 53 ); 54 } 55 56 return Constant( ptrtype, "0", (unsigned long long int)0 ); 57 } 58 48 59 unsigned long long Constant::get_ival() const { 49 60 assertf( safe_dynamic_cast<BasicType*>(type)->isInteger(), "Attempt to retrieve ival from non-integer constant." ); -
src/SynTree/Constant.h
r3d4b23fa r0720e049 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 : Thr Jun 22 10:13:00201713 // Update Count : 1 511 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Sat Jul 22 09:54:46 2017 13 // Update Count : 17 14 14 // 15 15 16 #ifndef CONSTANT_H 17 #define CONSTANT_H 16 #pragma once 18 17 19 18 #include "SynTree.h" … … 44 43 static Constant from_double( double d ); 45 44 45 /// generates a null pointer value for the given type. void * if omitted. 46 static Constant null( Type * ptrtype = nullptr ); 47 46 48 virtual void accept( Visitor & v ) { v.visit( this ); } 47 49 virtual Constant * acceptMutator( Mutator & m ) { return m.mutate( this ); } … … 58 60 }; 59 61 60 #endif // CONSTANT_H61 62 62 // Local Variables: // 63 63 // tab-width: 4 // -
src/SynTree/Declaration.cc
r3d4b23fa r0720e049 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 Mar 16 07:49:18201713 // Update Count : 2 411 // Last Modified By : Andrew Beach 12 // Last Modified On : Wed Aug 9 14:38:00 2017 13 // Update Count : 25 14 14 // 15 15 … … 28 28 29 29 Declaration::Declaration( const std::string &name, Type::StorageClasses scs, LinkageSpec::Spec linkage ) 30 : name( name ), storageClasses( scs ), linkage( linkage), uniqueId( 0 ) {30 : name( name ), linkage( linkage ), storageClasses( scs ), uniqueId( 0 ) { 31 31 } 32 32 33 33 Declaration::Declaration( const Declaration &other ) 34 : BaseSyntaxNode( other ), name( other.name ), storageClasses( other.storageClasses ), linkage( other.linkage), uniqueId( other.uniqueId ) {34 : BaseSyntaxNode( other ), name( other.name ), linkage( other.linkage ), extension( other.extension ), storageClasses( other.storageClasses ), uniqueId( other.uniqueId ) { 35 35 } 36 36 -
src/SynTree/Declaration.h
r3d4b23fa r0720e049 10 10 // Created On : Mon May 18 07:44:20 2015 11 11 // Last Modified By : Andrew Beach 12 // Last Modified On : Tus Jun 27 15:31:00 2017 13 // Update Count : 122 14 // 15 16 #ifndef DECLARATION_H 17 #define DECLARATION_H 12 // Last Modified On : Wed Aug 9 14:45:00 2017 13 // Update Count : 126 14 // 15 16 #pragma once 18 17 19 18 #include <string> … … 28 27 class Declaration : public BaseSyntaxNode { 29 28 public: 29 std::string name; 30 LinkageSpec::Spec linkage; 31 bool extension = false; 32 30 33 Declaration( const std::string &name, Type::StorageClasses scs, LinkageSpec::Spec linkage ); 31 34 Declaration( const Declaration &other ); … … 54 57 static void dumpIds( std::ostream &os ); 55 58 static Declaration *declFromId( UniqueId id ); 56 private: 57 std::string name; 59 60 private: 58 61 Type::StorageClasses storageClasses; 59 LinkageSpec::Spec linkage;60 62 UniqueId uniqueId; 61 bool extension = false;62 63 }; 63 64 64 65 class DeclarationWithType : public Declaration { 65 66 public: 66 DeclarationWithType( const std::string &name, Type::StorageClasses scs, LinkageSpec::Spec linkage, const std::list< Attribute * > & attributes, Type::FuncSpecifiers fs );67 DeclarationWithType( const DeclarationWithType &other );68 virtual ~DeclarationWithType();69 70 std::string get_mangleName() const { return mangleName; }71 DeclarationWithType * set_mangleName( std::string newValue ) { mangleName = newValue; return this; }72 73 std::string get_scopedMangleName() const { return mangleName + "_" + std::to_string(scopeLevel); }74 75 int get_scopeLevel() const { return scopeLevel; }76 DeclarationWithType * set_scopeLevel( int newValue ) { scopeLevel = newValue; return this; }77 78 ConstantExpr *get_asmName() const { return asmName; }79 DeclarationWithType * set_asmName( ConstantExpr *newValue ) { asmName = newValue; return this; }80 81 std::list< Attribute * >& get_attributes() { return attributes; }82 const std::list< Attribute * >& get_attributes() const { return attributes; }83 84 Type::FuncSpecifiers get_funcSpec() const { return fs; }85 //void set_functionSpecifiers( Type::FuncSpecifiers newValue ) { fs = newValue; }86 87 virtual DeclarationWithType *clone() const = 0;88 virtual DeclarationWithType *acceptMutator( Mutator &m ) = 0;89 90 virtual Type *get_type() const = 0;91 virtual void set_type(Type *) = 0;92 private:93 67 // this represents the type with all types and typedefs expanded it is generated by SymTab::Validate::Pass2 94 68 std::string mangleName; … … 98 72 ConstantExpr *asmName; 99 73 std::list< Attribute * > attributes; 74 75 DeclarationWithType( const std::string &name, Type::StorageClasses scs, LinkageSpec::Spec linkage, const std::list< Attribute * > & attributes, Type::FuncSpecifiers fs ); 76 DeclarationWithType( const DeclarationWithType &other ); 77 virtual ~DeclarationWithType(); 78 79 std::string get_mangleName() const { return mangleName; } 80 DeclarationWithType * set_mangleName( std::string newValue ) { mangleName = newValue; return this; } 81 82 std::string get_scopedMangleName() const { return mangleName + "_" + std::to_string(scopeLevel); } 83 84 int get_scopeLevel() const { return scopeLevel; } 85 DeclarationWithType * set_scopeLevel( int newValue ) { scopeLevel = newValue; return this; } 86 87 ConstantExpr *get_asmName() const { return asmName; } 88 DeclarationWithType * set_asmName( ConstantExpr *newValue ) { asmName = newValue; return this; } 89 90 std::list< Attribute * >& get_attributes() { return attributes; } 91 const std::list< Attribute * >& get_attributes() const { return attributes; } 92 93 Type::FuncSpecifiers get_funcSpec() const { return fs; } 94 //void set_functionSpecifiers( Type::FuncSpecifiers newValue ) { fs = newValue; } 95 96 virtual DeclarationWithType *clone() const = 0; 97 virtual DeclarationWithType *acceptMutator( Mutator &m ) = 0; 98 99 virtual Type *get_type() const = 0; 100 virtual void set_type(Type *) = 0; 101 102 private: 100 103 Type::FuncSpecifiers fs; 101 104 }; … … 104 107 typedef DeclarationWithType Parent; 105 108 public: 109 Type *type; 110 Initializer *init; 111 Expression *bitfieldWidth; 112 106 113 ObjectDecl( const std::string &name, Type::StorageClasses scs, LinkageSpec::Spec linkage, Expression *bitfieldWidth, Type *type, Initializer *init, 107 114 const std::list< Attribute * > attributes = std::list< Attribute * >(), Type::FuncSpecifiers fs = Type::FuncSpecifiers() ); … … 123 130 virtual void print( std::ostream &os, int indent = 0 ) const; 124 131 virtual void printShort( std::ostream &os, int indent = 0 ) const; 125 private:126 Type *type;127 Initializer *init;128 Expression *bitfieldWidth;129 132 }; 130 133 … … 132 135 typedef DeclarationWithType Parent; 133 136 public: 137 FunctionType *type; 138 CompoundStmt *statements; 139 134 140 FunctionDecl( const std::string &name, Type::StorageClasses scs, LinkageSpec::Spec linkage, FunctionType *type, CompoundStmt *statements, 135 141 const std::list< Attribute * > attributes = std::list< Attribute * >(), Type::FuncSpecifiers fs = Type::FuncSpecifiers() ); … … 150 156 virtual void print( std::ostream &os, int indent = 0 ) const; 151 157 virtual void printShort( std::ostream &os, int indent = 0 ) const; 152 private:153 FunctionType *type;154 CompoundStmt *statements;155 158 }; 156 159 … … 158 161 typedef Declaration Parent; 159 162 public: 163 Type *base; 164 std::list< TypeDecl* > parameters; 165 std::list< DeclarationWithType* > assertions; 166 160 167 NamedTypeDecl( const std::string &name, Type::StorageClasses scs, Type *type ); 161 168 NamedTypeDecl( const NamedTypeDecl &other ); … … 172 179 virtual void print( std::ostream &os, int indent = 0 ) const; 173 180 virtual void printShort( std::ostream &os, int indent = 0 ) const; 174 protected:175 private:176 Type *base;177 std::list< TypeDecl* > parameters;178 std::list< DeclarationWithType* > assertions;179 181 }; 180 182 … … 183 185 public: 184 186 enum Kind { Any, Dtype, Ftype, Ttype }; 187 188 Type * init; 189 bool sized; 190 185 191 /// Data extracted from a type decl 186 192 struct Data { … … 217 223 private: 218 224 Kind kind; 219 Type * init;220 bool sized;221 225 }; 222 226 … … 224 228 typedef NamedTypeDecl Parent; 225 229 public: 226 TypedefDecl( const std::string &name, Type::StorageClasses scs, Type *type ) : Parent( name, scs, type ) {}230 TypedefDecl( const std::string &name, Type::StorageClasses scs, Type *type, LinkageSpec::Spec spec = LinkageSpec::Cforall ) : Parent( name, scs, type ) { set_linkage( spec ); } 227 231 TypedefDecl( const TypedefDecl &other ) : Parent( other ) {} 228 232 … … 238 242 typedef Declaration Parent; 239 243 public: 240 AggregateDecl( const std::string &name, const std::list< Attribute * > & attributes = std::list< class Attribute * >(), LinkageSpec::Spec linkage = LinkageSpec::Cforall );241 AggregateDecl( const AggregateDecl &other );242 virtual ~AggregateDecl();243 244 std::list<Declaration*>& get_members() { return members; }245 std::list<TypeDecl*>& get_parameters() { return parameters; }246 247 std::list< Attribute * >& get_attributes() { return attributes; }248 const std::list< Attribute * >& get_attributes() const { return attributes; }249 250 bool has_body() const { return body; }251 AggregateDecl * set_body( bool body ) { AggregateDecl::body = body; return this; }252 253 virtual void print( std::ostream &os, int indent = 0 ) const;254 virtual void printShort( std::ostream &os, int indent = 0 ) const;255 protected:256 virtual std::string typeString() const = 0;257 258 private:259 244 std::list<Declaration*> members; 260 245 std::list<TypeDecl*> parameters; 261 246 bool body; 262 247 std::list< Attribute * > attributes; 248 249 AggregateDecl( const std::string &name, const std::list< Attribute * > & attributes = std::list< class Attribute * >(), LinkageSpec::Spec linkage = LinkageSpec::Cforall ); 250 AggregateDecl( const AggregateDecl &other ); 251 virtual ~AggregateDecl(); 252 253 std::list<Declaration*>& get_members() { return members; } 254 std::list<TypeDecl*>& get_parameters() { return parameters; } 255 256 std::list< Attribute * >& get_attributes() { return attributes; } 257 const std::list< Attribute * >& get_attributes() const { return attributes; } 258 259 bool has_body() const { return body; } 260 AggregateDecl * set_body( bool body ) { AggregateDecl::body = body; return this; } 261 262 virtual void print( std::ostream &os, int indent = 0 ) const; 263 virtual void printShort( std::ostream &os, int indent = 0 ) const; 264 protected: 265 virtual std::string typeString() const = 0; 263 266 }; 264 267 … … 266 269 typedef AggregateDecl Parent; 267 270 public: 268 StructDecl( const std::string &name, DeclarationNode::Aggregate kind = DeclarationNode::Struct, const std::list< Attribute * > & attributes = std::list< class Attribute * >(), LinkageSpec::Spec linkage = LinkageSpec::Cforall ) : Parent( name, attributes, linkage ), kind( kind ) {} 271 StructDecl( const std::string &name, DeclarationNode::Aggregate kind = DeclarationNode::Struct, const std::list< Attribute * > & attributes = std::list< class Attribute * >(), LinkageSpec::Spec linkage = LinkageSpec::Cforall ) : Parent( name, attributes, linkage ), kind( kind ), tagged( false ), parent_name( "" ) {} 272 StructDecl( const std::string &name, const std::string *parent, const std::list< Attribute * > & attributes = std::list< class Attribute * >(), LinkageSpec::Spec linkage = LinkageSpec::Cforall ) : Parent( name, attributes, linkage ), kind( DeclarationNode::Struct ), tagged( true ), parent_name( parent ? *parent : "" ) {} 269 273 StructDecl( const StructDecl &other ) : Parent( other ) {} 270 274 … … 273 277 bool is_thread() { return kind == DeclarationNode::Thread; } 274 278 279 // Tagged/Tree Structure Excetion 280 bool get_tagged() { return tagged; } 281 void set_tagged( bool newValue ) { tagged = newValue; } 282 bool has_parent() { return parent_name != ""; } 283 std::string get_parentName() { return parent_name; } 284 275 285 virtual StructDecl *clone() const { return new StructDecl( *this ); } 276 286 virtual void accept( Visitor &v ) { v.visit( this ); } … … 279 289 DeclarationNode::Aggregate kind; 280 290 virtual std::string typeString() const; 291 292 bool tagged; 293 std::string parent_name; 281 294 }; 282 295 … … 324 337 class AsmDecl : public Declaration { 325 338 public: 339 AsmStmt *stmt; 340 326 341 AsmDecl( AsmStmt *stmt ); 327 342 AsmDecl( const AsmDecl &other ); … … 336 351 virtual void print( std::ostream &os, int indent = 0 ) const; 337 352 virtual void printShort( std::ostream &os, int indent = 0 ) const; 338 private:339 AsmStmt *stmt;340 353 }; 341 354 342 355 std::ostream & operator<<( std::ostream & out, const Declaration * decl ); 343 356 std::ostream & operator<<( std::ostream & os, const TypeDecl::Data & data ); 344 345 #endif // DECLARATION_H346 357 347 358 // Local Variables: // -
src/SynTree/Expression.cc
r3d4b23fa r0720e049 10 10 // Created On : Mon May 18 07:44:20 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : T hu Mar 30 16:41:13201713 // Update Count : 5 212 // Last Modified On : Tue Jul 25 14:15:47 2017 13 // Update Count : 54 14 14 // 15 15 … … 298 298 if ( result->isVoid() ) { 299 299 os << "nothing"; 300 } else { 301 result->print( os, indent+2 ); 302 } // if 303 os << std::endl; 304 Expression::print( os, indent ); 305 } 306 307 VirtualCastExpr::VirtualCastExpr( Expression *arg_, Type *toType ) : Expression(), arg(arg_) { 308 set_result(toType); 309 } 310 311 VirtualCastExpr::VirtualCastExpr( const VirtualCastExpr &other ) : Expression( other ), arg( maybeClone( other.arg ) ) { 312 } 313 314 VirtualCastExpr::~VirtualCastExpr() { 315 delete arg; 316 } 317 318 void VirtualCastExpr::print( std::ostream &os, int indent ) const { 319 os << "Virtual Cast of:" << std::endl << std::string( indent+2, ' ' ); 320 arg->print(os, indent+2); 321 os << std::endl << std::string( indent, ' ' ) << "to:" << std::endl; 322 os << std::string( indent+2, ' ' ); 323 if ( ! result ) { 324 os << "unknown"; 300 325 } else { 301 326 result->print( os, indent+2 ); … … 503 528 } 504 529 505 AsmExpr::AsmExpr( const AsmExpr & other ) : inout( maybeClone( other.inout ) ), constraint( maybeClone( other.constraint ) ), operand( maybeClone( other.operand ) ) {}530 AsmExpr::AsmExpr( const AsmExpr & other ) : Expression( other ), inout( maybeClone( other.inout ) ), constraint( maybeClone( other.constraint ) ), operand( maybeClone( other.operand ) ) {} 506 531 507 532 -
src/SynTree/Expression.h
r3d4b23fa r0720e049 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 Mar 30 16:44:00 201713 // Update Count : 4 111 // Last Modified By : Andrew Beach 12 // Last Modified On : Fri Aug 8 11:54:00 2017 13 // Update Count : 44 14 14 // 15 15 16 #ifndef EXPRESSION_H 17 #define EXPRESSION_H 16 #pragma once 18 17 19 18 #include <map> … … 30 29 class Expression : public BaseSyntaxNode{ 31 30 public: 31 Type * result; 32 TypeSubstitution * env; 33 Expression * argName; // if expression is used as an argument, it can be "designated" by this name 34 bool extension = false; 35 32 36 Expression( Expression * _aname = nullptr ); 33 37 Expression( const Expression & other ); … … 50 54 virtual Expression * acceptMutator( Mutator & m ) = 0; 51 55 virtual void print( std::ostream & os, int indent = 0 ) const; 52 protected:53 Type * result;54 TypeSubstitution * env;55 Expression * argName; // if expression is used as an argument, it can be "designated" by this name56 bool extension = false;57 56 }; 58 57 … … 80 79 class ApplicationExpr : public Expression { 81 80 public: 82 ApplicationExpr( Expression * function ); 81 Expression * function; 82 83 ApplicationExpr( Expression * function, const std::list<Expression *> & args = std::list< Expression * >() ); 83 84 ApplicationExpr( const ApplicationExpr & other ); 84 85 virtual ~ApplicationExpr(); … … 93 94 virtual Expression * acceptMutator( Mutator & m ) { return m.mutate( this ); } 94 95 virtual void print( std::ostream & os, int indent = 0 ) const; 96 95 97 private: 96 Expression * function;97 98 std::list<Expression *> args; 98 99 InferredParams inferParams; … … 104 105 class UntypedExpr : public Expression { 105 106 public: 107 Expression * function; 108 std::list<Expression*> args; 109 106 110 UntypedExpr( Expression * function, const std::list<Expression *> & args = std::list< Expression * >(), Expression *_aname = nullptr ); 107 111 UntypedExpr( const UntypedExpr & other ); … … 124 128 virtual void print( std::ostream & os, int indent = 0 ) const; 125 129 virtual void printArgs(std::ostream & os, int indent = 0) const; 126 private:127 Expression * function;128 std::list<Expression*> args;129 130 }; 130 131 … … 132 133 class NameExpr : public Expression { 133 134 public: 135 std::string name; 136 134 137 NameExpr( std::string name, Expression *_aname = nullptr ); 135 138 NameExpr( const NameExpr & other ); … … 143 146 virtual Expression * acceptMutator( Mutator & m ) { return m.mutate( this ); } 144 147 virtual void print( std::ostream & os, int indent = 0 ) const; 145 private:146 std::string name;147 148 }; 148 149 … … 153 154 class AddressExpr : public Expression { 154 155 public: 156 Expression * arg; 157 155 158 AddressExpr( Expression * arg, Expression *_aname = nullptr ); 156 159 AddressExpr( const AddressExpr & other ); … … 164 167 virtual Expression * acceptMutator( Mutator & m ) { return m.mutate( this ); } 165 168 virtual void print( std::ostream & os, int indent = 0 ) const; 166 private:167 Expression * arg;168 169 }; 169 170 … … 171 172 class LabelAddressExpr : public Expression { 172 173 public: 174 Expression * arg; 175 173 176 LabelAddressExpr( Expression * arg ); 174 177 LabelAddressExpr( const LabelAddressExpr & other ); … … 182 185 virtual Expression * acceptMutator( Mutator & m ) { return m.mutate( this ); } 183 186 virtual void print( std::ostream & os, int indent = 0 ) const; 184 private:185 Expression * arg;186 187 }; 187 188 … … 189 190 class CastExpr : public Expression { 190 191 public: 192 Expression * arg; 193 191 194 CastExpr( Expression * arg, Expression *_aname = nullptr ); 192 195 CastExpr( Expression * arg, Type * toType, Expression *_aname = nullptr ); … … 195 198 196 199 Expression * get_arg() const { return arg; } 197 void set_arg( Expression * newValue ) { arg = newValue; }200 void set_arg( Expression * newValue ) { arg = newValue; } 198 201 199 202 virtual CastExpr * clone() const { return new CastExpr( * this ); } … … 201 204 virtual Expression * acceptMutator( Mutator & m ) { return m.mutate( this ); } 202 205 virtual void print( std::ostream & os, int indent = 0 ) const; 203 private: 206 }; 207 208 /// VirtualCastExpr repersents a virtual dynamic cast, e.g. (virtual exception)e 209 class VirtualCastExpr : public Expression { 210 public: 204 211 Expression * arg; 212 213 VirtualCastExpr( Expression * arg, Type * toType ); 214 VirtualCastExpr( const VirtualCastExpr & other ); 215 virtual ~VirtualCastExpr(); 216 217 Expression * get_arg() const { return arg; } 218 void set_arg( Expression * newValue ) { arg = newValue; } 219 220 virtual VirtualCastExpr * clone() const { return new VirtualCastExpr( * this ); } 221 virtual void accept( Visitor & v ) { v.visit( this ); } 222 virtual Expression * acceptMutator( Mutator & m ) { return m.mutate( this ); } 223 virtual void print( std::ostream & os, int indent = 0 ) const; 205 224 }; 206 225 … … 208 227 class UntypedMemberExpr : public Expression { 209 228 public: 229 Expression * member; 230 Expression * aggregate; 231 210 232 UntypedMemberExpr( Expression * member, Expression * aggregate, Expression *_aname = nullptr ); 211 233 UntypedMemberExpr( const UntypedMemberExpr & other ); … … 221 243 virtual Expression * acceptMutator( Mutator & m ) { return m.mutate( this ); } 222 244 virtual void print( std::ostream & os, int indent = 0 ) const; 223 private:224 Expression * member;225 Expression * aggregate;226 245 }; 227 246 … … 230 249 class MemberExpr : public Expression { 231 250 public: 251 DeclarationWithType * member; 252 Expression * aggregate; 253 232 254 MemberExpr( DeclarationWithType * member, Expression * aggregate, Expression *_aname = nullptr ); 233 255 MemberExpr( const MemberExpr & other ); … … 243 265 virtual Expression * acceptMutator( Mutator & m ) { return m.mutate( this ); } 244 266 virtual void print( std::ostream & os, int indent = 0 ) const; 245 private:246 DeclarationWithType * member;247 Expression * aggregate;248 267 }; 249 268 … … 252 271 class VariableExpr : public Expression { 253 272 public: 273 DeclarationWithType * var; 274 254 275 VariableExpr( DeclarationWithType * var, Expression *_aname = nullptr ); 255 276 VariableExpr( const VariableExpr & other ); … … 263 284 virtual Expression * acceptMutator( Mutator & m ) { return m.mutate( this ); } 264 285 virtual void print( std::ostream & os, int indent = 0 ) const; 265 private:266 DeclarationWithType * var;267 286 }; 268 287 … … 270 289 class ConstantExpr : public Expression { 271 290 public: 291 Constant constant; 292 272 293 ConstantExpr( Constant constant, Expression *_aname = nullptr ); 273 294 ConstantExpr( const ConstantExpr & other ); … … 281 302 virtual Expression * acceptMutator( Mutator & m ) { return m.mutate( this ); } 282 303 virtual void print( std::ostream & os, int indent = 0 ) const; 283 private:284 Constant constant;285 304 }; 286 305 … … 288 307 class SizeofExpr : public Expression { 289 308 public: 309 Expression * expr; 310 Type * type; 311 bool isType; 312 290 313 SizeofExpr( Expression * expr, Expression *_aname = nullptr ); 291 314 SizeofExpr( const SizeofExpr & other ); … … 304 327 virtual Expression * acceptMutator( Mutator & m ) { return m.mutate( this ); } 305 328 virtual void print( std::ostream & os, int indent = 0 ) const; 306 private: 329 }; 330 331 /// AlignofExpr represents an alignof expression 332 class AlignofExpr : public Expression { 333 public: 307 334 Expression * expr; 308 335 Type * type; 309 336 bool isType; 310 }; 311 312 /// AlignofExpr represents an alignof expression 313 class AlignofExpr : public Expression { 314 public: 337 315 338 AlignofExpr( Expression * expr, Expression *_aname = nullptr ); 316 339 AlignofExpr( const AlignofExpr & other ); … … 329 352 virtual Expression * acceptMutator( Mutator & m ) { return m.mutate( this ); } 330 353 virtual void print( std::ostream & os, int indent = 0 ) const; 331 private:332 Expression * expr;333 Type * type;334 bool isType;335 354 }; 336 355 … … 338 357 class UntypedOffsetofExpr : public Expression { 339 358 public: 359 Type * type; 360 std::string member; 361 340 362 UntypedOffsetofExpr( Type * type, const std::string & member, Expression *_aname = nullptr ); 341 363 UntypedOffsetofExpr( const UntypedOffsetofExpr & other ); … … 351 373 virtual Expression * acceptMutator( Mutator & m ) { return m.mutate( this ); } 352 374 virtual void print( std::ostream & os, int indent = 0 ) const; 353 private:354 Type * type;355 std::string member;356 375 }; 357 376 … … 359 378 class OffsetofExpr : public Expression { 360 379 public: 380 Type * type; 381 DeclarationWithType * member; 382 361 383 OffsetofExpr( Type * type, DeclarationWithType * member, Expression *_aname = nullptr ); 362 384 OffsetofExpr( const OffsetofExpr & other ); … … 372 394 virtual Expression * acceptMutator( Mutator & m ) { return m.mutate( this ); } 373 395 virtual void print( std::ostream & os, int indent = 0 ) const; 374 private:375 Type * type;376 DeclarationWithType * member;377 396 }; 378 397 … … 380 399 class OffsetPackExpr : public Expression { 381 400 public: 401 StructInstType * type; 402 382 403 OffsetPackExpr( StructInstType * type_, Expression * aname_ = 0 ); 383 404 OffsetPackExpr( const OffsetPackExpr & other ); … … 390 411 virtual void accept( Visitor & v ) { v.visit( this ); } 391 412 virtual Expression * acceptMutator( Mutator & m ) { return m.mutate( this ); } 392 393 virtual void print( std::ostream & os, int indent = 0 ) const; 394 395 private: 396 StructInstType * type; 413 virtual void print( std::ostream & os, int indent = 0 ) const; 397 414 }; 398 415 … … 400 417 class AttrExpr : public Expression { 401 418 public: 419 Expression * attr; 420 Expression * expr; 421 Type * type; 422 bool isType; 423 402 424 AttrExpr(Expression * attr, Expression * expr, Expression *_aname = nullptr ); 403 425 AttrExpr( const AttrExpr & other ); … … 418 440 virtual Expression * acceptMutator( Mutator & m ) { return m.mutate( this ); } 419 441 virtual void print( std::ostream & os, int indent = 0 ) const; 420 private:421 Expression * attr;422 Expression * expr;423 Type * type;424 bool isType;425 442 }; 426 443 … … 428 445 class LogicalExpr : public Expression { 429 446 public: 447 Expression * arg1; 448 Expression * arg2; 449 430 450 LogicalExpr( Expression * arg1, Expression * arg2, bool andp = true, Expression *_aname = nullptr ); 431 451 LogicalExpr( const LogicalExpr & other ); … … 442 462 virtual Expression * acceptMutator( Mutator & m ) { return m.mutate( this ); } 443 463 virtual void print( std::ostream & os, int indent = 0 ) const; 464 444 465 private: 466 bool isAnd; 467 }; 468 469 /// ConditionalExpr represents the three-argument conditional ( p ? a : b ) 470 class ConditionalExpr : public Expression { 471 public: 445 472 Expression * arg1; 446 473 Expression * arg2; 447 bool isAnd; 448 }; 449 450 /// ConditionalExpr represents the three-argument conditional ( p ? a : b ) 451 class ConditionalExpr : public Expression { 452 public: 474 Expression * arg3; 475 453 476 ConditionalExpr( Expression * arg1, Expression * arg2, Expression * arg3, Expression *_aname = nullptr ); 454 477 ConditionalExpr( const ConditionalExpr & other ); … … 466 489 virtual Expression * acceptMutator( Mutator & m ) { return m.mutate( this ); } 467 490 virtual void print( std::ostream & os, int indent = 0 ) const; 468 private: 491 }; 492 493 /// CommaExpr represents the sequence operator ( a, b ) 494 class CommaExpr : public Expression { 495 public: 469 496 Expression * arg1; 470 497 Expression * arg2; 471 Expression * arg3; 472 }; 473 474 /// CommaExpr represents the sequence operator ( a, b ) 475 class CommaExpr : public Expression { 476 public: 498 477 499 CommaExpr( Expression * arg1, Expression * arg2, Expression *_aname = nullptr ); 478 500 CommaExpr( const CommaExpr & other ); … … 488 510 virtual Expression * acceptMutator( Mutator & m ) { return m.mutate( this ); } 489 511 virtual void print( std::ostream & os, int indent = 0 ) const; 490 private:491 Expression * arg1;492 Expression * arg2;493 512 }; 494 513 … … 496 515 class TypeExpr : public Expression { 497 516 public: 517 Type * type; 518 498 519 TypeExpr( Type * type ); 499 520 TypeExpr( const TypeExpr & other ); … … 507 528 virtual Expression * acceptMutator( Mutator & m ) { return m.mutate( this ); } 508 529 virtual void print( std::ostream & os, int indent = 0 ) const; 509 private:510 Type * type;511 530 }; 512 531 … … 514 533 class AsmExpr : public Expression { 515 534 public: 535 Expression * inout; 536 ConstantExpr * constraint; 537 Expression * operand; 538 516 539 AsmExpr( Expression * inout, ConstantExpr * constraint, Expression * operand ) : inout( inout ), constraint( constraint ), operand( operand ) {} 517 540 AsmExpr( const AsmExpr & other ); … … 531 554 virtual Expression * acceptMutator( Mutator & m ) { return m.mutate( this ); } 532 555 virtual void print( std::ostream & os, int indent = 0 ) const; 533 private: 556 534 557 // https://gcc.gnu.org/onlinedocs/gcc-4.7.1/gcc/Machine-Constraints.html#Machine-Constraints 535 Expression * inout;536 ConstantExpr * constraint;537 Expression * operand;538 558 }; 539 559 … … 542 562 class ImplicitCopyCtorExpr : public Expression { 543 563 public: 544 ImplicitCopyCtorExpr( ApplicationExpr * callExpr );545 ImplicitCopyCtorExpr( const ImplicitCopyCtorExpr & other );546 virtual ~ImplicitCopyCtorExpr();547 548 ApplicationExpr * get_callExpr() const { return callExpr; }549 void set_callExpr( ApplicationExpr * newValue ) { callExpr = newValue; }550 551 std::list< ObjectDecl * > & get_tempDecls() { return tempDecls; }552 std::list< ObjectDecl * > & get_returnDecls() { return returnDecls; }553 std::list< Expression * > & get_dtors() { return dtors; }554 555 virtual ImplicitCopyCtorExpr * clone() const { return new ImplicitCopyCtorExpr( * this ); }556 virtual void accept( Visitor & v ) { v.visit( this ); }557 virtual Expression * acceptMutator( Mutator & m ) { return m.mutate( this ); }558 virtual void print( std::ostream & os, int indent = 0 ) const;559 private:560 564 ApplicationExpr * callExpr; 561 565 std::list< ObjectDecl * > tempDecls; 562 566 std::list< ObjectDecl * > returnDecls; 563 567 std::list< Expression * > dtors; 568 569 ImplicitCopyCtorExpr( ApplicationExpr * callExpr ); 570 ImplicitCopyCtorExpr( const ImplicitCopyCtorExpr & other ); 571 virtual ~ImplicitCopyCtorExpr(); 572 573 ApplicationExpr * get_callExpr() const { return callExpr; } 574 void set_callExpr( ApplicationExpr * newValue ) { callExpr = newValue; } 575 576 std::list< ObjectDecl * > & get_tempDecls() { return tempDecls; } 577 std::list< ObjectDecl * > & get_returnDecls() { return returnDecls; } 578 std::list< Expression * > & get_dtors() { return dtors; } 579 580 virtual ImplicitCopyCtorExpr * clone() const { return new ImplicitCopyCtorExpr( * this ); } 581 virtual void accept( Visitor & v ) { v.visit( this ); } 582 virtual Expression * acceptMutator( Mutator & m ) { return m.mutate( this ); } 583 virtual void print( std::ostream & os, int indent = 0 ) const; 564 584 }; 565 585 … … 567 587 class ConstructorExpr : public Expression { 568 588 public: 589 Expression * callExpr; 590 569 591 ConstructorExpr( Expression * callExpr ); 570 592 ConstructorExpr( const ConstructorExpr & other ); … … 578 600 virtual Expression * acceptMutator( Mutator & m ) { return m.mutate( this ); } 579 601 virtual void print( std::ostream & os, int indent = 0 ) const; 580 private:581 Expression * callExpr;582 602 }; 583 603 … … 585 605 class CompoundLiteralExpr : public Expression { 586 606 public: 607 Initializer * initializer; 608 587 609 CompoundLiteralExpr( Type * type, Initializer * initializer ); 588 610 CompoundLiteralExpr( const CompoundLiteralExpr & other ); … … 596 618 virtual Expression * acceptMutator( Mutator & m ) { return m.mutate( this ); } 597 619 virtual void print( std::ostream & os, int indent = 0 ) const; 598 private:599 Initializer * initializer;600 620 }; 601 621 … … 603 623 class RangeExpr : public Expression { 604 624 public: 625 Expression * low, * high; 626 605 627 RangeExpr( Expression * low, Expression * high ); 606 628 RangeExpr( const RangeExpr & other ); … … 615 637 virtual Expression * acceptMutator( Mutator & m ) { return m.mutate( this ); } 616 638 virtual void print( std::ostream & os, int indent = 0 ) const; 617 private:618 Expression * low, * high;619 639 }; 620 640 … … 622 642 class UntypedTupleExpr : public Expression { 623 643 public: 644 std::list<Expression*> exprs; 645 624 646 UntypedTupleExpr( const std::list< Expression * > & exprs, Expression *_aname = nullptr ); 625 647 UntypedTupleExpr( const UntypedTupleExpr & other ); … … 632 654 virtual Expression * acceptMutator( Mutator & m ) { return m.mutate( this ); } 633 655 virtual void print( std::ostream & os, int indent = 0 ) const; 634 private:635 std::list<Expression*> exprs;636 656 }; 637 657 … … 639 659 class TupleExpr : public Expression { 640 660 public: 661 std::list<Expression*> exprs; 662 641 663 TupleExpr( const std::list< Expression * > & exprs, Expression *_aname = nullptr ); 642 664 TupleExpr( const TupleExpr & other ); … … 649 671 virtual Expression * acceptMutator( Mutator & m ) { return m.mutate( this ); } 650 672 virtual void print( std::ostream & os, int indent = 0 ) const; 651 private:652 std::list<Expression*> exprs;653 673 }; 654 674 … … 656 676 class TupleIndexExpr : public Expression { 657 677 public: 678 Expression * tuple; 679 unsigned int index; 680 658 681 TupleIndexExpr( Expression * tuple, unsigned int index ); 659 682 TupleIndexExpr( const TupleIndexExpr & other ); … … 669 692 virtual Expression * acceptMutator( Mutator & m ) { return m.mutate( this ); } 670 693 virtual void print( std::ostream & os, int indent = 0 ) const; 671 private:672 Expression * tuple;673 unsigned int index;674 694 }; 675 695 … … 677 697 class TupleAssignExpr : public Expression { 678 698 public: 699 StmtExpr * stmtExpr = nullptr; 700 679 701 TupleAssignExpr( const std::list< Expression * > & assigns, const std::list< ObjectDecl * > & tempDecls, Expression * _aname = nullptr ); 680 702 TupleAssignExpr( const TupleAssignExpr & other ); … … 688 710 virtual Expression * acceptMutator( Mutator & m ) { return m.mutate( this ); } 689 711 virtual void print( std::ostream & os, int indent = 0 ) const; 690 private:691 StmtExpr * stmtExpr = nullptr;692 712 }; 693 713 … … 695 715 class StmtExpr : public Expression { 696 716 public: 717 CompoundStmt * statements; 718 std::list< ObjectDecl * > returnDecls; // return variable(s) for stmt expression 719 std::list< Expression * > dtors; // destructor(s) for return variable(s) 720 697 721 StmtExpr( CompoundStmt * statements ); 698 722 StmtExpr( const StmtExpr & other ); … … 709 733 virtual Expression * acceptMutator( Mutator & m ) { return m.mutate( this ); } 710 734 virtual void print( std::ostream & os, int indent = 0 ) const; 711 private:712 CompoundStmt * statements;713 std::list< ObjectDecl * > returnDecls; // return variable(s) for stmt expression714 std::list< Expression * > dtors; // destructor(s) for return variable(s)715 735 }; 716 736 717 737 class UniqueExpr : public Expression { 718 738 public: 739 Expression * expr; 740 ObjectDecl * object; 741 VariableExpr * var; 742 719 743 UniqueExpr( Expression * expr, long long idVal = -1 ); 720 744 UniqueExpr( const UniqueExpr & other ); … … 736 760 virtual Expression * acceptMutator( Mutator & m ) { return m.mutate( this ); } 737 761 virtual void print( std::ostream & os, int indent = 0 ) const; 762 738 763 private: 739 Expression * expr;740 ObjectDecl * object;741 VariableExpr * var;742 764 int id; 743 765 static long long count; … … 756 778 class UntypedInitExpr : public Expression { 757 779 public: 780 Expression * expr; 781 std::list<InitAlternative> initAlts; 782 758 783 UntypedInitExpr( Expression * expr, const std::list<InitAlternative> & initAlts ); 759 784 UntypedInitExpr( const UntypedInitExpr & other ); … … 769 794 virtual Expression * acceptMutator( Mutator & m ) { return m.mutate( this ); } 770 795 virtual void print( std::ostream & os, int indent = 0 ) const; 771 private:772 Expression * expr;773 std::list<InitAlternative> initAlts;774 796 }; 775 797 776 798 class InitExpr : public Expression { 777 799 public: 800 Expression * expr; 801 Designation * designation; 802 778 803 InitExpr( Expression * expr, Designation * designation ); 779 804 InitExpr( const InitExpr & other ); … … 790 815 virtual Expression * acceptMutator( Mutator & m ) { return m.mutate( this ); } 791 816 virtual void print( std::ostream & os, int indent = 0 ) const; 792 private:793 Expression * expr;794 Designation * designation;795 817 }; 796 818 797 819 798 820 std::ostream & operator<<( std::ostream & out, const Expression * expr ); 799 800 #endif // EXPRESSION_H801 821 802 822 // Local Variables: // -
src/SynTree/Initializer.cc
r3d4b23fa r0720e049 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 : Fri May 13 13:23:03201613 // Update Count : 2 811 // Last Modified By : Andrew Beach 12 // Last Modified On : Thr Aug 3 11:33:00 2016 13 // Update Count : 29 14 14 // 15 15 … … 74 74 } 75 75 } 76 assertf( initializers.size() == designations.size(), "Created ListInit with mismatching initializers (% d) and designations (%d)", initializers.size(), designations.size() );76 assertf( initializers.size() == designations.size(), "Created ListInit with mismatching initializers (%lu) and designations (%lu)", initializers.size(), designations.size() ); 77 77 } 78 78 -
src/SynTree/Initializer.h
r3d4b23fa r0720e049 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 Mar 23 16:12:42201713 // Update Count : 2 011 // Last Modified By : Andrew Beach 12 // Last Modified On : Wed Aug 9 10:19:00 2017 13 // Update Count : 22 14 14 // 15 15 16 #ifndef INITIALIZER_H 17 #define INITIALIZER_H 16 #pragma once 18 17 19 18 #include <cassert> … … 28 27 class Designation : public BaseSyntaxNode { 29 28 public: 29 std::list< Expression * > designators; 30 30 31 Designation( const std::list< Expression * > & designators ); 31 32 Designation( const Designation & other ); … … 38 39 virtual Designation * acceptMutator( Mutator &m ) { return m.mutate( this ); } 39 40 virtual void print( std::ostream &os, int indent = 0 ) const; 40 private:41 std::list< Expression * > designators;42 41 }; 43 42 … … 64 63 class SingleInit : public Initializer { 65 64 public: 65 //Constant *value; 66 Expression *value; // has to be a compile-time constant 67 66 68 SingleInit( Expression *value, bool maybeConstructed = false ); 67 69 SingleInit( const SingleInit &other ); … … 75 77 virtual Initializer *acceptMutator( Mutator &m ) { return m.mutate( this ); } 76 78 virtual void print( std::ostream &os, int indent = 0 ) const; 77 private:78 //Constant *value;79 Expression *value; // has to be a compile-time constant80 79 }; 81 80 … … 84 83 class ListInit : public Initializer { 85 84 public: 85 std::list<Initializer *> initializers; // order *is* important 86 std::list<Designation *> designations; // order/length is consistent with initializers 87 86 88 ListInit( const std::list<Initializer*> &initializers, 87 89 const std::list<Designation *> &designators = {}, bool maybeConstructed = false ); … … 103 105 virtual Initializer *acceptMutator( Mutator &m ) { return m.mutate( this ); } 104 106 virtual void print( std::ostream &os, int indent = 0 ) const; 105 private:106 std::list<Initializer *> initializers; // order *is* important107 std::list<Designation *> designations; // order/length is consistent with initializers108 107 }; 109 108 … … 114 113 class ConstructorInit : public Initializer { 115 114 public: 115 Statement * ctor; 116 Statement * dtor; 117 116 118 ConstructorInit( Statement * ctor, Statement * dtor, Initializer * init ); 117 119 ConstructorInit( const ConstructorInit &other ); … … 131 133 132 134 private: 133 Statement * ctor;134 Statement * dtor;135 135 // C-style initializer made up of SingleInit and ListInit nodes to use as a fallback 136 136 // if an appropriate constructor definition is not found by the resolver … … 141 141 std::ostream & operator<<( std::ostream & out, const Designation * des ); 142 142 143 #endif // INITIALIZER_H144 145 143 // Local Variables: // 146 144 // tab-width: 4 // -
src/SynTree/Label.h
r3d4b23fa r0720e049 10 10 // Created On : Wed Jun 8 12:53:12 2016 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : S un Aug 7 14:44:29 201613 // Update Count : 212 // Last Modified On : Sat Jul 22 09:52:44 2017 13 // Update Count : 3 14 14 // 15 15 16 #ifndef LABEL_H 17 #define LABEL_H 16 #pragma once 18 17 19 18 #include <string> … … 51 50 static const std::list< Label > noLabels; 52 51 53 #endif // LABEL_H54 55 52 // Local Variables: // 56 53 // tab-width: 4 // -
src/SynTree/Mutator.cc
r3d4b23fa r0720e049 10 10 // Created On : Mon May 18 07:44:20 2015 11 11 // Last Modified By : Andrew Beach 12 // Last Modified On : Thu Jun 22 13:43:00 201713 // Update Count : 2 412 // Last Modified On : Mon Jul 24 16:32:00 2017 13 // Update Count : 25 14 14 // 15 15 … … 235 235 } 236 236 237 Expression *Mutator::mutate( VirtualCastExpr *castExpr ) { 238 castExpr->set_env( maybeMutate( castExpr->get_env(), *this ) ); 239 castExpr->set_result( maybeMutate( castExpr->get_result(), *this ) ); 240 castExpr->set_arg( maybeMutate( castExpr->get_arg(), *this ) ); 241 return castExpr; 242 } 243 237 244 Expression *Mutator::mutate( UntypedMemberExpr *memberExpr ) { 238 245 memberExpr->set_env( maybeMutate( memberExpr->get_env(), *this ) ); -
src/SynTree/Mutator.h
r3d4b23fa r0720e049 10 10 // Created On : Mon May 18 07:44:20 2015 11 11 // Last Modified By : Andrew Beach 12 // Last Modified On : Thu Jun 8 15:45:00 201713 // Update Count : 1 412 // Last Modified On : Mon Jul 24 16:31:00 2017 13 // Update Count : 16 14 14 // 15 15 #include <cassert> … … 18 18 #include "Common/SemanticError.h" 19 19 20 #ifndef MUTATOR_H 21 #define MUTATOR_H 20 #pragma once 22 21 23 22 class Mutator { … … 60 59 virtual Expression* mutate( LabelAddressExpr *labAddressExpr ); 61 60 virtual Expression* mutate( CastExpr *castExpr ); 61 virtual Expression* mutate( VirtualCastExpr *castExpr ); 62 62 virtual Expression* mutate( UntypedMemberExpr *memberExpr ); 63 63 virtual Expression* mutate( MemberExpr *memberExpr ); … … 150 150 } 151 151 152 #endif // MUTATOR_H153 154 152 // Local Variables: // 155 153 // tab-width: 4 // -
src/SynTree/NamedTypeDecl.cc
r3d4b23fa r0720e049 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 Mar 16 07:49:44201713 // Update Count : 1 311 // Last Modified By : Andrew Beach 12 // Last Modified On : Wed Aug 9 13:28:00 2017 13 // Update Count : 14 14 14 // 15 15 … … 38 38 if ( get_name() != "" ) { 39 39 os << get_name() << ": "; 40 } // if 41 if ( get_linkage() != LinkageSpec::Cforall ) { 42 os << LinkageSpec::linkageName( get_linkage() ) << " "; 40 43 } // if 41 44 get_storageClasses().print( os ); -
src/SynTree/Statement.h
r3d4b23fa r0720e049 10 10 // Created On : Mon May 18 07:44:20 2015 11 11 // Last Modified By : Andrew Beach 12 // Last Modified On : Mon Jun 12 13:35:00 201713 // Update Count : 6 712 // Last Modified On : Thr Aug 3 14:08:00 2017 13 // Update Count : 69 14 14 // 15 15 16 #ifndef STATEMENT_H 17 #define STATEMENT_H 16 #pragma once 18 17 19 18 #include "BaseSyntaxNode.h" … … 27 26 class Statement : public BaseSyntaxNode { 28 27 public: 28 std::list<Label> labels; 29 29 30 Statement( std::list<Label> labels ); 30 31 virtual ~Statement(); … … 37 38 virtual Statement *acceptMutator( Mutator &m ) = 0; 38 39 virtual void print( std::ostream &os, int indent = 0 ) const; 39 protected:40 std::list<Label> labels;41 40 }; 42 41 43 42 class CompoundStmt : public Statement { 44 43 public: 44 std::list<Statement*> kids; 45 45 46 CompoundStmt( std::list<Label> labels ); 46 47 CompoundStmt( const CompoundStmt &other ); … … 55 56 virtual CompoundStmt *acceptMutator( Mutator &m ) { return m.mutate( this ); } 56 57 virtual void print( std::ostream &os, int indent = 0 ) const; 57 private:58 std::list<Statement*> kids;59 58 }; 60 59 … … 68 67 virtual NullStmt *acceptMutator( Mutator &m ) { return m.mutate( this ); } 69 68 virtual void print( std::ostream &os, int indent = 0 ) const; 70 71 private:72 69 }; 73 70 74 71 class ExprStmt : public Statement { 75 72 public: 73 Expression *expr; 74 76 75 ExprStmt( std::list<Label> labels, Expression *expr ); 77 76 ExprStmt( const ExprStmt &other ); … … 85 84 virtual Statement *acceptMutator( Mutator &m ) { return m.mutate( this ); } 86 85 virtual void print( std::ostream &os, int indent = 0 ) const; 87 private:88 Expression *expr;89 86 }; 90 87 91 88 class AsmStmt : public Statement { 92 89 public: 90 bool voltile; 91 ConstantExpr *instruction; 92 std::list<Expression *> output, input; 93 std::list<ConstantExpr *> clobber; 94 std::list<Label> gotolabels; 95 93 96 AsmStmt( std::list<Label> labels, bool voltile, ConstantExpr *instruction, std::list<Expression *> input, std::list<Expression *> output, std::list<ConstantExpr *> clobber, std::list<Label> gotolabels ); 94 97 AsmStmt( const AsmStmt &other ); … … 112 115 virtual Statement *acceptMutator( Mutator &m ) { return m.mutate( this ); } 113 116 virtual void print( std::ostream &os, int indent = 0 ) const; 114 private:115 bool voltile;116 ConstantExpr *instruction;117 std::list<Expression *> output, input;118 std::list<ConstantExpr *> clobber;119 std::list<Label> gotolabels;120 117 }; 121 118 122 119 class IfStmt : public Statement { 123 120 public: 121 Expression *condition; 122 Statement *thenPart; 123 Statement *elsePart; 124 124 125 IfStmt( std::list<Label> labels, Expression *condition, Statement *thenPart, Statement *elsePart ); 125 126 IfStmt( const IfStmt &other ); … … 137 138 virtual Statement *acceptMutator( Mutator &m ) { return m.mutate( this ); } 138 139 virtual void print( std::ostream &os, int indent = 0 ) const; 139 private:140 Expression *condition;141 Statement *thenPart;142 Statement *elsePart;143 140 }; 144 141 145 142 class SwitchStmt : public Statement { 146 143 public: 144 Expression * condition; 145 147 146 SwitchStmt( std::list<Label> labels, Expression *condition, std::list<Statement *> &statements ); 148 147 SwitchStmt( const SwitchStmt &other ); … … 160 159 virtual void print( std::ostream &os, int indent = 0 ) const; 161 160 private: 161 std::list<Statement *> statements; 162 }; 163 164 class CaseStmt : public Statement { 165 public: 162 166 Expression * condition; 163 std::list<Statement *> statements; 164 }; 165 166 class CaseStmt : public Statement { 167 public: 167 std::list<Statement *> stmts; 168 168 169 CaseStmt( std::list<Label> labels, Expression *conditions, std::list<Statement *> &stmts, bool isdef = false ) throw(SemanticError); 169 170 CaseStmt( const CaseStmt &other ); … … 187 188 virtual void print( std::ostream &os, int indent = 0 ) const; 188 189 private: 189 Expression * condition;190 std::list<Statement *> stmts;191 190 bool _isDefault; 192 191 }; … … 194 193 class WhileStmt : public Statement { 195 194 public: 195 Expression *condition; 196 Statement *body; 197 bool isDoWhile; 198 196 199 WhileStmt( std::list<Label> labels, Expression *condition, 197 200 Statement *body, bool isDoWhile = false ); … … 210 213 virtual Statement *acceptMutator( Mutator &m ) { return m.mutate( this ); } 211 214 virtual void print( std::ostream &os, int indent = 0 ) const; 212 private: 215 }; 216 217 class ForStmt : public Statement { 218 public: 219 std::list<Statement *> initialization; 213 220 Expression *condition; 221 Expression *increment; 214 222 Statement *body; 215 bool isDoWhile; 216 }; 217 218 class ForStmt : public Statement { 219 public: 223 220 224 ForStmt( std::list<Label> labels, std::list<Statement *> initialization, 221 225 Expression *condition = 0, Expression *increment = 0, Statement *body = 0 ); … … 236 240 virtual Statement *acceptMutator( Mutator &m ) { return m.mutate( this ); } 237 241 virtual void print( std::ostream &os, int indent = 0 ) const; 238 private:239 std::list<Statement *> initialization;240 Expression *condition;241 Expression *increment;242 Statement *body;243 242 }; 244 243 … … 246 245 public: 247 246 enum Type { Goto = 0, Break, Continue }; 247 248 // originalTarget kept for error messages. 249 const Label originalTarget; 250 Label target; 251 Expression *computedTarget; 252 Type type; 248 253 249 254 BranchStmt( std::list<Label> labels, Label target, Type ) throw (SemanticError); … … 266 271 private: 267 272 static const char *brType[]; 268 Label originalTarget; // can give better error messages if we remember the label name that the user entered269 Label target;270 Expression *computedTarget;271 Type type;272 273 }; 273 274 274 275 class ReturnStmt : public Statement { 275 276 public: 277 Expression *expr; 278 276 279 ReturnStmt( std::list<Label> labels, Expression *expr ); 277 280 ReturnStmt( const ReturnStmt &other ); … … 285 288 virtual Statement *acceptMutator( Mutator &m ) { return m.mutate( this ); } 286 289 virtual void print( std::ostream &os, int indent = 0 ) const; 287 private:288 Expression *expr;289 290 }; 290 291 … … 292 293 public: 293 294 enum Kind { Terminate, Resume }; 295 296 const Kind kind; 297 Expression * expr; 298 Expression * target; 294 299 295 300 ThrowStmt( std::list<Label> labels, Kind kind, Expression * expr, Expression * target = nullptr ); … … 307 312 virtual Statement *acceptMutator( Mutator &m ) { return m.mutate( this ); } 308 313 virtual void print( std::ostream &os, int indent = 0 ) const; 309 private:310 Kind kind;311 Expression * expr;312 Expression * target;313 314 }; 314 315 315 316 class TryStmt : public Statement { 316 317 public: 318 CompoundStmt *block; 319 std::list<CatchStmt *> handlers; 320 FinallyStmt *finallyBlock; 321 317 322 TryStmt( std::list<Label> labels, CompoundStmt *tryBlock, std::list<CatchStmt *> &handlers, FinallyStmt *finallyBlock = 0 ); 318 323 TryStmt( const TryStmt &other ); … … 330 335 virtual Statement *acceptMutator( Mutator &m ) { return m.mutate( this ); } 331 336 virtual void print( std::ostream &os, int indent = 0 ) const; 332 333 private:334 CompoundStmt *block;335 std::list<CatchStmt *> handlers;336 FinallyStmt *finallyBlock;337 337 }; 338 338 … … 340 340 public: 341 341 enum Kind { Terminate, Resume }; 342 343 const Kind kind; 344 Declaration *decl; 345 Expression *cond; 346 Statement *body; 342 347 343 348 CatchStmt( std::list<Label> labels, Kind kind, Declaration *decl, … … 358 363 virtual Statement *acceptMutator( Mutator &m ) { return m.mutate( this ); } 359 364 virtual void print( std::ostream &os, int indent = 0 ) const; 360 361 private:362 Kind kind;363 Declaration *decl;364 Expression *cond;365 Statement *body;366 365 }; 367 366 368 367 class FinallyStmt : public Statement { 369 368 public: 369 CompoundStmt *block; 370 370 371 FinallyStmt( std::list<Label> labels, CompoundStmt *block ); 371 372 FinallyStmt( const FinallyStmt &other ); … … 379 380 virtual Statement *acceptMutator( Mutator &m ) { return m.mutate( this ); } 380 381 virtual void print( std::ostream &os, int indent = 0 ) const; 381 private:382 CompoundStmt *block;383 382 }; 384 383 … … 387 386 class DeclStmt : public Statement { 388 387 public: 388 Declaration *decl; 389 389 390 DeclStmt( std::list<Label> labels, Declaration *decl ); 390 391 DeclStmt( const DeclStmt &other ); … … 398 399 virtual Statement *acceptMutator( Mutator &m ) { return m.mutate( this ); } 399 400 virtual void print( std::ostream &os, int indent = 0 ) const; 400 private:401 Declaration *decl;402 401 }; 403 402 … … 408 407 class ImplicitCtorDtorStmt : public Statement { 409 408 public: 409 // Non-owned pointer to the constructor/destructor statement 410 Statement * callStmt; 411 410 412 ImplicitCtorDtorStmt( Statement * callStmt ); 411 413 ImplicitCtorDtorStmt( const ImplicitCtorDtorStmt & other ); … … 419 421 virtual Statement *acceptMutator( Mutator &m ) { return m.mutate( this ); } 420 422 virtual void print( std::ostream &os, int indent = 0 ) const; 421 422 private:423 // Non-owned pointer to the constructor/destructor statement424 Statement * callStmt;425 423 }; 426 424 427 425 428 426 std::ostream & operator<<( std::ostream & out, const Statement * statement ); 429 430 #endif // STATEMENT_H431 427 432 428 // Local Variables: // -
src/SynTree/SynTree.h
r3d4b23fa r0720e049 10 10 // Created On : Mon May 18 07:44:20 2015 11 11 // Last Modified By : Andrew Beach 12 // Last Modified On : Thu Jun 8 17:00:00 201713 // Update Count : 912 // Last Modified On : Mon Jul 24 16:54:00 2017 13 // Update Count : 11 14 14 // 15 15 16 #ifndef SYNTREE_H 17 #define SYNTREE_H 16 #pragma once 18 17 19 18 #include <string> … … 67 66 class LabelAddressExpr; 68 67 class CastExpr; 68 class VirtualCastExpr; 69 69 class MemberExpr; 70 70 class UntypedMemberExpr; … … 135 135 class Attribute; 136 136 137 #endif // SYNTREE_H138 139 137 // Local Variables: // 140 138 // tab-width: 4 // -
src/SynTree/Type.cc
r3d4b23fa r0720e049 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 08:42:47201713 // Update Count : 2 811 // Last Modified By : Andrew Beach 12 // Last Modified On : Wed Aug 2 11:11:00 2017 13 // Update Count : 29 14 14 // 15 15 … … 88 88 } 89 89 90 // Empty Variable declarations: 91 const Type::FuncSpecifiers noFuncSpecifiers; 92 const Type::StorageClasses noStorageClasses; 93 const Type::Qualifiers noQualifiers; 94 90 95 std::ostream & operator<<( std::ostream & out, const Type * type ) { 91 96 if ( type ) { -
src/SynTree/Type.h
r3d4b23fa r0720e049 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 Mar 23 16:16:36201713 // Update Count : 1 4911 // Last Modified By : Andrew Beach 12 // Last Modified On : Wed Aug 9 14:25:00 2017 13 // Update Count : 152 14 14 // 15 15 16 #ifndef TYPE_H 17 #define TYPE_H 16 #pragma once 18 17 19 18 #include "BaseSyntaxNode.h" … … 128 127 }; // Qualifiers 129 128 129 typedef std::list<TypeDecl *> ForallList; 130 131 Qualifiers tq; 132 ForallList forall; 133 std::list< Attribute * > attributes; 134 130 135 Type( const Qualifiers & tq, const std::list< Attribute * > & attributes ); 131 136 Type( const Type & other ); … … 146 151 void set_atomic( bool newValue ) { tq.is_atomic = newValue; } 147 152 148 typedef std::list<TypeDecl *> ForallList;149 153 ForallList& get_forall() { return forall; } 150 154 … … 166 170 virtual Type *acceptMutator( Mutator & m ) = 0; 167 171 virtual void print( std::ostream & os, int indent = 0 ) const; 168 private: 169 Qualifiers tq; 170 ForallList forall; 171 std::list< Attribute * > attributes; 172 }; 173 174 extern Type::Qualifiers emptyQualifiers; // no qualifiers on constants 172 }; 173 174 extern const Type::FuncSpecifiers noFuncSpecifiers; 175 extern const Type::StorageClasses noStorageClasses; 176 extern const Type::Qualifiers noQualifiers; // no qualifiers on constants 175 177 176 178 class VoidType : public Type { … … 212 214 LongDoubleImaginary, 213 215 NUMBER_OF_BASIC_TYPES 214 } ;216 } kind; 215 217 216 218 static const char *typeNames[]; // string names for basic types, MUST MATCH with Kind … … 227 229 228 230 bool isInteger() const; 229 private:230 Kind kind;231 231 }; 232 232 233 233 class PointerType : public Type { 234 234 public: 235 Type *base; 236 237 // In C99, pointer types can be qualified in many ways e.g., int f( int a[ static 3 ] ) 238 Expression *dimension; 239 bool isVarLen; 240 bool isStatic; 241 235 242 PointerType( const Type::Qualifiers & tq, Type *base, const std::list< Attribute * > & attributes = std::list< Attribute * >() ); 236 243 PointerType( const Type::Qualifiers & tq, Type *base, Expression *dimension, bool isVarLen, bool isStatic, const std::list< Attribute * > & attributes = std::list< Attribute * >() ); … … 253 260 virtual Type *acceptMutator( Mutator & m ) { return m.mutate( this ); } 254 261 virtual void print( std::ostream & os, int indent = 0 ) const; 255 private: 262 }; 263 264 class ArrayType : public Type { 265 public: 256 266 Type *base; 257 258 // In C99, pointer types can be qualified in many ways e.g., int f( int a[ static 3 ] )259 267 Expression *dimension; 260 268 bool isVarLen; 261 269 bool isStatic; 262 }; 263 264 class ArrayType : public Type { 265 public: 270 266 271 ArrayType( const Type::Qualifiers & tq, Type *base, Expression *dimension, bool isVarLen, bool isStatic, const std::list< Attribute * > & attributes = std::list< Attribute * >() ); 267 272 ArrayType( const ArrayType& ); … … 283 288 virtual Type *acceptMutator( Mutator & m ) { return m.mutate( this ); } 284 289 virtual void print( std::ostream & os, int indent = 0 ) const; 285 private:286 Type *base;287 Expression *dimension;288 bool isVarLen;289 bool isStatic;290 290 }; 291 291 292 292 class FunctionType : public Type { 293 293 public: 294 std::list<DeclarationWithType*> returnVals; 295 std::list<DeclarationWithType*> parameters; 296 297 // Does the function accept a variable number of arguments following the arguments specified in the parameters list. 298 // This could be because of 299 // - an ellipsis in a prototype declaration 300 // - an unprototyped declaration 301 bool isVarArgs; 302 294 303 FunctionType( const Type::Qualifiers & tq, bool isVarArgs, const std::list< Attribute * > & attributes = std::list< Attribute * >() ); 295 304 FunctionType( const FunctionType& ); … … 306 315 virtual Type *acceptMutator( Mutator & m ) { return m.mutate( this ); } 307 316 virtual void print( std::ostream & os, int indent = 0 ) const; 308 private:309 std::list<DeclarationWithType*> returnVals;310 std::list<DeclarationWithType*> parameters;311 312 // Does the function accept a variable number of arguments following the arguments specified in the parameters list.313 // This could be because of314 // - an ellipsis in a prototype declaration315 // - an unprototyped declaration316 bool isVarArgs;317 317 }; 318 318 319 319 class ReferenceToType : public Type { 320 320 public: 321 std::list< Expression* > parameters; 322 std::string name; 323 bool hoistType; 324 321 325 ReferenceToType( const Type::Qualifiers & tq, const std::string & name, const std::list< Attribute * > & attributes ); 322 326 ReferenceToType( const ReferenceToType & other ); … … 337 341 protected: 338 342 virtual std::string typeString() const = 0; 339 std::list< Expression* > parameters;340 std::string name;341 private:342 bool hoistType;343 343 }; 344 344 … … 346 346 typedef ReferenceToType Parent; 347 347 public: 348 // this decl is not "owned" by the struct inst; it is merely a pointer to elsewhere in the tree, 349 // where the structure used in this type is actually defined 350 StructDecl *baseStruct; 351 348 352 StructInstType( const Type::Qualifiers & tq, const std::string & name, const std::list< Attribute * > & attributes = std::list< Attribute * >() ) : Parent( tq, name, attributes ), baseStruct( 0 ) {} 349 353 StructInstType( const Type::Qualifiers & tq, StructDecl * baseStruct, const std::list< Attribute * > & attributes = std::list< Attribute * >() ); … … 369 373 private: 370 374 virtual std::string typeString() const; 371 372 // this decl is not "owned" by the struct inst; it is merely a pointer to elsewhere in the tree,373 // where the structure used in this type is actually defined374 StructDecl *baseStruct;375 375 }; 376 376 … … 378 378 typedef ReferenceToType Parent; 379 379 public: 380 // this decl is not "owned" by the union inst; it is merely a pointer to elsewhere in the tree, 381 // where the union used in this type is actually defined 382 UnionDecl *baseUnion; 383 380 384 UnionInstType( const Type::Qualifiers & tq, const std::string & name, const std::list< Attribute * > & attributes = std::list< Attribute * >() ) : Parent( tq, name, attributes ), baseUnion( 0 ) {} 381 385 UnionInstType( const Type::Qualifiers & tq, UnionDecl * baseUnion, const std::list< Attribute * > & attributes = std::list< Attribute * >() ); … … 401 405 private: 402 406 virtual std::string typeString() const; 403 407 }; 408 409 class EnumInstType : public ReferenceToType { 410 typedef ReferenceToType Parent; 411 public: 404 412 // this decl is not "owned" by the union inst; it is merely a pointer to elsewhere in the tree, 405 413 // where the union used in this type is actually defined 406 UnionDecl *baseUnion; 407 }; 408 409 class EnumInstType : public ReferenceToType { 410 typedef ReferenceToType Parent; 411 public: 414 EnumDecl *baseEnum = nullptr; 415 412 416 EnumInstType( const Type::Qualifiers & tq, const std::string & name, const std::list< Attribute * > & attributes = std::list< Attribute * >() ) : Parent( tq, name, attributes ) {} 413 417 EnumInstType( const Type::Qualifiers & tq, EnumDecl * baseEnum, const std::list< Attribute * > & attributes = std::list< Attribute * >() ); … … 424 428 private: 425 429 virtual std::string typeString() const; 426 427 // this decl is not "owned" by the union inst; it is merely a pointer to elsewhere in the tree,428 // where the union used in this type is actually defined429 EnumDecl *baseEnum = nullptr;430 430 }; 431 431 … … 433 433 typedef ReferenceToType Parent; 434 434 public: 435 // this member is filled in by the validate pass, which instantiates the members of the correponding 436 // aggregate with the actual type parameters specified for this use of the context 437 std::list< Declaration* > members; 438 435 439 TraitInstType( const Type::Qualifiers & tq, const std::string & name, const std::list< Attribute * > & attributes = std::list< Attribute * >() ) : Parent( tq, name, attributes ) {} 436 440 TraitInstType( const TraitInstType & other ); … … 446 450 private: 447 451 virtual std::string typeString() const; 448 449 // this member is filled in by the validate pass, which instantiates the members of the correponding450 // aggregate with the actual type parameters specified for this use of the context451 std::list< Declaration* > members;452 452 }; 453 453 … … 455 455 typedef ReferenceToType Parent; 456 456 public: 457 // this decl is not "owned" by the type inst; it is merely a pointer to elsewhere in the tree, 458 // where the type used here is actually defined 459 TypeDecl *baseType; 460 bool isFtype; 461 457 462 TypeInstType( const Type::Qualifiers & tq, const std::string & name, TypeDecl *baseType, const std::list< Attribute * > & attributes = std::list< Attribute * >() ); 458 463 TypeInstType( const Type::Qualifiers & tq, const std::string & name, bool isFtype, const std::list< Attribute * > & attributes = std::list< Attribute * >() ); … … 473 478 private: 474 479 virtual std::string typeString() const; 475 // this decl is not "owned" by the type inst; it is merely a pointer to elsewhere in the tree,476 // where the type used here is actually defined477 TypeDecl *baseType;478 bool isFtype;479 480 }; 480 481 481 482 class TupleType : public Type { 482 483 public: 484 std::list<Type *> types; 485 std::list<Declaration *> members; 486 483 487 TupleType( const Type::Qualifiers & tq, const std::list< Type * > & types, const std::list< Attribute * > & attributes = std::list< Attribute * >() ); 484 488 TupleType( const TupleType& ); … … 509 513 virtual Type *acceptMutator( Mutator & m ) { return m.mutate( this ); } 510 514 virtual void print( std::ostream & os, int indent = 0 ) const; 511 private:512 std::list<Type *> types;513 std::list<Declaration *> members;514 515 }; 515 516 516 517 class TypeofType : public Type { 517 518 public: 519 Expression *expr; 520 518 521 TypeofType( const Type::Qualifiers & tq, Expression *expr, const std::list< Attribute * > & attributes = std::list< Attribute * >() ); 519 522 TypeofType( const TypeofType& ); … … 529 532 virtual Type *acceptMutator( Mutator & m ) { return m.mutate( this ); } 530 533 virtual void print( std::ostream & os, int indent = 0 ) const; 531 private: 534 }; 535 536 class AttrType : public Type { 537 public: 538 std::string name; 532 539 Expression *expr; 533 }; 534 535 class AttrType : public Type { 536 public: 540 Type *type; 541 bool isType; 542 537 543 AttrType( const Type::Qualifiers & tq, const std::string & name, Expression *expr, const std::list< Attribute * > & attributes = std::list< Attribute * >() ); 538 544 AttrType( const Type::Qualifiers & tq, const std::string & name, Type *type, const std::list< Attribute * > & attributes = std::list< Attribute * >() ); … … 555 561 virtual Type *acceptMutator( Mutator & m ) { return m.mutate( this ); } 556 562 virtual void print( std::ostream & os, int indent = 0 ) const; 557 private:558 std::string name;559 Expression *expr;560 Type *type;561 bool isType;562 563 }; 563 564 … … 601 602 602 603 std::ostream & operator<<( std::ostream & out, const Type * type ); 603 604 #endif // TYPE_H605 604 606 605 // Local Variables: // -
src/SynTree/TypeDecl.cc
r3d4b23fa r0720e049 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 Mar 16 07:49:58201713 // Update Count : 511 // Last Modified By : Andrew Beach 12 // Last Modified On : Wed Aug 9 14:35:00 2017 13 // Update Count : 6 14 14 // 15 15 … … 18 18 #include "Common/utility.h" 19 19 20 TypeDecl::TypeDecl( const std::string &name, Type::StorageClasses scs, Type *type, Kind kind, Type * init ) : Parent( name, scs, type ), kind( kind ), init( init ), sized( kind == Any || kind == Ttype) {20 TypeDecl::TypeDecl( const std::string &name, Type::StorageClasses scs, Type *type, Kind kind, Type * init ) : Parent( name, scs, type ), init( init ), sized( kind == Any || kind == Ttype ), kind( kind ) { 21 21 } 22 22 23 TypeDecl::TypeDecl( const TypeDecl &other ) : Parent( other ), kind( other.kind ), init( maybeClone( other.init ) ), sized( other.sized ) {23 TypeDecl::TypeDecl( const TypeDecl &other ) : Parent( other ), init( maybeClone( other.init ) ), sized( other.sized ), kind( other.kind ) { 24 24 } 25 25 -
src/SynTree/TypeExpr.cc
r3d4b23fa r0720e049 21 21 } 22 22 23 TypeExpr::TypeExpr( const TypeExpr &other ) : type( maybeClone( other.type ) ) {23 TypeExpr::TypeExpr( const TypeExpr &other ) : Expression( other ), type( maybeClone( other.type ) ) { 24 24 } 25 25 -
src/SynTree/TypeSubstitution.h
r3d4b23fa r0720e049 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 : Fri Apr 29 15:00:20 201613 // Update Count : 211 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Sat Jul 22 09:52:24 2017 13 // Update Count : 3 14 14 // 15 15 16 #ifndef TYPESUBSTITUTION_H 17 #define TYPESUBSTITUTION_H 16 #pragma once 18 17 19 18 #include <map> … … 180 179 std::ostream & operator<<( std::ostream & out, const TypeSubstitution & sub ); 181 180 182 #endif // TYPESUBSTITUTION_H183 184 181 // Local Variables: // 185 182 // tab-width: 4 // -
src/SynTree/VarExprReplacer.h
r3d4b23fa r0720e049 9 9 // Author : Rob Schluntz 10 10 // Created On : Wed Jan 13 16:29:30 2016 11 // Last Modified By : Rob Schluntz12 // Last Modified On : Fri May 13 11:27:52 201613 // Update Count : 511 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Sat Jul 22 09:53:41 2017 13 // Update Count : 6 14 14 // 15 15 16 #ifndef VAR_EXPR_REPLACER_H 17 #define VAR_EXPR_REPLACER_H 16 #pragma once 18 17 19 18 #include <map> … … 35 34 }; 36 35 37 #endif // VAR_EXPR_REPLACER_H38 39 36 // Local Variables: // 40 37 // tab-width: 4 // -
src/SynTree/Visitor.cc
r3d4b23fa r0720e049 10 10 // Created On : Mon May 18 07:44:20 2015 11 11 // Last Modified By : Andrew Beach 12 // Last Modified On : Thu Jun 22 13:41:00 201713 // Update Count : 2 612 // Last Modified On : Mon Jul 24 16:30:00 2017 13 // Update Count : 27 14 14 // 15 15 … … 192 192 } 193 193 194 void Visitor::visit( VirtualCastExpr *castExpr ) { 195 maybeAccept( castExpr->get_result(), *this ); 196 maybeAccept( castExpr->get_arg(), *this ); 197 } 198 194 199 void Visitor::visit( UntypedMemberExpr *memberExpr ) { 195 200 maybeAccept( memberExpr->get_result(), *this ); -
src/SynTree/Visitor.h
r3d4b23fa r0720e049 10 10 // Created On : Mon May 18 07:44:20 2015 11 11 // Last Modified By : Andrew Beach 12 // Last Modified On : Thr Jun 08 15:45:00 201713 // Update Count : 1 112 // Last Modified On : Mon Jul 24 16:28:00 2017 13 // Update Count : 13 14 14 // 15 15 16 #ifndef VISITOR_H 17 #define VISITOR_H 16 #pragma once 18 17 19 18 #include "SynTree.h" … … 61 60 virtual void visit( NameExpr *nameExpr ); 62 61 virtual void visit( CastExpr *castExpr ); 62 virtual void visit( VirtualCastExpr *castExpr ); 63 63 virtual void visit( AddressExpr *addressExpr ); 64 64 virtual void visit( LabelAddressExpr *labAddressExpr ); … … 174 174 } 175 175 176 #endif // VISITOR_H177 178 176 // Local Variables: // 179 177 // tab-width: 4 //
Note:
See TracChangeset
for help on using the changeset viewer.