Changeset 2162c2c for src/SynTree
- Timestamp:
- Jan 11, 2017, 4:11:02 PM (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:
- 075734f
- Parents:
- bb82c03 (diff), d3a85240 (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:
-
- 18 edited
-
ApplicationExpr.cc (modified) (4 diffs)
-
Declaration.cc (modified) (1 diff)
-
Declaration.h (modified) (1 diff)
-
Expression.cc (modified) (1 diff)
-
Expression.h (modified) (3 diffs)
-
FunctionType.cc (modified) (3 diffs)
-
Mutator.cc (modified) (33 diffs)
-
Mutator.h (modified) (1 diff)
-
Statement.cc (modified) (1 diff)
-
SynTree.h (modified) (1 diff)
-
TupleExpr.cc (modified) (2 diffs)
-
Type.cc (modified) (1 diff)
-
Type.h (modified) (1 diff)
-
TypeDecl.cc (modified) (2 diffs)
-
TypeSubstitution.cc (modified) (1 diff)
-
TypeSubstitution.h (modified) (1 diff)
-
Visitor.cc (modified) (2 diffs)
-
Visitor.h (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
src/SynTree/ApplicationExpr.cc
rbb82c03 r2162c2c 24 24 25 25 ParamEntry::ParamEntry( const ParamEntry &other ) : 26 decl( other.decl ), actualType( maybeClone( other.actualType ) ), formalType( maybeClone( other.formalType ) ), expr( maybeClone( other.expr ) ) {26 decl( other.decl ), actualType( maybeClone( other.actualType ) ), formalType( maybeClone( other.formalType ) ), expr( maybeClone( other.expr ) ), inferParams( new InferredParams( *other.inferParams ) ) { 27 27 } 28 28 … … 34 34 formalType = maybeClone( other.formalType ); 35 35 expr = maybeClone( other.expr ); 36 *inferParams = *other.inferParams; 36 37 return *this; 37 38 } … … 62 63 } 63 64 65 void printInferParams( const InferredParams & inferParams, std::ostream &os, int indent, int level ) { 66 if ( ! inferParams.empty() ) { 67 os << std::string(indent, ' ') << "with inferred parameters " << level << ":" << std::endl; 68 for ( InferredParams::const_iterator i = inferParams.begin(); i != inferParams.end(); ++i ) { 69 os << std::string(indent+2, ' '); 70 Declaration::declFromId( i->second.decl )->printShort( os, indent+2 ); 71 os << std::endl; 72 printInferParams( *i->second.inferParams, os, indent+2, level+1 ); 73 } // for 74 } // if 75 } 76 64 77 void ApplicationExpr::print( std::ostream &os, int indent ) const { 65 78 os << "Application of" << std::endl << std::string(indent+2, ' '); … … 69 82 printAll( args, os, indent+2 ); 70 83 } // if 71 if ( ! inferParams.empty() ) { 72 os << std::string(indent, ' ') << "with inferred parameters:" << std::endl; 73 for ( InferredParams::const_iterator i = inferParams.begin(); i != inferParams.end(); ++i ) { 74 os << std::string(indent+2, ' '); 75 Declaration::declFromId( i->second.decl )->printShort( os, indent+2 ); 76 os << std::endl; 77 } // for 78 } // if 84 printInferParams( inferParams, os, indent+2, 0 ); 79 85 Expression::print( os, indent ); 80 86 } -
src/SynTree/Declaration.cc
rbb82c03 r2162c2c 57 57 58 58 std::ostream & operator<<( std::ostream & out, const Declaration * decl ) { 59 decl->print( out ); 59 if ( decl ){ 60 decl->print( out ); 61 } else { 62 out << "nullptr"; 63 } 60 64 return out; 61 65 } -
src/SynTree/Declaration.h
rbb82c03 r2162c2c 179 179 typedef NamedTypeDecl Parent; 180 180 public: 181 enum Kind { Any, Dtype, Ftype };181 enum Kind { Any, Dtype, Ftype, Ttype }; 182 182 /// Data extracted from a type decl 183 183 struct Data { -
src/SynTree/Expression.cc
rbb82c03 r2162c2c 672 672 673 673 std::ostream & operator<<( std::ostream & out, const Expression * expr ) { 674 expr->print( out ); 674 if ( expr ) { 675 expr->print( out ); 676 } else { 677 out << "nullptr"; 678 } 675 679 return out; 676 680 } -
src/SynTree/Expression.h
rbb82c03 r2162c2c 54 54 }; 55 55 56 struct ParamEntry; 57 typedef std::map< UniqueId, ParamEntry > InferredParams; 58 56 59 /// ParamEntry contains the i.d. of a declaration and a type that is derived from that declaration, 57 60 /// but subject to decay-to-pointer and type parameter renaming 58 61 struct ParamEntry { 59 ParamEntry(): decl( 0 ), actualType( 0 ), formalType( 0 ), expr( 0 ) {}60 ParamEntry( UniqueId decl, Type *actualType, Type *formalType, Expression* expr ): decl( decl ), actualType( actualType ), formalType( formalType ), expr( expr ) {}62 ParamEntry(): decl( 0 ), actualType( 0 ), formalType( 0 ), expr( 0 ), inferParams( new InferredParams ) {} 63 ParamEntry( UniqueId decl, Type *actualType, Type *formalType, Expression* expr ): decl( decl ), actualType( actualType ), formalType( formalType ), expr( expr ), inferParams( new InferredParams ) {} 61 64 ParamEntry( const ParamEntry &other ); 62 65 ~ParamEntry(); … … 67 70 Type *formalType; 68 71 Expression* expr; 69 }; 70 71 typedef std::map< UniqueId, ParamEntry > InferredParams; 72 std::unique_ptr< InferredParams > inferParams; 73 }; 72 74 73 75 /// ApplicationExpr represents the application of a function to a set of parameters. This is the result of running an … … 634 636 }; 635 637 638 /// UntypedTupleExpr represents a tuple expression ( [a, b, c] ) before resolution 639 class UntypedTupleExpr : public Expression { 640 public: 641 UntypedTupleExpr( const std::list< Expression * > & exprs, Expression *_aname = nullptr ); 642 UntypedTupleExpr( const UntypedTupleExpr &other ); 643 virtual ~UntypedTupleExpr(); 644 645 std::list<Expression*>& get_exprs() { return exprs; } 646 647 virtual UntypedTupleExpr *clone() const { return new UntypedTupleExpr( *this ); } 648 virtual void accept( Visitor &v ) { v.visit( this ); } 649 virtual Expression *acceptMutator( Mutator &m ) { return m.mutate( this ); } 650 virtual void print( std::ostream &os, int indent = 0 ) const; 651 private: 652 std::list<Expression*> exprs; 653 }; 654 636 655 /// TupleExpr represents a tuple expression ( [a, b, c] ) 637 656 class TupleExpr : public Expression { 638 657 public: 639 TupleExpr( const std::list< Expression * > & exprs = std::list< Expression * >(), Expression *_aname = nullptr );658 TupleExpr( const std::list< Expression * > & exprs, Expression *_aname = nullptr ); 640 659 TupleExpr( const TupleExpr &other ); 641 660 virtual ~TupleExpr(); 642 661 643 void set_exprs( std::list<Expression*> newValue ) { exprs = newValue; }644 662 std::list<Expression*>& get_exprs() { return exprs; } 645 663 -
src/SynTree/FunctionType.cc
rbb82c03 r2162c2c 5 5 // file "LICENCE" distributed with Cforall. 6 6 // 7 // FunctionType.cc -- 7 // FunctionType.cc -- 8 8 // 9 9 // Author : Richard C. Bilson … … 19 19 #include "Declaration.h" 20 20 #include "Common/utility.h" 21 #include "Tuples/Tuples.h" 21 22 22 23 FunctionType::FunctionType( const Type::Qualifiers &tq, bool isVarArgs ) : Type( tq ), isVarArgs( isVarArgs ) { … … 31 32 deleteAll( returnVals ); 32 33 deleteAll( parameters ); 34 } 35 36 namespace { 37 bool containsTtype( const std::list<DeclarationWithType * > & l ) { 38 if ( ! l.empty() ) { 39 return Tuples::isTtype( l.back()->get_type() ); 40 } 41 return false; 42 } 43 } 44 45 bool FunctionType::isTtype() const { 46 return containsTtype( returnVals ) || containsTtype( parameters ); 33 47 } 34 48 -
src/SynTree/Mutator.cc
rbb82c03 r2162c2c 23 23 #include "Constant.h" 24 24 #include "Common/utility.h" 25 #include "TypeSubstitution.h" 25 26 26 27 Mutator::Mutator() {} … … 178 179 179 180 Expression *Mutator::mutate( ApplicationExpr *applicationExpr ) { 181 applicationExpr->set_env( maybeMutate( applicationExpr->get_env(), *this ) ); 180 182 applicationExpr->set_result( maybeMutate( applicationExpr->get_result(), *this ) ); 181 183 applicationExpr->set_function( maybeMutate( applicationExpr->get_function(), *this ) ); … … 185 187 186 188 Expression *Mutator::mutate( UntypedExpr *untypedExpr ) { 189 untypedExpr->set_env( maybeMutate( untypedExpr->get_env(), *this ) ); 187 190 untypedExpr->set_result( maybeMutate( untypedExpr->get_result(), *this ) ); 188 191 mutateAll( untypedExpr->get_args(), *this ); … … 191 194 192 195 Expression *Mutator::mutate( NameExpr *nameExpr ) { 196 nameExpr->set_env( maybeMutate( nameExpr->get_env(), *this ) ); 193 197 nameExpr->set_result( maybeMutate( nameExpr->get_result(), *this ) ); 194 198 return nameExpr; … … 196 200 197 201 Expression *Mutator::mutate( AddressExpr *addressExpr ) { 202 addressExpr->set_env( maybeMutate( addressExpr->get_env(), *this ) ); 198 203 addressExpr->set_result( maybeMutate( addressExpr->get_result(), *this ) ); 199 204 addressExpr->set_arg( maybeMutate( addressExpr->get_arg(), *this ) ); … … 202 207 203 208 Expression *Mutator::mutate( LabelAddressExpr *labelAddressExpr ) { 209 labelAddressExpr->set_env( maybeMutate( labelAddressExpr->get_env(), *this ) ); 204 210 labelAddressExpr->set_result( maybeMutate( labelAddressExpr->get_result(), *this ) ); 205 211 labelAddressExpr->set_arg( maybeMutate( labelAddressExpr->get_arg(), *this ) ); … … 208 214 209 215 Expression *Mutator::mutate( CastExpr *castExpr ) { 216 castExpr->set_env( maybeMutate( castExpr->get_env(), *this ) ); 210 217 castExpr->set_result( maybeMutate( castExpr->get_result(), *this ) ); 211 218 castExpr->set_arg( maybeMutate( castExpr->get_arg(), *this ) ); … … 214 221 215 222 Expression *Mutator::mutate( UntypedMemberExpr *memberExpr ) { 223 memberExpr->set_env( maybeMutate( memberExpr->get_env(), *this ) ); 216 224 memberExpr->set_result( maybeMutate( memberExpr->get_result(), *this ) ); 217 225 memberExpr->set_aggregate( maybeMutate( memberExpr->get_aggregate(), *this ) ); … … 221 229 222 230 Expression *Mutator::mutate( MemberExpr *memberExpr ) { 231 memberExpr->set_env( maybeMutate( memberExpr->get_env(), *this ) ); 223 232 memberExpr->set_result( maybeMutate( memberExpr->get_result(), *this ) ); 224 233 memberExpr->set_aggregate( maybeMutate( memberExpr->get_aggregate(), *this ) ); … … 227 236 228 237 Expression *Mutator::mutate( VariableExpr *variableExpr ) { 238 variableExpr->set_env( maybeMutate( variableExpr->get_env(), *this ) ); 229 239 variableExpr->set_result( maybeMutate( variableExpr->get_result(), *this ) ); 230 240 return variableExpr; … … 232 242 233 243 Expression *Mutator::mutate( ConstantExpr *constantExpr ) { 244 constantExpr->set_env( maybeMutate( constantExpr->get_env(), *this ) ); 234 245 constantExpr->set_result( maybeMutate( constantExpr->get_result(), *this ) ); 235 246 // maybeMutate( constantExpr->get_constant(), *this ) … … 238 249 239 250 Expression *Mutator::mutate( SizeofExpr *sizeofExpr ) { 251 sizeofExpr->set_env( maybeMutate( sizeofExpr->get_env(), *this ) ); 240 252 sizeofExpr->set_result( maybeMutate( sizeofExpr->get_result(), *this ) ); 241 253 if ( sizeofExpr->get_isType() ) { … … 248 260 249 261 Expression *Mutator::mutate( AlignofExpr *alignofExpr ) { 262 alignofExpr->set_env( maybeMutate( alignofExpr->get_env(), *this ) ); 250 263 alignofExpr->set_result( maybeMutate( alignofExpr->get_result(), *this ) ); 251 264 if ( alignofExpr->get_isType() ) { … … 258 271 259 272 Expression *Mutator::mutate( UntypedOffsetofExpr *offsetofExpr ) { 273 offsetofExpr->set_env( maybeMutate( offsetofExpr->get_env(), *this ) ); 260 274 offsetofExpr->set_result( maybeMutate( offsetofExpr->get_result(), *this ) ); 261 275 offsetofExpr->set_type( maybeMutate( offsetofExpr->get_type(), *this ) ); … … 264 278 265 279 Expression *Mutator::mutate( OffsetofExpr *offsetofExpr ) { 280 offsetofExpr->set_env( maybeMutate( offsetofExpr->get_env(), *this ) ); 266 281 offsetofExpr->set_result( maybeMutate( offsetofExpr->get_result(), *this ) ); 267 282 offsetofExpr->set_type( maybeMutate( offsetofExpr->get_type(), *this ) ); … … 271 286 272 287 Expression *Mutator::mutate( OffsetPackExpr *offsetPackExpr ) { 288 offsetPackExpr->set_env( maybeMutate( offsetPackExpr->get_env(), *this ) ); 273 289 offsetPackExpr->set_result( maybeMutate( offsetPackExpr->get_result(), *this ) ); 274 290 offsetPackExpr->set_type( maybeMutate( offsetPackExpr->get_type(), *this ) ); … … 277 293 278 294 Expression *Mutator::mutate( AttrExpr *attrExpr ) { 295 attrExpr->set_env( maybeMutate( attrExpr->get_env(), *this ) ); 279 296 attrExpr->set_result( maybeMutate( attrExpr->get_result(), *this ) ); 280 297 if ( attrExpr->get_isType() ) { … … 287 304 288 305 Expression *Mutator::mutate( LogicalExpr *logicalExpr ) { 306 logicalExpr->set_env( maybeMutate( logicalExpr->get_env(), *this ) ); 289 307 logicalExpr->set_result( maybeMutate( logicalExpr->get_result(), *this ) ); 290 308 logicalExpr->set_arg1( maybeMutate( logicalExpr->get_arg1(), *this ) ); … … 294 312 295 313 Expression *Mutator::mutate( ConditionalExpr *conditionalExpr ) { 314 conditionalExpr->set_env( maybeMutate( conditionalExpr->get_env(), *this ) ); 296 315 conditionalExpr->set_result( maybeMutate( conditionalExpr->get_result(), *this ) ); 297 316 conditionalExpr->set_arg1( maybeMutate( conditionalExpr->get_arg1(), *this ) ); … … 302 321 303 322 Expression *Mutator::mutate( CommaExpr *commaExpr ) { 323 commaExpr->set_env( maybeMutate( commaExpr->get_env(), *this ) ); 304 324 commaExpr->set_result( maybeMutate( commaExpr->get_result(), *this ) ); 305 325 commaExpr->set_arg1( maybeMutate( commaExpr->get_arg1(), *this ) ); … … 309 329 310 330 Expression *Mutator::mutate( TypeExpr *typeExpr ) { 331 typeExpr->set_env( maybeMutate( typeExpr->get_env(), *this ) ); 311 332 typeExpr->set_result( maybeMutate( typeExpr->get_result(), *this ) ); 312 333 typeExpr->set_type( maybeMutate( typeExpr->get_type(), *this ) ); … … 315 336 316 337 Expression *Mutator::mutate( AsmExpr *asmExpr ) { 338 asmExpr->set_env( maybeMutate( asmExpr->get_env(), *this ) ); 317 339 asmExpr->set_inout( maybeMutate( asmExpr->get_inout(), *this ) ); 318 340 asmExpr->set_constraint( maybeMutate( asmExpr->get_constraint(), *this ) ); … … 322 344 323 345 Expression* Mutator::mutate( ImplicitCopyCtorExpr *impCpCtorExpr ) { 346 impCpCtorExpr->set_env( maybeMutate( impCpCtorExpr->get_env(), *this ) ); 347 impCpCtorExpr->set_result( maybeMutate( impCpCtorExpr->get_result(), *this ) ); 324 348 impCpCtorExpr->set_callExpr( maybeMutate( impCpCtorExpr->get_callExpr(), *this ) ); 325 349 mutateAll( impCpCtorExpr->get_tempDecls(), *this ); … … 330 354 331 355 Expression* Mutator::mutate( ConstructorExpr *ctorExpr ) { 356 ctorExpr->set_env( maybeMutate( ctorExpr->get_env(), *this ) ); 332 357 ctorExpr->set_result( maybeMutate( ctorExpr->get_result(), *this ) ); 333 358 ctorExpr->set_callExpr( maybeMutate( ctorExpr->get_callExpr(), *this ) ); … … 336 361 337 362 Expression *Mutator::mutate( CompoundLiteralExpr *compLitExpr ) { 363 compLitExpr->set_env( maybeMutate( compLitExpr->get_env(), *this ) ); 338 364 compLitExpr->set_result( maybeMutate( compLitExpr->get_result(), *this ) ); 339 365 compLitExpr->set_type( maybeMutate( compLitExpr->get_type(), *this ) ); … … 343 369 344 370 Expression *Mutator::mutate( UntypedValofExpr *valofExpr ) { 371 valofExpr->set_env( maybeMutate( valofExpr->get_env(), *this ) ); 345 372 valofExpr->set_result( maybeMutate( valofExpr->get_result(), *this ) ); 346 373 return valofExpr; … … 348 375 349 376 Expression *Mutator::mutate( RangeExpr *rangeExpr ) { 377 rangeExpr->set_env( maybeMutate( rangeExpr->get_env(), *this ) ); 350 378 rangeExpr->set_low( maybeMutate( rangeExpr->get_low(), *this ) ); 351 379 rangeExpr->set_high( maybeMutate( rangeExpr->get_high(), *this ) ); … … 353 381 } 354 382 355 Expression *Mutator::mutate( TupleExpr *tupleExpr ) { 383 Expression *Mutator::mutate( UntypedTupleExpr *tupleExpr ) { 384 tupleExpr->set_env( maybeMutate( tupleExpr->get_env(), *this ) ); 356 385 tupleExpr->set_result( maybeMutate( tupleExpr->get_result(), *this ) ); 357 386 mutateAll( tupleExpr->get_exprs(), *this ); … … 359 388 } 360 389 390 Expression *Mutator::mutate( TupleExpr *tupleExpr ) { 391 tupleExpr->set_env( maybeMutate( tupleExpr->get_env(), *this ) ); 392 tupleExpr->set_result( maybeMutate( tupleExpr->get_result(), *this ) ); 393 mutateAll( tupleExpr->get_exprs(), *this ); 394 return tupleExpr; 395 } 396 361 397 Expression *Mutator::mutate( TupleIndexExpr *tupleExpr ) { 398 tupleExpr->set_env( maybeMutate( tupleExpr->get_env(), *this ) ); 362 399 tupleExpr->set_result( maybeMutate( tupleExpr->get_result(), *this ) ); 363 400 tupleExpr->set_tuple( maybeMutate( tupleExpr->get_tuple(), *this ) ); … … 366 403 367 404 Expression *Mutator::mutate( MemberTupleExpr *tupleExpr ) { 405 tupleExpr->set_env( maybeMutate( tupleExpr->get_env(), *this ) ); 368 406 tupleExpr->set_result( maybeMutate( tupleExpr->get_result(), *this ) ); 369 407 tupleExpr->set_member( maybeMutate( tupleExpr->get_member(), *this ) ); … … 373 411 374 412 Expression *Mutator::mutate( TupleAssignExpr *assignExpr ) { 413 assignExpr->set_env( maybeMutate( assignExpr->get_env(), *this ) ); 375 414 assignExpr->set_result( maybeMutate( assignExpr->get_result(), *this ) ); 376 415 assignExpr->set_stmtExpr( maybeMutate( assignExpr->get_stmtExpr(), *this ) ); … … 379 418 380 419 Expression *Mutator::mutate( StmtExpr *stmtExpr ) { 420 stmtExpr->set_env( maybeMutate( stmtExpr->get_env(), *this ) ); 381 421 stmtExpr->set_result( maybeMutate( stmtExpr->get_result(), *this ) ); 382 422 stmtExpr->set_statements( maybeMutate( stmtExpr->get_statements(), *this ) ); … … 387 427 388 428 Expression *Mutator::mutate( UniqueExpr *uniqueExpr ) { 429 uniqueExpr->set_env( maybeMutate( uniqueExpr->get_env(), *this ) ); 389 430 uniqueExpr->set_result( maybeMutate( uniqueExpr->get_result(), *this ) ); 390 431 uniqueExpr->set_expr( maybeMutate( uniqueExpr->get_expr(), *this ) ); -
src/SynTree/Mutator.h
rbb82c03 r2162c2c 78 78 virtual Expression* mutate( UntypedValofExpr *valofExpr ); 79 79 virtual Expression* mutate( RangeExpr *rangeExpr ); 80 virtual Expression* mutate( UntypedTupleExpr *tupleExpr ); 80 81 virtual Expression* mutate( TupleExpr *tupleExpr ); 81 82 virtual Expression* mutate( TupleIndexExpr *tupleExpr ); -
src/SynTree/Statement.cc
rbb82c03 r2162c2c 388 388 389 389 std::ostream & operator<<( std::ostream & out, const Statement * statement ) { 390 statement->print( out ); 390 if ( statement ) { 391 statement->print( out ); 392 } else { 393 out << "nullptr"; 394 } 391 395 return out; 392 396 } -
src/SynTree/SynTree.h
rbb82c03 r2162c2c 83 83 class UntypedValofExpr; 84 84 class RangeExpr; 85 class UntypedTupleExpr; 85 86 class TupleExpr; 86 87 class TupleIndexExpr; -
src/SynTree/TupleExpr.cc
rbb82c03 r2162c2c 21 21 #include "VarExprReplacer.h" 22 22 23 UntypedTupleExpr::UntypedTupleExpr( const std::list< Expression * > & exprs, Expression *_aname ) : Expression( _aname ), exprs( exprs ) { 24 } 25 26 UntypedTupleExpr::UntypedTupleExpr( const UntypedTupleExpr &other ) : Expression( other ) { 27 cloneAll( other.exprs, exprs ); 28 } 29 30 UntypedTupleExpr::~UntypedTupleExpr() { 31 deleteAll( exprs ); 32 } 33 34 void UntypedTupleExpr::print( std::ostream &os, int indent ) const { 35 os << "Untyped Tuple:" << std::endl; 36 printAll( exprs, os, indent+2 ); 37 Expression::print( os, indent ); 38 } 39 23 40 TupleExpr::TupleExpr( const std::list< Expression * > & exprs, Expression *_aname ) : Expression( _aname ), exprs( exprs ) { 24 if ( ! exprs.empty() ) { 25 if ( std::all_of( exprs.begin(), exprs.end(), [](Expression * expr) { return expr->get_result(); } ) ) { 26 set_result( Tuples::makeTupleType( exprs ) ); 27 } 28 } 41 set_result( Tuples::makeTupleType( exprs ) ); 29 42 } 30 43 … … 45 58 TupleIndexExpr::TupleIndexExpr( Expression * tuple, unsigned int index ) : tuple( tuple ), index( index ) { 46 59 TupleType * type = safe_dynamic_cast< TupleType * >( tuple->get_result() ); 47 assert ( type->size() > index);60 assertf( type->size() > index, "TupleIndexExpr index out of bounds: tuple size %d, requested index %d in expr %s", type->size(), index, toString( tuple ).c_str() ); 48 61 set_result( (*std::next( type->get_types().begin(), index ))->clone() ); 49 62 get_result()->set_isLvalue( type->get_isLvalue() ); -
src/SynTree/Type.cc
rbb82c03 r2162c2c 85 85 86 86 std::ostream & operator<<( std::ostream & out, const Type * type ) { 87 type->print( out ); 87 if ( type ) { 88 type->print( out ); 89 } else { 90 out << "nullptr"; 91 } 88 92 return out; 89 93 } -
src/SynTree/Type.h
rbb82c03 r2162c2c 204 204 std::list<DeclarationWithType*> & get_returnVals() { return returnVals; } 205 205 std::list<DeclarationWithType*> & get_parameters() { return parameters; } 206 bool get_isVarArgs() { return isVarArgs; }206 bool get_isVarArgs() const { return isVarArgs; } 207 207 void set_isVarArgs( bool newValue ) { isVarArgs = newValue; } 208 209 bool isTtype() const; 208 210 209 211 virtual FunctionType *clone() const { return new FunctionType( *this ); } -
src/SynTree/TypeDecl.cc
rbb82c03 r2162c2c 18 18 #include "Common/utility.h" 19 19 20 TypeDecl::TypeDecl( const std::string &name, DeclarationNode::StorageClass sc, Type *type, Kind kind ) : Parent( name, sc, type ), kind( kind ), sized( kind == Any ) {20 TypeDecl::TypeDecl( const std::string &name, DeclarationNode::StorageClass sc, Type *type, Kind kind ) : Parent( name, sc, type ), kind( kind ), sized( kind == Any || kind == Ttype ) { 21 21 } 22 22 … … 25 25 26 26 std::string TypeDecl::typeString() const { 27 static const char *kindNames[] = { "type", "incomplete type", "function type" };27 static const char *kindNames[] = { "type", "incomplete type", "function type", "tuple type" }; 28 28 return kindNames[ kind ]; 29 29 } -
src/SynTree/TypeSubstitution.cc
rbb82c03 r2162c2c 231 231 } 232 232 233 TypeSubstitution * TypeSubstitution::acceptMutator( Mutator & mutator ) { 234 for ( auto & p : typeEnv ) { 235 p.second = maybeMutate( p.second, mutator ); 236 } 237 for ( auto & p : varEnv ) { 238 p.second = maybeMutate( p.second, mutator ); 239 } 240 return this; 241 } 242 233 243 void TypeSubstitution::print( std::ostream &os, int indent ) const { 234 244 os << std::string( indent, ' ' ) << "Types:" << std::endl; -
src/SynTree/TypeSubstitution.h
rbb82c03 r2162c2c 53 53 54 54 void normalize(); 55 56 TypeSubstitution * acceptMutator( Mutator & mutator ); 55 57 56 58 void print( std::ostream &os, int indent = 0 ) const; -
src/SynTree/Visitor.cc
rbb82c03 r2162c2c 273 273 274 274 void Visitor::visit( ImplicitCopyCtorExpr *impCpCtorExpr ) { 275 maybeAccept( impCpCtorExpr->get_result(), *this ); 275 276 maybeAccept( impCpCtorExpr->get_callExpr(), *this ); 276 277 acceptAll( impCpCtorExpr->get_tempDecls(), *this ); … … 298 299 maybeAccept( rangeExpr->get_low(), *this ); 299 300 maybeAccept( rangeExpr->get_high(), *this ); 301 } 302 303 void Visitor::visit( UntypedTupleExpr *tupleExpr ) { 304 maybeAccept( tupleExpr->get_result(), *this ); 305 acceptAll( tupleExpr->get_exprs(), *this ); 300 306 } 301 307 -
src/SynTree/Visitor.h
rbb82c03 r2162c2c 78 78 virtual void visit( UntypedValofExpr *valofExpr ); 79 79 virtual void visit( RangeExpr *rangeExpr ); 80 virtual void visit( UntypedTupleExpr *tupleExpr ); 80 81 virtual void visit( TupleExpr *tupleExpr ); 81 82 virtual void visit( TupleIndexExpr *tupleExpr );
Note:
See TracChangeset
for help on using the changeset viewer.