Changeset bdd516a


Ignore:
Timestamp:
Apr 28, 2015, 4:21:36 PM (7 years ago)
Author:
Peter A. Buhr <pabuhr@…>
Branches:
aaron-thesis, arm-eh, cleanup-dtors, ctor, deferred_resn, demangler, gc_noraii, jacob/cs343-translation, jenkins-sandbox, master, memory, new-ast, new-ast-unique-expr, new-env, no_list, persistent-indexer, resolv-new, string, with_gc
Children:
42e2ad7
Parents:
ad17ba6a
Message:

fixed sizeof type variable, find lowest cost alternative for sizeof expression, removed unused classes, added compiler flag, remove temporary file for -CFA, formatting

Files:
3 added
1 deleted
42 edited

Legend:

Unmodified
Added
Removed
  • driver/cc1.cc

    rad17ba6a rbdd516a  
    88// Created On       : Fri Aug 26 14:23:51 2005
    99// Last Modified By : Peter A. Buhr
    10 // Last Modified On : Sat Jan 10 14:16:06 2015
    11 // Update Count     : 15
     10// Last Modified On : Mon Apr 27 23:11:52 2015
     11// Update Count     : 39
    1212//
    1313
     
    3434string D__CFA_FLAGPREFIX__( "-D__CFA_FLAG__=" );
    3535
     36char tmpname[] = P_tmpdir "/CFAXXXXXX";
     37int tmpfilefd = -1;
     38
    3639
    3740bool prefix( string arg, string pre ) {
     
    6972    } // if
    7073} // checkEnv
     74
     75
     76void rmtmpfile() {
     77    if ( unlink( tmpname ) == -1 ) {                    // remove tmpname
     78        perror ( "CFA Translator error: cpp failed" );
     79        exit( EXIT_FAILURE );
     80    } // if
     81    tmpfilefd = -1;                                     // mark closed
     82} // rmtmpfile
     83
     84
     85void sigTermHandler( int signal ) {
     86    if ( tmpfilefd != -1 ) {                            // RACE, file created ?
     87        rmtmpfile();                                    // remove
     88        exit( EXIT_FAILURE );                           // terminate
     89    } // if
     90} // sigTermHandler
    7191
    7292
     
    89109    const char *uargs[20];                              // leave space for 20 additional cfa-cpp command line values
    90110    int nuargs = 1;                                     // 0 => command name
     111
     112    signal( SIGINT,  sigTermHandler );
     113    signal( SIGTERM, sigTermHandler );
    91114
    92115    // process all the arguments
     
    116139                i += 1;                                 // and the argument
    117140
    118             // strip cfa flags controlling cpp step
    119 
     141            // strip flags controlling cpp step
     142
     143            } else if ( arg == "-D__CPP__" ) {
     144                cpp_flag = true;
     145            } else if ( arg == "-D" && string( argv[i + 1] ) == "__CPP__" ) {
     146                i += 1;                                 // and the argument
     147                cpp_flag = true;
    120148            } else if ( arg == "-D__CFA__" ) {
    121149                CFA_flag = true;
     
    123151                i += 1;                                 // and the argument
    124152                CFA_flag = true;
    125             } else if ( arg == "-D__CPP__" ) {
    126                 cpp_flag = true;
    127             } else if ( arg == "-D" && string( argv[i + 1] ) == "__CPP__" ) {
    128                 i += 1;                                 // and the argument
    129                 cpp_flag = true;
    130153            } else if ( prefix( arg, D__CFA_FLAGPREFIX__ ) ) {
    131154                uargs[nuargs] = ( *new string( arg.substr( D__CFA_FLAGPREFIX__.size() ) ) ).c_str();
     
    233256    // Create a temporary file to store output of the C preprocessor.
    234257
    235     char tmpname[] = P_tmpdir "/CFAXXXXXX";
    236     int tmpfile = mkstemp( tmpname );
    237     if ( tmpfile == -1 ) {
     258    tmpfilefd = mkstemp( tmpname );
     259    if ( tmpfilefd == -1 ) {
    238260        perror( "CFA Translator error: cpp level, mkstemp" );
    239261        exit( EXIT_FAILURE );
     
    241263
    242264#ifdef __DEBUG_H__
    243     cerr << "tmpname:" << tmpname << " tmpfile:" << tmpfile << endl;
     265    cerr << "tmpname:" << tmpname << " tmpfilefd:" << tmpfilefd << endl;
    244266#endif // __DEBUG_H__
    245267
     
    280302
    281303    if ( WIFSIGNALED(code) != 0 ) {                     // child failed ?
    282         unlink( tmpname );                              // remove tmpname
     304        rmtmpfile();                                    // remove tmpname
    283305        cerr << "CFA Translator error: cpp failed with signal " << WTERMSIG(code) << endl;
    284306        exit( EXIT_FAILURE );
     
    286308
    287309    if ( WEXITSTATUS(code) != 0 ) {                     // child error ?
    288         unlink( tmpname );                              // remove tmpname
     310        rmtmpfile();                                    // remove tmpname
    289311        exit( WEXITSTATUS( code ) );                    // do not continue
    290312    } // if
     
    293315    // output.  Otherwise, run the cfa-cpp preprocessor on the temporary file and save the result into the output file.
    294316
    295     if ( CFA_flag || fork() == 0 ) {                    // conditional fork ?
     317    if ( fork() == 0 ) {                                // child runs CFA
    296318        uargs[0] = ( *new string( bprefix + "/cfa-cpp" ) ).c_str();
    297319
     
    330352
    331353    // Must unlink here because file must exist across execvp.
    332     if ( unlink( tmpname ) == -1 ) {
    333         perror( "CFA Translator error: cpp level, unlink" );
    334         exit( EXIT_FAILURE );
    335     } // if
     354    rmtmpfile();                                        // remove tmpname
    336355
    337356    if ( WIFSIGNALED(code) ) {                          // child failed ?
  • driver/cpp.cc

    rad17ba6a rbdd516a  
    88// Created On       : Thu Aug 29 12:24:06 2002
    99// Last Modified By : Peter A. Buhr
    10 // Last Modified On : Sat Dec  6 08:31:49 2014
    11 // Update Count     : 51
     10// Last Modified On : Tue Apr 21 07:23:38 2015
     11// Update Count     : 52
    1212//
    1313
     
    218218    if ( cpp_flag && CFA_flag ) {
    219219        cerr << argv[0] << " Error cannot use -E and -CFA flags together." << endl;
    220         exit( -1 );
     220        exit( EXIT_FAILURE );
    221221    } // if
    222222
     
    234234            if ( freopen( cpp_out.c_str(), "w", stdout ) == NULL ) { // redirect stdout if not -E
    235235                cerr << argv[0] << ": Error can't write to " << cpp_out << endl;
    236                 exit( -1 );
     236                exit( EXIT_FAILURE );
    237237            } // if
    238238
     
    274274        execvp( args[0], (char *const *)args );         // should not return
    275275        perror( "CFA translator error: cpp level, exec" );
    276         exit( -1 );
     276        exit( EXIT_FAILURE );
    277277    } // if
    278278
     
    282282        if ( freopen( tmpfile, "w", stdout ) == NULL) { // redirect output to tmpfile
    283283            cerr << argv[0] << ": Error can't write to " << tmpfile << endl;
    284             exit( -1 );
     284            exit( EXIT_FAILURE );
    285285        } // if
    286286
     
    308308        execvp( args[0], (char *const *)args );         // should not return
    309309        perror( "CFA translator error: cpp level, exec" );
    310         exit( -1 );
     310        exit( EXIT_FAILURE );
    311311    } // if
    312312
     
    316316        unlink( tmpfile );
    317317        cerr << "CFA translator error: cpp failed with signal " << WTERMSIG(code) << endl;
    318         exit( -1 );
     318        exit( EXIT_FAILURE );
    319319    } // if
    320320
     
    357357    wait( &code );                                      // wait for child to finish
    358358
    359     unlink( tmpfile );
     359    if ( unlink( tmpfile ) == -1 ) {
     360        cerr << "CFA translator error: cfa-cpp failed " << errno << " to remove temporary file \"" << tmpfile << "\"" << endl;
     361        exit( EXIT_FAILURE );
     362    } // if
    360363
    361364    if ( WIFSIGNALED(code) != 0 ) {                     // child completed successfully ?
    362365        cerr << "CFA translator error: cfa-cpp failed with signal " << WTERMSIG(code) << endl;
    363         exit( -1 );
     366        exit( EXIT_FAILURE );
    364367    } // if
    365368
    366369    if ( CFA_flag ) {                                   // -CFA flag ?
    367         exit( -1 );                                     // tell gcc not to go any further
     370        exit( EXIT_FAILURE );                           // tell gcc not to go any further
    368371    } else {
    369372        exit( WEXITSTATUS(code) );
  • libcfa/prelude.cf

    rad17ba6a rbdd516a  
    88// Created On       : Sat Nov 29 07:23:41 2014
    99// Last Modified By : Peter A. Buhr
    10 // Last Modified On : Mon Jan 19 22:20:57 2015
    11 // Update Count     : 51
     10// Last Modified On : Wed Mar 18 11:36:59 2015
     11// Update Count     : 69
    1212//
    1313
     
    3535// ------------------------------------------------------------
    3636
    37 _Bool                   ?++( _Bool * ),                         ?--( _Bool * );
    38 signed int              ?++( signed int * ),                    ?--( signed int * );
    39 unsigned int            ?++( unsigned int * ),                  ?--( unsigned int * );
    40 signed long int         ?++( signed long int * ),               ?--( signed long int * );
    41 unsigned long int       ?++( unsigned long int * ),             ?--( unsigned long int * );
    42 signed long long int    ?++( signed long long int * ),          ?--( signed long long int * );
    43 unsigned long long int  ?++( unsigned long long int * ),        ?--( unsigned long long int * );
    44 float                   ?++( float * ),                         ?--( float * );
    45 double                  ?++( double * ),                        ?--( double * );
    46 long double             ?++( long double * ),                   ?--( long double * );
    47 float _Complex          ?++( float _Complex * ),                ?--( float _Complex * );
    48 double _Complex         ?++( double _Complex * ),               ?--( double _Complex * );
    49 long double _Complex    ?++( long double _Complex * ),          ?--( long double _Complex * );
     37_Bool                   ?++( _Bool * ),                         ?++( volatile _Bool * );
     38_Bool                   ?--( _Bool * ),                         ?--( volatile _Bool * );
     39unsigned char           ?++( unsigned char * ),                 ?++( volatile unsigned char * );
     40signed int              ?++( signed int * ),                    ?++( volatile signed int * );
     41signed int              ?--( signed int * ),                    ?--( volatile signed int * );
     42unsigned int            ?++( unsigned int * ),                  ?++( volatile unsigned int * );
     43unsigned int            ?--( unsigned int * ),                  ?--( volatile unsigned int * );
     44signed long int         ?++( signed long int * ),               ?++( volatile signed long int * );
     45signed long int         ?--( signed long int * ),               ?--( volatile signed long int * );
     46unsigned long int       ?++( unsigned long int * ),             ?++( volatile unsigned long int * );
     47unsigned long int       ?--( unsigned long int * ),             ?--( volatile unsigned long int * );
     48signed long long int    ?++( signed long long int * ),          ?++( volatile signed long long int * );
     49signed long long int    ?--( signed long long int * ),          ?--( volatile signed long long int * );
     50unsigned long long int  ?++( unsigned long long int * ),        ?++( volatile unsigned long long int * );
     51unsigned long long int  ?--( unsigned long long int * ),        ?--( volatile unsigned long long int * );
     52float                   ?++( float * ),                         ?++( volatile float * );
     53float                   ?--( float * ),                         ?--( volatile float * );
     54double                  ?++( double * ),                        ?++( volatile double * );
     55double                  ?--( double * ),                        ?--( volatile double * );
     56long double             ?++( long double * ),                   ?++( volatile long double * );
     57long double             ?--( long double * ),                   ?--( volatile long double * );
     58float _Complex          ?++( float _Complex * ),                ?++( volatile float _Complex * );
     59float _Complex          ?--( float _Complex * ),                ?--( volatile float _Complex * );
     60double _Complex         ?++( double _Complex * ),               ?++( volatile double _Complex * );
     61double _Complex         ?--( double _Complex * ),               ?--( volatile double _Complex * );
     62long double _Complex    ?++( long double _Complex * ),          ?++( volatile long double _Complex * );
     63long double _Complex    ?--( long double _Complex * ),          ?--( volatile long double _Complex * );
    5064
    5165forall( type T ) T *                     ?++(                T ** );
     
    203217signed int ?<?( _Bool, _Bool ),                         ?<=?( _Bool, _Bool ),
    204218           ?>?( _Bool, _Bool ),                         ?>=?( _Bool, _Bool );
     219signed int ?<?( unsigned char, unsigned char ),         ?<=?( unsigned char, unsigned char ),
     220           ?>?( unsigned char, unsigned char ),         ?>=?( unsigned char, unsigned char );
    205221signed int ?<?( signed int, signed int ),               ?<=?( signed int, signed int ),
    206222           ?>?( signed int, signed int ),               ?>=?( signed int, signed int );
  • libcfa/prototypes.awk

    rad17ba6a rbdd516a  
     1# http://llvm.org/svn/llvm-project/cfe/trunk/include/clang/Basic/Builtins.def
     2
    13BEGIN {
    24    FS = "("
  • translator/CodeGen/GenType.cc

    rad17ba6a rbdd516a  
    7474        if ( qualifiers.isRestrict ) {
    7575            os << "__restrict ";
     76        } // if
     77        if ( qualifiers.isAtomic ) {
     78            os << "_Atomic ";
    7679        } // if
    7780        if ( isVarLen ) {
     
    180183            typeString = "__restrict " + typeString;
    181184        } // if
     185        if ( type->get_isAtomic() ) {
     186            typeString = "_Atomic " + typeString;
     187        } // if
    182188    }
    183189} // namespace CodeGen
  • translator/GenPoly/Box.cc

    rad17ba6a rbdd516a  
    772772        Expression *Pass1::mutate( AddressExpr *addrExpr ) {
    773773            assert( !addrExpr->get_arg()->get_results().empty() );
    774             mutateExpression( addrExpr->get_arg() );
     774            addrExpr->set_arg( mutateExpression( addrExpr->get_arg() ) );
    775775            if ( isPolyType( addrExpr->get_arg()->get_results().front(), env, scopeTyVars ) ) {
    776776                Expression *ret = addrExpr->get_arg();
  • translator/GenPoly/ScrubTyVars.cc

    rad17ba6a rbdd516a  
    44#include "SynTree/Mutator.h"
    55#include "SynTree/Type.h"
     6#include "SynTree/Expression.h"
    67
    78
    89namespace GenPoly {
     10    Type * ScrubTyVars::mutate( TypeInstType *typeInst ) {
     11        TyVarMap::const_iterator tyVar = tyVars.find( typeInst->get_name() );
     12        if ( doAll || tyVar != tyVars.end() ) {
     13            switch( tyVar->second ) {
     14              case TypeDecl::Any:
     15              case TypeDecl::Dtype:
     16                {
     17                    PointerType *ret = new PointerType( Type::Qualifiers(), new VoidType( typeInst->get_qualifiers() ) );
     18                    delete typeInst;
     19                    return ret;
     20                }
     21              case TypeDecl::Ftype:
     22                delete typeInst;
     23                return new PointerType( Type::Qualifiers(), new FunctionType( Type::Qualifiers(), true ) );
     24            }
     25        }
     26        return typeInst;
     27    }
    928
    10 Type*
    11 ScrubTyVars::mutate( TypeInstType *typeInst )
    12 {
    13   TyVarMap::const_iterator tyVar = tyVars.find( typeInst->get_name() );
    14   if( doAll || tyVar != tyVars.end() ) {
    15     switch( tyVar->second ) {
    16     case TypeDecl::Any:
    17     case TypeDecl::Dtype:
    18     {
    19       PointerType *ret = new PointerType( Type::Qualifiers(), new VoidType( typeInst->get_qualifiers() ) );
    20       delete typeInst;
    21       return ret;
     29    Expression * ScrubTyVars::mutate( SizeofExpr *szeof ) {
     30        // sizeof( T ) => T parameter, which is the size of T
     31        if ( TypeInstType *typeInst = dynamic_cast< TypeInstType * >( szeof->get_type() ) ) {
     32            Expression *expr = new NameExpr( typeInst->get_name() );
     33            return expr;
     34        } else {
     35            return Mutator::mutate( szeof );
     36        }
    2237    }
    23      
    24     case TypeDecl::Ftype:
    25       delete typeInst;
    26       return new PointerType( Type::Qualifiers(), new FunctionType( Type::Qualifiers(), true ) );
     38
     39    Type * ScrubTyVars::mutate( PointerType *pointer ) {
     40        if ( TypeInstType *typeInst = dynamic_cast< TypeInstType * >( pointer->get_base() ) ) {
     41            if ( doAll || tyVars.find( typeInst->get_name() ) != tyVars.end() ) {
     42                Type *ret = mutate( typeInst );
     43                ret->get_qualifiers() += pointer->get_qualifiers();
     44                pointer->set_base( 0 );
     45                delete pointer;
     46                return ret;
     47            }
     48        }
     49        return Mutator::mutate( pointer );
    2750    }
    28   }
    29   return typeInst;
    30 }
    31 
    32 Type*
    33 ScrubTyVars::mutate( PointerType *pointer )
    34 {
    35   if( TypeInstType *typeInst = dynamic_cast< TypeInstType * >( pointer->get_base() ) ) {
    36     if( doAll || tyVars.find( typeInst->get_name() ) != tyVars.end() ) {
    37       Type *ret = mutate( typeInst );
    38 ///       std::cout << "pointer is ";
    39 ///       pointer->print( std::cout );
    40 ///       std::cout << std::endl << "ret is ";
    41 ///       ret->print( std::cout );
    42 ///       std::cout << std::endl;
    43       ret->get_qualifiers() += pointer->get_qualifiers();
    44       pointer->set_base( 0 );
    45       delete pointer;
    46       return ret;
    47     }
    48   }
    49   return Mutator::mutate( pointer );
    50 }
    51 
    5251} // namespace GenPoly
  • translator/GenPoly/ScrubTyVars.h

    rad17ba6a rbdd516a  
    1 /*
    2  * This file is part of the Cforall project
    3  *
    4  * $Id: ScrubTyVars.h,v 1.4 2005/08/29 20:14:13 rcbilson Exp $
    5  *
    6  */
    7 
    81#ifndef GENPOLY_SCRUBTYVARS_H
    92#define GENPOLY_SCRUBTYVARS_H
     
    158
    169namespace GenPoly {
     10    class ScrubTyVars : public Mutator {
     11      public:
     12        ScrubTyVars( bool doAll, const TyVarMap &tyVars ): doAll( doAll ), tyVars( tyVars ) {}
     13 
     14        template< typename SynTreeClass >
     15        static SynTreeClass *scrub( SynTreeClass *target, const TyVarMap &tyVars );
     16        template< typename SynTreeClass >
     17        static SynTreeClass *scrub( SynTreeClass *target );
     18 
     19        virtual Type* mutate( TypeInstType *typeInst );
     20        Expression* mutate( SizeofExpr *szeof );
     21        virtual Type* mutate( PointerType *pointer );
     22      private:
     23        bool doAll;
     24        const TyVarMap &tyVars;
     25    };
    1726
    18 class ScrubTyVars : public Mutator
    19 {
    20 public:
    21   ScrubTyVars( bool doAll, const TyVarMap &tyVars ): doAll( doAll ), tyVars( tyVars ) {}
    22  
    23   template< typename SynTreeClass >
    24   static SynTreeClass *scrub( SynTreeClass *target, const TyVarMap &tyVars );
    25   template< typename SynTreeClass >
    26   static SynTreeClass *scrub( SynTreeClass *target );
    27  
    28   virtual Type* mutate( TypeInstType *typeInst );
    29   virtual Type* mutate( PointerType *pointer );
     27    /* static class method */
     28    template< typename SynTreeClass >
     29    SynTreeClass * ScrubTyVars::scrub( SynTreeClass *target, const TyVarMap &tyVars ) {
     30        ScrubTyVars scrubber( false, tyVars );
     31        return static_cast< SynTreeClass * >( target->acceptMutator( scrubber ) );
     32    }
    3033
    31 private:
    32   bool doAll;
    33   const TyVarMap &tyVars;
    34 };
    35 
    36 /* static class method */
    37 template< typename SynTreeClass >
    38 SynTreeClass *
    39 ScrubTyVars::scrub( SynTreeClass *target, const TyVarMap &tyVars )
    40 {
    41   ScrubTyVars scrubber( false, tyVars );
    42   return static_cast< SynTreeClass* >( target->acceptMutator( scrubber ) );
    43 }
    44 
    45 /* static class method */
    46 template< typename SynTreeClass >
    47 SynTreeClass *
    48 ScrubTyVars::scrub( SynTreeClass *target )
    49 {
    50   TyVarMap tyVars;
    51   ScrubTyVars scrubber( true, tyVars );
    52   return static_cast< SynTreeClass* >( target->acceptMutator( scrubber ) );
    53 }
    54 
     34    /* static class method */
     35    template< typename SynTreeClass >
     36    SynTreeClass * ScrubTyVars::scrub( SynTreeClass *target ) {
     37        TyVarMap tyVars;
     38        ScrubTyVars scrubber( true, tyVars );
     39        return static_cast< SynTreeClass* >( target->acceptMutator( scrubber ) );
     40    }
    5541} // namespace GenPoly
    5642
    57 #endif /* #ifndef GENPOLY_SCRUBTYVARS_H */
     43#endif // GENPOLY_SCRUBTYVARS_H
  • translator/InitTweak/InitModel.h

    rad17ba6a rbdd516a  
    1212
    1313namespace InitTweak {
     14    class InitModelBuilder : public AssociationBuilder, public Visitor {
     15      public:
     16        InitModelBuilder( Declaration * );
     17        ~InitModelBuilder();
    1418
    15   class InitModelBuilder : public AssociationBuilder, public Visitor {
    16   public:
    17     InitModelBuilder( Declaration * );
    18     ~InitModelBuilder();
     19        virtual Association *grab_assoc() { taken = true; return building; }
     20        virtual Association *get_assoc() { return building; }
     21        void set_assoc( Association *newAssoc ) { building = newAssoc; }
    1922
    20     virtual Association *grab_assoc() { taken = true; return building; }
    21     virtual Association *get_assoc() { return building; }
    22     void set_assoc( Association *newAssoc ) { building = newAssoc; }
     23        void init();
     24        static int interpretDimension( Expression *exp ) {
     25            ConstantFolder folder( exp );
     26            try {
     27                return folder.get_constant();
     28            } catch (...) {
     29                throw SemanticError("Invalid array dimension");
     30            }
     31        }
    2332
    24     void init();
    25     static int interpretDimension( Expression *exp ) {
    26       ConstantFolder folder( exp );
    27       try {
    28         return folder.get_constant();
    29       } catch (...) {
    30         throw SemanticError("Invalid array dimension");
    31       }
    32     }
     33        // types
     34        virtual void visit( ArrayType * );
     35        virtual void visit( StructInstType * );
     36        virtual void visit( UnionInstType * );
     37        virtual void visit( EnumInstType * );
     38        virtual void visit( ContextInstType * ) { throw 0; }
     39        virtual void visit( TypeInstType * )    { throw 0; }
     40        // virtual void visit( TupleType *tupleType );
     41        // declarations
     42        virtual void visit( StructDecl *);
     43        virtual void visit( UnionDecl *);
     44        virtual void visit( EnumDecl *);
     45      private:
     46        class ConstantFolder : public Visitor {
     47          public:
     48            ConstantFolder( Expression *_expr = 0 ): expr(_expr) {}
     49            int get_constant() throw() { expr->accept( *this ); return value; }
     50            void set_constant( Expression *newExp ) { expr = newExp; }
     51            // Visitor interface
     52            void visit( Expression * ) { throw 0; }
     53            void visit( NameExpr * ) { throw 0; }
     54            void visit( CastExpr * ) { throw 0; }
     55            void visit( UntypedMemberExpr * ) { throw 0; }
     56            void visit( VariableExpr * ) { throw 0; }
     57            void visit( ConstantExpr * );
     58            void visit( SizeofExpr * ) { throw 0; }
     59            void visit( AttrExpr * ) { throw 0; }
     60            void visit( LogicalExpr * ) { throw 0; }
     61            void visit( ConditionalExpr * ) { throw 0; }
     62            void visit( CommaExpr * ) { throw 0; }
     63          private:
     64            Expression *expr;
     65            int value;
     66        };
    3367
    34     // types
    35     virtual void visit( ArrayType * );
    36     virtual void visit( StructInstType * );
    37     virtual void visit( UnionInstType * );
    38     virtual void visit( EnumInstType * );
    39     virtual void visit( ContextInstType * ) { throw 0; }
    40     virtual void visit( TypeInstType * )    { throw 0; }
    41     // virtual void visit( TupleType *tupleType );
    42     // declarations
    43     virtual void visit( StructDecl *);
    44     virtual void visit( UnionDecl *);
    45     virtual void visit( EnumDecl *);
    46 
    47   private:
    48     class ConstantFolder : public Visitor {
    49     public:
    50       ConstantFolder( Expression *_expr = 0 ): expr(_expr) {}
    51       int get_constant() throw() { expr->accept( *this ); return value; }
    52       void set_constant( Expression *newExp ) { expr = newExp; }
    53       // Visitor interface
    54       void visit( Expression * ) { throw 0; }
    55       void visit( NameExpr * ) { throw 0; }
    56       void visit( CastExpr * ) { throw 0; }
    57       void visit( UntypedMemberExpr * ) { throw 0; }
    58       void visit( VariableExpr * ) { throw 0; }
    59       void visit( ConstantExpr * );
    60       void visit( SizeofExpr * ) { throw 0; }
    61       void visit( AttrExpr * ) { throw 0; }
    62       void visit( LogicalExpr * ) { throw 0; }
    63       void visit( ConditionalExpr * ) { throw 0; }
    64       void visit( CommaExpr * ) { throw 0; }
    65     private:
    66       Expression *expr;
    67       int value;
     68        bool taken;
     69        Declaration *decl;  // ?
     70        Association *building;
    6871    };
    6972
    70     bool taken;
    71     Declaration *decl;  // ?
    72     Association *building;
    73   };
     73    class InitModelFiller : public AssociationFiller, public Visitor {
     74      public:
     75        InitModelFiller( Association *, Initializer *, bool _topLevel = false );
     76        ~InitModelFiller() { /* pointers in here are not owned by object (never created by object either) */ }
     77        virtual Association *get_assoc() { return model; }
     78        virtual void set_assoc( Association *newAssoc ) { model = newAssoc; }
    7479
    75   class InitModelFiller : public AssociationFiller, public Visitor {
    76   public:
    77     InitModelFiller( Association *, Initializer *, bool _topLevel = false );
    78     ~InitModelFiller() { /* pointers in here are not owned by object (never created by object either) */ }
    79     virtual Association *get_assoc() { return model; }
    80     virtual void set_assoc( Association *newAssoc ) { model = newAssoc; }
     80        void init();
     81        // Visitor interface
     82        virtual void visit( SingleInit *singleInit );
     83        virtual void visit( ListInit *listInit );
     84      private:
     85        Association *model;
     86        Initializer *orgInit;
     87        bool topLevel;
     88        long int next;
     89    };
    8190
    82     void init();
    83     // Visitor interface
    84     virtual void visit( MemberInit *memberInit ) { throw 0; }
    85     virtual void visit( ElementInit *elementInit ) { throw 0; }
    86     virtual void visit( SingleInit *singleInit );
    87     virtual void visit( ListInit *listInit );
     91    class InitUnspooler : public AssociationVisitor {
     92      public:
     93        InitUnspooler() : init(0), taken( false ) {}
     94        virtual ~InitUnspooler() { if (!taken && (init != 0)) { delete init; init = 0; } }
     95        Initializer *get_initializer() { return init; }
     96        Initializer *grab_initializer() { taken = true; return init; }
    8897
    89   private:
    90     Association *model;
    91     Initializer *orgInit;
    92     bool topLevel;
    93     long int next;
    94   };
    95 
    96   class InitUnspooler : public AssociationVisitor {
    97   public:
    98     InitUnspooler() : init(0), taken( false ) {}
    99     virtual ~InitUnspooler() { if (!taken && (init != 0)) { delete init; init = 0; } }
    100     Initializer *get_initializer() { return init; }
    101     Initializer *grab_initializer() { taken = true; return init; }
    102 
    103     virtual void visit( SingleName * );
    104     virtual void visit( PointAssociation * );
    105     virtual void visit( RangeAssociation * ) { std::cerr << "InitUnspooler - In a range assoc" << std::endl; return; }
    106 
    107   private:
    108     Initializer *init;
    109     bool taken;
    110   };
     98        virtual void visit( SingleName * );
     99        virtual void visit( PointAssociation * );
     100        virtual void visit( RangeAssociation * ) { std::cerr << "InitUnspooler - In a range assoc" << std::endl; return; }
     101      private:
     102        Initializer *init;
     103        bool taken;
     104    };
    111105
    112106} // namespace InitTweak
    113107
    114 #endif // #define _INITTWEAK_MODEL_H_
     108#endif // _INITTWEAK_MODEL_H_
    115109
    116110/*
  • translator/Parser/DeclarationNode.cc

    rad17ba6a rbdd516a  
    55#include <cassert>
    66
    7 #include "ParseNode.h"
    87#include "TypeData.h"
    9 #include "utility.h"
    10 #include "SynTree/Declaration.h"
    118#include "SynTree/Expression.h"
    12 #include "SynTree/Initializer.h"
    13 #include "SemanticError.h"
    14 #include "UniqueName.h"
    15 #include "LinkageSpec.h"
     9
    1610
    1711using namespace std;
    1812
    19 /* these must remain in the same order as the corresponding DeclarationNode enumerations */
    20 const char *DeclarationNode::qualifierName[] = { "const", "restrict", "volatile", "lvalue" };
     13// These must remain in the same order as the corresponding DeclarationNode enumerations.
     14const char *DeclarationNode::qualifierName[] = { "const", "restrict", "volatile", "lvalue", "_Atomic" };
    2115const char *DeclarationNode::basicTypeName[] = { "char", "int", "float", "double", "void", "_Bool", "_Complex", "_Imaginary" };
    2216const char *DeclarationNode::modifierName[] = { "signed", "unsigned", "short", "long" };
     
    6761    os << string(indent, ' ' );
    6862    if ( name == "" ) {
    69 ///     os << "An unnamed ";
     63        os << "unnamed: ";
    7064    } else {
    71         os << name << ": a ";
     65        os << name << ": ";
    7266    }
    7367
     
    862856              ret = new StructInstType( type->buildQualifiers(), type->aggregate->name );
    863857              break;
    864 
    865858            case DeclarationNode::Union:
    866859              ret = new UnionInstType( type->buildQualifiers(), type->aggregate->name );
    867860              break;
    868 
    869861            case DeclarationNode::Context:
    870862              ret = new ContextInstType( type->buildQualifiers(), type->aggregate->name );
    871863              break;
    872 
    873864            default:
    874865              assert( false );
    875           }
     866          } // switch
    876867          buildList( type->aggregate->actuals, ret->get_parameters() );
    877868          return ret;
     
    884875      default:
    885876        return type->build();
    886     }
     877    } // switch
    887878}
    888879
  • translator/Parser/ExpressionNode.cc

    rad17ba6a rbdd516a  
    1616ExpressionNode::ExpressionNode() : ParseNode(), argName( 0 ) {}
    1717
    18 ExpressionNode::ExpressionNode(string *name_) : ParseNode( *name_ ), argName( 0 ) {
     18ExpressionNode::ExpressionNode( string *name_) : ParseNode( *name_ ), argName( 0 ) {
    1919    delete name_;
    2020}
     
    2525    } else {
    2626        argName = 0;
    27     }
     27    } // if
    2828}
    2929
    3030ExpressionNode * ExpressionNode::set_asArgName( std::string *aName ) {
    31     argName = new VarRefNode(aName);
     31    argName = new VarRefNode( aName );
    3232    return this;
    3333}
     
    4040void ExpressionNode::printDesignation( std::ostream &os, int indent ) const {
    4141    if ( argName ) {
    42         os << string(' ', indent) << "(designated by:  ";
    43         argName->printOneLine(os, indent );
     42        os << string(' ', indent ) << "(designated by:  ";
     43        argName->printOneLine( os, indent );
    4444        os << ")" << std::endl;
    45     }
     45    } // if
    4646}
    4747
     
    5252}
    5353
    54 void NullExprNode::print(std::ostream & os, int indent) const {
    55     printDesignation(os);
     54void NullExprNode::print( std::ostream & os, int indent ) const {
     55    printDesignation( os );
    5656    os << "null expression";
    5757}
    5858
    59 void NullExprNode::printOneLine(std::ostream & os, int indent) const {
    60     printDesignation(os);
     59void NullExprNode::printOneLine( std::ostream & os, int indent ) const {
     60    printDesignation( os );
    6161    os << "null";
    6262}
     
    6666}
    6767
    68 CommaExprNode *ExpressionNode::add_to_list(ExpressionNode *exp){
    69     return new CommaExprNode(this, exp );
     68CommaExprNode *ExpressionNode::add_to_list( ExpressionNode *exp ){
     69    return new CommaExprNode( this, exp );
    7070}
    7171
    7272//  enum ConstantNode::Type =  { Integer, Float, Character, String, Range }
    7373
    74 ConstantNode::ConstantNode(void) : ExpressionNode(), sign(true), longs(0), size(0) {}
    75 
    76 ConstantNode::ConstantNode(string *name_) : ExpressionNode(name_), sign(true), longs(0), size(0) {}
    77 
    78 ConstantNode::ConstantNode(Type t, string *inVal) : type(t), sign(true), longs(0), size(0) {
     74ConstantNode::ConstantNode( void ) : ExpressionNode(), sign( true ), longs(0), size(0) {}
     75
     76ConstantNode::ConstantNode( string *name_) : ExpressionNode( name_), sign( true ), longs(0), size(0) {}
     77
     78ConstantNode::ConstantNode( Type t, string *inVal ) : type( t ), sign( true ), longs(0), size(0) {
    7979    if ( inVal ) {
    8080        value = *inVal;
     
    8282    } else {
    8383        value = "";
    84     }
    85 
    86     classify(value);
     84    } // if
     85
     86    classify( value );
    8787}
    8888
     
    9696}
    9797
    98 void ConstantNode::classify(std::string &str){
    99     switch (type){
     98void ConstantNode::classify( std::string &str ){
     99    switch ( type ){
    100100      case Integer:
    101101      case Float:
     
    105105            int i = str.length() - 1;
    106106
    107             while ( i >= 0 && !isxdigit(c = str.at(i--)) )
     107            while ( i >= 0 && !isxdigit( c = str.at( i--)) )
    108108                sfx += c;
    109109
     
    111111
    112112            // get rid of underscores
    113             value.erase(remove(value.begin(), value.end(), '_'), value.end());
    114 
    115             std::transform(sfx.begin(), sfx.end(), sfx.begin(), tolower_hack);
     113            value.erase( remove( value.begin(), value.end(), '_'), value.end());
     114
     115            std::transform( sfx.begin(), sfx.end(), sfx.begin(), tolower_hack );
    116116
    117117            if ( sfx.find("ll") != string::npos ){
    118118                longs = 2;
    119             } else if (sfx.find("l") != string::npos ){
     119            } else if ( sfx.find("l") != string::npos ){
    120120                longs = 1;
    121             }
    122 
    123             assert((longs >= 0) && (longs <= 2));
     121            } // if
     122
     123            assert(( longs >= 0) && ( longs <= 2));
    124124
    125125            if ( sfx.find("u") != string::npos )
     
    131131        {
    132132            // remove underscores from hex and oct escapes
    133             if (str.substr(1,2) == "\\x")
    134                 value.erase(remove(value.begin(), value.end(), '_'), value.end());
     133            if ( str.substr(1,2) == "\\x")
     134                value.erase( remove( value.begin(), value.end(), '_'), value.end());
    135135
    136136            break;
     
    142142}
    143143
    144 ConstantNode::Type ConstantNode::get_type(void) const {
     144ConstantNode::Type ConstantNode::get_type( void ) const {
    145145    return type;
    146146}
     
    148148ConstantNode *ConstantNode::append( std::string *newValue ) {
    149149    if ( newValue ) {
    150         if (type == String){
     150        if ( type == String ){
    151151            std::string temp = *newValue;
    152152            value.resize( value.size() - 1 );
     
    156156
    157157        delete newValue;
    158     }
     158    } // if
    159159    return this;
    160160}
    161161
    162 void ConstantNode::printOneLine(std::ostream &os, int indent ) const {
    163     os << string(indent, ' ');
    164     printDesignation(os);
     162void ConstantNode::printOneLine( std::ostream &os, int indent ) const {
     163    os << string( indent, ' ');
     164    printDesignation( os );
    165165
    166166    switch ( type ) {
     
    185185}
    186186
    187 void ConstantNode::print(std::ostream &os, int indent ) const {
     187void ConstantNode::print( std::ostream &os, int indent ) const {
    188188    printOneLine( os, indent );
    189189    os << endl;
     
    194194    BasicType *bt;
    195195
    196     switch (get_type()){
     196    switch ( get_type()){
    197197      case Integer:
    198198        /* Cfr. standard 6.4.4.1 */
    199         //bt.set_kind(BasicType::SignedInt);
    200         bt = new BasicType(q, BasicType::SignedInt);
     199        //bt.set_kind( BasicType::SignedInt );
     200        bt = new BasicType( q, BasicType::SignedInt );
    201201        break;
    202202      case Float:
    203         bt = new BasicType(q, BasicType::Float);
     203        bt = new BasicType( q, BasicType::Float );
    204204        break;
    205205      case Character:
    206         bt = new BasicType(q, BasicType::Char);
     206        bt = new BasicType( q, BasicType::Char );
    207207        break;
    208208      case String:
     
    210210        ArrayType *at;
    211211        std::string value = get_value();
    212         at = new ArrayType(q, new BasicType(q, BasicType::Char),
    213                            new ConstantExpr( Constant( new BasicType(q, BasicType::SignedInt),
     212        at = new ArrayType( q, new BasicType( q, BasicType::Char ),
     213                           new ConstantExpr( Constant( new BasicType( q, BasicType::SignedInt ),
    214214                                                       toString( value.size() - 1 ) ) ),  // account for '\0'
    215215                           false, false );
    216         return new ConstantExpr( Constant(at, value), maybeBuild< Expression >( get_argName() ) );
     216        return new ConstantExpr( Constant( at, value ), maybeBuild< Expression >( get_argName() ) );
    217217    }
    218     return new ConstantExpr(  Constant(bt, get_value()),  maybeBuild< Expression >( get_argName() ) );
    219 }
    220 
    221 VarRefNode::VarRefNode() : isLabel(false) {}
    222 
    223 VarRefNode::VarRefNode(string *name_, bool labelp) : ExpressionNode(name_), isLabel(labelp) {}
     218    return new ConstantExpr(  Constant( bt, get_value()),  maybeBuild< Expression >( get_argName() ) );
     219}
     220
     221VarRefNode::VarRefNode() : isLabel( false ) {}
     222
     223VarRefNode::VarRefNode( string *name_, bool labelp ) : ExpressionNode( name_), isLabel( labelp ) {}
    224224
    225225VarRefNode::VarRefNode( const VarRefNode &other ) : ExpressionNode( other ), isLabel( other.isLabel ) {
     
    230230}
    231231
    232 void VarRefNode::printOneLine(std::ostream &os, int indent ) const {
    233     printDesignation(os);
     232void VarRefNode::printOneLine( std::ostream &os, int indent ) const {
     233    printDesignation( os );
    234234    os << get_name() << ' ';
    235235}
    236236
    237 void VarRefNode::print(std::ostream &os, int indent ) const {
    238     printDesignation(os);
    239     os << '\r' << string(indent, ' ') << "Referencing: ";
     237void VarRefNode::print( std::ostream &os, int indent ) const {
     238    printDesignation( os );
     239    os << '\r' << string( indent, ' ') << "Referencing: ";
    240240    os << "Variable: " << get_name();
    241241    os << endl;
    242242}
    243243
    244 OperatorNode::OperatorNode(Type t) : type(t) {}
     244OperatorNode::OperatorNode( Type t ) : type( t ) {}
    245245
    246246OperatorNode::OperatorNode( const OperatorNode &other ) : ExpressionNode( other ), type( other.type ) {
     
    249249OperatorNode::~OperatorNode() {}
    250250
    251 OperatorNode::Type OperatorNode::get_type(void) const{
     251OperatorNode::Type OperatorNode::get_type( void ) const{
    252252    return type;
    253253}
    254254
    255255void OperatorNode::printOneLine( std::ostream &os, int indent ) const {
    256     printDesignation(os);
     256    printDesignation( os );
    257257    os << OpName[ type ] << ' ';
    258258}
    259259
    260260void OperatorNode::print( std::ostream &os, int indent ) const{
    261     printDesignation(os);
    262     os << '\r' << string(indent, ' ') << "Operator: " << OpName[type] << endl;
     261    printDesignation( os );
     262    os << '\r' << string( indent, ' ') << "Operator: " << OpName[type] << endl;
    263263    return;
    264264}
    265265
    266 std::string OperatorNode::get_typename(void) const{
    267     return string(OpName[ type ]);
     266std::string OperatorNode::get_typename( void ) const{
     267    return string( OpName[ type ]);
    268268}
    269269
     
    282282};
    283283
    284 CompositeExprNode::CompositeExprNode(void) : ExpressionNode(), function( 0 ), arguments( 0 ) {
    285 }
    286 
    287 CompositeExprNode::CompositeExprNode(string *name_) : ExpressionNode(name_), function( 0 ), arguments( 0 ) {
    288 }
    289 
    290 CompositeExprNode::CompositeExprNode(ExpressionNode *f, ExpressionNode *args):
    291     function(f), arguments(args) {
    292 }
    293 
    294 CompositeExprNode::CompositeExprNode(ExpressionNode *f, ExpressionNode *arg1, ExpressionNode *arg2):
    295     function(f), arguments(arg1) {
    296     arguments->set_link(arg2);
     284CompositeExprNode::CompositeExprNode( void ) : ExpressionNode(), function( 0 ), arguments( 0 ) {
     285}
     286
     287CompositeExprNode::CompositeExprNode( string *name_) : ExpressionNode( name_), function( 0 ), arguments( 0 ) {
     288}
     289
     290CompositeExprNode::CompositeExprNode( ExpressionNode *f, ExpressionNode *args ):
     291    function( f ), arguments( args ) {
     292}
     293
     294CompositeExprNode::CompositeExprNode( ExpressionNode *f, ExpressionNode *arg1, ExpressionNode *arg2):
     295    function( f ), arguments( arg1) {
     296    arguments->set_link( arg2);
    297297}
    298298
     
    303303            arguments->set_link( cur->clone() );
    304304        } else {
    305             arguments = (ExpressionNode*)cur->clone();
    306         }
     305            arguments = ( ExpressionNode*)cur->clone();
     306        } // if
    307307        cur = cur->get_link();
    308308    }
     
    333333    std::list<Expression *> args;
    334334
    335     buildList(get_args(), args);
    336 
    337     if ( ! ( op = dynamic_cast<OperatorNode *>(function)) ) {
     335    buildList( get_args(), args );
     336
     337    if ( ! ( op = dynamic_cast<OperatorNode *>( function )) ) {
    338338        // a function as opposed to an operator
    339         return new UntypedExpr(function->build(), args, maybeBuild< Expression >( get_argName() ));
     339        return new UntypedExpr( function->build(), args, maybeBuild< Expression >( get_argName() ));
    340340    } else {
    341         switch (op->get_type()){
     341        switch ( op->get_type()){
    342342          case OperatorNode::Incr:
    343343          case OperatorNode::Decr:
     
    412412          case OperatorNode::Cast:
    413413            {
    414                 TypeValueNode * arg = dynamic_cast<TypeValueNode *>(get_args());
     414                TypeValueNode * arg = dynamic_cast<TypeValueNode *>( get_args());
    415415                assert( arg );
    416416
    417417                DeclarationNode *decl_node = arg->get_decl();
    418                 ExpressionNode *expr_node = dynamic_cast<ExpressionNode *>(arg->get_link());
     418                ExpressionNode *expr_node = dynamic_cast<ExpressionNode *>( arg->get_link());
    419419
    420420                Type *targetType = decl_node->buildType();
     
    423423                    return new CastExpr( expr_node->build(), maybeBuild< Expression >( get_argName() ) );
    424424                } else {
    425                     return new CastExpr(expr_node->build(),targetType, maybeBuild< Expression >( get_argName() ) );
    426                 }
     425                    return new CastExpr( expr_node->build(),targetType, maybeBuild< Expression >( get_argName() ) );
     426                } // if
    427427            }
    428428          case OperatorNode::FieldSel:
     
    430430                assert( args.size() == 2 );
    431431
    432                 NameExpr *member = dynamic_cast<NameExpr *>(args.back());
    433                 // TupleExpr *memberTup = dynamic_cast<TupleExpr *>(args.back());
    434 
    435                 if ( member != 0 )
    436                     {
    437                         UntypedMemberExpr *ret = new UntypedMemberExpr(member->get_name(), args.front());
    438                         delete member;
    439                         return ret;
    440                     }
     432                NameExpr *member = dynamic_cast<NameExpr *>( args.back());
     433                // TupleExpr *memberTup = dynamic_cast<TupleExpr *>( args.back());
     434
     435                if ( member != 0 ) {
     436                    UntypedMemberExpr *ret = new UntypedMemberExpr( member->get_name(), args.front());
     437                    delete member;
     438                    return ret;
    441439                /* else if ( memberTup != 0 )
    442440                   {
    443                    UntypedMemberExpr *ret = new UntypedMemberExpr(memberTup->get_name(), args.front());
     441                   UntypedMemberExpr *ret = new UntypedMemberExpr( memberTup->get_name(), args.front());
    444442                   delete member;
    445443                   return ret;
    446444                   } */
    447                 else
     445                } else
    448446                    assert( false );
    449447            }
     
    452450                assert( args.size() == 2 );
    453451
    454                 NameExpr *member = dynamic_cast<NameExpr *>(args.back());  // modify for Tuples   xxx
     452                NameExpr *member = dynamic_cast<NameExpr *>( args.back());  // modify for Tuples   xxx
    455453                assert( member != 0 );
    456454
     
    458456                deref->get_args().push_back( args.front() );
    459457
    460                 UntypedMemberExpr *ret = new UntypedMemberExpr(member->get_name(), deref);
     458                UntypedMemberExpr *ret = new UntypedMemberExpr( member->get_name(), deref );
    461459                delete member;
    462460                return ret;
     
    465463          case OperatorNode::SizeOf:
    466464            {
    467 ///     bool isSizeOf = (op->get_type() == OperatorNode::SizeOf);
    468 
    469                 if ( TypeValueNode * arg = dynamic_cast<TypeValueNode *>(get_args()) ) {
    470                     return new SizeofExpr(arg->get_decl()->buildType());
     465///     bool isSizeOf = ( op->get_type() == OperatorNode::SizeOf );
     466
     467                if ( TypeValueNode * arg = dynamic_cast<TypeValueNode *>( get_args()) ) {
     468                    return new SizeofExpr( arg->get_decl()->buildType());
    471469                } else {
    472                     return new SizeofExpr(args.front());
    473                 }
     470                    return new SizeofExpr( args.front());
     471                } // if
    474472            }
    475473          case OperatorNode::Attr:
    476474            {
    477                 VarRefNode *var = dynamic_cast<VarRefNode *>(get_args());
     475                VarRefNode *var = dynamic_cast<VarRefNode *>( get_args());
    478476                assert( var );
    479477                if ( !get_args()->get_link() ) {
    480                     return new AttrExpr(var->build(), (Expression*)0);
    481                 } else if ( TypeValueNode * arg = dynamic_cast<TypeValueNode *>(get_args()->get_link()) ) {
    482                     return new AttrExpr(var->build(), arg->get_decl()->buildType());
     478                    return new AttrExpr( var->build(), ( Expression*)0);
     479                } else if ( TypeValueNode * arg = dynamic_cast<TypeValueNode *>( get_args()->get_link()) ) {
     480                    return new AttrExpr( var->build(), arg->get_decl()->buildType());
    483481                } else {
    484                     return new AttrExpr(var->build(), args.back());
    485                 }
     482                    return new AttrExpr( var->build(), args.back());
     483                } // if
    486484            }
    487485          case OperatorNode::CompLit:
     
    490488          case OperatorNode::Or:
    491489          case OperatorNode::And:
    492             assert(args.size() == 2);
    493             return new LogicalExpr( notZeroExpr( args.front() ), notZeroExpr( args.back() ), (op->get_type() == OperatorNode::And) );
     490            assert( args.size() == 2);
     491            return new LogicalExpr( notZeroExpr( args.front() ), notZeroExpr( args.back() ), ( op->get_type() == OperatorNode::And ) );
    494492          case OperatorNode::Cond:
    495493            {
    496                 assert(args.size() == 3);
     494                assert( args.size() == 3);
    497495                std::list< Expression* >::const_iterator i = args.begin();
    498496                Expression *arg1 = notZeroExpr( *i++ );
     
    505503          case OperatorNode::Comma:
    506504            {
    507                 assert(args.size() == 2);
     505                assert( args.size() == 2);
    508506                std::list< Expression* >::const_iterator i = args.begin();
    509507                Expression *ret = *i++;
     
    527525}
    528526
    529 void CompositeExprNode::printOneLine(std::ostream &os, int indent) const {
    530     printDesignation(os);
     527void CompositeExprNode::printOneLine( std::ostream &os, int indent ) const {
     528    printDesignation( os );
    531529    os << "( ";
    532530    function->printOneLine( os, indent );
    533     for( ExpressionNode *cur = arguments; cur != 0; cur = dynamic_cast< ExpressionNode* >( cur->get_link() ) ) {
     531    for ( ExpressionNode *cur = arguments; cur != 0; cur = dynamic_cast< ExpressionNode* >( cur->get_link() ) ) {
    534532        cur->printOneLine( os, indent );
    535533    }
     
    537535}
    538536
    539 void CompositeExprNode::print(std::ostream &os, int indent) const {
    540     printDesignation(os);
    541     os << '\r' << string(indent, ' ') << "Application of: " << endl;
     537void CompositeExprNode::print( std::ostream &os, int indent ) const {
     538    printDesignation( os );
     539    os << '\r' << string( indent, ' ') << "Application of: " << endl;
    542540    function->print( os, indent + ParseNode::indent_by );
    543541
    544     os << '\r' << string(indent, ' ') ;
     542    os << '\r' << string( indent, ' ') ;
    545543    if ( arguments ) {
    546544        os << "... on arguments: " << endl;
    547         arguments->printList(os, indent + ParseNode::indent_by);
     545        arguments->printList( os, indent + ParseNode::indent_by );
    548546    } else
    549547        os << "... on no arguments: " << endl;
    550548}
    551549
    552 void CompositeExprNode::set_function(ExpressionNode *f){
     550void CompositeExprNode::set_function( ExpressionNode *f ){
    553551    function = f;
    554552}
    555553
    556 void CompositeExprNode::set_args(ExpressionNode *args){
     554void CompositeExprNode::set_args( ExpressionNode *args ){
    557555    arguments = args;
    558556}
    559557
    560 ExpressionNode *CompositeExprNode::get_function(void) const {
     558ExpressionNode *CompositeExprNode::get_function( void ) const {
    561559    return function;
    562560}
    563561
    564 ExpressionNode *CompositeExprNode::get_args(void) const {
     562ExpressionNode *CompositeExprNode::get_args( void ) const {
    565563    return arguments;
    566564}
    567565
    568 void CompositeExprNode::add_arg(ExpressionNode *arg){
    569     if (arguments)
    570         arguments->set_link(arg);
     566void CompositeExprNode::add_arg( ExpressionNode *arg ){
     567    if ( arguments )
     568        arguments->set_link( arg );
    571569    else
    572         set_args(arg);
    573 }
    574 
    575 CommaExprNode::CommaExprNode(): CompositeExprNode(new OperatorNode(OperatorNode::Comma)) {}
    576 
    577 CommaExprNode::CommaExprNode(ExpressionNode *exp) : CompositeExprNode( new OperatorNode(OperatorNode::Comma), exp ) {
    578 }
    579 
    580 CommaExprNode::CommaExprNode(ExpressionNode *exp1, ExpressionNode *exp2) : CompositeExprNode(new OperatorNode(OperatorNode::Comma), exp1, exp2) {
    581 }
    582 
    583 CommaExprNode *CommaExprNode::add_to_list(ExpressionNode *exp){
    584     add_arg(exp);
     570        set_args( arg );
     571}
     572
     573CommaExprNode::CommaExprNode(): CompositeExprNode( new OperatorNode( OperatorNode::Comma )) {}
     574
     575CommaExprNode::CommaExprNode( ExpressionNode *exp ) : CompositeExprNode( new OperatorNode( OperatorNode::Comma ), exp ) {
     576}
     577
     578CommaExprNode::CommaExprNode( ExpressionNode *exp1, ExpressionNode *exp2) : CompositeExprNode( new OperatorNode( OperatorNode::Comma ), exp1, exp2) {
     579}
     580
     581CommaExprNode *CommaExprNode::add_to_list( ExpressionNode *exp ){
     582    add_arg( exp );
    585583
    586584    return this;
     
    590588}
    591589
    592 ValofExprNode::ValofExprNode(StatementNode *s): body(s) {}
     590ValofExprNode::ValofExprNode( StatementNode *s ): body( s ) {}
    593591
    594592ValofExprNode::ValofExprNode( const ValofExprNode &other ) : ExpressionNode( other ), body( maybeClone( body ) ) {
     
    600598
    601599void ValofExprNode::print( std::ostream &os, int indent ) const {
    602     printDesignation(os);
    603     os << string(indent, ' ') << "Valof Expression:" << std::endl;
    604     get_body()->print(os, indent + 4);
     600    printDesignation( os );
     601    os << string( indent, ' ') << "Valof Expression:" << std::endl;
     602    get_body()->print( os, indent + 4);
    605603}
    606604
     
    613611}
    614612
    615 ForCtlExprNode::ForCtlExprNode(ParseNode *init_, ExpressionNode *cond, ExpressionNode *incr) throw (SemanticError) : condition(cond), change(incr) {
     613ForCtlExprNode::ForCtlExprNode( ParseNode *init_, ExpressionNode *cond, ExpressionNode *incr ) throw ( SemanticError ) : condition( cond ), change( incr ) {
    616614    if ( init_ == 0 )
    617615        init = 0;
     
    620618        ExpressionNode *exp;
    621619
    622         if ((decl = dynamic_cast<DeclarationNode *>(init_)) != 0)
    623             init = new StatementNode(decl);
    624         else if ((exp = dynamic_cast<ExpressionNode *>(init_)) != 0)
    625             init = new StatementNode(StatementNode::Exp, exp);
     620        if (( decl = dynamic_cast<DeclarationNode *>( init_)) != 0)
     621            init = new StatementNode( decl );
     622        else if (( exp = dynamic_cast<ExpressionNode *>( init_)) != 0)
     623            init = new StatementNode( StatementNode::Exp, exp );
    626624        else
    627625            throw SemanticError("Error in for control expression");
     
    646644
    647645void ForCtlExprNode::print( std::ostream &os, int indent ) const{
    648     os << string(indent,' ') << "For Control Expression -- : " << endl;
    649 
    650     os << "\r" << string(indent + 2,' ') << "initialization: ";
    651     if (init != 0)
    652         init->print(os, indent + 4);
    653 
    654     os << "\n\r" << string(indent + 2,' ') << "condition: ";
    655     if (condition != 0)
    656         condition->print(os, indent + 4);
    657     os << "\n\r" << string(indent + 2,' ') << "increment: ";
    658     if (change != 0)
    659         change->print(os, indent + 4);
     646    os << string( indent,' ') << "For Control Expression -- : " << endl;
     647
     648    os << "\r" << string( indent + 2,' ') << "initialization: ";
     649    if ( init != 0)
     650        init->print( os, indent + 4);
     651
     652    os << "\n\r" << string( indent + 2,' ') << "condition: ";
     653    if ( condition != 0)
     654        condition->print( os, indent + 4);
     655    os << "\n\r" << string( indent + 2,' ') << "increment: ";
     656    if ( change != 0)
     657        change->print( os, indent + 4);
    660658}
    661659
     
    664662}
    665663
    666 TypeValueNode::TypeValueNode(DeclarationNode *decl)
     664TypeValueNode::TypeValueNode( DeclarationNode *decl )
    667665    : decl( decl ) {
    668666}
     
    676674}
    677675
    678 void TypeValueNode::print(std::ostream &os, int indent) const {
     676void TypeValueNode::print( std::ostream &os, int indent ) const {
    679677    os << std::string( indent, ' ' ) << "Type:";
    680     get_decl()->print(os, indent + 2);
    681 }
    682 
    683 void TypeValueNode::printOneLine(std::ostream &os, int indent) const {
     678    get_decl()->print( os, indent + 2);
     679}
     680
     681void TypeValueNode::printOneLine( std::ostream &os, int indent ) const {
    684682    os << "Type:";
    685     get_decl()->print(os, indent + 2);
     683    get_decl()->print( os, indent + 2);
    686684}
    687685
     
    690688        {
    691689            OperatorNode *op;
    692             if ( (op = dynamic_cast< OperatorNode * >( composite->get_function() )) && (op->get_type() == OperatorNode::Comma) )
     690            if ( ( op = dynamic_cast< OperatorNode * >( composite->get_function() )) && ( op->get_type() == OperatorNode::Comma ) )
    693691                {
    694692                    if ( ExpressionNode *next = dynamic_cast< ExpressionNode * >( list->get_link() ) )
     
    707705    if ( CompositeExprNode *composite = dynamic_cast< CompositeExprNode * >( tuple ) ) {
    708706        OperatorNode *op = 0;
    709         if ( (op = dynamic_cast< OperatorNode * >( composite->get_function() )) && (op->get_type() == OperatorNode::TupleC) )
     707        if ( ( op = dynamic_cast< OperatorNode * >( composite->get_function() )) && ( op->get_type() == OperatorNode::TupleC ) )
    710708            return composite->get_args();
    711709    }
  • translator/Parser/InitializerNode.cc

    rad17ba6a rbdd516a  
     1#include <cassert>
     2#include <iostream>
     3using namespace std;
     4
    15#include "ParseNode.h"
    26#include "SynTree/Expression.h"
    37#include "SynTree/Initializer.h"
    4 #include "utility.h"
    5 #include "SemanticError.h"
    6 // #include <cstdlib> // for strtol
    7 #include <cassert>
    8 
    9 #include <iostream>
    10 using namespace std;
    118
    129InitializerNode::InitializerNode( ExpressionNode *_expr, bool aggrp, ExpressionNode *des )
  • translator/Parser/ParseNode.cc

    rad17ba6a rbdd516a  
    7373}
    7474
    75 ParseNode *mkList(ParseNode &pn){
     75ParseNode *mkList( ParseNode &pn ) {
    7676    /* it just relies on `operator,' to take care of the "arguments" and provides
    7777       a nice interface to an awful-looking address-of, rendering, for example
    7878       (StatementNode *)(&(*$5 + *$7)) into (StatementNode *)mkList(($5, $7))
    79        (although "nice"  is probably not the word)
     79       (although "nice" is probably not the word)
    8080    */
    8181    return &pn;
  • translator/Parser/ParseNode.h

    rad17ba6a rbdd516a  
    22#define PARSENODE_H
    33
    4 #include <iostream>
    54#include <string>
    65#include <list>
     
    87
    98#include "utility.h"
    10 #include "SynTree/SynTree.h"
    119#include "SynTree/Declaration.h"
    12 #include "SemanticError.h"
    1310#include "UniqueName.h"
    1411
     
    2320// Builder
    2421class ParseNode {
    25 public:
    26   ParseNode(void);
    27   ParseNode (std::string);
    28   virtual ~ParseNode(void);
    29 
    30   ParseNode *set_name (std::string) ;
    31   ParseNode *set_name (std::string *) ;
    32 
    33   std::string get_name(void);
    34 
    35   ParseNode *get_link(void) const;
    36   ParseNode *get_last(void);
    37   ParseNode *set_link(ParseNode *);
    38   void set_next( ParseNode *newlink ) { next = newlink; }
    39 
    40   virtual ParseNode *clone() const { return 0; };
    41 
    42   const std::string get_name(void) const;
    43   virtual void print( std::ostream &, int indent = 0 ) const;
    44   virtual void printList( std::ostream &, int indent = 0 ) const;
    45 
    46   ParseNode &operator,(ParseNode &);
    47 
    48 protected:
    49   std::string name;
    50   ParseNode *next;
    51   static int indent_by;
    52 };
    53 
    54 ParseNode *mkList(ParseNode &);
     22  public:
     23    ParseNode( void );
     24    ParseNode ( std::string );
     25    virtual ~ParseNode( void );
     26
     27    ParseNode *set_name ( std::string ) ;
     28    ParseNode *set_name ( std::string * ) ;
     29
     30    std::string get_name( void );
     31
     32    ParseNode *get_link( void ) const;
     33    ParseNode *get_last( void );
     34    ParseNode *set_link( ParseNode * );
     35    void set_next( ParseNode *newlink ) { next = newlink; }
     36
     37    virtual ParseNode *clone() const { return 0; };
     38
     39    const std::string get_name( void ) const;
     40    virtual void print( std::ostream &, int indent = 0 ) const;
     41    virtual void printList( std::ostream &, int indent = 0 ) const;
     42
     43    ParseNode &operator,( ParseNode &);
     44  protected:
     45    std::string name;
     46    ParseNode *next;
     47    static int indent_by;
     48};
     49
     50ParseNode *mkList( ParseNode & );
    5551
    5652class ExpressionNode : public ParseNode {
    57 public:
    58   ExpressionNode();
    59   ExpressionNode(std::string *);
    60   ExpressionNode( const ExpressionNode &other );
    61   virtual ~ExpressionNode() { /* can't delete asArgName because it might be referenced elsewhere */ };
    62 
    63   virtual ExpressionNode *clone() const = 0;
    64 
    65   virtual CommaExprNode *add_to_list(ExpressionNode *);
    66 
    67   ExpressionNode *get_argName() const { return argName; }
    68   ExpressionNode *set_asArgName( std::string *aName );
    69   ExpressionNode *set_asArgName( ExpressionNode *aDesignator );
    70 
    71   virtual void print(std::ostream &, int indent = 0) const = 0;
    72   virtual void printOneLine(std::ostream &, int indent = 0) const = 0;
    73 
    74   virtual Expression *build() const = 0;
    75 protected:
    76   void printDesignation (std::ostream &, int indent = 0) const;
    77 
    78 private:
    79   ExpressionNode *argName;
    80 };
    81 
    82 // NullExprNode is used in tuples as a place-holder where a tuple component is omitted
    83 // e.g., [ 2, , 3 ]
    84 class NullExprNode : public ExpressionNode
    85 {
    86 public:
    87   NullExprNode();
    88 
    89   virtual NullExprNode *clone() const;
    90 
    91   virtual void print(std::ostream &, int indent = 0) const;
    92   virtual void printOneLine(std::ostream &, int indent = 0) const;
    93 
    94   virtual Expression *build() const;
     53  public:
     54    ExpressionNode();
     55    ExpressionNode( std::string * );
     56    ExpressionNode( const ExpressionNode &other );
     57    virtual ~ExpressionNode() { /* can't delete asArgName because it might be referenced elsewhere */ };
     58
     59    virtual ExpressionNode *clone() const = 0;
     60
     61    virtual CommaExprNode *add_to_list( ExpressionNode * );
     62
     63    ExpressionNode *get_argName() const { return argName; }
     64    ExpressionNode *set_asArgName( std::string *aName );
     65    ExpressionNode *set_asArgName( ExpressionNode *aDesignator );
     66
     67    virtual void print( std::ostream &, int indent = 0) const = 0;
     68    virtual void printOneLine( std::ostream &, int indent = 0) const = 0;
     69
     70    virtual Expression *build() const = 0;
     71  protected:
     72    void printDesignation ( std::ostream &, int indent = 0) const;
     73  private:
     74    ExpressionNode *argName;
     75};
     76
     77// NullExprNode is used in tuples as a place-holder where a tuple component is omitted e.g., [ 2, , 3 ]
     78class NullExprNode : public ExpressionNode {
     79  public:
     80    NullExprNode();
     81
     82    virtual NullExprNode *clone() const;
     83
     84    virtual void print( std::ostream &, int indent = 0) const;
     85    virtual void printOneLine( std::ostream &, int indent = 0) const;
     86
     87    virtual Expression *build() const;
    9588};
    9689
    9790class ConstantNode : public ExpressionNode {
    98 public:
    99   enum Type {
    100     Integer, Float, Character, String /* , Range, EnumConstant  */
    101   };
    102 
    103   ConstantNode(void);
    104   ConstantNode(std::string *);
    105   ConstantNode(Type, std::string *);
    106   ConstantNode( const ConstantNode &other );
    107 
    108   virtual ConstantNode *clone() const { return new ConstantNode( *this ); }
    109 
    110   Type get_type(void) const ;
    111   virtual void print(std::ostream &, int indent = 0) const;
    112   virtual void printOneLine(std::ostream &, int indent = 0) const;
    113 
    114   std::string get_value() const { return value; }
    115   ConstantNode *append( std::string *newValue );
    116 
    117   Expression *build() const;
    118 
    119 private:
    120   void classify(std::string &);
    121   Type type;
    122   std::string value;
    123   bool sign;
    124   short base;
    125   int longs, size;
     91  public:
     92    enum Type {
     93        Integer, Float, Character, String /* , Range, EnumConstant  */
     94    };
     95
     96    ConstantNode( void );
     97    ConstantNode( std::string * );
     98    ConstantNode( Type, std::string * );
     99    ConstantNode( const ConstantNode &other );
     100
     101    virtual ConstantNode *clone() const { return new ConstantNode( *this ); }
     102
     103    Type get_type( void ) const ;
     104    virtual void print( std::ostream &, int indent = 0) const;
     105    virtual void printOneLine( std::ostream &, int indent = 0) const;
     106
     107    std::string get_value() const { return value; }
     108    ConstantNode *append( std::string *newValue );
     109
     110    Expression *build() const;
     111  private:
     112    void classify( std::string &);
     113    Type type;
     114    std::string value;
     115    bool sign;
     116    short base;
     117    int longs, size;
    126118};
    127119
    128120class VarRefNode : public ExpressionNode {
    129 public:
    130   VarRefNode();
    131   VarRefNode(std::string *, bool isLabel = false );
    132   VarRefNode( const VarRefNode &other );
    133 
    134   virtual Expression *build() const ;
    135 
    136   virtual VarRefNode *clone() const { return new VarRefNode( *this ); }
    137 
    138   virtual void print(std::ostream &, int indent = 0) const;
    139   virtual void printOneLine(std::ostream &, int indent = 0) const;
    140 private:
    141   bool isLabel;
    142 };
    143 
    144 class TypeValueNode : public ExpressionNode
    145 {
    146 public:
    147   TypeValueNode(DeclarationNode *);
    148   TypeValueNode( const TypeValueNode &other );
    149 
    150   DeclarationNode *get_decl() const { return decl; }
    151 
    152   virtual Expression *build() const ;
    153 
    154   virtual TypeValueNode *clone() const { return new TypeValueNode( *this ); }
    155 
    156   virtual void print(std::ostream &, int indent = 0) const;
    157   virtual void printOneLine(std::ostream &, int indent = 0) const;
    158 private:
    159   DeclarationNode *decl;
     121  public:
     122    VarRefNode();
     123    VarRefNode( std::string *, bool isLabel = false );
     124    VarRefNode( const VarRefNode &other );
     125
     126    virtual Expression *build() const ;
     127
     128    virtual VarRefNode *clone() const { return new VarRefNode( *this ); }
     129
     130    virtual void print( std::ostream &, int indent = 0) const;
     131    virtual void printOneLine( std::ostream &, int indent = 0) const;
     132  private:
     133    bool isLabel;
     134};
     135
     136class TypeValueNode : public ExpressionNode {
     137  public:
     138    TypeValueNode( DeclarationNode * );
     139    TypeValueNode( const TypeValueNode &other );
     140
     141    DeclarationNode *get_decl() const { return decl; }
     142
     143    virtual Expression *build() const ;
     144
     145    virtual TypeValueNode *clone() const { return new TypeValueNode( *this ); }
     146
     147    virtual void print( std::ostream &, int indent = 0) const;
     148    virtual void printOneLine( std::ostream &, int indent = 0) const;
     149  private:
     150    DeclarationNode *decl;
    160151};
    161152
    162153class OperatorNode : public ExpressionNode {
    163 public:
    164   enum Type { TupleC, Comma, TupleFieldSel,
    165               Cond, NCond,
    166               SizeOf, AlignOf, Attr, CompLit, Plus, Minus, Mul, Div, Mod, Or, And,
     154  public:
     155    enum Type { TupleC, Comma, TupleFieldSel,
     156                Cond, NCond,
     157                SizeOf, AlignOf, Attr, CompLit, Plus, Minus, Mul, Div, Mod, Or, And,
    167158                BitOr, BitAnd, Xor, Cast, LShift, RShift, LThan, GThan, LEThan, GEThan, Eq, Neq,
    168159                Assign, MulAssn, DivAssn, ModAssn, PlusAssn, MinusAssn, LSAssn, RSAssn, AndAssn,
    169160                ERAssn, OrAssn, Index, FieldSel, PFieldSel, Range,
    170               UnPlus, UnMinus, AddressOf, PointTo, Neg, BitNeg, Incr, IncrPost, Decr, DecrPost, LabelAddress
    171             };
    172 
    173   OperatorNode(Type t);
    174   OperatorNode( const OperatorNode &other );
    175   virtual ~OperatorNode();
    176 
    177   virtual OperatorNode *clone() const { return new OperatorNode( *this ); }
    178 
    179   Type get_type(void) const;
    180   std::string get_typename(void) const;
    181 
    182   virtual void print(std::ostream &, int indent = 0) const;
    183   virtual void printOneLine(std::ostream &, int indent = 0) const;
    184 
    185   virtual Expression *build() const { return 0; }
     161                UnPlus, UnMinus, AddressOf, PointTo, Neg, BitNeg, Incr, IncrPost, Decr, DecrPost, LabelAddress
     162    };
     163
     164    OperatorNode( Type t );
     165    OperatorNode( const OperatorNode &other );
     166    virtual ~OperatorNode();
     167
     168    virtual OperatorNode *clone() const { return new OperatorNode( *this ); }
     169
     170    Type get_type( void ) const;
     171    std::string get_typename( void ) const;
     172
     173    virtual void print( std::ostream &, int indent = 0) const;
     174    virtual void printOneLine( std::ostream &, int indent = 0) const;
     175
     176    virtual Expression *build() const { return 0; }
     177  private:
     178    Type type;
     179    static const char *OpName[];
     180};
     181
     182
     183class CompositeExprNode : public ExpressionNode {
     184  public:
     185    CompositeExprNode( void );
     186    CompositeExprNode( std::string * );
     187    CompositeExprNode( ExpressionNode *f, ExpressionNode *args = 0 );
     188    CompositeExprNode( ExpressionNode *f, ExpressionNode *arg1, ExpressionNode *arg2 );
     189    CompositeExprNode( const CompositeExprNode &other );
     190    virtual ~CompositeExprNode();
     191
     192    virtual CompositeExprNode *clone() const { return new CompositeExprNode( *this ); }
     193    virtual Expression *build() const;
     194
     195    virtual void print( std::ostream &, int indent = 0) const;
     196    virtual void printOneLine( std::ostream &, int indent = 0) const;
     197
     198    void set_function( ExpressionNode * );
     199    void set_args( ExpressionNode * );
     200
     201    void add_arg( ExpressionNode * );
     202
     203    ExpressionNode *get_function() const;
     204    ExpressionNode *get_args() const;
     205  private:
     206    ExpressionNode *function;
     207    ExpressionNode *arguments;
     208};
     209
     210class CommaExprNode : public CompositeExprNode {
     211  public:
     212    CommaExprNode();
     213    CommaExprNode( ExpressionNode * );
     214    CommaExprNode( ExpressionNode *, ExpressionNode * );
     215    CommaExprNode( const CommaExprNode &other );
     216
     217    virtual CommaExprNode *add_to_list( ExpressionNode * );
     218    virtual CommaExprNode *clone() const { return new CommaExprNode( *this ); }
     219};
     220
     221class ForCtlExprNode : public ExpressionNode {
     222  public:
     223    ForCtlExprNode( ParseNode *, ExpressionNode *, ExpressionNode * ) throw ( SemanticError );
     224    ForCtlExprNode( const ForCtlExprNode &other );
     225    ~ForCtlExprNode();
     226
     227    StatementNode *get_init() const { return init; }
     228    ExpressionNode *get_condition() const { return condition; }
     229    ExpressionNode *get_change() const { return change; }
     230
     231    virtual ForCtlExprNode *clone() const { return new ForCtlExprNode( *this ); }
     232    virtual Expression *build() const;
     233
     234    virtual void print( std::ostream &, int indent = 0 ) const;
     235    virtual void printOneLine( std::ostream &, int indent = 0 ) const;
     236  private:
     237    StatementNode *init;
     238    ExpressionNode *condition;
     239    ExpressionNode *change;
     240};
     241
     242class ValofExprNode : public ExpressionNode {
     243  public:
     244    ValofExprNode();
     245    ValofExprNode( StatementNode *s = 0 );
     246    ValofExprNode( const ValofExprNode &other );
     247    ~ValofExprNode();
    186248 
    187 private:
    188   Type type;
    189   static const char *OpName[];
    190 };
    191 
    192 
    193 class CompositeExprNode : public ExpressionNode {
    194 public:
    195   CompositeExprNode(void);
    196   CompositeExprNode(std::string *);
    197   CompositeExprNode(ExpressionNode *f, ExpressionNode *args = 0);
    198   CompositeExprNode(ExpressionNode *f, ExpressionNode *arg1, ExpressionNode *arg2);
    199   CompositeExprNode( const CompositeExprNode &other );
    200   virtual ~CompositeExprNode();
    201 
    202   virtual CompositeExprNode *clone() const { return new CompositeExprNode( *this ); }
    203   virtual Expression *build() const;
    204 
    205   virtual void print(std::ostream &, int indent = 0) const;
    206   virtual void printOneLine(std::ostream &, int indent = 0) const;
    207 
    208   void set_function(ExpressionNode *);
    209   void set_args(ExpressionNode *);
    210 
    211   void add_arg(ExpressionNode *);
    212 
    213   ExpressionNode *get_function() const;
    214   ExpressionNode *get_args() const;
    215 
    216 private:
    217   ExpressionNode *function;
    218   ExpressionNode *arguments;
    219 };
    220 
    221 class CommaExprNode : public CompositeExprNode {
    222 public:
    223   CommaExprNode();
    224   CommaExprNode(ExpressionNode *);
    225   CommaExprNode(ExpressionNode *, ExpressionNode *);
    226   CommaExprNode( const CommaExprNode &other );
    227 
    228   virtual CommaExprNode *add_to_list(ExpressionNode *);
    229   virtual CommaExprNode *clone() const { return new CommaExprNode( *this ); }
    230 };
    231 
    232 class ForCtlExprNode : public ExpressionNode {
    233 public:
    234   ForCtlExprNode(ParseNode *, ExpressionNode *, ExpressionNode *) throw (SemanticError);
    235   ForCtlExprNode( const ForCtlExprNode &other );
    236   ~ForCtlExprNode();
    237 
    238   StatementNode *get_init() const { return init; }
    239   ExpressionNode *get_condition() const { return condition; }
    240   ExpressionNode *get_change() const { return change; }
    241 
    242   virtual ForCtlExprNode *clone() const { return new ForCtlExprNode( *this ); }
    243   virtual Expression *build() const;
    244 
    245   virtual void print( std::ostream &, int indent = 0 ) const;
    246   virtual void printOneLine( std::ostream &, int indent = 0 ) const;
    247 private:
    248   StatementNode *init;
    249   ExpressionNode *condition;
    250   ExpressionNode *change;
    251 };
    252 
    253 class ValofExprNode : public ExpressionNode {
    254 public:
    255   ValofExprNode();
    256   ValofExprNode( StatementNode *s = 0 );
    257   ValofExprNode( const ValofExprNode &other );
    258   ~ValofExprNode();
    259  
    260   virtual ValofExprNode *clone() const { return new ValofExprNode( *this ); }
    261 
    262   StatementNode *get_body() const { return body; }
    263   void print( std::ostream &, int indent = 0 ) const;
    264   void printOneLine( std::ostream &, int indent = 0 ) const;
    265   Expression *build() const;
    266 
    267 private:
    268   StatementNode *body;
     249    virtual ValofExprNode *clone() const { return new ValofExprNode( *this ); }
     250
     251    StatementNode *get_body() const { return body; }
     252    void print( std::ostream &, int indent = 0 ) const;
     253    void printOneLine( std::ostream &, int indent = 0 ) const;
     254    Expression *build() const;
     255
     256  private:
     257    StatementNode *body;
    269258};
    270259
    271260class TypeData;
    272261
    273 class DeclarationNode : public ParseNode
    274 {
    275 public:
    276   enum Qualifier { Const, Restrict, Volatile, Lvalue };
    277   enum StorageClass { Static, Auto, Extern, Register, Inline, Fortran };
    278   enum BasicType { Char, Int, Float, Double, Void, Bool, Complex, Imaginary };
    279   enum Modifier { Signed, Unsigned, Short, Long };
    280   enum TyCon { Struct, Union, Context };
    281   enum TypeClass { Type, Dtype, Ftype };
    282 
    283   static const char *qualifierName[];
    284   static const char *basicTypeName[];
    285   static const char *modifierName[];
    286   static const char *tyConName[];
    287   static const char *typeClassName[];
    288 
    289   static DeclarationNode *newFunction( std::string* name, DeclarationNode *ret, DeclarationNode *param,
    290                                        StatementNode *body, bool newStyle = false );
    291   static DeclarationNode *newQualifier( Qualifier );
    292   static DeclarationNode *newStorageClass( StorageClass );
    293   static DeclarationNode *newBasicType( BasicType );
    294   static DeclarationNode *newModifier( Modifier );
    295   static DeclarationNode *newForall( DeclarationNode* );
    296   static DeclarationNode *newFromTypedef( std::string* );
    297   static DeclarationNode *newAggregate( TyCon kind, std::string* name, DeclarationNode *formals, ExpressionNode *actuals, DeclarationNode *fields );
    298   static DeclarationNode *newEnum( std::string *name, DeclarationNode *constants );
    299   static DeclarationNode *newEnumConstant( std::string* name, ExpressionNode *constant );
    300   static DeclarationNode *newName( std::string* );
    301   static DeclarationNode *newFromTypeGen( std::string*, ExpressionNode *params );
    302   static DeclarationNode *newTypeParam( TypeClass, std::string* );
    303   static DeclarationNode *newContext( std::string *name, DeclarationNode *params, DeclarationNode *asserts );
    304   static DeclarationNode *newContextUse( std::string *name, ExpressionNode *params );
    305   static DeclarationNode *newTypeDecl( std::string *name, DeclarationNode *typeParams );
    306   static DeclarationNode *newPointer( DeclarationNode *qualifiers );
    307   static DeclarationNode *newArray( ExpressionNode *size, DeclarationNode *qualifiers, bool isStatic );
    308   static DeclarationNode *newVarArray( DeclarationNode *qualifiers );
    309   static DeclarationNode *newBitfield( ExpressionNode *size );
    310   static DeclarationNode *newTuple( DeclarationNode *members );
    311   static DeclarationNode *newTypeof( ExpressionNode *expr );
    312   static DeclarationNode *newAttr( std::string*, ExpressionNode *expr );
    313   static DeclarationNode *newAttr( std::string*, DeclarationNode *type );
    314 
    315   DeclarationNode *addQualifiers( DeclarationNode* );
    316   DeclarationNode *copyStorageClasses( DeclarationNode* );
    317   DeclarationNode *addType( DeclarationNode* );
    318   DeclarationNode *addTypedef();
    319   DeclarationNode *addAssertions( DeclarationNode* );
    320   DeclarationNode *addName( std::string* );
    321   DeclarationNode *addBitfield( ExpressionNode *size );
    322   DeclarationNode *addVarArgs();
    323   DeclarationNode *addFunctionBody( StatementNode *body );
    324   DeclarationNode *addOldDeclList( DeclarationNode *list );
    325   DeclarationNode *addPointer( DeclarationNode *qualifiers );
    326   DeclarationNode *addArray( DeclarationNode *array );
    327   DeclarationNode *addNewPointer( DeclarationNode *pointer );
    328   DeclarationNode *addNewArray( DeclarationNode *array );
    329   DeclarationNode *addParamList( DeclarationNode *list );
    330   DeclarationNode *addIdList( DeclarationNode *list );       // old-style functions
    331   DeclarationNode *addInitializer( InitializerNode *init );
    332 
    333   DeclarationNode *cloneType( std::string *newName );
    334   DeclarationNode *cloneType( DeclarationNode *existing );
    335   DeclarationNode *cloneType( int ) { return cloneType( (std::string*)0 ); }
    336   DeclarationNode *cloneBaseType( std::string *newName );
    337   DeclarationNode *cloneBaseType( DeclarationNode *newdecl );
    338 
    339   DeclarationNode *appendList( DeclarationNode * );
    340 
    341   DeclarationNode *clone() const;
    342   void print( std::ostream &, int indent = 0 ) const;
    343   void printList( std::ostream &, int indent = 0 ) const;
    344 
    345   Declaration *build() const;
    346   ::Type *buildType() const;
    347 
    348   bool get_hasEllipsis() const;
    349   std::string get_name() const { return name; }
    350   LinkageSpec::Type get_linkage() const { return linkage; }
    351   DeclarationNode *extractAggregate() const;
    352 
    353   DeclarationNode();
    354   ~DeclarationNode();
    355 private:
    356   Declaration::StorageClass buildStorageClass() const;
    357   bool buildInline() const;
    358 
    359   TypeData *type;
    360   std::string name;
    361   std::list< StorageClass > storageClasses;
    362   ExpressionNode *bitfieldWidth;
    363   InitializerNode *initializer;
    364   bool hasEllipsis;
    365   LinkageSpec::Type linkage;
    366 
    367   static UniqueName anonymous;
     262class DeclarationNode : public ParseNode {
     263  public:
     264    enum Qualifier { Const, Restrict, Volatile, Lvalue, Atomic };
     265    enum StorageClass { Static, Auto, Extern, Register, Inline, Fortran };
     266    enum BasicType { Char, Int, Float, Double, Void, Bool, Complex, Imaginary };
     267    enum Modifier { Signed, Unsigned, Short, Long };
     268    enum TyCon { Struct, Union, Context };
     269    enum TypeClass { Type, Dtype, Ftype };
     270
     271    static const char *qualifierName[];
     272    static const char *basicTypeName[];
     273    static const char *modifierName[];
     274    static const char *tyConName[];
     275    static const char *typeClassName[];
     276
     277    static DeclarationNode *newFunction( std::string *name, DeclarationNode *ret, DeclarationNode *param,
     278                                         StatementNode *body, bool newStyle = false );
     279    static DeclarationNode *newQualifier( Qualifier );
     280    static DeclarationNode *newStorageClass( StorageClass );
     281    static DeclarationNode *newBasicType( BasicType );
     282    static DeclarationNode *newModifier( Modifier );
     283    static DeclarationNode *newForall( DeclarationNode *);
     284    static DeclarationNode *newFromTypedef( std::string *);
     285    static DeclarationNode *newAggregate( TyCon kind, std::string *name, DeclarationNode *formals, ExpressionNode *actuals, DeclarationNode *fields );
     286    static DeclarationNode *newEnum( std::string *name, DeclarationNode *constants );
     287    static DeclarationNode *newEnumConstant( std::string *name, ExpressionNode *constant );
     288    static DeclarationNode *newName( std::string *);
     289    static DeclarationNode *newFromTypeGen( std::string*, ExpressionNode *params );
     290    static DeclarationNode *newTypeParam( TypeClass, std::string *);
     291    static DeclarationNode *newContext( std::string *name, DeclarationNode *params, DeclarationNode *asserts );
     292    static DeclarationNode *newContextUse( std::string *name, ExpressionNode *params );
     293    static DeclarationNode *newTypeDecl( std::string *name, DeclarationNode *typeParams );
     294    static DeclarationNode *newPointer( DeclarationNode *qualifiers );
     295    static DeclarationNode *newArray( ExpressionNode *size, DeclarationNode *qualifiers, bool isStatic );
     296    static DeclarationNode *newVarArray( DeclarationNode *qualifiers );
     297    static DeclarationNode *newBitfield( ExpressionNode *size );
     298    static DeclarationNode *newTuple( DeclarationNode *members );
     299    static DeclarationNode *newTypeof( ExpressionNode *expr );
     300    static DeclarationNode *newAttr( std::string*, ExpressionNode *expr );
     301    static DeclarationNode *newAttr( std::string*, DeclarationNode *type );
     302
     303    DeclarationNode *addQualifiers( DeclarationNode *);
     304    DeclarationNode *copyStorageClasses( DeclarationNode *);
     305    DeclarationNode *addType( DeclarationNode *);
     306    DeclarationNode *addTypedef();
     307    DeclarationNode *addAssertions( DeclarationNode *);
     308    DeclarationNode *addName( std::string *);
     309    DeclarationNode *addBitfield( ExpressionNode *size );
     310    DeclarationNode *addVarArgs();
     311    DeclarationNode *addFunctionBody( StatementNode *body );
     312    DeclarationNode *addOldDeclList( DeclarationNode *list );
     313    DeclarationNode *addPointer( DeclarationNode *qualifiers );
     314    DeclarationNode *addArray( DeclarationNode *array );
     315    DeclarationNode *addNewPointer( DeclarationNode *pointer );
     316    DeclarationNode *addNewArray( DeclarationNode *array );
     317    DeclarationNode *addParamList( DeclarationNode *list );
     318    DeclarationNode *addIdList( DeclarationNode *list );       // old-style functions
     319    DeclarationNode *addInitializer( InitializerNode *init );
     320
     321    DeclarationNode *cloneType( std::string *newName );
     322    DeclarationNode *cloneType( DeclarationNode *existing );
     323    DeclarationNode *cloneType( int ) { return cloneType( ( std::string *)0 ); }
     324    DeclarationNode *cloneBaseType( std::string *newName );
     325    DeclarationNode *cloneBaseType( DeclarationNode *newdecl );
     326
     327    DeclarationNode *appendList( DeclarationNode  *);
     328
     329    DeclarationNode *clone() const;
     330    void print( std::ostream &, int indent = 0 ) const;
     331    void printList( std::ostream &, int indent = 0 ) const;
     332
     333    Declaration *build() const;
     334    ::Type *buildType() const;
     335
     336    bool get_hasEllipsis() const;
     337    std::string get_name() const { return name; }
     338    LinkageSpec::Type get_linkage() const { return linkage; }
     339    DeclarationNode *extractAggregate() const;
     340
     341    DeclarationNode();
     342    ~DeclarationNode();
     343  private:
     344    Declaration::StorageClass buildStorageClass() const;
     345    bool buildInline() const;
     346
     347    TypeData *type;
     348    std::string name;
     349    std::list< StorageClass > storageClasses;
     350    ExpressionNode *bitfieldWidth;
     351    InitializerNode *initializer;
     352    bool hasEllipsis;
     353    LinkageSpec::Type linkage;
     354
     355    static UniqueName anonymous;
    368356};
    369357
    370358class StatementNode : public ParseNode {
    371 public:
    372   enum Type { Exp,   If,        Switch,  Case,    Default,  Choose,   Fallthru,
    373               While, Do,        For,
    374               Goto,  Continue,  Break,   Return,  Throw,
    375               Try,   Catch,     Finally, Asm,
    376               Decl
    377             };
    378 
    379   StatementNode( void );
    380   StatementNode( std::string );
    381   StatementNode( Type, ExpressionNode *e = 0, StatementNode *s = 0 );
    382   StatementNode( Type, std::string *target );
    383   StatementNode( DeclarationNode *decl );
    384 
    385 
    386   ~StatementNode(void);
    387 
    388   static StatementNode * newCatchStmt(DeclarationNode *d = 0, StatementNode *s = 0, bool catchRestP = false );
    389 
    390   void set_control(ExpressionNode *);
    391   StatementNode * set_block(StatementNode *);
    392 
    393   ExpressionNode *get_control() const ;
    394   StatementNode *get_block() const;
    395   StatementNode::Type get_type(void) const;
    396 
    397   StatementNode *add_label(std::string *);
    398   std::list<std::string> *get_labels() const;
    399 
    400   void addDeclaration( DeclarationNode *newDecl ) { decl = newDecl; }
    401   void setCatchRest( bool newVal ) { isCatchRest = newVal; }
    402 
    403   std::string get_target() const;
    404 
    405   StatementNode *add_controlexp(ExpressionNode *);
    406   StatementNode *append_block(StatementNode *);
    407   StatementNode *append_last_case(StatementNode *);
    408 
    409   void print( std::ostream &, int indent = 0) const;
    410 
    411   virtual StatementNode *clone() const;
    412 
    413   virtual Statement *build() const;
    414 
    415 private:
    416   static const char *StType[];
    417   Type type;
    418   ExpressionNode *control;
    419   StatementNode *block;
    420   std::list<std::string> *labels;
    421   std::string *target; // target label for jump statements
    422   DeclarationNode *decl;
    423 
    424   bool isCatchRest;
     359  public:
     360    enum Type { Exp,   If,        Switch,  Case,    Default,  Choose,   Fallthru,
     361                While, Do,        For,
     362                Goto,  Continue,  Break,   Return,  Throw,
     363                Try,   Catch,     Finally, Asm,
     364                Decl
     365    };
     366
     367    StatementNode( void );
     368    StatementNode( std::string );
     369    StatementNode( Type, ExpressionNode *e = 0, StatementNode *s = 0 );
     370    StatementNode( Type, std::string *target );
     371    StatementNode( DeclarationNode *decl );
     372
     373
     374    ~StatementNode( void );
     375
     376    static StatementNode  *newCatchStmt( DeclarationNode *d = 0, StatementNode *s = 0, bool catchRestP = false );
     377
     378    void set_control( ExpressionNode * );
     379    StatementNode * set_block( StatementNode * );
     380
     381    ExpressionNode *get_control() const ;
     382    StatementNode *get_block() const;
     383    StatementNode::Type get_type( void ) const;
     384
     385    StatementNode *add_label( std::string * );
     386    std::list<std::string> *get_labels() const;
     387
     388    void addDeclaration( DeclarationNode *newDecl ) { decl = newDecl; }
     389    void setCatchRest( bool newVal ) { isCatchRest = newVal; }
     390
     391    std::string get_target() const;
     392
     393    StatementNode *add_controlexp( ExpressionNode * );
     394    StatementNode *append_block( StatementNode * );
     395    StatementNode *append_last_case( StatementNode * );
     396
     397    void print( std::ostream &, int indent = 0) const;
     398
     399    virtual StatementNode *clone() const;
     400
     401    virtual Statement *build() const;
     402  private:
     403    static const char *StType[];
     404    Type type;
     405    ExpressionNode *control;
     406    StatementNode *block;
     407    std::list<std::string> *labels;
     408    std::string *target;                                // target label for jump statements
     409    DeclarationNode *decl;
     410
     411    bool isCatchRest;
    425412};
    426413
    427414class CompoundStmtNode : public StatementNode {
    428 public:
    429   CompoundStmtNode(void);
    430   CompoundStmtNode(std::string *);
    431   CompoundStmtNode(StatementNode *);
    432   ~CompoundStmtNode();
    433 
    434   void add_statement(StatementNode *);
    435 
    436   void print( std::ostream &, int indent = 0 ) const;
    437 
    438   virtual Statement *build() const;
    439 
    440 private:
    441   StatementNode *first, *last;
     415  public:
     416    CompoundStmtNode( void );
     417    CompoundStmtNode( std::string * );
     418    CompoundStmtNode( StatementNode * );
     419    ~CompoundStmtNode();
     420
     421    void add_statement( StatementNode * );
     422
     423    void print( std::ostream &, int indent = 0 ) const;
     424
     425    virtual Statement *build() const;
     426  private:
     427    StatementNode *first, *last;
    442428};
    443429
    444430class NullStmtNode : public CompoundStmtNode {
    445 public:
    446   Statement *build() const;
    447   void print(std::ostream &, int indent = 0) const;
     431  public:
     432    Statement *build() const;
     433    void print( std::ostream &, int indent = 0) const;
    448434};
    449435
    450436class InitializerNode : public ParseNode {
    451 public:
    452   InitializerNode( ExpressionNode *, bool aggrp = false,  ExpressionNode *des = 0 );
    453   InitializerNode( InitializerNode *, bool aggrp = false, ExpressionNode *des = 0 );
    454   ~InitializerNode();
    455 
    456   ExpressionNode *get_expression() const { return expr; }
    457 
    458   InitializerNode *set_designators( ExpressionNode *des ) { designator = des; return this; }
    459   ExpressionNode *get_designators() const { return designator; }
    460 
    461   InitializerNode *next_init() const { return kids; }
    462 
    463   void print( std::ostream &, int indent = 0 ) const;
    464   void printOneLine( std::ostream & ) const;
    465 
    466   virtual Initializer *build() const;
    467 
    468 private:
    469   ExpressionNode *expr;
    470   bool aggregate;
    471   ExpressionNode *designator; // may be list
    472   InitializerNode *kids;
     437  public:
     438    InitializerNode( ExpressionNode *, bool aggrp = false,  ExpressionNode *des = 0 );
     439    InitializerNode( InitializerNode *, bool aggrp = false, ExpressionNode *des = 0 );
     440    ~InitializerNode();
     441
     442    ExpressionNode *get_expression() const { return expr; }
     443
     444    InitializerNode *set_designators( ExpressionNode *des ) { designator = des; return this; }
     445    ExpressionNode *get_designators() const { return designator; }
     446
     447    InitializerNode *next_init() const { return kids; }
     448
     449    void print( std::ostream &, int indent = 0 ) const;
     450    void printOneLine( std::ostream & ) const;
     451
     452    virtual Initializer *build() const;
     453  private:
     454    ExpressionNode *expr;
     455    bool aggregate;
     456    ExpressionNode *designator; // may be list
     457    InitializerNode *kids;
    473458};
    474459
     
    477462template< typename SynTreeType, typename NodeType >
    478463void
    479 buildList( const NodeType *firstNode, std::list< SynTreeType* > &outputList )
     464buildList( const NodeType *firstNode, std::list< SynTreeType *> &outputList )
    480465{
    481   SemanticError errors;
    482   std::back_insert_iterator< std::list< SynTreeType* > > out( outputList );
    483   const NodeType *cur = firstNode;
    484 
    485   while( cur ) {
    486     try {
    487       SynTreeType *result = dynamic_cast< SynTreeType* >( cur->build() );
    488       if( result ) {
    489         *out++ = result;
    490       } else {
    491       }
    492     } catch( SemanticError &e ) {
    493       errors.append( e );
    494     }
    495     cur = dynamic_cast< NodeType* >( cur->get_link() );
    496   }
    497   if( !errors.isEmpty() ) {
    498     throw errors;
    499   }
     466    SemanticError errors;
     467    std::back_insert_iterator< std::list< SynTreeType *> > out( outputList );
     468    const NodeType *cur = firstNode;
     469
     470    while ( cur ) {
     471        try {
     472            SynTreeType *result = dynamic_cast< SynTreeType *>( cur->build() );
     473            if ( result ) {
     474                *out++ = result;
     475            } else {
     476            } // if
     477        } catch( SemanticError &e ) {
     478            errors.append( e );
     479        } // try
     480        cur = dynamic_cast< NodeType *>( cur->get_link() );
     481    } // while
     482    if ( !errors.isEmpty() ) {
     483        throw errors;
     484    } // if
    500485}
    501486
    502487// in DeclarationNode.cc
    503 void buildList( const DeclarationNode *firstNode, std::list< Declaration* > &outputList );
    504 void buildList( const DeclarationNode *firstNode, std::list< DeclarationWithType* > &outputList );
    505 void buildTypeList( const DeclarationNode *firstNode, std::list< Type* > &outputList );
     488void buildList( const DeclarationNode *firstNode, std::list< Declaration *> &outputList );
     489void buildList( const DeclarationNode *firstNode, std::list< DeclarationWithType *> &outputList );
     490void buildTypeList( const DeclarationNode *firstNode, std::list< Type *> &outputList );
    506491
    507492// in ExpressionNode.cc
     
    509494ExpressionNode *tupleContents( ExpressionNode *tuple );
    510495
    511 #endif /* #ifndef PARSENODE_H */
     496#endif // PARSENODE_H
    512497
    513498// Local Variables: //
  • translator/Parser/TypeData.cc

    rad17ba6a rbdd516a  
    541541          case DeclarationNode::Lvalue:
    542542            q.isLvalue = true;
     543            break;
     544          case DeclarationNode::Atomic:
     545            q.isAtomic = true;
    543546            break;
    544547        }
  • translator/Parser/TypeData.h

    rad17ba6a rbdd516a  
    33
    44#include <list>
     5
    56#include "ParseNode.h"
    6 #include "SynTree/SynTree.h"
    77#include "SynTree/Type.h"
    8 #include "SynTree/Declaration.h"
    9 #include "SemanticError.h"
    10 #include "LinkageSpec.h"
    118
    129struct TypeData {
  • translator/Parser/cfa.y

    rad17ba6a rbdd516a  
    1010 * Created On       : Sat Sep  1 20:22:55 2001
    1111 * Last Modified By : Peter A. Buhr
    12  * Last Modified On : Sat Jan 17 09:23:45 2015
    13  * Update Count     : 908
     12 * Last Modified On : Wed Apr 15 15:11:16 2015
     13 * Update Count     : 913
    1414 */
    1515
     
    11441144        declaration_specifier declarator asm_name_opt initializer_opt
    11451145                {
    1146                         typedefTable.addToEnclosingScope( TypedefTable::ID);
     1146                        typedefTable.addToEnclosingScope( TypedefTable::ID );
    11471147                        $$ = ($2->addType( $1 ))->addInitializer($4);
    11481148                }
     
    12011201        | LVALUE                                        /* CFA */
    12021202                { $$ = DeclarationNode::newQualifier( DeclarationNode::Lvalue ); }
     1203        | ATOMIC
     1204                { $$ = DeclarationNode::newQualifier( DeclarationNode::Atomic ); }
    12031205        | FORALL '('
    12041206                {
  • translator/Parser/parseutility.cc

    rad17ba6a rbdd516a  
    1 /*
    2  * This file is part of the Cforall project
    3  *
    4  * $Id: parseutility.cc,v 1.2 2005/08/29 20:14:15 rcbilson Exp $
    5  *
    6  */
    7 
    81#include "parseutility.h"
    92#include "SynTree/Type.h"
     
    114
    125
    13 Expression *
    14 notZeroExpr( Expression *orig )
    15 {
     6Expression *notZeroExpr( Expression *orig ) {
    167      UntypedExpr *comparison = new UntypedExpr( new NameExpr( "?!=?" ) );
    178      comparison->get_args().push_back( orig );
  • translator/Parser/parseutility.h

    rad17ba6a rbdd516a  
    1 /*
    2  * This file is part of the Cforall project
    3  *
    4  * $Id: parseutility.h,v 1.2 2005/08/29 20:14:15 rcbilson Exp $
    5  *
    6  */
    7 
    81#ifndef PARSER_PARSEUTILITY_H
    92#define PARSER_PARSEUTILITY_H
     
    136Expression *notZeroExpr( Expression *orig );
    147
    15 #endif /* #ifndef PARSER_PARSEUTILITY_H */
     8#endif // PARSER_PARSEUTILITY_H
  • translator/ResolvExpr/AlternativeFinder.cc

    rad17ba6a rbdd516a  
    756756            alternatives.push_back( Alternative( sizeofExpr->clone(), env, Cost::zero ) );
    757757        } else {
     758            // find all alternatives for the argument to sizeof
    758759            AlternativeFinder finder( indexer, env );
    759760            finder.find( sizeofExpr->get_expr() );
    760             if ( finder.alternatives.size() != 1 ) {
     761            // find the lowest cost alternative among the alternatives, otherwise ambiguous
     762            AltList winners;
     763            findMinCost( finder.alternatives.begin(), finder.alternatives.end(), back_inserter( winners ) );
     764            if ( winners.size() != 1 ) {
    761765                throw SemanticError( "Ambiguous expression in sizeof operand: ", sizeofExpr->get_expr() );
    762766            }
    763             Alternative &choice = finder.alternatives.front();
     767            // return the lowest cost alternative for the argument
     768            Alternative &choice = winners.front();
    764769            alternatives.push_back( Alternative( new SizeofExpr( choice.expr->clone() ), choice.env, Cost::zero ) );
    765770        }
  • translator/ResolvExpr/Resolver.cc

    rad17ba6a rbdd516a  
    4444        acceptAll( translationUnit, resolver );
    4545#if 0
     46        resolver.print( cerr );
    4647        for ( std::list< Declaration * >::iterator i = translationUnit.begin(); i != translationUnit.end(); ++i ) {
    4748            (*i)->print( std::cerr );
     
    241242    void Resolver::visit( SingleInit *singleInit ) {
    242243        if ( singleInit->get_value() ) {
     244#if 0
     245            if (NameExpr * ne = dynamic_cast<NameExpr*>(singleInit->get_value())) {
     246                string n = ne->get_name();
     247                if (n == "0") {
     248                    initContext = new BasicType(Type::Qualifiers(),
     249                                                BasicType::SignedInt);
     250                } else {
     251                    DeclarationWithType * decl = lookupId(n);
     252                    initContext = decl->get_type();
     253                }
     254            } else if (ConstantExpr * e =
     255                       dynamic_cast<ConstantExpr*>(singleInit->get_value())) {
     256                Constant *c = e->get_constant();
     257                initContext = c->get_type();
     258            } else {
     259                assert(0);
     260            }
     261#endif
    243262            CastExpr *castExpr = new CastExpr( singleInit->get_value(), initContext->clone() );
    244263            Expression *newExpr = findSingleExpression( castExpr, *this );
     
    250269
    251270    void Resolver::visit( ListInit *listInit ) {
     271        Visitor::visit(listInit);
     272#if 0
    252273        if ( ArrayType *at = dynamic_cast<ArrayType*>(initContext) ) {
    253             initContext = at->get_base();
    254             Visitor::visit( listInit );
     274            std::list<Initializer *>::iterator iter( listInit->begin_initializers() );
     275            for ( ; iter != listInit->end_initializers(); ++iter ) {
     276                initContext = at->get_base();
     277                (*iter)->accept( *this );
     278            } // for
    255279        } else if ( StructInstType *st = dynamic_cast<StructInstType*>(initContext) ) {
    256280            StructDecl *baseStruct = st->get_baseStruct();
     
    295319            (*listInit->begin_initializers())->accept( *this );
    296320        } // if
     321#endif
    297322    }
    298323} // namespace ResolvExpr
  • translator/SymTab/IdTable.cc

    rad17ba6a rbdd516a  
    8282    }
    8383  }
    84   for( InnerTableType::const_iterator i = declTable.begin(); i != declTable.end(); ++i ) {
     84  // ensure the set of routines with C linkage cannot be overloaded
     85  for( InnerTableType::iterator i = declTable.begin(); i != declTable.end(); ++i ) {
    8586    if( !i->second.empty() && i->second.top().first->get_linkage() == LinkageSpec::C && declTable.size() > 1 ) {
    86       throw SemanticError( "invalid overload of C function ", i->second.top().first );
     87        InnerTableType::iterator j = i;
     88        for( j++; j != declTable.end(); ++j ) {
     89          if( !j->second.empty() && j->second.top().first->get_linkage() == LinkageSpec::C ) {
     90            throw SemanticError( "invalid overload of C function " );
     91          }
     92        }
    8793    }
    8894  }
     
    103109}
    104110
     111DeclarationWithType* IdTable::lookupId( const std::string &id) const {
     112   DeclarationWithType* result = 0;
     113   int depth = -1;
     114
     115   OuterTableType::const_iterator outer = table.find( id );
     116   if( outer == table.end() ) return 0;
     117   const InnerTableType &declTable = outer->second;
     118   for( InnerTableType::const_iterator it = declTable.begin(); it != declTable.end(); ++it ) {
     119     const std::stack< DeclEntry >& entry = it->second;
     120     if( !entry.empty() && entry.top().second > depth ) {
     121       result = entry.top().first;
     122       depth = entry.top().second;
     123     }
     124   }
     125   return result;
     126}
     127
    105128void
    106129IdTable::dump( std::ostream &os ) const
    107130{
     131  for( OuterTableType::const_iterator outer = table.begin(); outer != table.end(); ++outer ) {
     132    for( InnerTableType::const_iterator inner = outer->second.begin(); inner != outer->second.end(); ++inner ) {
     133#if 0
     134      const std::stack< DeclEntry >& entry = inner->second;
     135      if( !entry.empty() ) { // && entry.top().second == scopeLevel ) {
     136        os << outer->first << " (" << inner->first << ") (" << entry.top().second << ")" << std::endl;
     137      } else {
     138        os << outer->first << " (" << inner->first << ") ( entry-empty)" << std::endl;
     139      }
     140#endif
     141#if 0
     142      std::stack<DeclEntry> stack = inner->second;
     143      os << "dumping a stack" << std::endl;
     144      while (!stack.empty()) {
     145        DeclEntry d = stack.top();
     146        os << outer->first << " (" << inner->first << ") (" << d.second << ") " << std::endl;
     147        stack.pop();
     148      }
     149#endif
     150    }
     151  }
     152#if 0
    108153  for( OuterTableType::const_iterator outer = table.begin(); outer != table.end(); ++outer ) {
    109154    for( InnerTableType::const_iterator inner = outer->second.begin(); inner != outer->second.end(); ++inner ) {
     
    114159    }
    115160  }
     161#endif
    116162}
    117163
  • translator/SymTab/IdTable.h

    rad17ba6a rbdd516a  
    1 /*
    2  * This file is part of the Cforall project
    3  *
    4  * $Id: IdTable.h,v 1.4 2005/08/29 20:14:17 rcbilson Exp $
    5  *
    6  */
    7 
    81#ifndef SYMTAB_IDTABLE_H
    92#define SYMTAB_IDTABLE_H
     
    1710
    1811namespace SymTab {
     12    class IdTable {
     13      public:
     14        IdTable();
     15 
     16        void enterScope();
     17        void leaveScope();
     18        void addDecl( DeclarationWithType *decl );
     19        void lookupId( const std::string &id, std::list< DeclarationWithType* >& decls ) const;
     20        DeclarationWithType* lookupId( const std::string &id) const;
     21 
     22        void dump( std::ostream &os ) const; // debugging
    1923
    20 class IdTable
    21 {
    22 public:
    23   IdTable();
    24  
    25   void enterScope();
    26   void leaveScope();
    27   void addDecl( DeclarationWithType *decl );
    28   void lookupId( const std::string &id, std::list< DeclarationWithType* >& decls ) const;
    29  
    30   void dump( std::ostream &os ) const; // debugging
     24      private:
     25        typedef std::pair< DeclarationWithType*, int > DeclEntry;
     26        typedef std::map< std::string, std::stack< DeclEntry > > InnerTableType;
     27        typedef std::map< std::string, InnerTableType > OuterTableType;
    3128
    32  private:
    33   typedef std::pair< DeclarationWithType*, int > DeclEntry;
    34   typedef std::map< std::string, std::stack< DeclEntry > > InnerTableType;
    35   typedef std::map< std::string, InnerTableType > OuterTableType;
    36 
    37   OuterTableType table;
    38   int scopeLevel;
    39 };
    40 
     29        OuterTableType table;
     30        int scopeLevel;
     31    };
    4132} // namespace SymTab
    4233
    43 #endif /* #ifndef SYMTAB_IDTABLE_H */
     34#endif // SYMTAB_IDTABLE_H
  • translator/SymTab/Indexer.cc

    rad17ba6a rbdd516a  
    162162    }
    163163
     164    DeclarationWithType* Indexer::lookupId( const std::string &id) const {
     165        return idTable.lookupId(id);
     166    }
     167
    164168    NamedTypeDecl *Indexer::lookupType( const std::string &id ) const {
    165169        return typeTable.lookup( id );
     
    216220
    217221    void Indexer::print( std::ostream &os, int indent ) const {
     222        using std::cerr;
     223        using std::endl;
     224
     225        cerr << "===idTable===" << endl;
     226        idTable.dump( os );
     227        cerr << "===typeTable===" << endl;
     228        typeTable.dump( os );
     229        cerr << "===structTable===" << endl;
     230        structTable.dump( os );
     231        cerr << "===enumTable===" << endl;
     232        enumTable.dump( os );
     233        cerr << "===unionTable===" << endl;
     234        unionTable.dump( os );
     235        cerr << "===contextTable===" << endl;
     236        contextTable.dump( os );
     237#if 0
    218238        idTable.dump( os );
    219239        typeTable.dump( os );
     
    222242        unionTable.dump( os );
    223243        contextTable.dump( os );
     244#endif
    224245    }
    225246} // namespace SymTab
  • translator/SymTab/Indexer.h

    rad17ba6a rbdd516a  
    3939
    4040        void lookupId( const std::string &id, std::list< DeclarationWithType* >& ) const;
     41        DeclarationWithType* lookupId( const std::string &id) const;
    4142        NamedTypeDecl *lookupType( const std::string &id ) const;
    4243        StructDecl *lookupStruct( const std::string &id ) const;
     
    5859} // namespace SymTab
    5960
    60 #endif /* #ifndef SYMTAB_INDEXER_H */
     61#endif // SYMTAB_INDEXER_H
  • translator/SymTab/Mangler.cc

    rad17ba6a rbdd516a  
    226226            mangleName << "L";
    227227        }
     228        if ( type->get_isAtomic() ) {
     229            mangleName << "A";
     230        }
    228231    }
    229232} // SymTab
  • translator/SymTab/Validate.cc

    rad17ba6a rbdd516a  
    278278            ObjectDecl *obj = dynamic_cast< ObjectDecl * >( *i );
    279279            assert( obj );
    280             obj->set_type( new EnumInstType( Type::Qualifiers( true, false, false, false ), enumDecl->get_name() ) );
     280            obj->set_type( new EnumInstType( Type::Qualifiers( true, false, false, false, false ), enumDecl->get_name() ) );
    281281        } // for
    282282        Parent::visit( enumDecl );
  • translator/SynTree/Initializer.cc

    rad17ba6a rbdd516a  
    3939}
    4040
    41 MemberInit::MemberInit( Expression *_value, std::string _member ) : member ( _member ), value ( _value ) {}
    42 
    43 MemberInit::~MemberInit() {}
    44 
    45 MemberInit * MemberInit::clone() const {
    46     return new MemberInit( *this );
    47 }
    48 
    49 void MemberInit::print( std::ostream &os, int indent ) {
    50     os << "Member Initializer";
    51     value->print( os, indent+2 );
    52 }
    53 
    5441ListInit::ListInit( std::list<Initializer*> &_initializers, std::list<Expression *> &_designators )
    5542    : initializers( _initializers ), designators( _designators ) {
  • translator/SynTree/Initializer.h

    rad17ba6a rbdd516a  
    6161};
    6262
    63 // MemberInit represents an initializer for a member of an aggregate object (e.g., struct q { int a; } x = { a : 4 } )
    64 class MemberInit : public Initializer {
    65   public:
    66     MemberInit( Expression *value, std::string member = std::string("") );
    67     virtual ~MemberInit();
    68    
    69     std::string get_member() { return member; }
    70     void set_member( std::string newValue ) { member = newValue; }
    71     Expression *get_value() { return value; }
    72     void set_value( Expression *newValue ) { value = newValue; }
    73 
    74     virtual MemberInit *clone() const;
    75     virtual void accept( Visitor &v ) { v.visit( this ); }
    76     virtual Initializer *acceptMutator( Mutator &m ) { return m.mutate( this ); }
    77     virtual void print( std::ostream &os, int indent = 0 );
    78   private:
    79     std::string member;
    80     Expression *value;
    81 };
    82 
    83 // ElementInit represents an initializer of an element of an array (e.g., [10] int x = { [7] : 4 }
    84 class ElementInit : public Initializer {
    85   public:
    86     ElementInit( Expression *value );
    87     virtual ~ElementInit();
    88    
    89     int get_index() { return index; }
    90     void set_index( int newValue ) { index = newValue; }
    91     Expression *get_value() { return value; }
    92     void set_value( Expression *newValue ) { value = newValue; }
    93 
    94     virtual ElementInit *clone() const;
    95     virtual void accept( Visitor &v ) { v.visit( this ); }
    96     virtual Initializer *acceptMutator( Mutator &m ) { return m.mutate( this ); }
    97     virtual void print( std::ostream &os, int indent = 0 );
    98   private:
    99     int index;
    100     Expression *value;
    101 };
    102 
    10363// ListInit represents an initializer that is composed recursively of a list of initializers; this is used to initialize
    10464// an array or aggregate
  • translator/SynTree/Mutator.cc

    rad17ba6a rbdd516a  
    368368}
    369369
    370 Initializer *Mutator::mutate( MemberInit *memberInit ) {
    371     memberInit->set_value( memberInit->get_value()->acceptMutator( *this ) );
    372     return memberInit;
    373 }
    374 
    375 Initializer *Mutator::mutate( ElementInit *elementInit ) {
    376     elementInit->set_value( elementInit->get_value()->acceptMutator( *this ) );
    377     return elementInit;
    378 }
    379 
    380370Initializer *Mutator::mutate( SingleInit *singleInit ) {
    381371    singleInit->set_value( singleInit->get_value()->acceptMutator( *this ) );
  • translator/SynTree/Mutator.h

    rad17ba6a rbdd516a  
    7272    virtual Type* mutate( AttrType *attrType );
    7373
    74     virtual Initializer* mutate( MemberInit *memberInit );
    75     virtual Initializer* mutate( ElementInit *elementInit );
    7674    virtual Initializer* mutate( SingleInit *singleInit );
    7775    virtual Initializer* mutate( ListInit *listInit );
  • translator/SynTree/SynTree.h

    rad17ba6a rbdd516a  
    8989
    9090class Initializer;
    91 class MemberInit;
    92 class ElementInit;
    9391class SingleInit;
    9492class ListInit;
  • translator/SynTree/Type.cc

    rad17ba6a rbdd516a  
    5757        os << "lvalue ";
    5858    } // if
     59    if ( tq.isAtomic ) {
     60        os << "_Atomic ";
     61    } // if
    5962}
  • translator/SynTree/Type.h

    rad17ba6a rbdd516a  
    1010  public:
    1111    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 ) {}
     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 ) {}
    1414       
    1515        Qualifiers &operator+=( const Qualifiers &other );
     
    2727        bool isRestrict;
    2828        bool isLvalue;
     29        bool isAtomic;
    2930    }; 
    3031
     
    3839    bool get_isRestrict() { return tq.isRestrict; }
    3940    bool get_isLvalue() { return tq.isLvalue; }
     41    bool get_isAtomic() { return tq.isAtomic; }
    4042    void set_isConst( bool newValue ) { tq.isConst = newValue; }
    4143    void set_iisVolatile( bool newValue ) { tq.isVolatile = newValue; }
    4244    void set_isRestrict( bool newValue ) { tq.isRestrict = newValue; }
    4345    void set_isLvalue( bool newValue ) { tq.isLvalue = newValue; }
     46    void set_isAtomic( bool newValue ) { tq.isAtomic = newValue; }
    4447    std::list<TypeDecl*>& get_forall() { return forall; }
    4548
     
    380383    isRestrict |= other.isRestrict;
    381384    isLvalue |= other.isLvalue;
     385    isAtomic |= other.isAtomic;
    382386    return *this;
    383387}
     
    387391    if ( other.isVolatile ) isVolatile = 0;
    388392    if ( other.isRestrict ) isRestrict = 0;
     393    if ( other.isAtomic ) isAtomic = 0;
    389394    return *this;
    390395}
     
    398403inline bool Type::Qualifiers::operator==( const Qualifiers &other ) {
    399404    return isConst == other.isConst
    400     && isVolatile == other.isVolatile
    401     && isRestrict == other.isRestrict;
    402 ///         && isLvalue == other.isLvalue;
     405        && isVolatile == other.isVolatile
     406        && isRestrict == other.isRestrict
     407//      && isLvalue == other.isLvalue
     408        && isAtomic == other.isAtomic;
    403409}
    404410
     
    406412    return isConst != other.isConst
    407413        || isVolatile != other.isVolatile
    408         || isRestrict != other.isRestrict;
    409 ///         && isLvalue == other.isLvalue;
     414        || isRestrict != other.isRestrict
     415//      || isLvalue != other.isLvalue
     416        || isAtomic != other.isAtomic;
    410417}
    411418
     
    413420    return isConst <= other.isConst
    414421        && isVolatile <= other.isVolatile
    415         && isRestrict <= other.isRestrict;
    416 ///         && isLvalue >= other.isLvalue;
     422        && isRestrict <= other.isRestrict
     423//      && isLvalue >= other.isLvalue
     424        && isAtomic == other.isAtomic;
    417425}
    418426
     
    420428    return isConst >= other.isConst
    421429        && isVolatile >= other.isVolatile
    422         && isRestrict >= other.isRestrict;
    423 ///         && isLvalue <= other.isLvalue;
     430        && isRestrict >= other.isRestrict
     431//      && isLvalue <= other.isLvalue
     432        && isAtomic == other.isAtomic;
    424433}
    425434
  • translator/SynTree/Visitor.cc

    rad17ba6a rbdd516a  
    309309}
    310310
    311 void Visitor::visit(MemberInit *memberInit) {
    312     memberInit->get_value()->accept( *this );
    313 }
    314 
    315 void Visitor::visit(ElementInit *elementInit) {
    316     elementInit->get_value()->accept( *this );
    317 }
    318 
    319311void Visitor::visit(SingleInit *singleInit) {
    320312    singleInit->get_value()->accept( *this );
  • translator/SynTree/Visitor.h

    rad17ba6a rbdd516a  
    7272    virtual void visit( AttrType *attrType );
    7373
    74     virtual void visit( MemberInit *memberInit );
    75     virtual void visit( ElementInit *elementInit );
    7674    virtual void visit( SingleInit *singleInit );
    7775    virtual void visit( ListInit *listInit );
  • translator/Tests/Parser/Constant0-1.c

    rad17ba6a rbdd516a  
    55int 0;
    66const int 0;
    7 static const int 0;
     7//static const int 0;
    88int 1;
    99const int 1;
    10 static const int 1;
     10//static const int 1;
    1111int 0, 1;
    1212const int 0, 1;
    13 static const int 0, 1;
     13//static const int 0, 1;
    1414struct { int i; } 0;
    1515const struct { int i; } 1;
     
    2727* int x, 0;
    2828const * int x, 0;
    29 static const * int x, 0;
     29//static const * int x, 0;
    3030* struct { int i; } 0;
    3131const * struct { int i; } 0;
    3232static const * struct { int i; } 0;
    33 static * int x, 0;
    34 static const * int x, 0;
     33//static * int x, 0;
     34//static const * int x, 0;
    3535const * * int x, 0;
     36
     37int main() {
     38//int 1, * 0;
     39//* int x, 0;
     40}
  • translator/examples/includes.c

    rad17ba6a rbdd516a  
    3434#include <curses.h>
    3535#else
     36#include <time.h>               // FAILS -- includes locale.h
    3637#endif // 0
    3738
  • translator/examples/min.c

    rad17ba6a rbdd516a  
    1010int main() {
    1111    char c;
    12     c = min( 'a', 'z' );
     12    c = min( 'z', 'a' );
    1313    printf( "minimum %d\n", c );
    1414    int i;
  • translator/examples/square.c

    rad17ba6a rbdd516a  
    1212int main() {
    1313    printf( "result of square of 5 is %d\n", square( 5 ) );
     14    printf( "result of square of 5 is %f\n", square( 5.0 ) );
    1415}
  • translator/examples/sum.c

    rad17ba6a rbdd516a  
    77    T ?+?( T, T );
    88    T ?++( T * );
    9     [T] ?+=?( T *, T );
     9    T ?+=?( T *, T );
    1010};
    1111
    1212forall( type T | sumable( T ) )
    1313T sum( int n, T a[] ) {
    14     T total = 0;                        // instantiate T, select 0
     14    T total;                            // instantiate T, select 0
     15    total = 0;
    1516    for ( int i = 0; i < n; i += 1 )
    1617        total = total + a[i];           // select +
     
    1819}
    1920
     21// Required to satisfy sumable as char does not have addition.
     22const char 0;
     23char ?+?( char op1, char op2 ) { return op1 + op2; }
     24char ?++( char *op ) { return *op + 1; }
     25
     26const double 0; // TEMPORARY, incorrect use of int 0
     27
    2028int main() {
    2129    const int size = 10, low = 0, High = 10;
    22     int si, ai[10]; // size
     30    int si = 0, ai[10]; // size
    2331    int i;
    2432    for ( i = low; i < High; i += 1 ) {
     
    2836    printf( "sum from %d to %d is %d, check %d\n",
    2937            low, High, sum( size, ai ), si );
    30     double sd, ad[10]; // size
     38
     39//    char ci[10];
     40//    char c = sum( size, ci );
     41//    float fi[10];
     42//    float f = sum( size, fi );
     43
     44    double sd = 0.0, ad[10]; // size
    3145    for ( i = low; i < High; i += 1 ) {
    3246        double d = i / (double)size;
  • translator/main.cc

    rad17ba6a rbdd516a  
    4848    bool debugp = false, treep = false, astp = false, manglep = false, symtabp = false, validp = false;
    4949    bool preludep = true, protop = false, libp = false;
    50     bool exprp = false;
     50    bool exprp = false, codegenp = false;
    5151    int c;
    5252    FILE *input, *prelude, *builtins;
     
    5555    opterr = 0;
    5656
    57     while ( (c = getopt( argc, argv, "dtsgmvxcenprlD:" )) != -1 ) {
     57    while ( (c = getopt( argc, argv, "dtsgmvxcenprlDz:" )) != -1 ) {
    5858        switch (c) {
    5959          case 'd':
     
    8989            exprp = true;
    9090            break;
     91          case 'z':
     92            codegenp = true;
     93            break;
    9194          case 'n':
    9295            /* don't read preamble */
     
    234237            return 0;
    235238        } // if
     239
     240        if ( codegenp ) {
     241            // print the tree right before code generation...
     242                        // InitTweak::mutate( translationUnit );
     243            //            InitTweak::tweak( translationUnit );
     244            //printAll( translationUnit, std::cout );
     245
     246            // std::cerr << "finished tweaking" << std::endl;
     247            SymTab::validate( translationUnit, false );
     248            ControlStruct::mutate( translationUnit );
     249            CodeGen::fixNames( translationUnit );
     250            ResolvExpr::resolve( translationUnit );
     251            GenPoly::copyParams( translationUnit );
     252            GenPoly::convertSpecializations( translationUnit );
     253            GenPoly::convertLvalue( translationUnit );
     254            GenPoly::box( translationUnit );
     255            printAll( translationUnit, std::cout );
     256            return 0;
     257        } // if
    236258
    237259        //std::cerr << "before validate" << std::endl;
Note: See TracChangeset for help on using the changeset viewer.