- Timestamp:
- Jun 7, 2019, 4:14:48 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:
- 05d55ff
- Parents:
- 5684736
- git-author:
- Aaron Moss <a3moss@…> (06/07/19 16:14:40)
- git-committer:
- Aaron Moss <a3moss@…> (06/07/19 16:14:48)
- Location:
- src/AST
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
src/AST/Convert.cpp
r5684736 r60aaa51d 16 16 #include "Convert.hpp" 17 17 18 #include <deque> 18 19 #include <unordered_map> 19 20 … … 575 576 576 577 if ( srcInferred.mode == ast::Expr::InferUnion::Params ) { 577 const ast::InferredParams &srcParams = srcInferred.inferParams Const();578 const ast::InferredParams &srcParams = srcInferred.inferParams(); 578 579 for (auto srcParam : srcParams) { 579 580 tgtInferParams[srcParam.first] = ParamEntry( … … 585 586 } 586 587 } else if ( srcInferred.mode == ast::Expr::InferUnion::Slots ) { 587 const ast::ResnSlots &srcSlots = srcInferred.resnSlots Const();588 const ast::ResnSlots &srcSlots = srcInferred.resnSlots(); 588 589 for (auto srcSlot : srcSlots) { 589 590 tgtResnSlots.push_back(srcSlot); … … 1413 1414 # define GET_ACCEPT_V(child, type) \ 1414 1415 getAcceptV< ast::type, decltype( old->child ) >( old->child ) 1416 1417 template<typename NewT, typename OldC> 1418 std::deque< ast::ptr<NewT> > getAcceptD( OldC& old ) { 1419 std::deque< ast::ptr<NewT> > ret; 1420 for ( auto a : old ) { 1421 a->accept( *this ); 1422 ret.emplace_back( strict_dynamic_cast< NewT * >(node) ); 1423 node = nullptr; 1424 } 1425 return ret; 1426 } 1427 1428 # define GET_ACCEPT_D(child, type) \ 1429 getAcceptD< ast::type, decltype( old->child ) >( old->child ) 1415 1430 1416 1431 ast::Label make_label(Label* old) { … … 2449 2464 2450 2465 virtual void visit( UntypedInitExpr * old ) override final { 2451 std:: vector<ast::InitAlternative> initAlts;2466 std::deque<ast::InitAlternative> initAlts; 2452 2467 for (auto ia : old->initAlts) { 2453 2468 initAlts.push_back(ast::InitAlternative( … … 2714 2729 this->node = new ast::Designation( 2715 2730 old->location, 2716 GET_ACCEPT_ V(designators, Expr)2731 GET_ACCEPT_D(designators, Expr) 2717 2732 ); 2718 2733 } -
src/AST/Expr.cpp
r5684736 r60aaa51d 163 163 result = mem->get_type(); 164 164 // substitute aggregate generic parameters into member type 165 genericSubs itution( aggregate->result ).apply( result );165 genericSubstitution( aggregate->result ).apply( result ); 166 166 // ensure lvalue and appropriate restrictions from aggregate type 167 167 add_qualifiers( result, aggregate->result->qualifiers | CV::Lvalue ); -
src/AST/Expr.hpp
r5684736 r60aaa51d 17 17 18 18 #include <cassert> 19 #include <deque> 19 20 #include <map> 20 21 #include <string> … … 111 112 } 112 113 113 const ResnSlots& resnSlots Const() const {114 const ResnSlots& resnSlots() const { 114 115 if (mode == Slots) { 115 116 return data.resnSlots; … … 128 129 } 129 130 130 const InferredParams& inferParams Const() const {131 const InferredParams& inferParams() const { 131 132 if (mode == Params) { 132 133 return data.inferParams; … … 134 135 assert(!"Mode was not already Params"); 135 136 return *((InferredParams*)nullptr); 137 } 138 139 /// splices other InferUnion into this one. Will fail if one union is in `Slots` mode 140 /// and the other is in `Params`. 141 void splice( InferUnion && o ) { 142 if ( o.mode == Empty ) return; 143 if ( mode == Empty ) { init_from( o ); return; } 144 assert( mode == o.mode && "attempt to splice incompatible InferUnion" ); 145 146 if ( mode == Slots ){ 147 data.resnSlots.insert( 148 data.resnSlots.end(), o.data.resnSlots.begin(), o.data.resnSlots.end() ); 149 } else if ( mode == Params ) { 150 for ( const auto & p : o.data.inferParams ) { 151 data.inferParams[p.first] = std::move(p.second); 152 } 153 } else assert(!"invalid mode"); 136 154 } 137 155 }; … … 695 713 public: 696 714 ptr<Expr> expr; 697 std:: vector<InitAlternative> initAlts;698 699 UntypedInitExpr( const CodeLocation & loc, const Expr * e, std:: vector<InitAlternative> && as )715 std::deque<InitAlternative> initAlts; 716 717 UntypedInitExpr( const CodeLocation & loc, const Expr * e, std::deque<InitAlternative> && as ) 700 718 : Expr( loc ), expr( e ), initAlts( std::move(as) ) {} 701 719 -
src/AST/GenericSubstitution.cpp
r5684736 r60aaa51d 31 31 TypeSubstitution sub; 32 32 33 void previsit( const Type * ty) {34 assertf( false, "Attempted generic substitution for non-aggregate type: %s",35 toString( ty ).c_str() );33 void previsit( const Type * ) { 34 // allow empty substitution for non-generic type 35 visit_children = false; 36 36 } 37 37 … … 40 40 } 41 41 42 void previsit( const ReferenceToType * ty ) { 42 private: 43 // make substitution for generic type 44 void makeSub( const ReferenceToType * ty ) { 43 45 visit_children = false; 44 // build substitution from base parameters45 46 const AggregateDecl * aggr = ty->aggr(); 46 47 sub = TypeSubstitution{ aggr->params.begin(), aggr->params.end(), ty->params.begin() }; 48 } 49 50 public: 51 void previsit( const StructInstType * ty ) { 52 makeSub( ty ); 53 } 54 55 void previsit( const UnionInstType * ty ) { 56 makeSub( ty ); 47 57 } 48 58 }; 49 59 } 50 60 51 TypeSubstitution genericSubs itution( const Type * ty ) {61 TypeSubstitution genericSubstitution( const Type * ty ) { 52 62 Pass<GenericSubstitutionBuilder> builder; 53 63 maybe_accept( ty, builder ); -
src/AST/GenericSubstitution.hpp
r5684736 r60aaa51d 22 22 class Type; 23 23 24 TypeSubstitution genericSubs itution( const Type * );24 TypeSubstitution genericSubstitution( const Type * ); 25 25 26 26 } -
src/AST/Init.hpp
r5684736 r60aaa51d 16 16 #pragma once 17 17 18 #include <deque> 18 19 #include <utility> // for move 19 20 #include <vector> … … 35 36 class Designation final : public ParseNode { 36 37 public: 37 std:: vector<ptr<Expr>> designators;38 std::deque<ptr<Expr>> designators; 38 39 39 Designation( const CodeLocation& loc, std:: vector<ptr<Expr>>&& ds = {} )40 Designation( const CodeLocation& loc, std::deque<ptr<Expr>>&& ds = {} ) 40 41 : ParseNode( loc ), designators( std::move(ds) ) {} 41 42 -
src/AST/Node.hpp
r5684736 r60aaa51d 154 154 155 155 template< enum Node::ref_type o_ref_t > 156 ptr_base( const ptr_base<node_t, o_ref_t> & o ) : node(o. node) {156 ptr_base( const ptr_base<node_t, o_ref_t> & o ) : node(o.get()) { 157 157 if( node ) _inc(node); 158 158 } 159 159 160 160 template< enum Node::ref_type o_ref_t > 161 ptr_base( ptr_base<node_t, o_ref_t> && o ) : node(o. node) {161 ptr_base( ptr_base<node_t, o_ref_t> && o ) : node(o.get()) { 162 162 if( node ) _inc(node); 163 163 } … … 184 184 template< enum Node::ref_type o_ref_t > 185 185 ptr_base & operator=( const ptr_base<node_t, o_ref_t> & o ) { 186 assign(o. node);186 assign(o.get()); 187 187 return *this; 188 188 } … … 190 190 template< enum Node::ref_type o_ref_t > 191 191 ptr_base & operator=( ptr_base<node_t, o_ref_t> && o ) { 192 assign(o. node);192 assign(o.get()); 193 193 return *this; 194 194 } … … 228 228 void _check() const; 229 229 230 protected:231 230 const node_t * node; 232 231 }; -
src/AST/porting.md
r5684736 r60aaa51d 238 238 * also now returns `const AggregateDecl *` 239 239 * `genericSubstitution()` moved to own visitor in `AST/GenericSubstitution.hpp` 240 * subsumes old `makeGenericSubstitution()` 240 241 241 242 `BasicType`
Note: See TracChangeset
for help on using the changeset viewer.