Changeset 9b4f329 for src/InitTweak


Ignore:
Timestamp:
May 16, 2019, 6:46:51 PM (6 years ago)
Author:
Aaron Moss <a3moss@…>
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
Message:

Finished porting AST::Expr subclasses

Location:
src/InitTweak
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • src/InitTweak/InitTweak.cc

    rf3cc5b6 r9b4f329  
    55#include <memory>                  // for __shared_ptr
    66
     7#include "AST/Expr.hpp"
     8#include "AST/Stmt.hpp"
    79#include "AST/Type.hpp"
    810#include "Common/PassVisitor.h"
     
    2729#include "Tuples/Tuples.h"         // for Tuples::isTtype
    2830
    29 class UntypedValofExpr;
    30 
    3131namespace InitTweak {
    3232        namespace {
     
    433433                        assert( false );
    434434                }
     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                // }
    435448        }
    436449
     
    452465                        assertf( false, "Unexpected expression type passed to getCallArg: %s", toString( callExpr ).c_str() );
    453466                }
     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                // }
    454487        }
    455488
     
    516549        const ast::Type* getPointerBase( const ast::Type* t ) {
    517550                assert(!"needs to build Type.cpp before inclusion");
    518                 // if ( const ast::PointerType* p = dynamic_cast< const ast::PointerType* >( t ) ) {
     551                // if ( const auto * p = dynamic_cast< const ast::PointerType * >( t ) ) {
    519552                //      return p->base;
    520                 // } else if ( const ast::ArrayType* a = dynamic_cast< const ast::ArrayType* >( t ) ) {
     553                // } else if ( const auto * a = dynamic_cast< const ast::ArrayType * >( t ) ) {
    521554                //      return a->base;
    522                 // } else if ( const ast::ReferenceType* r = dynamic_cast< const ast::ReferenceType* >( t ) ) {
     555                // } else if ( const auto * r = dynamic_cast< const ast::ReferenceType * >( t ) ) {
    523556                //      return r->base;
    524557                // } else return nullptr;
  • src/InitTweak/InitTweak.h

    rf3cc5b6 r9b4f329  
    8181        /// returns the argument to a call expression in position N indexed from 0
    8282        Expression *& getCallArg( Expression * callExpr, unsigned int pos );
     83        const ast::Expr * getCallArg( const ast::Expr * call, unsigned pos );
    8384
    8485        /// returns the base type of a PointerType or ArrayType, else returns NULL
Note: See TracChangeset for help on using the changeset viewer.