Changeset 9e1d485 for src/InitTweak


Ignore:
Timestamp:
May 15, 2019, 3:41:08 PM (5 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:
69bafd2
Parents:
264e691
Message:

First draft of ast::Type with subclasses

Location:
src/InitTweak
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • src/InitTweak/InitTweak.cc

    r264e691 r9e1d485  
    55#include <memory>                  // for __shared_ptr
    66
     7#include "AST/Type.hpp"
    78#include "Common/PassVisitor.h"
    89#include "Common/SemanticError.h"  // for SemanticError
     
    513514                }
    514515        }
     516        const ast::Type* getPointerBase( const ast::Type* t ) {
     517                if ( const ast::PointerType* p = dynamic_cast< const ast::PointerType* >( t ) ) {
     518                        return p->base;
     519                } else if ( const ast::ArrayType* a = dynamic_cast< const ast::ArrayType* >( t ) ) {
     520                        return a->base;
     521                } else if ( const ast::ReferenceType* r = dynamic_cast< const ast::ReferenceType* >( t ) ) {
     522                        return r->base;
     523                } else return nullptr;
     524        }
    515525
    516526        Type * isPointerType( Type * type ) {
  • src/InitTweak/InitTweak.h

    r264e691 r9e1d485  
    2020#include <string>             // for string, allocator
    2121
     22#include "AST/Fwd.hpp"        // for AST nodes
    2223#include "SynTree/SynTree.h"  // for Visitor Nodes
    2324
     
    8384        /// returns the base type of a PointerType or ArrayType, else returns NULL
    8485        Type * getPointerBase( Type * );
     86        const ast::Type* getPointerBase( const ast::Type* );
    8587
    8688        /// returns the argument if it is a PointerType or ArrayType, else returns NULL
Note: See TracChangeset for help on using the changeset viewer.