Changeset 933f32f for src/InitTweak


Ignore:
Timestamp:
May 24, 2019, 10:19:41 AM (7 years ago)
Author:
Thierry Delisle <tdelisle@…>
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:
d908563
Parents:
6a9d4b4 (diff), 292642a (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.
Message:

Merge branch 'master' into cleanup-dtors

Location:
src/InitTweak
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • src/InitTweak/FixInit.cc

    r6a9d4b4 r933f32f  
    1010// Created On       : Wed Jan 13 16:29:30 2016
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Wed Jun 21 17:35:05 2017
    13 // Update Count     : 74
     12// Last Modified On : Wed Feb 13 18:15:56 2019
     13// Update Count     : 76
    1414//
    1515#include "FixInit.h"
     
    7272                };
    7373
    74                 struct InsertImplicitCalls : public WithTypeSubstitution {
     74                struct InsertImplicitCalls : public WithConstTypeSubstitution {
    7575                        /// wrap function application expressions as ImplicitCopyCtorExpr nodes so that it is easy to identify which
    7676                        /// function calls need their parameters to be copy constructed
  • src/InitTweak/InitTweak.cc

    r6a9d4b4 r933f32f  
    55#include <memory>                  // for __shared_ptr
    66
     7#include "AST/Expr.hpp"
     8#include "AST/Stmt.hpp"
     9#include "AST/Type.hpp"
    710#include "Common/PassVisitor.h"
    811#include "Common/SemanticError.h"  // for SemanticError
     
    2629#include "Tuples/Tuples.h"         // for Tuples::isTtype
    2730
    28 class UntypedValofExpr;
    29 
    3031namespace InitTweak {
    3132        namespace {
     
    432433                        assert( false );
    433434                }
     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                // }
    434448        }
    435449
     
    451465                        assertf( false, "Unexpected expression type passed to getCallArg: %s", toString( callExpr ).c_str() );
    452466                }
     467        }
     468        const ast::Expr * getCallArg( const ast::Expr * call, unsigned pos ) {
     469                (void)call;
     470                (void)pos;
     471                #warning unimplemented; needs to build AST/Expr.cpp
     472                assertf(false, "unimplemented; needs to build AST/Expr.cpp");
     473                // if ( auto app = dynamic_cast< const ast::ApplicationExpr * >( call ) ) {
     474                //      return callArg( app, pos );
     475                // } else if ( auto untyped = dynamic_cast< const ast::UntypedExpr * >( call ) ) {
     476                //      return callArg( untyped, pos );
     477                // } else if ( auto tupleAssn = dynamic_cast< const ast::TupleAssignExpr * >( call ) ) {
     478                //      const std::list<ast::ptr<ast::Stmt>>& stmts = tupleAssn->stmtExpr->stmts->kids;
     479                //      assertf( ! stmts.empty(), "TupleAssignExpr missing statements." );
     480                //      const ExprStmt * stmt = strict_dynamic_cast< const ast::ExprStmt * >( stmts.back() );
     481                //      const TupleExpr * tuple = strict_dynamic_cast< const ast::TupleExpr * >( stmt->expr );
     482                //      assertf( ! tuple->exprs.empty(), "TupleAssignExpr has empty tuple expr.");
     483                //      return getCallArg( tuple->exprs.front(), pos );
     484                // } else if ( auto ctor = dynamic_cast< const ast::ImplicitCopyCtorExpr * >( call ) ) {
     485                //      return getCallArg( ctor->callExpr, pos );
     486                // } else {
     487                //      assertf( false, "Unexpected expression type passed to getCallArg: %s",
     488                //              toString( call ).c_str() );
     489                // }
    453490        }
    454491
     
    513550                }
    514551        }
     552        const ast::Type* getPointerBase( const ast::Type* t ) {
     553                (void)t;
     554                #warning needs to build Type.cpp before inclusion
     555                assertf(false, "needs to build Type.cpp before inclusion");
     556                // if ( const auto * p = dynamic_cast< const ast::PointerType * >( t ) ) {
     557                //      return p->base;
     558                // } else if ( const auto * a = dynamic_cast< const ast::ArrayType * >( t ) ) {
     559                //      return a->base;
     560                // } else if ( const auto * r = dynamic_cast< const ast::ReferenceType * >( t ) ) {
     561                //      return r->base;
     562                // } else return nullptr;
     563        }
    515564
    516565        Type * isPointerType( Type * type ) {
  • src/InitTweak/InitTweak.h

    r6a9d4b4 r933f32f  
    2020#include <string>             // for string, allocator
    2121
     22#include "AST/Fwd.hpp"        // for AST nodes
    2223#include "SynTree/SynTree.h"  // for Visitor Nodes
    2324
     
    8081        /// returns the argument to a call expression in position N indexed from 0
    8182        Expression *& getCallArg( Expression * callExpr, unsigned int pos );
     83        const ast::Expr * getCallArg( const ast::Expr * call, unsigned pos );
    8284
    8385        /// returns the base type of a PointerType or ArrayType, else returns NULL
    8486        Type * getPointerBase( Type * );
     87        const ast::Type* getPointerBase( const ast::Type* );
    8588
    8689        /// returns the argument if it is a PointerType or ArrayType, else returns NULL
  • src/InitTweak/module.mk

    r6a9d4b4 r933f32f  
    2020        InitTweak/InitTweak.cc
    2121
     22SRCDEMANGLE += InitTweak/GenInit.cc \
     23        InitTweak/InitTweak.cc
     24
Note: See TracChangeset for help on using the changeset viewer.