Changeset 8bf784a for src/SynTree


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/SynTree
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • TabularUnified 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}
  • TabularUnified 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}
  • TabularUnified 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
  • TabularUnified 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}
  • TabularUnified 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}
  • TabularUnified 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 ); }
  • TabularUnified 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}
Note: See TracChangeset for help on using the changeset viewer.