- Timestamp:
- Jun 12, 2019, 4:06:37 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:
- 462a7c7, d60780c
- Parents:
- aaeacf4 (diff), 6625727 (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. - Location:
- src/AST
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
src/AST/Convert.cpp
raaeacf4 r21300d7 2193 2193 2194 2194 int isStringlikeConstantType(const Type *t) { 2195 const Type *referentType = nullptr; 2195 2196 if ( const ArrayType * aty = dynamic_cast< const ArrayType * >( t ) ) { 2196 if ( const BasicType * bty = dynamic_cast< const BasicType * >( aty->base ) ) { 2197 referentType = aty->base; 2198 } else if ( const PointerType * pty = dynamic_cast< const PointerType * >( t ) ) { 2199 referentType = pty->base; 2200 } 2201 if (referentType) { 2202 if ( const BasicType * bty = dynamic_cast< const BasicType * >( referentType ) ) { 2197 2203 if ( bty->kind == BasicType::Kind::Char ) { 2198 2204 return true; … … 2205 2211 virtual void visit( ConstantExpr * old ) override final { 2206 2212 ast::ConstantExpr *rslt = nullptr; 2207 if (isIntlikeConstantType(old->result)) { 2213 if (isStringlikeConstantType(old->result)) { 2214 rslt = new ast::ConstantExpr( 2215 old->location, 2216 GET_ACCEPT_1(result, Type), 2217 old->constant.get_value(), 2218 0, 2219 ast::ConstantExpr::Kind::String 2220 ); 2221 } else if (isIntlikeConstantType(old->result)) { 2208 2222 rslt = new ast::ConstantExpr( 2209 2223 old->location, … … 2219 2233 old->constant.get_value(), 2220 2234 (double) old->constant.get_dval() 2221 );2222 } else if (isStringlikeConstantType(old->result)) {2223 rslt = new ast::ConstantExpr(2224 old->location,2225 GET_ACCEPT_1(result, Type),2226 old->constant.get_value(),2227 0,2228 ast::ConstantExpr::Kind::String2229 2235 ); 2230 2236 } -
src/AST/Node.hpp
raaeacf4 r21300d7 99 99 100 100 /// Mutate a node field (only clones if not equal to existing value) 101 template<typename node_t, typename field_t> 102 const node_t * mutate_field( 103 const node_t * node, 104 typename std::remove_const<typename std::remove_reference<field_t>::type>::type node_t::* field, 105 field_t&& val 106 ) { 101 template<typename node_t, typename field_t, typename assn_t> 102 const node_t * mutate_field( const node_t * node, field_t node_t::* field, assn_t && val ) { 103 // skip mutate if equivalent 107 104 if ( node->*field == val ) return node; 108 105 106 // mutate and return 109 107 node_t * ret = mutate( node ); 110 ret->*field = std::forward< field_t >( val ); 108 ret->*field = std::forward< assn_t >( val ); 109 return ret; 110 } 111 112 /// Mutate a single index of a node field (only clones if not equal to existing value) 113 template<typename node_t, typename coll_t, typename ind_t, typename field_t> 114 const node_t * mutate_field_index( 115 const node_t * node, coll_t node_t::* field, ind_t i, field_t && val 116 ) { 117 // skip mutate if equivalent 118 if ( (node->*field)[i] == val ) return node; 119 120 // mutate and return 121 node_t * ret = mutate( node ); 122 (ret->*field)[i] = std::forward< field_t >( val ); 111 123 return ret; 112 124 } -
src/AST/Print.hpp
raaeacf4 r21300d7 16 16 #pragma once 17 17 18 #include <ios fwd>19 #include <utility> // for forward18 #include <iostream> 19 #include <utility> // for forward 20 20 21 21 #include "AST/Node.hpp" … … 32 32 void printShort( std::ostream & os, const ast::Decl * node, Indenter indent = {} ); 33 33 34 inline void printShort( std::ostream & os, const ast::Decl * node, unsigned int indent ) { 35 printShort( os, node, Indenter{ indent } ); 34 /// Print a collection of items 35 template< typename Coll > 36 void printAll( std::ostream & os, const Coll & c, Indenter indent = {} ) { 37 for ( const auto & i : c ) { 38 if ( ! i ) continue; 39 40 os << indent; 41 print( os, i, indent ); 42 os << std::endl; 43 } 36 44 } 37 45 -
src/AST/porting.md
raaeacf4 r21300d7 299 299 * `openVars` => `open` 300 300 301 `ExplodedActual` => `ExplodedArg` 302 * `ExplodedActual.h` => `ExplodedArg.hpp` 303 301 304 [1] https://gcc.gnu.org/onlinedocs/gcc-9.1.0/gcc/Type-Attributes.html#Type-Attributes 302 305
Note: See TracChangeset
for help on using the changeset viewer.