Changeset 5170d95


Ignore:
Timestamp:
Feb 19, 2019, 11:24:40 PM (3 years ago)
Author:
Peter A. Buhr <pabuhr@…>
Branches:
aaron-thesis, arm-eh, cleanup-dtors, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr, persistent-indexer
Children:
2ede686
Parents:
45af7e1
Message:

fix implict void cast problem

Location:
src
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • src/ResolvExpr/Resolver.cc

    r45af7e1 r5170d95  
    1010// Created On       : Sun May 17 12:17:01 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Wed Feb 13 18:13:43 2019
    13 // Update Count     : 216
     12// Last Modified On : Tue Feb 19 18:09:56 2019
     13// Update Count     : 240
    1414//
    1515
     
    5353                }
    5454
    55                 void previsit( FunctionDecl *functionDecl );
    56                 void postvisit( FunctionDecl *functionDecl );
    57                 void previsit( ObjectDecl *objectDecll );
     55                void previsit( FunctionDecl * functionDecl );
     56                void postvisit( FunctionDecl * functionDecl );
     57                void previsit( ObjectDecl * objectDecll );
    5858                void previsit( EnumDecl * enumDecl );
    5959                void previsit( StaticAssertDecl * assertDecl );
     
    6262                void previsit( PointerType * at );
    6363
    64                 void previsit( ExprStmt *exprStmt );
    65                 void previsit( AsmExpr *asmExpr );
    66                 void previsit( AsmStmt *asmStmt );
    67                 void previsit( IfStmt *ifStmt );
    68                 void previsit( WhileStmt *whileStmt );
    69                 void previsit( ForStmt *forStmt );
    70                 void previsit( SwitchStmt *switchStmt );
    71                 void previsit( CaseStmt *caseStmt );
    72                 void previsit( BranchStmt *branchStmt );
    73                 void previsit( ReturnStmt *returnStmt );
    74                 void previsit( ThrowStmt *throwStmt );
    75                 void previsit( CatchStmt *catchStmt );
     64                void previsit( ExprStmt * exprStmt );
     65                void previsit( AsmExpr * asmExpr );
     66                void previsit( AsmStmt * asmStmt );
     67                void previsit( IfStmt * ifStmt );
     68                void previsit( WhileStmt * whileStmt );
     69                void previsit( ForStmt * forStmt );
     70                void previsit( SwitchStmt * switchStmt );
     71                void previsit( CaseStmt * caseStmt );
     72                void previsit( BranchStmt * branchStmt );
     73                void previsit( ReturnStmt * returnStmt );
     74                void previsit( ThrowStmt * throwStmt );
     75                void previsit( CatchStmt * catchStmt );
    7676                void previsit( WaitForStmt * stmt );
    7777
    78                 void previsit( SingleInit *singleInit );
    79                 void previsit( ListInit *listInit );
    80                 void previsit( ConstructorInit *ctorInit );
     78                void previsit( SingleInit * singleInit );
     79                void previsit( ListInit * listInit );
     80                void previsit( ConstructorInit * ctorInit );
    8181          private:
    8282                typedef std::list< Initializer * >::iterator InitIterator;
     
    104104        }
    105105
    106         void resolveDecl( Declaration * decl, const SymTab::Indexer &indexer ) {
     106        void resolveDecl( Declaration * decl, const SymTab::Indexer & indexer ) {
    107107                PassVisitor<Resolver> resolver( indexer );
    108108                maybeAccept( decl, resolver );
     
    148148                };
    149149
    150                 void finishExpr( Expression *&expr, const TypeEnvironment &env, TypeSubstitution * oldenv = nullptr ) {
     150                void finishExpr( Expression *& expr, const TypeEnvironment & env, TypeSubstitution * oldenv = nullptr ) {
    151151                        expr->env = oldenv ? oldenv->clone() : new TypeSubstitution;
    152152                        env.makeSubstitution( *expr->env );
     
    279279
    280280        // used in resolveTypeof
    281         Expression * resolveInVoidContext( Expression *expr, const SymTab::Indexer &indexer ) {
     281        Expression * resolveInVoidContext( Expression * expr, const SymTab::Indexer & indexer ) {
    282282                TypeEnvironment env;
    283283                return resolveInVoidContext( expr, indexer, env );
    284284        }
    285285
    286         Expression * resolveInVoidContext( Expression *expr, const SymTab::Indexer &indexer, TypeEnvironment &env ) {
     286        Expression * resolveInVoidContext( Expression * expr, const SymTab::Indexer & indexer, TypeEnvironment & env ) {
    287287                // it's a property of the language that a cast expression has either 1 or 0 interpretations; if it has 0
    288288                // interpretations, an exception has already been thrown.
    289289                assertf( expr, "expected a non-null expression." );
    290290
    291                 static CastExpr untyped( nullptr ); // cast to void
    292                 untyped.location = expr->location;
     291                CastExpr * untyped = new CastExpr( expr ); // cast to void
     292                untyped->location = expr->location;
    293293
    294294                // set up and resolve expression cast to void
    295                 untyped.arg = expr;
    296295                Alternative choice;
    297                 findUnfinishedKindExpression( &untyped, choice, indexer, "", standardAlternativeFilter, ResolvMode::withAdjustment() );
     296                findUnfinishedKindExpression( untyped, choice, indexer, "", standardAlternativeFilter, ResolvMode::withAdjustment() );
    298297                CastExpr * castExpr = strict_dynamic_cast< CastExpr * >( choice.expr );
     298                assert( castExpr );
    299299                env = std::move( choice.env );
    300300
     
    304304
    305305                // unlink the arg so that it isn't deleted twice at the end of the program
    306                 untyped.arg = nullptr;
     306                untyped->arg = nullptr;
    307307                return ret;
    308308        }
    309309
    310         void findVoidExpression( Expression *& untyped, const SymTab::Indexer &indexer ) {
     310        void findVoidExpression( Expression *& untyped, const SymTab::Indexer & indexer ) {
    311311                resetTyVarRenaming();
    312312                TypeEnvironment env;
     
    317317        }
    318318
    319         void findSingleExpression( Expression *&untyped, const SymTab::Indexer &indexer ) {
     319        void findSingleExpression( Expression *& untyped, const SymTab::Indexer & indexer ) {
    320320                findKindExpression( untyped, indexer, "", standardAlternativeFilter );
    321321        }
     
    336336                        if ( dynamic_cast< EnumInstType * >( type ) ) {
    337337                                return true;
    338                         } else if ( BasicType *bt = dynamic_cast< BasicType * >( type ) ) {
     338                        } else if ( BasicType * bt = dynamic_cast< BasicType * >( type ) ) {
    339339                                return bt->isInteger();
    340340                        } else if ( dynamic_cast< ZeroType* >( type ) != nullptr || dynamic_cast< OneType* >( type ) != nullptr ) {
     
    345345                }
    346346
    347                 void findIntegralExpression( Expression *& untyped, const SymTab::Indexer &indexer ) {
     347                void findIntegralExpression( Expression *& untyped, const SymTab::Indexer & indexer ) {
    348348                        findKindExpression( untyped, indexer, "condition", isIntegralType );
    349349                }
     
    401401        }
    402402
    403         void Resolver::previsit( ObjectDecl *objectDecl ) {
     403        void Resolver::previsit( ObjectDecl * objectDecl ) {
    404404                // To handle initialization of routine pointers, e.g., int (*fp)(int) = foo(), means that
    405405                // class-variable initContext is changed multiple time because the LHS is analysed twice.
     
    431431        }
    432432
    433         void Resolver::previsit( FunctionDecl *functionDecl ) {
     433        void Resolver::previsit( FunctionDecl * functionDecl ) {
    434434#if 0
    435435                std::cerr << "resolver visiting functiondecl ";
     
    441441        }
    442442
    443         void Resolver::postvisit( FunctionDecl *functionDecl ) {
     443        void Resolver::postvisit( FunctionDecl * functionDecl ) {
    444444                // default value expressions have an environment which shouldn't be there and trips up
    445445                // later passes.
     
    466466        }
    467467
    468         void Resolver::previsit( ExprStmt *exprStmt ) {
     468        void Resolver::previsit( ExprStmt * exprStmt ) {
    469469                visit_children = false;
    470470                assertf( exprStmt->expr, "ExprStmt has null Expression in resolver" );
     
    472472        }
    473473
    474         void Resolver::previsit( AsmExpr *asmExpr ) {
     474        void Resolver::previsit( AsmExpr * asmExpr ) {
    475475                visit_children = false;
    476476                findVoidExpression( asmExpr->operand, indexer );
     
    480480        }
    481481
    482         void Resolver::previsit( AsmStmt *asmStmt ) {
     482        void Resolver::previsit( AsmStmt * asmStmt ) {
    483483                visit_children = false;
    484484                acceptAll( asmStmt->get_input(), *visitor );
     
    486486        }
    487487
    488         void Resolver::previsit( IfStmt *ifStmt ) {
     488        void Resolver::previsit( IfStmt * ifStmt ) {
    489489                findIntegralExpression( ifStmt->condition, indexer );
    490490        }
    491491
    492         void Resolver::previsit( WhileStmt *whileStmt ) {
     492        void Resolver::previsit( WhileStmt * whileStmt ) {
    493493                findIntegralExpression( whileStmt->condition, indexer );
    494494        }
    495495
    496         void Resolver::previsit( ForStmt *forStmt ) {
     496        void Resolver::previsit( ForStmt * forStmt ) {
    497497                if ( forStmt->condition ) {
    498498                        findIntegralExpression( forStmt->condition, indexer );
     
    504504        }
    505505
    506         void Resolver::previsit( SwitchStmt *switchStmt ) {
     506        void Resolver::previsit( SwitchStmt * switchStmt ) {
    507507                GuardValue( currentObject );
    508508                findIntegralExpression( switchStmt->condition, indexer );
     
    511511        }
    512512
    513         void Resolver::previsit( CaseStmt *caseStmt ) {
     513        void Resolver::previsit( CaseStmt * caseStmt ) {
    514514                if ( caseStmt->condition ) {
    515515                        std::list< InitAlternative > initAlts = currentObject.getOptions();
     
    530530        }
    531531
    532         void Resolver::previsit( BranchStmt *branchStmt ) {
     532        void Resolver::previsit( BranchStmt * branchStmt ) {
    533533                visit_children = false;
    534534                // must resolve the argument for a computed goto
     
    541541        }
    542542
    543         void Resolver::previsit( ReturnStmt *returnStmt ) {
     543        void Resolver::previsit( ReturnStmt * returnStmt ) {
    544544                visit_children = false;
    545545                if ( returnStmt->expr ) {
     
    548548        }
    549549
    550         void Resolver::previsit( ThrowStmt *throwStmt ) {
     550        void Resolver::previsit( ThrowStmt * throwStmt ) {
    551551                visit_children = false;
    552552                // TODO: Replace *exception type with &exception type.
     
    560560        }
    561561
    562         void Resolver::previsit( CatchStmt *catchStmt ) {
     562        void Resolver::previsit( CatchStmt * catchStmt ) {
    563563                if ( catchStmt->cond ) {
    564564                        findSingleExpression( catchStmt->cond, new BasicType( noQualifiers, BasicType::Bool ), indexer );
     
    724724
    725725                                                }
    726                                                 catch( SemanticErrorException &e ) {
     726                                                catch( SemanticErrorException & e ) {
    727727                                                        errors.append( e );
    728728                                                }
    729729                                        }
    730730                                }
    731                                 catch( SemanticErrorException &e ) {
     731                                catch( SemanticErrorException & e ) {
    732732                                        errors.append( e );
    733733                                }
     
    781781        }
    782782
    783         void Resolver::previsit( SingleInit *singleInit ) {
     783        void Resolver::previsit( SingleInit * singleInit ) {
    784784                visit_children = false;
    785785                // resolve initialization using the possibilities as determined by the currentObject cursor
     
    813813                                if ( PointerType * pt = dynamic_cast< PointerType *>( newExpr->get_result() ) ) {
    814814                                        if ( isCharType( pt->get_base() ) ) {
    815                                                 if ( CastExpr *ce = dynamic_cast< CastExpr * >( newExpr ) ) {
     815                                                if ( CastExpr * ce = dynamic_cast< CastExpr * >( newExpr ) ) {
    816816                                                        // strip cast if we're initializing a char[] with a char *,
    817817                                                        // e.g.  char x[] = "hello";
     
    893893        }
    894894
    895         void Resolver::previsit( ConstructorInit *ctorInit ) {
     895        void Resolver::previsit( ConstructorInit * ctorInit ) {
    896896                visit_children = false;
    897897                // xxx - fallback init has been removed => remove fallbackInit function and remove complexity from FixInit and remove C-init from ConstructorInit
  • src/ResolvExpr/Resolver.h

    r45af7e1 r5170d95  
    1010// Created On       : Sun May 17 12:18:34 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Sat Jul 22 09:36:57 2017
    13 // Update Count     : 3
     12// Last Modified On : Mon Feb 18 20:40:38 2019
     13// Update Count     : 4
    1414//
    1515
     
    2929        /// Checks types and binds syntactic constructs to typed representations
    3030        void resolve( std::list< Declaration * > translationUnit );
    31         void resolveDecl( Declaration *, const SymTab::Indexer &indexer );
    32         Expression *resolveInVoidContext( Expression * expr, const SymTab::Indexer &indexer );
    33         void findVoidExpression( Expression *& untyped, const SymTab::Indexer &indexer );
    34         void findSingleExpression( Expression *& untyped, const SymTab::Indexer &indexer );
    35         void findSingleExpression( Expression *& untyped, Type * type, const SymTab::Indexer &indexer );
     31        void resolveDecl( Declaration *, const SymTab::Indexer & indexer );
     32        Expression *resolveInVoidContext( Expression * expr, const SymTab::Indexer & indexer );
     33        void findVoidExpression( Expression *& untyped, const SymTab::Indexer & indexer );
     34        void findSingleExpression( Expression *& untyped, const SymTab::Indexer & indexer );
     35        void findSingleExpression( Expression *& untyped, Type * type, const SymTab::Indexer & indexer );
    3636        void resolveCtorInit( ConstructorInit * ctorInit, const SymTab::Indexer & indexer );
    3737        void resolveStmtExpr( StmtExpr * stmtExpr, const SymTab::Indexer & indexer );
  • src/SynTree/Expression.cc

    r45af7e1 r5170d95  
    1010// Created On       : Mon May 18 07:44:20 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Tue Jul 25 14:15:47 2017
    13 // Update Count     : 54
     12// Last Modified On : Tue Feb 19 18:10:55 2019
     13// Update Count     : 60
    1414//
    1515
     
    3333#include "GenPoly/Lvalue.h"
    3434
    35 void printInferParams( const InferredParams & inferParams, std::ostream &os, Indenter indent, int level ) {
     35void printInferParams( const InferredParams & inferParams, std::ostream & os, Indenter indent, int level ) {
    3636        if ( ! inferParams.empty() ) {
    3737                os << indent << "with inferred parameters " << level << ":" << std::endl;
     
    4747Expression::Expression() : result( 0 ), env( 0 ) {}
    4848
    49 Expression::Expression( const Expression &other ) : BaseSyntaxNode( other ), result( maybeClone( other.result ) ), env( maybeClone( other.env ) ), extension( other.extension ), inferParams( other.inferParams ), resnSlots( other.resnSlots ) {}
     49Expression::Expression( const Expression & other ) : BaseSyntaxNode( other ), result( maybeClone( other.result ) ), env( maybeClone( other.env ) ), extension( other.extension ), inferParams( other.inferParams ), resnSlots( other.resnSlots ) {}
    5050
    5151void Expression::spliceInferParams( Expression * other ) {
     
    6262}
    6363
    64 void Expression::print( std::ostream &os, Indenter indent ) const {
     64void Expression::print( std::ostream & os, Indenter indent ) const {
    6565        printInferParams( inferParams, os, indent+1, 0 );
    6666
     
    7979}
    8080
    81 ConstantExpr::ConstantExpr( const ConstantExpr &other) : Expression( other ), constant( other.constant ) {
     81ConstantExpr::ConstantExpr( const ConstantExpr & other) : Expression( other ), constant( other.constant ) {
    8282}
    8383
    8484ConstantExpr::~ConstantExpr() {}
    8585
    86 void ConstantExpr::print( std::ostream &os, Indenter indent ) const {
     86void ConstantExpr::print( std::ostream & os, Indenter indent ) const {
    8787        os << "constant expression " ;
    8888        constant.print( os );
     
    124124}
    125125
    126 VariableExpr::VariableExpr( const VariableExpr &other ) : Expression( other ), var( other.var ) {
     126VariableExpr::VariableExpr( const VariableExpr & other ) : Expression( other ), var( other.var ) {
    127127}
    128128
     
    137137}
    138138
    139 void VariableExpr::print( std::ostream &os, Indenter indent ) const {
     139void VariableExpr::print( std::ostream & os, Indenter indent ) const {
    140140        os << "Variable Expression: ";
    141141        var->printShort(os, indent);
     
    143143}
    144144
    145 SizeofExpr::SizeofExpr( Expression *expr_ ) :
     145SizeofExpr::SizeofExpr( Expression * expr_ ) :
    146146                Expression(), expr(expr_), type(0), isType(false) {
    147147        set_result( new BasicType( Type::Qualifiers(), BasicType::LongUnsignedInt ) );
    148148}
    149149
    150 SizeofExpr::SizeofExpr( Type *type_ ) :
     150SizeofExpr::SizeofExpr( Type * type_ ) :
    151151                Expression(), expr(0), type(type_), isType(true) {
    152152        set_result( new BasicType( Type::Qualifiers(), BasicType::LongUnsignedInt ) );
    153153}
    154154
    155 SizeofExpr::SizeofExpr( const SizeofExpr &other ) :
     155SizeofExpr::SizeofExpr( const SizeofExpr & other ) :
    156156        Expression( other ), expr( maybeClone( other.expr ) ), type( maybeClone( other.type ) ), isType( other.isType ) {
    157157}
     
    162162}
    163163
    164 void SizeofExpr::print( std::ostream &os, Indenter indent) const {
     164void SizeofExpr::print( std::ostream & os, Indenter indent) const {
    165165        os << "Sizeof Expression on: ";
    166166        if (isType) type->print(os, indent+1);
     
    169169}
    170170
    171 AlignofExpr::AlignofExpr( Expression *expr_ ) :
     171AlignofExpr::AlignofExpr( Expression * expr_ ) :
    172172                Expression(), expr(expr_), type(0), isType(false) {
    173173        set_result( new BasicType( Type::Qualifiers(), BasicType::LongUnsignedInt ) );
    174174}
    175175
    176 AlignofExpr::AlignofExpr( Type *type_ ) :
     176AlignofExpr::AlignofExpr( Type * type_ ) :
    177177                Expression(), expr(0), type(type_), isType(true) {
    178178        set_result( new BasicType( Type::Qualifiers(), BasicType::LongUnsignedInt ) );
    179179}
    180180
    181 AlignofExpr::AlignofExpr( const AlignofExpr &other ) :
     181AlignofExpr::AlignofExpr( const AlignofExpr & other ) :
    182182        Expression( other ), expr( maybeClone( other.expr ) ), type( maybeClone( other.type ) ), isType( other.isType ) {
    183183}
     
    188188}
    189189
    190 void AlignofExpr::print( std::ostream &os, Indenter indent) const {
     190void AlignofExpr::print( std::ostream & os, Indenter indent) const {
    191191        os << "Alignof Expression on: ";
    192192        if (isType) type->print(os, indent+1);
     
    195195}
    196196
    197 UntypedOffsetofExpr::UntypedOffsetofExpr( Type *type, const std::string &member ) :
     197UntypedOffsetofExpr::UntypedOffsetofExpr( Type * type, const std::string & member ) :
    198198                Expression(), type(type), member(member) {
    199199        assert( type );
     
    201201}
    202202
    203 UntypedOffsetofExpr::UntypedOffsetofExpr( const UntypedOffsetofExpr &other ) :
     203UntypedOffsetofExpr::UntypedOffsetofExpr( const UntypedOffsetofExpr & other ) :
    204204        Expression( other ), type( maybeClone( other.type ) ), member( other.member ) {}
    205205
     
    208208}
    209209
    210 void UntypedOffsetofExpr::print( std::ostream &os, Indenter indent) const {
     210void UntypedOffsetofExpr::print( std::ostream & os, Indenter indent) const {
    211211        os << "Untyped Offsetof Expression on member " << member << " of ";
    212212        type->print(os, indent+1);
     
    214214}
    215215
    216 OffsetofExpr::OffsetofExpr( Type *type, DeclarationWithType *member ) :
     216OffsetofExpr::OffsetofExpr( Type * type, DeclarationWithType * member ) :
    217217                Expression(), type(type), member(member) {
    218218        assert( member );
     
    221221}
    222222
    223 OffsetofExpr::OffsetofExpr( const OffsetofExpr &other ) :
     223OffsetofExpr::OffsetofExpr( const OffsetofExpr & other ) :
    224224        Expression( other ), type( maybeClone( other.type ) ), member( other.member ) {}
    225225
     
    228228}
    229229
    230 void OffsetofExpr::print( std::ostream &os, Indenter indent) const {
     230void OffsetofExpr::print( std::ostream & os, Indenter indent) const {
    231231        os << "Offsetof Expression on member " << member->name << " of ";
    232232        type->print(os, indent+1);
     
    234234}
    235235
    236 OffsetPackExpr::OffsetPackExpr( StructInstType *type ) : Expression(), type( type ) {
     236OffsetPackExpr::OffsetPackExpr( StructInstType * type ) : Expression(), type( type ) {
    237237        assert( type );
    238238        set_result( new ArrayType( Type::Qualifiers(), new BasicType( Type::Qualifiers(), BasicType::LongUnsignedInt ), 0, false, false ) );
    239239}
    240240
    241 OffsetPackExpr::OffsetPackExpr( const OffsetPackExpr &other ) : Expression( other ), type( maybeClone( other.type ) ) {}
     241OffsetPackExpr::OffsetPackExpr( const OffsetPackExpr & other ) : Expression( other ), type( maybeClone( other.type ) ) {}
    242242
    243243OffsetPackExpr::~OffsetPackExpr() { delete type; }
    244244
    245 void OffsetPackExpr::print( std::ostream &os, Indenter indent ) const {
     245void OffsetPackExpr::print( std::ostream & os, Indenter indent ) const {
    246246        os << "Offset pack expression on ";
    247247        type->print(os, indent+1);
     
    249249}
    250250
    251 AttrExpr::AttrExpr( Expression *attr, Expression *expr_ ) :
     251AttrExpr::AttrExpr( Expression * attr, Expression * expr_ ) :
    252252                Expression(), attr( attr ), expr(expr_), type(0), isType(false) {
    253253}
    254254
    255 AttrExpr::AttrExpr( Expression *attr, Type *type_ ) :
     255AttrExpr::AttrExpr( Expression * attr, Type * type_ ) :
    256256                Expression(), attr( attr ), expr(0), type(type_), isType(true) {
    257257}
    258258
    259 AttrExpr::AttrExpr( const AttrExpr &other ) :
     259AttrExpr::AttrExpr( const AttrExpr & other ) :
    260260                Expression( other ), attr( maybeClone( other.attr ) ), expr( maybeClone( other.expr ) ), type( maybeClone( other.type ) ), isType( other.isType ) {
    261261}
     
    267267}
    268268
    269 void AttrExpr::print( std::ostream &os, Indenter indent) const {
     269void AttrExpr::print( std::ostream & os, Indenter indent) const {
    270270        os << "Attr ";
    271271        attr->print( os, indent+1);
     
    278278}
    279279
    280 CastExpr::CastExpr( Expression *arg, Type *toType, bool isGenerated ) : Expression(), arg(arg), isGenerated( isGenerated ) {
     280CastExpr::CastExpr( Expression * arg, Type * toType, bool isGenerated ) : arg(arg), isGenerated( isGenerated ) {
    281281        set_result(toType);
    282282}
    283283
    284 CastExpr::CastExpr( Expression *arg, bool isGenerated ) : Expression(), arg(arg), isGenerated( isGenerated ) {
     284CastExpr::CastExpr( Expression * arg, bool isGenerated ) : arg(arg), isGenerated( isGenerated ) {
    285285        set_result( new VoidType( Type::Qualifiers() ) );
    286286}
    287287
    288 CastExpr::CastExpr( const CastExpr &other ) : Expression( other ), arg( maybeClone( other.arg ) ), isGenerated( other.isGenerated ) {
     288CastExpr::CastExpr( const CastExpr & other ) : Expression( other ), arg( maybeClone( other.arg ) ), isGenerated( other.isGenerated ) {
    289289}
    290290
     
    293293}
    294294
    295 void CastExpr::print( std::ostream &os, Indenter indent ) const {
    296         os << "Cast of:" << std::endl << indent+1;
     295void CastExpr::print( std::ostream & os, Indenter indent ) const {
     296        os << (isGenerated ? "Generated " : "Explicit ") << "Cast of:" << std::endl << indent+1;
    297297        arg->print(os, indent+1);
    298298        os << std::endl << indent << "... to:";
     
    306306}
    307307
    308 KeywordCastExpr::KeywordCastExpr( Expression *arg, Target target ) : Expression(), arg(arg), target( target ) {
    309 }
    310 
    311 KeywordCastExpr::KeywordCastExpr( const KeywordCastExpr &other ) : Expression( other ), arg( maybeClone( other.arg ) ), target( other.target ) {
     308KeywordCastExpr::KeywordCastExpr( Expression * arg, Target target ) : Expression(), arg(arg), target( target ) {
     309}
     310
     311KeywordCastExpr::KeywordCastExpr( const KeywordCastExpr & other ) : Expression( other ), arg( maybeClone( other.arg ) ), target( other.target ) {
    312312}
    313313
     
    327327}
    328328
    329 void KeywordCastExpr::print( std::ostream &os, Indenter indent ) const {
     329void KeywordCastExpr::print( std::ostream & os, Indenter indent ) const {
    330330        os << "Keyword Cast of:" << std::endl << indent+1;
    331331        arg->print(os, indent+1);
     
    335335}
    336336
    337 VirtualCastExpr::VirtualCastExpr( Expression *arg_, Type *toType ) : Expression(), arg(arg_) {
     337VirtualCastExpr::VirtualCastExpr( Expression * arg_, Type * toType ) : Expression(), arg(arg_) {
    338338        set_result(toType);
    339339}
    340340
    341 VirtualCastExpr::VirtualCastExpr( const VirtualCastExpr &other ) : Expression( other ), arg( maybeClone( other.arg ) ) {
     341VirtualCastExpr::VirtualCastExpr( const VirtualCastExpr & other ) : Expression( other ), arg( maybeClone( other.arg ) ) {
    342342}
    343343
     
    346346}
    347347
    348 void VirtualCastExpr::print( std::ostream &os, Indenter indent ) const {
     348void VirtualCastExpr::print( std::ostream & os, Indenter indent ) const {
    349349        os << "Virtual Cast of:" << std::endl << indent+1;
    350350        arg->print(os, indent+1);
     
    359359}
    360360
    361 UntypedMemberExpr::UntypedMemberExpr( Expression * member, Expression *aggregate ) :
     361UntypedMemberExpr::UntypedMemberExpr( Expression * member, Expression * aggregate ) :
    362362                Expression(), member(member), aggregate(aggregate) {
    363363        assert( aggregate );
    364364}
    365365
    366 UntypedMemberExpr::UntypedMemberExpr( const UntypedMemberExpr &other ) :
     366UntypedMemberExpr::UntypedMemberExpr( const UntypedMemberExpr & other ) :
    367367                Expression( other ), member( maybeClone( other.member ) ), aggregate( maybeClone( other.aggregate ) ) {
    368368}
     
    373373}
    374374
    375 void UntypedMemberExpr::print( std::ostream &os, Indenter indent ) const {
     375void UntypedMemberExpr::print( std::ostream & os, Indenter indent ) const {
    376376        os << "Untyped Member Expression, with field: " << std::endl << indent+1;
    377377        member->print(os, indent+1 );
     
    381381}
    382382
    383 MemberExpr::MemberExpr( DeclarationWithType *member, Expression *aggregate ) :
     383MemberExpr::MemberExpr( DeclarationWithType * member, Expression * aggregate ) :
    384384                Expression(), member(member), aggregate(aggregate) {
    385385        assert( member );
     
    395395}
    396396
    397 MemberExpr::MemberExpr( const MemberExpr &other ) :
     397MemberExpr::MemberExpr( const MemberExpr & other ) :
    398398                Expression( other ), member( other.member ), aggregate( maybeClone( other.aggregate ) ) {
    399399}
     
    404404}
    405405
    406 void MemberExpr::print( std::ostream &os, Indenter indent ) const {
     406void MemberExpr::print( std::ostream & os, Indenter indent ) const {
    407407        os << "Member Expression, with field:" << std::endl;
    408408        os << indent+1;
     
    413413}
    414414
    415 UntypedExpr::UntypedExpr( Expression *function, const std::list<Expression *> &args ) :
     415UntypedExpr::UntypedExpr( Expression * function, const std::list<Expression *> & args ) :
    416416                Expression(), function(function), args(args) {}
    417417
    418 UntypedExpr::UntypedExpr( const UntypedExpr &other ) :
     418UntypedExpr::UntypedExpr( const UntypedExpr & other ) :
    419419                Expression( other ), function( maybeClone( other.function ) ) {
    420420        cloneAll( other.args, args );
     
    455455
    456456
    457 void UntypedExpr::print( std::ostream &os, Indenter indent ) const {
     457void UntypedExpr::print( std::ostream & os, Indenter indent ) const {
    458458        os << "Applying untyped:" << std::endl;
    459459        os << indent+1;
     
    469469}
    470470
    471 NameExpr::NameExpr( const NameExpr &other ) : Expression( other ), name( other.name ) {
     471NameExpr::NameExpr( const NameExpr & other ) : Expression( other ), name( other.name ) {
    472472}
    473473
    474474NameExpr::~NameExpr() {}
    475475
    476 void NameExpr::print( std::ostream &os, Indenter indent ) const {
     476void NameExpr::print( std::ostream & os, Indenter indent ) const {
    477477        os << "Name: " << get_name();
    478478        Expression::print( os, indent );
    479479}
    480480
    481 LogicalExpr::LogicalExpr( Expression *arg1_, Expression *arg2_, bool andp ) :
     481LogicalExpr::LogicalExpr( Expression * arg1_, Expression * arg2_, bool andp ) :
    482482                Expression(), arg1(arg1_), arg2(arg2_), isAnd(andp) {
    483483        set_result( new BasicType( Type::Qualifiers(), BasicType::SignedInt ) );
    484484}
    485485
    486 LogicalExpr::LogicalExpr( const LogicalExpr &other ) :
     486LogicalExpr::LogicalExpr( const LogicalExpr & other ) :
    487487                Expression( other ), arg1( maybeClone( other.arg1 ) ), arg2( maybeClone( other.arg2 ) ), isAnd( other.isAnd ) {
    488488}
     
    493493}
    494494
    495 void LogicalExpr::print( std::ostream &os, Indenter indent )const {
     495void LogicalExpr::print( std::ostream & os, Indenter indent )const {
    496496        os << "Short-circuited operation (" << (isAnd ? "and" : "or") << ") on: ";
    497497        arg1->print(os);
     
    504504                Expression(), arg1(arg1), arg2(arg2), arg3(arg3) {}
    505505
    506 ConditionalExpr::ConditionalExpr( const ConditionalExpr &other ) :
     506ConditionalExpr::ConditionalExpr( const ConditionalExpr & other ) :
    507507                Expression( other ), arg1( maybeClone( other.arg1 ) ), arg2( maybeClone( other.arg2 ) ), arg3( maybeClone( other.arg3 ) ) {
    508508}
     
    514514}
    515515
    516 void ConditionalExpr::print( std::ostream &os, Indenter indent ) const {
     516void ConditionalExpr::print( std::ostream & os, Indenter indent ) const {
    517517        os << "Conditional expression on: " << std::endl << indent+1;
    518518        arg1->print( os, indent+1 );
     
    527527
    528528
    529 void AsmExpr::print( std::ostream &os, Indenter indent ) const {
     529void AsmExpr::print( std::ostream & os, Indenter indent ) const {
    530530        os << "Asm Expression: " << std::endl;
    531531        if ( inout ) inout->print( os, indent+1 );
     
    555555}
    556556
    557 void ImplicitCopyCtorExpr::print( std::ostream &os, Indenter indent ) const {
     557void ImplicitCopyCtorExpr::print( std::ostream & os, Indenter indent ) const {
    558558        os <<  "Implicit Copy Constructor Expression: " << std::endl << indent+1;
    559559        callExpr->print( os, indent+1 );
     
    581581}
    582582
    583 void ConstructorExpr::print( std::ostream &os, Indenter indent ) const {
     583void ConstructorExpr::print( std::ostream & os, Indenter indent ) const {
    584584        os <<  "Constructor Expression: " << std::endl << indent+1;
    585585        callExpr->print( os, indent + 2 );
     
    594594}
    595595
    596 CompoundLiteralExpr::CompoundLiteralExpr( const CompoundLiteralExpr &other ) : Expression( other ), initializer( other.initializer->clone() ) {}
     596CompoundLiteralExpr::CompoundLiteralExpr( const CompoundLiteralExpr & other ) : Expression( other ), initializer( other.initializer->clone() ) {}
    597597
    598598CompoundLiteralExpr::~CompoundLiteralExpr() {
     
    600600}
    601601
    602 void CompoundLiteralExpr::print( std::ostream &os, Indenter indent ) const {
     602void CompoundLiteralExpr::print( std::ostream & os, Indenter indent ) const {
    603603        os << "Compound Literal Expression: " << std::endl << indent+1;
    604604        result->print( os, indent+1 );
     
    608608}
    609609
    610 RangeExpr::RangeExpr( Expression *low, Expression *high ) : low( low ), high( high ) {}
    611 RangeExpr::RangeExpr( const RangeExpr &other ) : Expression( other ), low( other.low->clone() ), high( other.high->clone() ) {}
    612 void RangeExpr::print( std::ostream &os, Indenter indent ) const {
     610RangeExpr::RangeExpr( Expression * low, Expression * high ) : low( low ), high( high ) {}
     611RangeExpr::RangeExpr( const RangeExpr & other ) : Expression( other ), low( other.low->clone() ), high( other.high->clone() ) {}
     612void RangeExpr::print( std::ostream & os, Indenter indent ) const {
    613613        os << "Range Expression: ";
    614614        low->print( os, indent );
     
    618618}
    619619
    620 StmtExpr::StmtExpr( CompoundStmt *statements ) : statements( statements ) {
     620StmtExpr::StmtExpr( CompoundStmt * statements ) : statements( statements ) {
    621621        computeResult();
    622622}
    623 StmtExpr::StmtExpr( const StmtExpr &other ) : Expression( other ), statements( other.statements->clone() ) {
     623StmtExpr::StmtExpr( const StmtExpr & other ) : Expression( other ), statements( other.statements->clone() ) {
    624624        cloneAll( other.returnDecls, returnDecls );
    625625        cloneAll( other.dtors, dtors );
     
    650650        }
    651651}
    652 void StmtExpr::print( std::ostream &os, Indenter indent ) const {
     652void StmtExpr::print( std::ostream & os, Indenter indent ) const {
    653653        os << "Statement Expression: " << std::endl << indent+1;
    654654        statements->print( os, indent+1 );
     
    666666
    667667long long UniqueExpr::count = 0;
    668 UniqueExpr::UniqueExpr( Expression *expr, long long idVal ) : expr( expr ), object( nullptr ), var( nullptr ), id( idVal ) {
     668UniqueExpr::UniqueExpr( Expression * expr, long long idVal ) : expr( expr ), object( nullptr ), var( nullptr ), id( idVal ) {
    669669        assert( expr );
    670670        assert( count != -1 );
     
    674674        }
    675675}
    676 UniqueExpr::UniqueExpr( const UniqueExpr &other ) : Expression( other ), expr( maybeClone( other.expr ) ), object( maybeClone( other.object ) ), var( maybeClone( other.var ) ), id( other.id ) {
     676UniqueExpr::UniqueExpr( const UniqueExpr & other ) : Expression( other ), expr( maybeClone( other.expr ) ), object( maybeClone( other.object ) ), var( maybeClone( other.var ) ), id( other.id ) {
    677677}
    678678UniqueExpr::~UniqueExpr() {
     
    681681        delete var;
    682682}
    683 void UniqueExpr::print( std::ostream &os, Indenter indent ) const {
     683void UniqueExpr::print( std::ostream & os, Indenter indent ) const {
    684684        os << "Unique Expression with id:" << id << std::endl << indent+1;
    685685        expr->print( os, indent+1 );
  • src/SynTree/Expression.h

    r45af7e1 r5170d95  
    1010// Created On       : Mon May 18 07:44:20 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Sun Sep  3 19:23:46 2017
    13 // Update Count     : 48
     12// Last Modified On : Mon Feb 18 18:29:51 2019
     13// Update Count     : 49
    1414//
    1515
     
    195195  public:
    196196        Expression * arg;
    197         bool isGenerated = true; // whether this cast appeared in the source program
     197        bool isGenerated = true; // cast generated implicitly by code generation or explicit in program
    198198
    199199        CastExpr( Expression * arg, bool isGenerated = true );
Note: See TracChangeset for help on using the changeset viewer.