Changeset 9b4f329 for src/InitTweak
- Timestamp:
- May 16, 2019, 6:46:51 PM (6 years ago)
- Branches:
- ADT, arm-eh, ast-experimental, cleanup-dtors, enum, forall-pointer-decay, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr, pthread-emulation, qualifiedEnum
- Children:
- 246c245
- Parents:
- f3cc5b6
- Location:
- src/InitTweak
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
src/InitTweak/InitTweak.cc
rf3cc5b6 r9b4f329 5 5 #include <memory> // for __shared_ptr 6 6 7 #include "AST/Expr.hpp" 8 #include "AST/Stmt.hpp" 7 9 #include "AST/Type.hpp" 8 10 #include "Common/PassVisitor.h" … … 27 29 #include "Tuples/Tuples.h" // for Tuples::isTtype 28 30 29 class UntypedValofExpr;30 31 31 namespace InitTweak { 32 32 namespace { … … 433 433 assert( false ); 434 434 } 435 436 // template<typename CallExpr> 437 // const ast::Expr * callArg( const CallExpr * call, unsigned int pos ) { 438 // if( pos >= call->args.size() ) { 439 // assertf( false, "getCallArg for argument that doesn't exist: (%u); %s.", 440 // pos, toString( call ).c_str() ); 441 // } 442 // for ( const ast::Expr * arg : call->args ) { 443 // if ( pos == 0 ) return arg; 444 // --pos; 445 // } 446 // assert( false ); 447 // } 435 448 } 436 449 … … 452 465 assertf( false, "Unexpected expression type passed to getCallArg: %s", toString( callExpr ).c_str() ); 453 466 } 467 } 468 const ast::Expr * getCallArg( const ast::Expr * call, unsigned pos ) { 469 assert(!"implemented; needs to build AST/Expr.cpp"); 470 // if ( auto app = dynamic_cast< const ast::ApplicationExpr * >( call ) ) { 471 // return callArg( app, pos ); 472 // } else if ( auto untyped = dynamic_cast< const ast::UntypedExpr * >( call ) ) { 473 // return callArg( untyped, pos ); 474 // } else if ( auto tupleAssn = dynamic_cast< const ast::TupleAssignExpr * >( call ) ) { 475 // const std::list<ast::ptr<ast::Stmt>>& stmts = tupleAssn->stmtExpr->stmts->kids; 476 // assertf( ! stmts.empty(), "TupleAssignExpr missing statements." ); 477 // const ExprStmt * stmt = strict_dynamic_cast< const ast::ExprStmt * >( stmts.back() ); 478 // const TupleExpr * tuple = strict_dynamic_cast< const ast::TupleExpr * >( stmt->expr ); 479 // assertf( ! tuple->exprs.empty(), "TupleAssignExpr has empty tuple expr."); 480 // return getCallArg( tuple->exprs.front(), pos ); 481 // } else if ( auto ctor = dynamic_cast< const ast::ImplicitCopyCtorExpr * >( call ) ) { 482 // return getCallArg( ctor->callExpr, pos ); 483 // } else { 484 // assertf( false, "Unexpected expression type passed to getCallArg: %s", 485 // toString( call ).c_str() ); 486 // } 454 487 } 455 488 … … 516 549 const ast::Type* getPointerBase( const ast::Type* t ) { 517 550 assert(!"needs to build Type.cpp before inclusion"); 518 // if ( const a st::PointerType* p = dynamic_cast< const ast::PointerType* >( t ) ) {551 // if ( const auto * p = dynamic_cast< const ast::PointerType * >( t ) ) { 519 552 // return p->base; 520 // } else if ( const a st::ArrayType* a = dynamic_cast< const ast::ArrayType* >( t ) ) {553 // } else if ( const auto * a = dynamic_cast< const ast::ArrayType * >( t ) ) { 521 554 // return a->base; 522 // } else if ( const a st::ReferenceType* r = dynamic_cast< const ast::ReferenceType* >( t ) ) {555 // } else if ( const auto * r = dynamic_cast< const ast::ReferenceType * >( t ) ) { 523 556 // return r->base; 524 557 // } else return nullptr; -
src/InitTweak/InitTweak.h
rf3cc5b6 r9b4f329 81 81 /// returns the argument to a call expression in position N indexed from 0 82 82 Expression *& getCallArg( Expression * callExpr, unsigned int pos ); 83 const ast::Expr * getCallArg( const ast::Expr * call, unsigned pos ); 83 84 84 85 /// returns the base type of a PointerType or ArrayType, else returns NULL
Note:
See TracChangeset
for help on using the changeset viewer.