Changeset 8bf784a for src


Ignore:
Timestamp:
Dec 21, 2016, 2:54:31 PM (8 years ago)
Author:
Rob Schluntz <rschlunt@…>
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, with_gc
Children:
e33f321
Parents:
6d4d1a6
Message:

name mangling for ttype, fix SynTree? operator<< to work with nullptr, add isTtype check, ttype variables are automatically "sized"

Location:
src
Files:
12 edited

Legend:

Unmodified
Added
Removed
  • src/GenPoly/Box.cc

    r6d4d1a6 r8bf784a  
    686686                        for ( std::list< Expression* >::iterator param = params.begin(); param != params.end(); ++param ) {
    687687                                TypeExpr *paramType = dynamic_cast< TypeExpr* >( *param );
    688                                 assert(paramType && "Aggregate parameters should be type expressions");
     688                                assertf(paramType, "Aggregate parameters should be type expressions");
    689689                                paramType->set_type( replaceWithConcrete( appExpr, paramType->get_type(), false ) );
    690690                        }
  • src/InitTweak/FixInit.cc

    r6d4d1a6 r8bf784a  
    3838#include "SynTree/AddStmtVisitor.h"
    3939#include "CodeGen/GenType.h"  // for warning/error messages
     40#include "Tuples/Tuples.h"
    4041
    4142bool ctordtorp = false; // print all debug
     
    392393
    393394                bool ResolveCopyCtors::skipCopyConstruct( Type * type ) {
    394                         return dynamic_cast< VarArgsType * >( type ) || GenPoly::getFunctionType( type );
     395                        return dynamic_cast< VarArgsType * >( type ) || GenPoly::getFunctionType( type ) || Tuples::isTtype( type );
    395396                }
    396397
  • src/SymTab/Mangler.cc

    r6d4d1a6 r8bf784a  
    214214                                mangleName << "f";
    215215                                break;
     216                                case TypeDecl::Ttype:
     217                                mangleName << "tVARGS";
     218                                break;
     219                                default:
     220                                assert( false );
    216221                        } // switch
    217222                        mangleName << numStream.str();
     
    256261                if ( ! type->get_forall().empty() ) {
    257262                        std::list< std::string > assertionNames;
    258                         int tcount = 0, dcount = 0, fcount = 0;
     263                        int tcount = 0, dcount = 0, fcount = 0, vcount = 0;
    259264                        mangleName << "A";
    260265                        for ( Type::ForallList::iterator i = type->get_forall().begin(); i != type->get_forall().end(); ++i ) {
     
    269274                                        fcount++;
    270275                                        break;
     276                                  case TypeDecl::Ttype:
     277                                        vcount++;
     278                                        break;
     279                                  default:
     280                                        assert( false );
    271281                                } // switch
    272282                                varNums[ (*i )->get_name() ] = std::pair< int, int >( nextVarNum++, (int )(*i )->get_kind() );
     
    280290                                } // for
    281291                        } // for
    282                         mangleName << tcount << "_" << dcount << "_" << fcount << "_";
     292                        mangleName << tcount << "_" << dcount << "_" << fcount << "_" << vcount << "_";
    283293                        std::copy( assertionNames.begin(), assertionNames.end(), std::ostream_iterator< std::string >( mangleName, "" ) );
    284294                        mangleName << "_";
  • src/SynTree/Declaration.cc

    r6d4d1a6 r8bf784a  
    5757
    5858std::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        }
    6064        return out;
    6165}
  • src/SynTree/Expression.cc

    r6d4d1a6 r8bf784a  
    672672
    673673std::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        }
    675679        return out;
    676680}
  • src/SynTree/FunctionType.cc

    r6d4d1a6 r8bf784a  
    55// file "LICENCE" distributed with Cforall.
    66//
    7 // FunctionType.cc -- 
     7// FunctionType.cc --
    88//
    99// Author           : Richard C. Bilson
     
    1919#include "Declaration.h"
    2020#include "Common/utility.h"
     21#include "Tuples/Tuples.h"
    2122
    2223FunctionType::FunctionType( const Type::Qualifiers &tq, bool isVarArgs ) : Type( tq ), isVarArgs( isVarArgs ) {
     
    3132        deleteAll( returnVals );
    3233        deleteAll( parameters );
     34}
     35
     36namespace {
     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
     45bool FunctionType::isTtype() const {
     46        return containsTtype( returnVals ) || containsTtype( parameters );
    3347}
    3448
  • src/SynTree/Statement.cc

    r6d4d1a6 r8bf784a  
    388388
    389389std::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        }
    391395        return out;
    392396}
  • src/SynTree/Type.cc

    r6d4d1a6 r8bf784a  
    8585
    8686std::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        }
    8892        return out;
    8993}
  • src/SynTree/Type.h

    r6d4d1a6 r8bf784a  
    204204        std::list<DeclarationWithType*> & get_returnVals() { return returnVals; }
    205205        std::list<DeclarationWithType*> & get_parameters() { return parameters; }
    206         bool get_isVarArgs() { return isVarArgs; }
     206        bool get_isVarArgs() const { return isVarArgs; }
    207207        void set_isVarArgs( bool newValue ) { isVarArgs = newValue; }
     208
     209        bool isTtype() const;
    208210
    209211        virtual FunctionType *clone() const { return new FunctionType( *this ); }
  • src/SynTree/TypeDecl.cc

    r6d4d1a6 r8bf784a  
    1818#include "Common/utility.h"
    1919
    20 TypeDecl::TypeDecl( const std::string &name, DeclarationNode::StorageClass sc, Type *type, Kind kind ) : Parent( name, sc, type ), kind( kind ), sized( kind == Any ) {
     20TypeDecl::TypeDecl( const std::string &name, DeclarationNode::StorageClass sc, Type *type, Kind kind ) : Parent( name, sc, type ), kind( kind ), sized( kind == Any || kind == Ttype ) {
    2121}
    2222
     
    2525
    2626std::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" };
    2828        return kindNames[ kind ];
    2929}
  • src/Tuples/TupleExpansion.cc

    r6d4d1a6 r8bf784a  
    318318        }
    319319
     320        TypeInstType * isTtype( Type * type ) {
     321                if ( TypeInstType * inst = dynamic_cast< TypeInstType * >( type ) ) {
     322                        if ( inst->get_baseType()->get_kind() == TypeDecl::Ttype ) {
     323                                return inst;
     324                        }
     325                }
     326                return nullptr;
     327        }
     328
    320329        namespace {
    321330                /// determines if impurity (read: side-effects) may exist in a piece of code. Currently gives a very crude approximation, wherein any function call expression means the code may be impure
  • src/Tuples/Tuples.h

    r6d4d1a6 r8bf784a  
    4242        Type * makeTupleType( const std::list< Expression * > & exprs );
    4343
     44        /// returns a TypeInstType if `type` is a ttype, nullptr otherwise
     45        TypeInstType * isTtype( Type * type );
     46
    4447        /// returns true if the expression may contain side-effects.
    4548        bool maybeImpure( Expression * expr );
Note: See TracChangeset for help on using the changeset viewer.