Changes in / [3f840e3:9d23c2d]
- Location:
- src
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
src/AST/Convert.cpp
r3f840e3 r9d23c2d 525 525 } 526 526 527 Expression * visitBaseExpr_skipResultType(const ast::Expr * src, Expression * tgt) { 528 529 tgt->location = src->location; 530 tgt->env = convertTypeSubstitution(src->env); 531 tgt->extension = src->extension; 532 533 convertInferUnion(tgt->inferParams, tgt->resnSlots, src->inferred); 534 return tgt; 535 } 536 527 537 Expression * visitBaseExpr(const ast::Expr * src, Expression * tgt) { 528 538 529 tgt->location = src->location;530 531 539 tgt->result = get<Type>().accept1(src->result); 532 tgt->env = convertTypeSubstitution(src->env); 533 534 tgt->extension = src->extension; 535 convertInferUnion(tgt->inferParams, tgt->resnSlots, src->inferred); 536 537 return tgt; 540 return visitBaseExpr_skipResultType(src, tgt); 538 541 } 539 542 … … 628 631 629 632 const ast::Expr * visit( const ast::VirtualCastExpr * node ) override final { 630 auto expr = visitBaseExpr ( node,633 auto expr = visitBaseExpr_skipResultType( node, 631 634 new VirtualCastExpr( 632 635 get<Expression>().accept1(node->arg), 633 nullptr // cast's "to" type is expr's result type; converted in visitBaseExpr636 get<Type>().accept1(node->result) 634 637 ) 635 638 ); … … 849 852 850 853 const ast::Expr * visit( const ast::TypeExpr * node ) override final { 851 (void)node; 854 auto expr = visitBaseExpr( node, 855 new TypeExpr( 856 get<Type>().accept1(node->type) 857 ) 858 ); 859 this->node = expr; 852 860 return nullptr; 853 861 } 854 862 855 863 const ast::Expr * visit( const ast::AsmExpr * node ) override final { 856 (void)node; 864 auto expr = visitBaseExpr( node, 865 new AsmExpr( 866 get<Expression>().accept1(node->inout), 867 get<Expression>().accept1(node->constraint), 868 get<Expression>().accept1(node->operand) 869 ) 870 ); 871 this->node = expr; 857 872 return nullptr; 858 873 } 859 874 860 875 const ast::Expr * visit( const ast::ImplicitCopyCtorExpr * node ) override final { 861 (void)node; 876 auto rslt = new ImplicitCopyCtorExpr( 877 get<ApplicationExpr>().accept1(node->callExpr) 878 ); 879 880 rslt->tempDecls = get<ObjectDecl>().acceptL(node->tempDecls); 881 rslt->returnDecls = get<ObjectDecl>().acceptL(node->returnDecls); 882 rslt->dtors = get<Expression>().acceptL(node->dtors); 883 884 auto expr = visitBaseExpr( node, rslt ); 885 this->node = expr; 862 886 return nullptr; 863 887 } 864 888 865 889 const ast::Expr * visit( const ast::ConstructorExpr * node ) override final { 866 (void)node; 890 auto expr = visitBaseExpr( node, 891 new ConstructorExpr( 892 get<Expression>().accept1(node->callExpr) 893 ) 894 ); 895 this->node = expr; 867 896 return nullptr; 868 897 } 869 898 870 899 const ast::Expr * visit( const ast::CompoundLiteralExpr * node ) override final { 871 (void)node; 900 auto expr = visitBaseExpr_skipResultType( node, 901 new CompoundLiteralExpr( 902 get<Type>().accept1(node->result), 903 get<Initializer>().accept1(node->init) 904 ) 905 ); 906 this->node = expr; 872 907 return nullptr; 873 908 } 874 909 875 910 const ast::Expr * visit( const ast::RangeExpr * node ) override final { 876 (void)node; 911 auto expr = visitBaseExpr( node, 912 new RangeExpr( 913 get<Expression>().accept1(node->low), 914 get<Expression>().accept1(node->high) 915 ) 916 ); 917 this->node = expr; 877 918 return nullptr; 878 919 } 879 920 880 921 const ast::Expr * visit( const ast::UntypedTupleExpr * node ) override final { 881 (void)node; 922 auto expr = visitBaseExpr( node, 923 new UntypedTupleExpr( 924 get<Expression>().acceptL(node->exprs) 925 ) 926 ); 927 this->node = expr; 882 928 return nullptr; 883 929 } 884 930 885 931 const ast::Expr * visit( const ast::TupleExpr * node ) override final { 886 (void)node; 932 auto expr = visitBaseExpr( node, 933 new UntypedTupleExpr( 934 get<Expression>().acceptL(node->exprs) 935 ) 936 ); 937 this->node = expr; 887 938 return nullptr; 888 939 } 889 940 890 941 const ast::Expr * visit( const ast::TupleIndexExpr * node ) override final { 891 (void)node; 942 auto expr = visitBaseExpr( node, 943 new TupleIndexExpr( 944 get<Expression>().accept1(node->tuple), 945 node->index 946 ) 947 ); 948 this->node = expr; 892 949 return nullptr; 893 950 } 894 951 895 952 const ast::Expr * visit( const ast::TupleAssignExpr * node ) override final { 896 (void)node; 953 auto expr = visitBaseExpr( node, 954 new TupleAssignExpr( 955 get<StmtExpr>().accept1(node->stmtExpr) 956 ) 957 ); 958 this->node = expr; 897 959 return nullptr; 898 960 } 899 961 900 962 const ast::Expr * visit( const ast::StmtExpr * node ) override final { 901 (void)node; 963 auto rslt = new StmtExpr( 964 get<CompoundStmt>().accept1(node->stmts) 965 ); 966 967 rslt->returnDecls = get<ObjectDecl>().acceptL(node->returnDecls); 968 rslt->dtors = get<Expression>().acceptL(node->dtors); 969 970 auto expr = visitBaseExpr( node, rslt ); 971 this->node = expr; 902 972 return nullptr; 903 973 } 904 974 905 975 const ast::Expr * visit( const ast::UniqueExpr * node ) override final { 906 (void)node; 976 auto rslt = new UniqueExpr( 977 get<Expression>().accept1(node->expr) 978 ); 979 980 rslt->object = get<ObjectDecl> ().accept1(node->object); 981 rslt->var = get<VariableExpr>().accept1(node->var); 982 983 auto expr = visitBaseExpr( node, rslt ); 984 this->node = expr; 907 985 return nullptr; 908 986 } 909 987 910 988 const ast::Expr * visit( const ast::UntypedInitExpr * node ) override final { 911 (void)node; 989 std::list<InitAlternative> initAlts; 990 for (auto ia : node->initAlts) { 991 initAlts.push_back(InitAlternative( 992 get<Type> ().accept1(ia.type), 993 get<Designation>().accept1(ia.designation) 994 )); 995 } 996 auto expr = visitBaseExpr( node, 997 new UntypedInitExpr( 998 get<Expression>().accept1(node->expr), 999 initAlts 1000 ) 1001 ); 1002 this->node = expr; 912 1003 return nullptr; 913 1004 } 914 1005 915 1006 const ast::Expr * visit( const ast::InitExpr * node ) override final { 916 (void)node; 1007 auto expr = visitBaseExpr( node, 1008 new InitExpr( 1009 get<Expression>().accept1(node->expr), 1010 get<Designation>().accept1(node->designation) 1011 ) 1012 ); 1013 this->node = expr; 917 1014 return nullptr; 918 1015 } 919 1016 920 1017 const ast::Expr * visit( const ast::DeletedExpr * node ) override final { 921 (void)node; 1018 auto expr = visitBaseExpr( node, 1019 new DeletedExpr( 1020 get<Expression>().accept1(node->expr), 1021 inCache(node->deleteStmt) ? 1022 this->node : 1023 get<BaseSyntaxNode>().accept1(node->deleteStmt) 1024 ) 1025 ); 1026 this->node = expr; 922 1027 return nullptr; 923 1028 } 924 1029 925 1030 const ast::Expr * visit( const ast::DefaultArgExpr * node ) override final { 926 (void)node; 1031 auto expr = visitBaseExpr( node, 1032 new DefaultArgExpr( 1033 get<Expression>().accept1(node->expr) 1034 ) 1035 ); 1036 this->node = expr; 927 1037 return nullptr; 928 1038 } 929 1039 930 1040 const ast::Expr * visit( const ast::GenericExpr * node ) override final { 931 (void)node; 1041 std::list<GenericExpr::Association> associations; 1042 for (auto association : node->associations) { 1043 associations.push_back(GenericExpr::Association( 1044 get<Type> ().accept1(association.type), 1045 get<Expression>().accept1(association.expr) 1046 )); 1047 } 1048 auto expr = visitBaseExpr( node, 1049 new GenericExpr( 1050 get<Expression>().accept1(node->control), 1051 associations 1052 ) 1053 ); 1054 this->node = expr; 932 1055 return nullptr; 933 1056 } … … 1696 1819 } 1697 1820 1698 ast::Expr * visitBaseExpr(Expression * old, ast::Expr * nw) { 1699 1700 nw->result = GET_ACCEPT_1(result, Type); 1821 ast::Expr * visitBaseExpr_SkipResultType(Expression * old, ast::Expr * nw) { 1822 1701 1823 nw->env = convertTypeSubstitution(old->env); 1702 1824 … … 1705 1827 1706 1828 return nw; 1829 } 1830 1831 ast::Expr * visitBaseExpr(Expression * old, ast::Expr * nw) { 1832 1833 nw->result = GET_ACCEPT_1(result, Type); 1834 return visitBaseExpr_SkipResultType(old, nw);; 1707 1835 } 1708 1836 … … 1772 1900 1773 1901 virtual void visit( VirtualCastExpr * old ) override final { 1774 this->node = visitBaseExpr ( old,1902 this->node = visitBaseExpr_SkipResultType( old, 1775 1903 new ast::VirtualCastExpr( 1776 1904 old->location, 1777 1905 GET_ACCEPT_1(arg, Expr), 1778 nullptr // cast's "to" type is expr's result type; converted in visitBaseExpr1906 GET_ACCEPT_1(result, Type) 1779 1907 ) 1780 1908 ); … … 2001 2129 } 2002 2130 2003 virtual void visit( TypeExpr * ) override final { 2004 2005 } 2006 2007 virtual void visit( AsmExpr * ) override final { 2008 2009 } 2010 2011 virtual void visit( ImplicitCopyCtorExpr * ) override final { 2012 2013 } 2014 2015 virtual void visit( ConstructorExpr * ) override final { 2016 2017 } 2018 2019 virtual void visit( CompoundLiteralExpr * ) override final { 2020 2021 } 2022 2023 virtual void visit( RangeExpr * ) override final { 2024 2025 } 2026 2027 virtual void visit( UntypedTupleExpr * ) override final { 2028 2029 } 2030 2031 virtual void visit( TupleExpr * ) override final { 2032 2033 } 2034 2035 virtual void visit( TupleIndexExpr * ) override final { 2036 2037 } 2038 2039 virtual void visit( TupleAssignExpr * ) override final { 2040 2041 } 2042 2043 virtual void visit( StmtExpr * ) override final { 2044 2045 } 2046 2047 virtual void visit( UniqueExpr * ) override final { 2048 2049 } 2050 2051 virtual void visit( UntypedInitExpr * ) override final { 2052 2053 } 2054 2055 virtual void visit( InitExpr * ) override final { 2056 2057 } 2058 2059 virtual void visit( DeletedExpr * ) override final { 2060 2061 } 2062 2063 virtual void visit( DefaultArgExpr * ) override final { 2064 2065 } 2066 2067 virtual void visit( GenericExpr * ) override final { 2068 2131 virtual void visit( TypeExpr * old ) override final { 2132 this->node = visitBaseExpr( old, 2133 new ast::TypeExpr( 2134 old->location, 2135 GET_ACCEPT_1(type, Type) 2136 ) 2137 ); 2138 } 2139 2140 virtual void visit( AsmExpr * old ) override final { 2141 this->node = visitBaseExpr( old, 2142 new ast::AsmExpr( 2143 old->location, 2144 GET_ACCEPT_1(inout, Expr), 2145 GET_ACCEPT_1(constraint, Expr), 2146 GET_ACCEPT_1(operand, Expr) 2147 ) 2148 ); 2149 } 2150 2151 virtual void visit( ImplicitCopyCtorExpr * old ) override final { 2152 auto rslt = new ast::ImplicitCopyCtorExpr( 2153 old->location, 2154 GET_ACCEPT_1(callExpr, ApplicationExpr) 2155 ); 2156 2157 rslt->tempDecls = GET_ACCEPT_V(tempDecls, ObjectDecl); 2158 rslt->returnDecls = GET_ACCEPT_V(returnDecls, ObjectDecl); 2159 rslt->dtors = GET_ACCEPT_V(dtors, Expr); 2160 2161 this->node = visitBaseExpr( old, rslt ); 2162 } 2163 2164 virtual void visit( ConstructorExpr * old ) override final { 2165 this->node = visitBaseExpr( old, 2166 new ast::ConstructorExpr( 2167 old->location, 2168 GET_ACCEPT_1(callExpr, Expr) 2169 ) 2170 ); 2171 } 2172 2173 virtual void visit( CompoundLiteralExpr * old ) override final { 2174 this->node = visitBaseExpr_SkipResultType( old, 2175 new ast::CompoundLiteralExpr( 2176 old->location, 2177 GET_ACCEPT_1(result, Type), 2178 GET_ACCEPT_1(initializer, Init) 2179 ) 2180 ); 2181 } 2182 2183 virtual void visit( RangeExpr * old ) override final { 2184 this->node = visitBaseExpr( old, 2185 new ast::RangeExpr( 2186 old->location, 2187 GET_ACCEPT_1(low, Expr), 2188 GET_ACCEPT_1(high, Expr) 2189 ) 2190 ); 2191 } 2192 2193 virtual void visit( UntypedTupleExpr * old ) override final { 2194 this->node = visitBaseExpr( old, 2195 new ast::UntypedTupleExpr( 2196 old->location, 2197 GET_ACCEPT_V(exprs, Expr) 2198 ) 2199 ); 2200 } 2201 2202 virtual void visit( TupleExpr * old ) override final { 2203 this->node = visitBaseExpr( old, 2204 new ast::TupleExpr( 2205 old->location, 2206 GET_ACCEPT_V(exprs, Expr) 2207 ) 2208 ); 2209 } 2210 2211 virtual void visit( TupleIndexExpr * old ) override final { 2212 this->node = visitBaseExpr( old, 2213 new ast::TupleIndexExpr( 2214 old->location, 2215 GET_ACCEPT_1(tuple, Expr), 2216 old->index 2217 ) 2218 ); 2219 } 2220 2221 virtual void visit( TupleAssignExpr * old ) override final { 2222 this->node = visitBaseExpr_SkipResultType( old, 2223 new ast::TupleAssignExpr( 2224 old->location, 2225 GET_ACCEPT_1(result, Type), 2226 GET_ACCEPT_1(stmtExpr, StmtExpr) 2227 ) 2228 ); 2229 } 2230 2231 virtual void visit( StmtExpr * old ) override final { 2232 auto rslt = new ast::StmtExpr( 2233 old->location, 2234 GET_ACCEPT_1(statements, CompoundStmt) 2235 ); 2236 rslt->returnDecls = GET_ACCEPT_V(returnDecls, ObjectDecl); 2237 rslt->dtors = GET_ACCEPT_V(dtors , Expr); 2238 2239 this->node = visitBaseExpr_SkipResultType( old, rslt ); 2240 } 2241 2242 virtual void visit( UniqueExpr * old ) override final { 2243 auto rslt = new ast::UniqueExpr( 2244 old->location, 2245 GET_ACCEPT_1(expr, Expr) 2246 ); 2247 rslt->object = GET_ACCEPT_1(object, ObjectDecl); 2248 rslt->var = GET_ACCEPT_1(var , VariableExpr); 2249 2250 this->node = visitBaseExpr( old, rslt ); 2251 } 2252 2253 virtual void visit( UntypedInitExpr * old ) override final { 2254 std::vector<ast::InitAlternative> initAlts; 2255 for (auto ia : old->initAlts) { 2256 initAlts.push_back(ast::InitAlternative( 2257 getAccept1< ast::Type, Type * >( ia.type ), 2258 getAccept1< ast::Designation, Designation * >( ia.designation ) 2259 )); 2260 } 2261 this->node = visitBaseExpr( old, 2262 new ast::UntypedInitExpr( 2263 old->location, 2264 GET_ACCEPT_1(expr, Expr), 2265 std::move(initAlts) 2266 ) 2267 ); 2268 } 2269 2270 virtual void visit( InitExpr * old ) override final { 2271 this->node = visitBaseExpr( old, 2272 new ast::InitExpr( 2273 old->location, 2274 GET_ACCEPT_1(expr, Expr), 2275 GET_ACCEPT_1(designation, Designation) 2276 ) 2277 ); 2278 } 2279 2280 virtual void visit( DeletedExpr * old ) override final { 2281 this->node = visitBaseExpr( old, 2282 new ast::DeletedExpr( 2283 old->location, 2284 GET_ACCEPT_1(expr, Expr), 2285 inCache(old->deleteStmt) ? 2286 this->node : 2287 GET_ACCEPT_1(deleteStmt, Node) 2288 ) 2289 ); 2290 } 2291 2292 virtual void visit( DefaultArgExpr * old ) override final { 2293 this->node = visitBaseExpr( old, 2294 new ast::DefaultArgExpr( 2295 old->location, 2296 GET_ACCEPT_1(expr, Expr) 2297 ) 2298 ); 2299 } 2300 2301 virtual void visit( GenericExpr * old ) override final { 2302 std::vector<ast::GenericExpr::Association> associations; 2303 for (auto association : old->associations) { 2304 associations.push_back(ast::GenericExpr::Association( 2305 getAccept1< ast::Type, Type * >( association.type ), 2306 getAccept1< ast::Expr, Expression * >( association.expr ) 2307 )); 2308 } 2309 this->node = visitBaseExpr( old, 2310 new ast::GenericExpr( 2311 old->location, 2312 GET_ACCEPT_1(control, Expr), 2313 std::move(associations) 2314 ) 2315 ); 2069 2316 } 2070 2317 -
src/AST/Expr.cpp
r3f840e3 r9d23c2d 335 335 } 336 336 337 TupleAssignExpr::TupleAssignExpr( 338 const CodeLocation & loc, const Type * result, const StmtExpr * s ) 339 : Expr( loc, result ), stmtExpr() { 340 stmtExpr = s; 341 } 342 337 343 // --- StmtExpr 338 344 -
src/AST/Expr.hpp
r3f840e3 r9d23c2d 30 30 #define MUTATE_FRIEND template<typename node_t> friend node_t * mutate(const node_t * node); 31 31 32 class ConverterOldToNew; 33 32 34 namespace ast { 33 35 … … 528 530 std::vector<ptr<ObjectDecl>> tempDecls; 529 531 std::vector<ptr<ObjectDecl>> returnDecls; 530 std::vector<ptr< ObjectDecl>> dtors;532 std::vector<ptr<Expr>> dtors; 531 533 532 534 ImplicitCopyCtorExpr( const CodeLocation& loc, const ApplicationExpr * call ) … … 635 637 636 638 const Expr * accept( Visitor & v ) const override { return v.visit( this ); } 639 640 friend class ::ConverterOldToNew; 641 637 642 private: 638 643 TupleAssignExpr * clone() const override { return new TupleAssignExpr{ *this }; } 644 TupleAssignExpr( const CodeLocation & loc, const Type * result, const StmtExpr * s ); 645 639 646 MUTATE_FRIEND 640 647 }; -
src/SynTree/Expression.h
r3f840e3 r9d23c2d 741 741 virtual Expression * acceptMutator( Mutator & m ) { return m.mutate( this ); } 742 742 virtual void print( std::ostream & os, Indenter indent = {} ) const; 743 744 friend class ConverterNewToOld; 745 private: 746 TupleAssignExpr( StmtExpr * stmts ); 743 747 }; 744 748 -
src/SynTree/TupleExpr.cc
r3f840e3 r9d23c2d 105 105 } 106 106 107 TupleAssignExpr::TupleAssignExpr( 108 StmtExpr * s ) 109 : Expression(), stmtExpr(s) { 110 } 111 112 107 113 TupleAssignExpr::~TupleAssignExpr() { 108 114 delete stmtExpr;
Note: See TracChangeset
for help on using the changeset viewer.