Changeset 7c608d5 for src


Ignore:
Timestamp:
Jun 5, 2019, 3:01:15 PM (5 years ago)
Author:
Peter A. Buhr <pabuhr@…>
Branches:
ADT, arm-eh, ast-experimental, enum, forall-pointer-decay, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr, pthread-emulation, qualifiedEnum
Children:
54d4c0e
Parents:
300fbee (diff), 2a8f0c1 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

Merge branch 'master' of plg.uwaterloo.ca:software/cfa/cfa-cc

Location:
src
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • src/AST/Decl.hpp

    r300fbee r7c608d5  
    103103
    104104        ObjectDecl( const CodeLocation & loc, const std::string & name, const Type * type,
    105                 Init * init = nullptr, Storage::Classes storage = {}, Linkage::Spec linkage = Linkage::C,
    106                 Expr * bitWd = nullptr, std::vector< ptr<Attribute> > && attrs = {},
    107                 Function::Specs fs = {} )
     105                const Init * init = nullptr, Storage::Classes storage = {},
     106                Linkage::Spec linkage = Linkage::C, const Expr * bitWd = nullptr,
     107                std::vector< ptr<Attribute> > && attrs = {}, Function::Specs fs = {} )
    108108        : DeclWithType( loc, name, storage, linkage, std::move(attrs), fs ), type( type ),
    109109          init( init ), bitfieldWidth( bitWd ) {}
  • src/ResolvExpr/Resolver.cc

    r300fbee r7c608d5  
    2727#include "typeops.h"                     // for extractResultType
    2828#include "Unify.h"                       // for unify
     29#include "AST/Decl.hpp"
     30#include "AST/Init.hpp"
    2931#include "AST/Pass.hpp"
    3032#include "AST/SymbolTable.hpp"
     
    941943          public ast::WithVisitorRef<Resolver_new>, public ast::WithShortCircuiting,
    942944          public ast::WithStmtsToAdd<> {
    943                  
     945       
     946                ast::ptr< ast::Type > functionReturn = nullptr;
     947                // ast::CurrentObject currentObject = nullptr;
     948                // bool inEnumDecl = false;
     949
    944950        public:
    945951                Resolver_new() = default;
    946952                Resolver_new( const ast::SymbolTable & syms ) { symtab = syms; }
    947953
    948                 void previsit( ast::FunctionDecl * functionDecl );
    949                 ast::DeclWithType * postvisit( ast::FunctionDecl * functionDecl );
    950                 void previsit( ast::ObjectDecl * objectDecl );
    951                 void previsit( ast::EnumDecl * enumDecl );
    952                 void previsit( ast::StaticAssertDecl * assertDecl );
    953 
    954                 void previsit( ast::ArrayType * at );
    955                 void previsit( ast::PointerType * pt );
    956 
    957                 void previsit( ast::ExprStmt * exprStmt );
    958                 void previsit( ast::AsmExpr * asmExpr );
    959                 void previsit( ast::AsmStmt * asmStmt );
    960                 void previsit( ast::IfStmt * ifStmt );
    961                 void previsit( ast::WhileStmt * whileStmt );
    962                 void previsit( ast::ForStmt * forStmt );
    963                 void previsit( ast::SwitchStmt * switchStmt );
    964                 void previsit( ast::CaseStmt * caseStmt );
    965                 void previsit( ast::BranchStmt * branchStmt );
    966                 void previsit( ast::ReturnStmt * returnStmt );
    967                 void previsit( ast::ThrowStmt * throwStmt );
    968                 void previsit( ast::CatchStmt * catchStmt );
    969                 void previsit( ast::WaitForStmt * stmt );
    970 
    971                 void previsit( ast::SingleInit * singleInit );
    972                 void previsit( ast::ListInit * listInit );
    973                 void previsit( ast::ConstructorInit * ctorInit );
     954                void previsit( const ast::FunctionDecl * functionDecl );
     955                const ast::FunctionDecl * postvisit( const ast::FunctionDecl * functionDecl );
     956                void previsit( const ast::ObjectDecl * objectDecl );
     957                void previsit( const ast::EnumDecl * enumDecl );
     958                void previsit( const ast::StaticAssertDecl * assertDecl );
     959
     960                void previsit( const ast::ArrayType * at );
     961                void previsit( const ast::PointerType * pt );
     962
     963                void previsit( const ast::ExprStmt * exprStmt );
     964                void previsit( const ast::AsmExpr * asmExpr );
     965                void previsit( const ast::AsmStmt * asmStmt );
     966                void previsit( const ast::IfStmt * ifStmt );
     967                void previsit( const ast::WhileStmt * whileStmt );
     968                void previsit( const ast::ForStmt * forStmt );
     969                void previsit( const ast::SwitchStmt * switchStmt );
     970                void previsit( const ast::CaseStmt * caseStmt );
     971                void previsit( const ast::BranchStmt * branchStmt );
     972                void previsit( const ast::ReturnStmt * returnStmt );
     973                void previsit( const ast::ThrowStmt * throwStmt );
     974                void previsit( const ast::CatchStmt * catchStmt );
     975                void previsit( const ast::WaitForStmt * stmt );
     976
     977                void previsit( const ast::SingleInit * singleInit );
     978                void previsit( const ast::ListInit * listInit );
     979                void previsit( const ast::ConstructorInit * ctorInit );
    974980        };
    975981
     
    979985        }
    980986
    981         void previsit( ast::FunctionDecl * functionDecl ) {
    982                 #warning unimplemented; Resolver port in progress
    983                 (void)functionDecl;
    984                 assert(false);
    985         }
    986 
    987         ast::DeclWithType * postvisit( ast::FunctionDecl * functionDecl ) {
    988                 #warning unimplemented; Resolver port in progress
    989                 (void)functionDecl;
    990                 assert(false);
    991                 return nullptr;
    992         }
    993 
    994         void previsit( ast::ObjectDecl * objectDecl ) {
     987        void Resolver_new::previsit( const ast::FunctionDecl * functionDecl ) {
     988                GuardValue( functionReturn );
     989                functionReturn = extractResultType( functionDecl->type );
     990        }
     991
     992        const ast::FunctionDecl * Resolver_new::postvisit( const ast::FunctionDecl * functionDecl ) {
     993                // default value expressions have an environment which shouldn't be there and trips up
     994                // later passes.
     995                ast::ptr< ast::FunctionDecl > ret = functionDecl;
     996                for ( unsigned i = 0; i < functionDecl->type->params.size(); ++i ) {
     997                        const ast::ptr<ast::DeclWithType> & d = functionDecl->type->params[i];
     998                       
     999                        if ( const ast::ObjectDecl * obj = d.as< ast::ObjectDecl >() ) {
     1000                                if ( const ast::SingleInit * init = obj->init.as< ast::SingleInit >() ) {
     1001                                        if ( init->value->env == nullptr ) continue;
     1002                                        // clone initializer minus the initializer environment
     1003                                        strict_dynamic_cast< ast::SingleInit * >(
     1004                                                strict_dynamic_cast< ast::ObjectDecl * >(
     1005                                                        ret.get_and_mutate()->type.get_and_mutate()->params[i].get_and_mutate()
     1006                                                )->init.get_and_mutate()
     1007                                        )->value.get_and_mutate()->env = nullptr;
     1008                                }
     1009                        }
     1010                }
     1011                return ret.get();
     1012        }
     1013
     1014        void Resolver_new::previsit( const ast::ObjectDecl * objectDecl ) {
    9951015                #warning unimplemented; Resolver port in progress
    9961016                (void)objectDecl;
     
    9981018        }
    9991019
    1000         void previsit( ast::EnumDecl * enumDecl ) {
     1020        void Resolver_new::previsit( const ast::EnumDecl * enumDecl ) {
    10011021                #warning unimplemented; Resolver port in progress
    10021022                (void)enumDecl;
     
    10041024        }
    10051025
    1006         void previsit( ast::StaticAssertDecl * assertDecl ) {
     1026        void Resolver_new::previsit( const ast::StaticAssertDecl * assertDecl ) {
    10071027                #warning unimplemented; Resolver port in progress
    10081028                (void)assertDecl;
     
    10101030        }
    10111031
    1012         void previsit( ast::ArrayType * at ) {
     1032        void Resolver_new::previsit( const ast::ArrayType * at ) {
    10131033                #warning unimplemented; Resolver port in progress
    10141034                (void)at;
     
    10161036        }
    10171037
    1018         void previsit( ast::PointerType * pt ) {
     1038        void Resolver_new::previsit( const ast::PointerType * pt ) {
    10191039                #warning unimplemented; Resolver port in progress
    10201040                (void)pt;
     
    10221042        }
    10231043
    1024         void previsit( ast::ExprStmt * exprStmt ) {
     1044        void Resolver_new::previsit( const ast::ExprStmt * exprStmt ) {
    10251045                #warning unimplemented; Resolver port in progress
    10261046                (void)exprStmt;
     
    10281048        }
    10291049
    1030         void previsit( ast::AsmExpr * asmExpr ) {
     1050        void Resolver_new::previsit( const ast::AsmExpr * asmExpr ) {
    10311051                #warning unimplemented; Resolver port in progress
    10321052                (void)asmExpr;
     
    10341054        }
    10351055
    1036         void previsit( ast::AsmStmt * asmStmt ) {
     1056        void Resolver_new::previsit( const ast::AsmStmt * asmStmt ) {
    10371057                #warning unimplemented; Resolver port in progress
    10381058                (void)asmStmt;
     
    10401060        }
    10411061
    1042         void previsit( ast::IfStmt * ifStmt ) {
     1062        void Resolver_new::previsit( const ast::IfStmt * ifStmt ) {
    10431063                #warning unimplemented; Resolver port in progress
    10441064                (void)ifStmt;
     
    10461066        }
    10471067
    1048         void previsit( ast::WhileStmt * whileStmt ) {
     1068        void Resolver_new::previsit( const ast::WhileStmt * whileStmt ) {
    10491069                #warning unimplemented; Resolver port in progress
    10501070                (void)whileStmt;
     
    10521072        }
    10531073
    1054         void previsit( ast::ForStmt * forStmt ) {
     1074        void Resolver_new::previsit( const ast::ForStmt * forStmt ) {
    10551075                #warning unimplemented; Resolver port in progress
    10561076                (void)forStmt;
     
    10581078        }
    10591079
    1060         void previsit( ast::SwitchStmt * switchStmt ) {
     1080        void Resolver_new::previsit( const ast::SwitchStmt * switchStmt ) {
    10611081                #warning unimplemented; Resolver port in progress
    10621082                (void)switchStmt;
     
    10641084        }
    10651085
    1066         void previsit( ast::CaseStmt * caseStmt ) {
     1086        void Resolver_new::previsit( const ast::CaseStmt * caseStmt ) {
    10671087                #warning unimplemented; Resolver port in progress
    10681088                (void)caseStmt;
     
    10701090        }
    10711091
    1072         void previsit( ast::BranchStmt * branchStmt ) {
     1092        void Resolver_new::previsit( const ast::BranchStmt * branchStmt ) {
    10731093                #warning unimplemented; Resolver port in progress
    10741094                (void)branchStmt;
     
    10761096        }
    10771097
    1078         void previsit( ast::ReturnStmt * returnStmt ) {
     1098        void Resolver_new::previsit( const ast::ReturnStmt * returnStmt ) {
    10791099                #warning unimplemented; Resolver port in progress
    10801100                (void)returnStmt;
     
    10821102        }
    10831103
    1084         void previsit( ast::ThrowStmt * throwStmt ) {
     1104        void Resolver_new::previsit( const ast::ThrowStmt * throwStmt ) {
    10851105                #warning unimplemented; Resolver port in progress
    10861106                (void)throwStmt;
     
    10881108        }
    10891109
    1090         void previsit( ast::CatchStmt * catchStmt ) {
     1110        void Resolver_new::previsit( const ast::CatchStmt * catchStmt ) {
    10911111                #warning unimplemented; Resolver port in progress
    10921112                (void)catchStmt;
     
    10941114        }
    10951115
    1096         void previsit( ast::WaitForStmt * stmt ) {
     1116        void Resolver_new::previsit( const ast::WaitForStmt * stmt ) {
    10971117                #warning unimplemented; Resolver port in progress
    10981118                (void)stmt;
     
    11001120        }
    11011121
    1102         void previsit( ast::SingleInit * singleInit ) {
     1122        void Resolver_new::previsit( const ast::SingleInit * singleInit ) {
    11031123                #warning unimplemented; Resolver port in progress
    11041124                (void)singleInit;
     
    11061126        }
    11071127
    1108         void previsit( ast::ListInit * listInit ) {
     1128        void Resolver_new::previsit( const ast::ListInit * listInit ) {
    11091129                #warning unimplemented; Resolver port in progress
    11101130                (void)listInit;
     
    11121132        }
    11131133
    1114         void previsit( ast::ConstructorInit * ctorInit ) {
     1134        void Resolver_new::previsit( const ast::ConstructorInit * ctorInit ) {
    11151135                #warning unimplemented; Resolver port in progress
    11161136                (void)ctorInit;
Note: See TracChangeset for help on using the changeset viewer.