Changeset 6a1dfda for src/AST/Convert.cpp
- Timestamp:
- Jun 13, 2019, 8:41:11 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:
- c36298d
- Parents:
- dc5072f (diff), 6896548 (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. - git-author:
- Peter A. Buhr <pabuhr@…> (06/13/19 20:39:34)
- git-committer:
- Peter A. Buhr <pabuhr@…> (06/13/19 20:41:11)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/AST/Convert.cpp
rdc5072f r6a1dfda 733 733 const ast::Expr * visit( const ast::VariableExpr * node ) override final { 734 734 auto expr = new VariableExpr(); 735 expr->var = get<DeclarationWithType>().accept1(node->var); 735 736 visitBaseExpr( node, expr ); 736 expr->var = get<DeclarationWithType>().accept1(node->var);737 Type * type = expr->var->get_type()->clone();738 if(FunctionType * ft = dynamic_cast<FunctionType*>(type)) {739 if(node->result.as<ast::PointerType>()) {740 type = new PointerType({}, ft);741 }742 }743 744 type->set_lvalue( true );745 expr->result = type ;746 737 this->node = expr; 747 738 return nullptr; … … 766 757 break; 767 758 case ast::ConstantExpr::String: 768 rslt = new ConstantExpr{Constant{ 769 get<Type>().accept1( node->result ), 770 node->rep, 771 (long long unsigned int)0 772 }}; 759 // Old world: two types: rslt->constant.type, rslt->result 760 // New workd: one type: node->result 761 // Both worlds: the outer, expression-level type can change during resolution 762 // in case of string, that's char[k] before-resolve and char * after 763 // Old world: the inner Constant type stays what it was built with 764 // in case of string, that's char[k] 765 // Both worlds: the "rep" field of a string constant is the string value it was initialized from, wrapped in quotes, but not otherwise escaped 766 ast::ptr<ast::Type> charType = nullptr; 767 if (const ast::ArrayType *arrRslt = node->result.as<ast::ArrayType>()) { 768 charType = arrRslt->base; 769 } else { 770 const ast::PointerType *ptrRslt = node->result.as<ast::PointerType>(); 771 assert(ptrRslt); 772 charType = ptrRslt->base; 773 } 774 rslt = new ConstantExpr(Constant::from_string( 775 node->rep, get<Type>().accept1(charType))); // rslt->result is char[k] 776 rslt->set_result( get<Type>().accept1( node->result ) ); // rslt->result is [[ node->rsult ]] 773 777 break; 774 778 } … … 2152 2156 ); 2153 2157 2154 visitBaseExpr_SkipResultType( old,2155 expr2156 );2157 2158 2158 expr->var = GET_ACCEPT_1(var, DeclWithType); 2159 expr->result = expr->var->get_type(); 2160 if(const ast::FunctionType * ft = expr->result.as<ast::FunctionType>()) { 2161 if(dynamic_cast<PointerType *>(old->result)) { 2162 expr->result = new ast::PointerType(ft); 2163 } 2164 } 2165 add_qualifiers( expr->result, ast::CV::Lvalue ); 2159 visitBaseExpr( old, expr ); 2160 2166 2161 this->node = expr; 2167 2162 } … … 2214 2209 rslt = new ast::ConstantExpr( 2215 2210 old->location, 2216 GET_ACCEPT_1(result, Type), 2211 GET_ACCEPT_1(result, Type), // preserve the expression-level type (old->result, not old->constant.type); see new-to-old 2217 2212 old->constant.get_value(), 2218 2213 0,
Note: See TracChangeset
for help on using the changeset viewer.