Changeset 2a8f0c1 for src/ResolvExpr
- Timestamp:
- Jun 5, 2019, 1:47:55 PM (5 years ago)
- 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:
- 4864a73, 7c608d5, 99d4584
- Parents:
- d4b6638
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/ResolvExpr/Resolver.cc
rd4b6638 r2a8f0c1 27 27 #include "typeops.h" // for extractResultType 28 28 #include "Unify.h" // for unify 29 #include "AST/Decl.hpp" 30 #include "AST/Init.hpp" 29 31 #include "AST/Pass.hpp" 30 32 #include "AST/SymbolTable.hpp" … … 941 943 public ast::WithVisitorRef<Resolver_new>, public ast::WithShortCircuiting, 942 944 public ast::WithStmtsToAdd<> { 943 945 946 ast::ptr< ast::Type > functionReturn = nullptr; 947 // ast::CurrentObject currentObject = nullptr; 948 // bool inEnumDecl = false; 949 944 950 public: 945 951 Resolver_new() = default; 946 952 Resolver_new( const ast::SymbolTable & syms ) { symtab = syms; } 947 953 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 ); 974 980 }; 975 981 … … 979 985 } 980 986 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 ) { 995 1015 #warning unimplemented; Resolver port in progress 996 1016 (void)objectDecl; … … 998 1018 } 999 1019 1000 void previsit(ast::EnumDecl * enumDecl ) {1020 void Resolver_new::previsit( const ast::EnumDecl * enumDecl ) { 1001 1021 #warning unimplemented; Resolver port in progress 1002 1022 (void)enumDecl; … … 1004 1024 } 1005 1025 1006 void previsit(ast::StaticAssertDecl * assertDecl ) {1026 void Resolver_new::previsit( const ast::StaticAssertDecl * assertDecl ) { 1007 1027 #warning unimplemented; Resolver port in progress 1008 1028 (void)assertDecl; … … 1010 1030 } 1011 1031 1012 void previsit(ast::ArrayType * at ) {1032 void Resolver_new::previsit( const ast::ArrayType * at ) { 1013 1033 #warning unimplemented; Resolver port in progress 1014 1034 (void)at; … … 1016 1036 } 1017 1037 1018 void previsit(ast::PointerType * pt ) {1038 void Resolver_new::previsit( const ast::PointerType * pt ) { 1019 1039 #warning unimplemented; Resolver port in progress 1020 1040 (void)pt; … … 1022 1042 } 1023 1043 1024 void previsit(ast::ExprStmt * exprStmt ) {1044 void Resolver_new::previsit( const ast::ExprStmt * exprStmt ) { 1025 1045 #warning unimplemented; Resolver port in progress 1026 1046 (void)exprStmt; … … 1028 1048 } 1029 1049 1030 void previsit(ast::AsmExpr * asmExpr ) {1050 void Resolver_new::previsit( const ast::AsmExpr * asmExpr ) { 1031 1051 #warning unimplemented; Resolver port in progress 1032 1052 (void)asmExpr; … … 1034 1054 } 1035 1055 1036 void previsit(ast::AsmStmt * asmStmt ) {1056 void Resolver_new::previsit( const ast::AsmStmt * asmStmt ) { 1037 1057 #warning unimplemented; Resolver port in progress 1038 1058 (void)asmStmt; … … 1040 1060 } 1041 1061 1042 void previsit(ast::IfStmt * ifStmt ) {1062 void Resolver_new::previsit( const ast::IfStmt * ifStmt ) { 1043 1063 #warning unimplemented; Resolver port in progress 1044 1064 (void)ifStmt; … … 1046 1066 } 1047 1067 1048 void previsit(ast::WhileStmt * whileStmt ) {1068 void Resolver_new::previsit( const ast::WhileStmt * whileStmt ) { 1049 1069 #warning unimplemented; Resolver port in progress 1050 1070 (void)whileStmt; … … 1052 1072 } 1053 1073 1054 void previsit(ast::ForStmt * forStmt ) {1074 void Resolver_new::previsit( const ast::ForStmt * forStmt ) { 1055 1075 #warning unimplemented; Resolver port in progress 1056 1076 (void)forStmt; … … 1058 1078 } 1059 1079 1060 void previsit(ast::SwitchStmt * switchStmt ) {1080 void Resolver_new::previsit( const ast::SwitchStmt * switchStmt ) { 1061 1081 #warning unimplemented; Resolver port in progress 1062 1082 (void)switchStmt; … … 1064 1084 } 1065 1085 1066 void previsit(ast::CaseStmt * caseStmt ) {1086 void Resolver_new::previsit( const ast::CaseStmt * caseStmt ) { 1067 1087 #warning unimplemented; Resolver port in progress 1068 1088 (void)caseStmt; … … 1070 1090 } 1071 1091 1072 void previsit(ast::BranchStmt * branchStmt ) {1092 void Resolver_new::previsit( const ast::BranchStmt * branchStmt ) { 1073 1093 #warning unimplemented; Resolver port in progress 1074 1094 (void)branchStmt; … … 1076 1096 } 1077 1097 1078 void previsit(ast::ReturnStmt * returnStmt ) {1098 void Resolver_new::previsit( const ast::ReturnStmt * returnStmt ) { 1079 1099 #warning unimplemented; Resolver port in progress 1080 1100 (void)returnStmt; … … 1082 1102 } 1083 1103 1084 void previsit(ast::ThrowStmt * throwStmt ) {1104 void Resolver_new::previsit( const ast::ThrowStmt * throwStmt ) { 1085 1105 #warning unimplemented; Resolver port in progress 1086 1106 (void)throwStmt; … … 1088 1108 } 1089 1109 1090 void previsit(ast::CatchStmt * catchStmt ) {1110 void Resolver_new::previsit( const ast::CatchStmt * catchStmt ) { 1091 1111 #warning unimplemented; Resolver port in progress 1092 1112 (void)catchStmt; … … 1094 1114 } 1095 1115 1096 void previsit(ast::WaitForStmt * stmt ) {1116 void Resolver_new::previsit( const ast::WaitForStmt * stmt ) { 1097 1117 #warning unimplemented; Resolver port in progress 1098 1118 (void)stmt; … … 1100 1120 } 1101 1121 1102 void previsit(ast::SingleInit * singleInit ) {1122 void Resolver_new::previsit( const ast::SingleInit * singleInit ) { 1103 1123 #warning unimplemented; Resolver port in progress 1104 1124 (void)singleInit; … … 1106 1126 } 1107 1127 1108 void previsit(ast::ListInit * listInit ) {1128 void Resolver_new::previsit( const ast::ListInit * listInit ) { 1109 1129 #warning unimplemented; Resolver port in progress 1110 1130 (void)listInit; … … 1112 1132 } 1113 1133 1114 void previsit(ast::ConstructorInit * ctorInit ) {1134 void Resolver_new::previsit( const ast::ConstructorInit * ctorInit ) { 1115 1135 #warning unimplemented; Resolver port in progress 1116 1136 (void)ctorInit;
Note: See TracChangeset
for help on using the changeset viewer.