Ignore:
Timestamp:
Nov 15, 2014, 10:46:42 PM (10 years ago)
Author:
Peter A. Buhr <pabuhr@…>
Branches:
ADT, aaron-thesis, arm-eh, ast-experimental, cleanup-dtors, ctor, deferred_resn, demangler, enum, forall-pointer-decay, gc_noraii, jacob/cs343-translation, jenkins-sandbox, master, memory, new-ast, new-ast-unique-expr, new-env, no_list, persistent-indexer, pthread-emulation, qualifiedEnum, resolv-new, string, with_gc
Children:
1ead581
Parents:
8c17ab0
Message:

reformat files

Location:
translator/SynTree
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • translator/SynTree/FunctionType.cc

    r8c17ab0 rc8ffe20b  
    1 /*
    2  * This file is part of the Cforall project
    3  *
    4  * $Id: FunctionType.cc,v 1.8 2005/08/29 20:59:25 rcbilson Exp $
    5  *
    6  */
    7 
    81#include <algorithm>
    92
     
    136
    147
    15 FunctionType::FunctionType( const Type::Qualifiers &tq, bool isVarArgs )
    16     : Type( tq ), isVarArgs( isVarArgs )
    17 {
     8FunctionType::FunctionType( const Type::Qualifiers &tq, bool isVarArgs ) : Type( tq ), isVarArgs( isVarArgs ) {
    189}
    1910
    20 FunctionType::FunctionType( const FunctionType &other )
    21     : Type( other ), isVarArgs( other.isVarArgs )
    22 {
     11FunctionType::FunctionType( const FunctionType &other ) : Type( other ), isVarArgs( other.isVarArgs ) {
    2312    cloneAll( other.returnVals, returnVals );
    2413    cloneAll( other.parameters, parameters );
    2514}
    2615
    27 FunctionType::~FunctionType()
    28 {
     16FunctionType::~FunctionType() {
    2917    deleteAll( returnVals );
    3018    deleteAll( parameters );
    3119}
    3220
    33 void
    34 FunctionType::print( std::ostream &os, int indent ) const
    35 {
     21void FunctionType::print( std::ostream &os, int indent ) const {
    3622    using std::string;
    3723    using std::endl;
     
    3925    Type::print( os, indent );
    4026    os << "function" << endl;
    41     if( !parameters.empty() ) {
    42         os << string( indent+2, ' ' ) << "with parameters" << endl;
    43         printAll( parameters, os, indent+4 );
    44         if( isVarArgs ) {
    45             os << string( indent+4, ' ' ) << "and a variable number of other arguments" << endl;
     27    if ( ! parameters.empty() ) {
     28        os << string( indent + 2, ' ' ) << "with parameters" << endl;
     29        printAll( parameters, os, indent + 4 );
     30        if ( isVarArgs ) {
     31            os << string( indent + 4, ' ' ) << "and a variable number of other arguments" << endl;
    4632        }
    47     } else if( isVarArgs ) {
    48         os << string( indent+4, ' ' ) << "accepting unspecified arguments" << endl;
     33    } else if ( isVarArgs ) {
     34        os << string( indent + 4, ' ' ) << "accepting unspecified arguments" << endl;
    4935    }
    50     os << string( indent+2, ' ' ) << "returning ";
    51     if( returnVals.empty() ) {
    52         os << endl << string( indent+4, ' ' ) << "nothing " << endl;
     36    os << string( indent + 2, ' ' ) << "returning ";
     37    if ( returnVals.empty() ) {
     38        os << endl << string( indent + 4, ' ' ) << "nothing " << endl;
    5339    } else {
    5440        os << endl;
    55         printAll( returnVals, os, indent+4 );
     41        printAll( returnVals, os, indent + 4 );
    5642    }
    57 
    5843}
    5944
  • translator/SynTree/Type.h

    r8c17ab0 rc8ffe20b  
    1 /*
    2  * This file is part of the Cforall project
    3  *
    4  * $Id: Type.h,v 1.30 2005/08/29 20:59:26 rcbilson Exp $
    5  *
    6  */
    7 
    81#ifndef TYPE_H
    92#define TYPE_H
     
    147
    158
    16 class Type
    17 {
    18 public:
    19     struct Qualifiers
    20     { 
    21         Qualifiers(): isConst( false ), isVolatile( false ), isRestrict( false ), isLvalue( false ) {}
    22         Qualifiers( bool isConst, bool isVolatile, bool isRestrict, bool isLvalue ): isConst( isConst ), isVolatile( isVolatile ), isRestrict( isRestrict ), isLvalue( isLvalue ) {}
     9class Type {
     10  public:
     11    struct Qualifiers { 
     12      Qualifiers(): isConst( false ), isVolatile( false ), isRestrict( false ), isLvalue( false ) {}
     13      Qualifiers( bool isConst, bool isVolatile, bool isRestrict, bool isLvalue ): isConst( isConst ), isVolatile( isVolatile ), isRestrict( isRestrict ), isLvalue( isLvalue ) {}
    2314       
    24         Qualifiers &operator+=( const Qualifiers &other);
    25         Qualifiers &operator-=( const Qualifiers &other);
     15        Qualifiers &operator+=( const Qualifiers &other );
     16        Qualifiers &operator-=( const Qualifiers &other );
    2617        Qualifiers operator+( const Type::Qualifiers &other );
    27         bool operator==( const Qualifiers &other);
    28         bool operator!=( const Qualifiers &other);
     18        bool operator==( const Qualifiers &other );
     19        bool operator!=( const Qualifiers &other );
    2920        bool operator<=( const Qualifiers &other );
    3021        bool operator>=( const Qualifiers &other );
     
    5748    virtual Type *acceptMutator( Mutator &m ) = 0;
    5849    virtual void print( std::ostream &os, int indent = 0 ) const;
    59 
    60 private:
     50  private:
    6151    Qualifiers tq;
    6252    std::list<TypeDecl*> forall;
    6353};
    6454
    65 class VoidType : public Type
    66 {
    67 public:
     55class VoidType : public Type {
     56  public:
    6857    VoidType( const Type::Qualifiers &tq );
    6958
     
    7463};
    7564
    76 class BasicType : public Type
    77 {
    78 public:
    79     enum Kind
    80         { 
    81             Bool,
    82             Char,
    83             SignedChar,
    84             UnsignedChar,
    85             ShortSignedInt,
    86             ShortUnsignedInt,
    87             SignedInt,
    88             UnsignedInt,
    89             LongSignedInt,
    90             LongUnsignedInt,
    91             LongLongSignedInt,
    92             LongLongUnsignedInt,
    93             Float,
    94             Double,
    95             LongDouble,
    96             FloatComplex,
    97             DoubleComplex,
    98             LongDoubleComplex,
    99             FloatImaginary,
    100             DoubleImaginary,
    101             LongDoubleImaginary,
    102             NUMBER_OF_BASIC_TYPES
    103         }; 
     65class BasicType : public Type {
     66  public:
     67    enum Kind { 
     68        Bool,
     69        Char,
     70        SignedChar,
     71        UnsignedChar,
     72        ShortSignedInt,
     73        ShortUnsignedInt,
     74        SignedInt,
     75        UnsignedInt,
     76        LongSignedInt,
     77        LongUnsignedInt,
     78        LongLongSignedInt,
     79        LongLongUnsignedInt,
     80        Float,
     81        Double,
     82        LongDouble,
     83        FloatComplex,
     84        DoubleComplex,
     85        LongDoubleComplex,
     86        FloatImaginary,
     87        DoubleImaginary,
     88        LongDoubleImaginary,
     89        NUMBER_OF_BASIC_TYPES
     90    }; 
    10491
    10592    BasicType( const Type::Qualifiers &tq, Kind bt );
     
    114101
    115102    bool isInteger() const;
    116 
    117 private:
     103  private:
    118104    Kind kind;
    119105};
    120106
    121 class PointerType : public Type
    122 {
    123 public:
     107class PointerType : public Type {
     108  public:
    124109    PointerType( const Type::Qualifiers &tq, Type *base );
    125110    PointerType( const Type::Qualifiers &tq, Type *base, Expression *dimension, bool isVarLen, bool isStatic );
     
    140125    virtual Type *acceptMutator( Mutator &m ) { return m.mutate( this ); }
    141126    virtual void print( std::ostream &os, int indent = 0 ) const;
    142 
    143 private:
     127  private:
    144128    Type *base;
    145129   
    146     // in C99, pointer types can be qualified in many ways
    147     // e.g., int f( int a[ static 3 ] )
     130    // In C99, pointer types can be qualified in many ways e.g., int f( int a[ static 3 ] )
    148131    Expression *dimension;
    149132    bool isVarLen;
     
    151134};
    152135
    153 class ArrayType : public Type
    154 {
    155 public:
     136class ArrayType : public Type {
     137  public:
    156138    ArrayType( const Type::Qualifiers &tq, Type *base, Expression *dimension, bool isVarLen, bool isStatic );
    157139    ArrayType( const ArrayType& );
     
    171153    virtual Type *acceptMutator( Mutator &m ) { return m.mutate( this ); }
    172154    virtual void print( std::ostream &os, int indent = 0 ) const;
    173 
    174 private:
     155  private:
    175156    Type *base;
    176157    Expression *dimension;
     
    179160};
    180161
    181 class FunctionType : public Type
    182 {
    183 public:
     162class FunctionType : public Type {
     163  public:
    184164    FunctionType( const Type::Qualifiers &tq, bool isVarArgs );
    185165    FunctionType( const FunctionType& );
     
    195175    virtual Type *acceptMutator( Mutator &m ) { return m.mutate( this ); }
    196176    virtual void print( std::ostream &os, int indent = 0 ) const;
    197 
    198 private:
     177  private:
    199178    std::list<DeclarationWithType*> returnVals;
    200179    std::list<DeclarationWithType*> parameters;
     
    207186};
    208187
    209 class ReferenceToType : public Type
    210 {
    211 public:
     188class ReferenceToType : public Type {
     189  public:
    212190    ReferenceToType( const Type::Qualifiers &tq, const std::string &name );
    213191    ReferenceToType( const ReferenceToType &other );
     
    222200    virtual Type *acceptMutator( Mutator &m ) = 0;
    223201    virtual void print( std::ostream &os, int indent = 0 ) const;
    224 
    225 protected:
     202  protected:
    226203    virtual std::string typeString() const = 0;
    227204    std::list< Expression* > parameters;
    228    
    229 private:
     205  private:
    230206    std::string name;
    231    
    232 };
    233 
    234 class StructInstType : public ReferenceToType
    235 {
     207};
     208
     209class StructInstType : public ReferenceToType {
    236210    typedef ReferenceToType Parent;
    237    
    238 public:
     211  public:
    239212    StructInstType( const Type::Qualifiers &tq, const std::string &name ) : Parent( tq, name ), baseStruct( 0 ) {}
    240213    StructInstType( const StructInstType &other ) : Parent( other ), baseStruct( other.baseStruct ) {}
     
    250223    virtual Type *acceptMutator( Mutator &m ) { return m.mutate( this ); }
    251224
    252 private:
     225  private:
    253226    virtual std::string typeString() const;
    254227   
     
    258231};
    259232
    260 class UnionInstType : public ReferenceToType
    261 {
     233class UnionInstType : public ReferenceToType {
    262234    typedef ReferenceToType Parent;
    263    
    264 public:
     235  public:
    265236    UnionInstType( const Type::Qualifiers &tq, const std::string &name ) : Parent( tq, name ), baseUnion( 0 ) {}
    266237    UnionInstType( const UnionInstType &other ) : Parent( other ), baseUnion( other.baseUnion ) {}
     
    275246    virtual void accept( Visitor &v ) { v.visit( this ); }
    276247    virtual Type *acceptMutator( Mutator &m ) { return m.mutate( this ); }
    277 
    278 private:
     248  private:
    279249    virtual std::string typeString() const;
    280250   
     
    284254};
    285255
    286 class EnumInstType : public ReferenceToType
    287 {
     256class EnumInstType : public ReferenceToType {
    288257    typedef ReferenceToType Parent;
    289    
    290 public:
     258  public:
    291259    EnumInstType( const Type::Qualifiers &tq, const std::string &name ) : Parent( tq, name ) {}
    292260    EnumInstType( const EnumInstType &other ) : Parent( other ) {}
     
    296264    virtual Type *acceptMutator( Mutator &m ) { return m.mutate( this ); }
    297265
    298 private:
     266  private:
    299267    virtual std::string typeString() const;
    300268};
    301269
    302 class ContextInstType : public ReferenceToType
    303 {
     270class ContextInstType : public ReferenceToType {
    304271    typedef ReferenceToType Parent;
    305    
    306 public:
     272  public:
    307273    ContextInstType( const Type::Qualifiers &tq, const std::string &name ) : Parent( tq, name ) {}
    308274    ContextInstType( const ContextInstType &other );
     
    314280    virtual void accept( Visitor &v ) { v.visit( this ); }
    315281    virtual Type *acceptMutator( Mutator &m ) { return m.mutate( this ); }
    316 
    317 private:
     282  private:
    318283    virtual std::string typeString() const;
    319284   
     
    323288};
    324289
    325 class TypeInstType : public ReferenceToType
    326 {
     290class TypeInstType : public ReferenceToType {
    327291    typedef ReferenceToType Parent;
    328    
    329 public:
     292  public:
    330293    TypeInstType( const Type::Qualifiers &tq, const std::string &name, TypeDecl *baseType );
    331294    TypeInstType( const Type::Qualifiers &tq, const std::string &name, bool isFtype );
     
    341304    virtual Type *acceptMutator( Mutator &m ) { return m.mutate( this ); }
    342305    virtual void print( std::ostream &os, int indent = 0 ) const;
    343 
    344 private:
     306  private:
    345307    virtual std::string typeString() const;
    346    
    347308    // this decl is not "owned" by the type inst; it is merely a pointer to elsewhere in the tree,
    348309    // where the type used here is actually defined
     
    351312};
    352313
    353 class TupleType : public Type
    354 {
    355 public:
     314class TupleType : public Type {
     315  public:
    356316    TupleType( const Type::Qualifiers &tq );
    357317    TupleType( const TupleType& );
     
    364324    virtual Type *acceptMutator( Mutator &m ) { return m.mutate( this ); }
    365325    virtual void print( std::ostream &os, int indent = 0 ) const;
    366 
    367 private:
     326  private:
    368327    std::list<Type*> types;
    369328};
    370329
    371 class TypeofType : public Type
    372 {
    373 public:
     330class TypeofType : public Type {
     331  public:
    374332    TypeofType( const Type::Qualifiers &tq, Expression *expr );
    375333    TypeofType( const TypeofType& );
     
    383341    virtual Type *acceptMutator( Mutator &m ) { return m.mutate( this ); }
    384342    virtual void print( std::ostream &os, int indent = 0 ) const;
    385 
    386 private:
     343  private:
    387344    Expression *expr;
    388345};
    389346
    390 class AttrType : public Type
    391 {
    392 public:
     347class AttrType : public Type {
     348  public:
    393349    AttrType( const Type::Qualifiers &tq, const std::string &name, Expression *expr );
    394350    AttrType( const Type::Qualifiers &tq, const std::string &name, Type *type );
     
    410366    virtual void print( std::ostream &os, int indent = 0 ) const;
    411367
    412 private:
     368  private:
    413369    std::string name;
    414370    Expression *expr;
     
    417373};
    418374
    419 inline Type::Qualifiers &
    420 Type::Qualifiers::operator+=( const Type::Qualifiers &other )
    421 {
     375inline Type::Qualifiers &Type::Qualifiers::operator+=( const Type::Qualifiers &other ) {
    422376    isConst |= other.isConst;
    423377    isVolatile |= other.isVolatile;
     
    427381}
    428382
    429 inline Type::Qualifiers &
    430 Type::Qualifiers::operator-=( const Type::Qualifiers &other )
    431 {
    432     if( other.isConst ) isConst = 0;
    433     if( other.isVolatile ) isVolatile = 0;
    434     if( other.isRestrict ) isRestrict = 0;
     383inline Type::Qualifiers &Type::Qualifiers::operator-=( const Type::Qualifiers &other ) {
     384    if ( other.isConst ) isConst = 0;
     385    if ( other.isVolatile ) isVolatile = 0;
     386    if ( other.isRestrict ) isRestrict = 0;
    435387    return *this;
    436388}
    437389
    438 inline Type::Qualifiers
    439 Type::Qualifiers::operator+( const Type::Qualifiers &other )
    440 {
     390inline Type::Qualifiers Type::Qualifiers::operator+( const Type::Qualifiers &other ) {
    441391    Qualifiers q = other;
    442392    q += *this;
     
    444394}
    445395
    446 inline bool
    447 Type::Qualifiers::operator==( const Qualifiers &other)
    448 {
     396inline bool Type::Qualifiers::operator==( const Qualifiers &other ) {
    449397    return isConst == other.isConst
    450         && isVolatile == other.isVolatile
    451         && isRestrict == other.isRestrict;
     398    && isVolatile == other.isVolatile
     399    && isRestrict == other.isRestrict;
    452400///         && isLvalue == other.isLvalue;
    453401}
    454402
    455 inline bool
    456 Type::Qualifiers::operator!=( const Qualifiers &other)
    457 {
     403inline bool Type::Qualifiers::operator!=( const Qualifiers &other ) {
    458404    return isConst != other.isConst
    459405        || isVolatile != other.isVolatile
     
    462408}
    463409
    464 inline bool
    465 Type::Qualifiers::operator<=( const Type::Qualifiers &other )
    466 {
     410inline bool Type::Qualifiers::operator<=( const Type::Qualifiers &other ) {
    467411    return isConst <= other.isConst
    468412        && isVolatile <= other.isVolatile
     
    471415}
    472416
    473 inline bool
    474 Type::Qualifiers::operator>=( const Type::Qualifiers &other )
    475 {
     417inline bool Type::Qualifiers::operator>=( const Type::Qualifiers &other ) {
    476418    return isConst >= other.isConst
    477419        && isVolatile >= other.isVolatile
     
    480422}
    481423
    482 inline bool
    483 Type::Qualifiers::operator<( const Type::Qualifiers &other )
    484 {
     424inline bool Type::Qualifiers::operator<( const Type::Qualifiers &other ) {
    485425    return operator!=( other ) && operator<=( other );
    486426}
    487427
    488 inline bool
    489 Type::Qualifiers::operator>( const Type::Qualifiers &other )
    490 {
     428inline bool Type::Qualifiers::operator>( const Type::Qualifiers &other ) {
    491429    return operator!=( other ) && operator>=( other );
    492430}
    493431
    494 
    495 #endif /* #ifndef TYPE_H */
     432#endif // TYPE_H
Note: See TracChangeset for help on using the changeset viewer.