Changeset c11e31c for translator/SynTree


Ignore:
Timestamp:
May 14, 2015, 1:44:55 PM (9 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:
4bf5298
Parents:
d4778a6
Message:

add inline and attribute qualifiers, cfa.y comment formatting, fix error message in isIntegralType

Location:
translator/SynTree
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • translator/SynTree/CompoundStmt.cc

    rd4778a6 rc11e31c  
    1111#include <functional>
    1212
     13using std::string;
     14using std::endl;
    1315
    1416CompoundStmt::CompoundStmt( std::list<Label> labels )
     
    3133CompoundStmt::print( std::ostream &os, int indent )
    3234{
    33     printAll( kids, os, indent );
     35    os << "\r" << string(indent, ' ') << "CompoundStmt Statement" << endl ;
     36    printAll( kids, os, indent + 4 );
    3437}
    3538
  • translator/SynTree/Declaration.h

    rd4778a6 rc11e31c  
    1212    enum StorageClass { 
    1313        NoStorageClass,
     14        Extern,
     15        Static,
    1416        Auto,
    15         Static,
    16         Extern,
    1717        Register,
    18         Fortran
     18        Inline,
     19        Fortran,
    1920    }; 
    2021
     
    108109    CompoundStmt *get_statements() const { return statements; }
    109110    void set_statements( CompoundStmt *newValue ) { statements = newValue; }
    110     bool get_isInline() const { return isInline; }
    111     void set_isInline( bool newValue ) { isInline = newValue; }
     111//    bool get_isInline() const { return isInline; }
     112//    void set_isInline( bool newValue ) { isInline = newValue; }
    112113    std::list< std::string >& get_oldIdents() { return oldIdents; }
    113114    std::list< Declaration* >& get_oldDecls() { return oldDecls; }
  • translator/SynTree/FunctionDecl.cc

    rd4778a6 rc11e31c  
    1 /*
    2  * This file is part of the Cforall project
    3  *
    4  * $Id: FunctionDecl.cc,v 1.15 2005/08/29 20:59:25 rcbilson Exp $
    5  *
    6  */
    7 
    81#include <cassert>
    92
     
    147
    158
    16 FunctionDecl::FunctionDecl( const std::string &name, StorageClass sc, LinkageSpec::Type linkage, FunctionType *type,
    17                                             CompoundStmt *statements, bool isInline )
    18     : Parent( name, sc, linkage ), type( type ), statements( statements ), isInline( isInline )
    19 {
    20     // this is a pretty brazen hack to force the function "main" to have C linkage
    21     if( name == "main" ) {
     9FunctionDecl::FunctionDecl( const std::string &name, StorageClass sc, LinkageSpec::Type linkage, FunctionType *type, CompoundStmt *statements, bool isInline )
     10        : Parent( name, sc, linkage ), type( type ), statements( statements ), isInline( isInline ) {
     11    // this is a brazen hack to force the function "main" to have C linkage
     12    if ( name == "main" ) {
    2213        set_linkage( LinkageSpec::C );
    2314    }
     
    2516
    2617FunctionDecl::FunctionDecl( const FunctionDecl &other )
    27     : Parent( other ), type( maybeClone( other.type ) ), statements( maybeClone( other.statements ) ),
    28         isInline( other.isInline )
    29 {
     18    : Parent( other ), type( maybeClone( other.type ) ), statements( maybeClone( other.statements ) ), isInline( other.isInline ) {
    3019}
    3120
    32 FunctionDecl::~FunctionDecl()
    33 {
     21FunctionDecl::~FunctionDecl() {
    3422    delete type;
    3523    delete statements;
    3624}
    3725
    38 Type*
    39 FunctionDecl::get_type() const
    40 {
     26Type * FunctionDecl::get_type() const {
    4127    return type;
    4228}
    4329
    44 void
    45 FunctionDecl::set_type(Type *t)
    46 {
     30void FunctionDecl::set_type( Type *t ) {
    4731    type = dynamic_cast< FunctionType* >( t );
    4832    assert( type );
    4933}
    5034
    51 void
    52 FunctionDecl::print( std::ostream &os, int indent ) const
    53 {
     35void FunctionDecl::print( std::ostream &os, int indent ) const {
    5436    using std::endl;
    5537    using std::string;
    5638   
    57     if( get_name() != "" ) {
     39    if ( get_name() != "" ) {
    5840        os << get_name() << ": a ";
    5941    }
    60     if( get_linkage() != LinkageSpec::Cforall ) {
     42    if ( get_linkage() != LinkageSpec::Cforall ) {
    6143        os << LinkageSpec::toString( get_linkage() ) << " ";
    6244    }
    63     if( isInline ) {
     45    if ( isInline ) {
    6446        os << "inline ";
    6547    }
    66     if( get_storageClass() != NoStorageClass ) {
     48    if ( get_storageClass() != NoStorageClass ) {
    6749        os << storageClassName[ get_storageClass() ] << ' ';
    6850    }
    69     if( get_type() ) {
     51    if ( get_type() ) {
    7052        get_type()->print( os, indent );
    7153    } else {
    7254        os << "untyped entity ";
    7355    }
    74     if( !oldIdents.empty() ) {
     56    if ( ! oldIdents.empty() ) {
    7557        os << string( indent+2, ' ' ) << "with parameter names" << endl;
    7658        for( std::list< std::string >::const_iterator i = oldIdents.begin(); i != oldIdents.end(); ++i ) {
     
    7860        }
    7961    }
    80     if( !oldDecls.empty() ) {
     62    if ( ! oldDecls.empty() ) {
    8163        os << string( indent+2, ' ' ) << "with parameter declarations" << endl;
    8264        printAll( oldDecls, os, indent+4 );
    8365    }
    84     if( statements ) {
     66    if ( statements ) {
    8567        os << string( indent+2, ' ' ) << "with body " << endl;
    8668        statements->print( os, indent+4 );
     
    8870}
    8971
    90 void
    91 FunctionDecl::printShort( std::ostream &os, int indent ) const
    92 {
     72void FunctionDecl::printShort( std::ostream &os, int indent ) const {
    9373    using std::endl;
    9474    using std::string;
    9575   
    96     if( get_name() != "" ) {
     76    if ( get_name() != "" ) {
    9777        os << get_name() << ": a ";
    9878    }
    99     if( isInline ) {
     79    if ( isInline ) {
    10080        os << "inline ";
    10181    }
    102     if( get_storageClass() != NoStorageClass ) {
     82    if ( get_storageClass() != NoStorageClass ) {
    10383        os << storageClassName[ get_storageClass() ] << ' ';
    10484    }
    105     if( get_type() ) {
     85    if ( get_type() ) {
    10686        get_type()->print( os, indent );
    10787    } else {
     
    10989    }
    11090}
    111 
  • translator/SynTree/Statement.cc

    rd4778a6 rc11e31c  
    1414
    1515
    16 // *** Statement
    1716Statement::Statement(std::list<Label> _labels):
    1817    labels(_labels) {}
     
    2221Statement::~Statement() {}
    2322
    24 //*** ExprStmt
    2523ExprStmt::ExprStmt( std::list<Label> _labels, Expression *_expr ):
    2624    Statement(_labels), expr(_expr) {}
     
    3331}
    3432
    35 //*** BranchStmt
    3633const char *BranchStmt::brType[] = { "Goto", "Break", "Continue" };
    3734
     
    5754}
    5855
    59 //*** ReturnStmt
    6056ReturnStmt::ReturnStmt( std::list<Label> labels, Expression *_expr, bool throwP ) :
    6157    Statement( labels ), expr( _expr ), isThrow( throwP ) {}
     
    7268
    7369
    74 // *** IfStmt
    7570IfStmt::IfStmt( std::list<Label> _labels, Expression *_condition, Statement *_thenPart, Statement *_elsePart ):
    7671    Statement(_labels), condition(_condition), thenPart(_thenPart), elsePart(_elsePart) {}
     
    9186}
    9287
    93 // *** SwitchStmt
    9488SwitchStmt::SwitchStmt(std::list<Label> _labels, Expression * _condition, std::list<Statement *> &_branches):
    9589    Statement(_labels), condition(_condition), branches(_branches)
     
    116110}
    117111
    118 // *** CaseStmt
    119112CaseStmt::CaseStmt( std::list<Label> _labels, Expression *_condition,
    120113                                        std::list<Statement *> &_statements, bool deflt )
     
    147140}
    148141
    149 //*** ChooseStmt
    150142//ChooseStmt::ChooseStmt( std::list<Label> labels, Expression *condition, Statement *body ) {}
    151143ChooseStmt::ChooseStmt(std::list<Label> _labels, Expression * _condition, std::list<Statement *> &_branches):
     
    172164}
    173165
    174 //*** FallthruStmt
    175166void FallthruStmt::print(std::ostream &os, int indent) {
    176167    os << "\r" << string(indent, ' ') << "Fall-through statement" << endl;
    177168}
    178169
    179 //*** WhileStmt
    180170WhileStmt::WhileStmt( std::list<Label> labels, Expression *condition_,
    181171                                            Statement *body_, bool isDoWhile_ ):
     
    196186}
    197187
    198 //*** ForStmt
    199188ForStmt::ForStmt( std::list<Label> labels, Statement *initialization_,
    200189                                    Expression *condition_, Expression *increment_, Statement *body_ ):
     
    233222}
    234223
    235 //*** TryStmt
    236224TryStmt::TryStmt( std::list<Label> labels, CompoundStmt *tryBlock, std::list<Statement *> &_handlers, FinallyStmt *_finallyBlock ) :
    237225    Statement( labels ), block( tryBlock ),  handlers( _handlers ), finallyBlock( _finallyBlock )
     
    266254}
    267255
    268 //*** CatchStmt
    269256CatchStmt::CatchStmt( std::list<Label> labels, Declaration *_decl, Statement *_body, bool isCatchRest ) :
    270257    Statement( labels ), decl ( _decl ), body( _body ), catchRest ( isCatchRest )
     
    290277
    291278
    292 //*** FinallyStmt
    293279FinallyStmt::FinallyStmt( std::list<Label> labels, CompoundStmt *_block ) :
    294280    Statement( labels ), block( _block )
     
    307293}
    308294
    309 //*** NullStmt
    310295NullStmt::NullStmt( std::list<Label> labels ) : CompoundStmt( labels ) {}
    311296NullStmt::NullStmt() : CompoundStmt( std::list<Label>() ) {}
  • translator/SynTree/Statement.h

    rd4778a6 rc11e31c  
    1 /*
    2  * This file is part of the Cforall project
    3  *
    4  * $Id: Statement.h,v 1.18 2005/08/29 20:59:26 rcbilson Exp $
    5  *
    6  */
    7 
    81#ifndef STATEMENT_H
    92#define STATEMENT_H
  • translator/SynTree/Type.h

    rd4778a6 rc11e31c  
    1010  public:
    1111    struct Qualifiers { 
    12       Qualifiers(): isConst( false ), isVolatile( false ), isRestrict( false ), isLvalue( false ), isAtomic( false ) {}
    13       Qualifiers( bool isConst, bool isVolatile, bool isRestrict, bool isLvalue, bool isAtomic ): isConst( isConst ), isVolatile( isVolatile ), isRestrict( isRestrict ), isLvalue( isLvalue ), isAtomic( isAtomic ) {}
     12      Qualifiers(): isConst( false ), isVolatile( false ), isRestrict( false ), isLvalue( false ), isAtomic( false ), isAttribute( false ) {}
     13      Qualifiers( bool isConst, bool isVolatile, bool isRestrict, bool isLvalue, bool isAtomic, bool isAttribute): isConst( isConst ), isVolatile( isVolatile ), isRestrict( isRestrict ), isLvalue( isLvalue ), isAtomic( isAtomic ), isAttribute( isAttribute ) {}
    1414       
    1515        Qualifiers &operator+=( const Qualifiers &other );
     
    2828        bool isLvalue;
    2929        bool isAtomic;
     30        bool isAttribute;
    3031    }; 
    3132
     
    4041    bool get_isLvalue() { return tq.isLvalue; }
    4142    bool get_isAtomic() { return tq.isAtomic; }
     43    bool get_isAttribute() { return tq.isAttribute; }
    4244    void set_isConst( bool newValue ) { tq.isConst = newValue; }
    4345    void set_iisVolatile( bool newValue ) { tq.isVolatile = newValue; }
     
    4547    void set_isLvalue( bool newValue ) { tq.isLvalue = newValue; }
    4648    void set_isAtomic( bool newValue ) { tq.isAtomic = newValue; }
     49    void set_isAttribute( bool newValue ) { tq.isAttribute = newValue; }
    4750    std::list<TypeDecl*>& get_forall() { return forall; }
    4851
Note: See TracChangeset for help on using the changeset viewer.