Changes in src/AST/Convert.cpp [6355ba7:558d13b]
- File:
-
- 1 edited
-
src/AST/Convert.cpp (modified) (10 diffs)
Legend:
- Unmodified
- Added
- Removed
-
src/AST/Convert.cpp
r6355ba7 r558d13b 10 10 // Created On : Thu May 09 15::37::05 2019 11 11 // Last Modified By : Andrew Beach 12 // Last Modified On : Thu May 06 19:51:00 201913 // Update Count : 1 012 // Last Modified On : Man Jun 10 11:51:00 2019 13 // Update Count : 11 14 14 // 15 15 … … 92 92 93 93 Label makeLabel(Statement * labelled, const ast::Label& label) { 94 // This probably will leak memory, but only until we get rid of the old tree. 95 if ( nullptr == labelled && label.location.isSet() ) { 96 labelled = new NullStmt(); 97 labelled->location = label.location; 98 } 94 99 return Label( 95 100 label.name, … … 1384 1389 // Local Utilities: 1385 1390 1386 #define construct(T, key, ...) ({ \1387 void * data = ::operator new(sizeof(T)); \1388 cache.emplace( key, (T*)data ); \1389 new (data) T( __VA_ARGS__ ); \1390 })1391 1392 1391 template<typename NewT, typename OldT> 1393 1392 NewT * getAccept1( OldT old ) { … … 1403 1402 1404 1403 template<typename NewT, typename OldC> 1405 std::vector< ast::ptr<NewT> > getAcceptV( OldC& old ) {1404 std::vector< ast::ptr<NewT> > getAcceptV( const OldC& old ) { 1406 1405 std::vector< ast::ptr<NewT> > ret; 1407 1406 ret.reserve( old.size() ); … … 1418 1417 1419 1418 template<typename NewT, typename OldC> 1420 std::deque< ast::ptr<NewT> > getAcceptD( OldC& old ) {1419 std::deque< ast::ptr<NewT> > getAcceptD( const OldC& old ) { 1421 1420 std::deque< ast::ptr<NewT> > ret; 1422 1421 for ( auto a : old ) { … … 1431 1430 getAcceptD< ast::type, decltype( old->child ) >( old->child ) 1432 1431 1433 ast::Label make_label(Label* old) { 1432 ast::Label make_label(const Label* old) { 1433 CodeLocation const & location = 1434 ( old->labelled ) ? old->labelled->location : CodeLocation(); 1434 1435 return ast::Label( 1435 old->labelled->location,1436 location, 1436 1437 old->name, 1437 1438 GET_ACCEPT_V(attributes, Attribute) … … 1805 1806 } 1806 1807 1807 Label label = old->originalTarget;1808 1808 auto stmt = new ast::BranchStmt( 1809 1809 old->location, 1810 1810 kind, 1811 make_label(& label),1811 make_label(&old->originalTarget), 1812 1812 GET_LABELS_V(old->labels) 1813 1813 ); … … 2191 2191 2192 2192 int isStringlikeConstantType(const Type *t) { 2193 const Type *referentType = nullptr; 2193 2194 if ( const ArrayType * aty = dynamic_cast< const ArrayType * >( t ) ) { 2194 if ( const BasicType * bty = dynamic_cast< const BasicType * >( aty->base ) ) { 2195 referentType = aty->base; 2196 } else if ( const PointerType * pty = dynamic_cast< const PointerType * >( t ) ) { 2197 referentType = pty->base; 2198 } 2199 if (referentType) { 2200 if ( const BasicType * bty = dynamic_cast< const BasicType * >( referentType ) ) { 2195 2201 if ( bty->kind == BasicType::Kind::Char ) { 2196 2202 return true; … … 2203 2209 virtual void visit( ConstantExpr * old ) override final { 2204 2210 ast::ConstantExpr *rslt = nullptr; 2205 if (isIntlikeConstantType(old->result)) { 2211 if (isStringlikeConstantType(old->result)) { 2212 rslt = new ast::ConstantExpr( 2213 old->location, 2214 GET_ACCEPT_1(result, Type), 2215 old->constant.get_value(), 2216 0, 2217 ast::ConstantExpr::Kind::String 2218 ); 2219 } else if (isIntlikeConstantType(old->result)) { 2206 2220 rslt = new ast::ConstantExpr( 2207 2221 old->location, … … 2217 2231 old->constant.get_value(), 2218 2232 (double) old->constant.get_dval() 2219 );2220 } else if (isStringlikeConstantType(old->result)) {2221 rslt = new ast::ConstantExpr(2222 old->location,2223 GET_ACCEPT_1(result, Type),2224 old->constant.get_value(),2225 0,2226 ast::ConstantExpr::Kind::String2227 2233 ); 2228 2234 }
Note:
See TracChangeset
for help on using the changeset viewer.