- Timestamp:
- Dec 11, 2023, 4:18:13 AM (23 months ago)
- Branches:
- master
- Children:
- 21ce2c7, 2554f24
- Parents:
- 5ddb8bf (diff), 1c85ffc (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:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
src/AST/Chain.hpp
r5ddb8bf r81da3da4 33 33 template<typename actual_node_t, typename child_t> 34 34 auto operator()( child_t actual_node_t::*child ) { 35 auto n = mutate(base.get());35 node_t * n = base.get_and_mutate(); 36 36 actual_node_t * node = strict_dynamic_cast<actual_node_t *>(n); 37 base = node;38 37 return _chain_mutator< typename std::remove_reference< decltype(node->*child) >::type >{node->*child}; 39 38 } 40 39 41 40 node_t * operator->() { 42 auto n = mutate(base.get()); 43 base = n; 44 return n; 41 return base.get_and_mutate(); 45 42 } 46 43 }; -
src/AST/Decl.cpp
r5ddb8bf r81da3da4 21 21 22 22 #include "Common/Eval.h" // for eval 23 #include "Common/SemanticError.h" 23 24 24 25 #include "Fwd.hpp" // for UniqueId … … 41 42 42 43 FunctionDecl::FunctionDecl( const CodeLocation & loc, const std::string & name, 43 std::vector<ptr<TypeDecl>>&& forall,44 44 std::vector<ptr<DeclWithType>>&& params, std::vector<ptr<DeclWithType>>&& returns, 45 45 CompoundStmt * stmts, Storage::Classes storage, Linkage::Spec linkage, 46 46 std::vector<ptr<Attribute>>&& attrs, Function::Specs fs, ArgumentFlag isVarArgs ) 47 : DeclWithType( loc, name, storage, linkage, std::move(attrs), fs ), 48 type_params(std::move(forall)), assertions(), 49 params(std::move(params)), returns(std::move(returns)), stmts( stmts ) { 50 FunctionType * ftype = new FunctionType( isVarArgs ); 51 for (auto & param : this->params) { 52 ftype->params.emplace_back(param->get_type()); 53 } 54 for (auto & ret : this->returns) { 55 ftype->returns.emplace_back(ret->get_type()); 56 } 57 for (auto & tp : this->type_params) { 58 ftype->forall.emplace_back(new TypeInstType(tp)); 59 for (auto & ap: tp->assertions) { 60 ftype->assertions.emplace_back(new VariableExpr(loc, ap)); 61 } 62 } 63 this->type = ftype; 47 : FunctionDecl( loc, name, {}, {}, std::move(params), std::move(returns), 48 stmts, storage, linkage, std::move(attrs), fs, isVarArgs ) { 64 49 } 65 50 -
src/AST/Decl.hpp
r5ddb8bf r81da3da4 30 30 #include "Visitor.hpp" 31 31 #include "Common/utility.h" 32 #include "Common/SemanticError.h" // error_str33 32 34 33 // Must be included in *all* AST classes; should be #undef'd at the end of the file … … 135 134 std::vector< ptr<Expr> > withExprs; 136 135 137 // The difference between the two constructors is in how they handle 138 // assertions. The first constructor uses the assertions from the type 139 // parameters, in the style of the old ast, and puts them on the type. 140 // The second takes an explicite list of assertions and builds a list of 141 // references to them on the type. 142 143 FunctionDecl( const CodeLocation & loc, const std::string & name, std::vector<ptr<TypeDecl>>&& forall, 136 /// Monomorphic Function Constructor: 137 FunctionDecl( const CodeLocation & locaction, const std::string & name, 144 138 std::vector<ptr<DeclWithType>>&& params, std::vector<ptr<DeclWithType>>&& returns, 145 139 CompoundStmt * stmts, Storage::Classes storage = {}, Linkage::Spec linkage = Linkage::Cforall, 146 140 std::vector<ptr<Attribute>>&& attrs = {}, Function::Specs fs = {}, ArgumentFlag isVarArgs = FixedArgs ); 147 141 142 /// Polymorphic Function Constructor: 148 143 FunctionDecl( const CodeLocation & location, const std::string & name, 149 144 std::vector<ptr<TypeDecl>>&& forall, std::vector<ptr<DeclWithType>>&& assertions, -
src/AST/Expr.cpp
r5ddb8bf r81da3da4 222 222 } 223 223 224 MemberExpr::MemberExpr( const CodeLocation & loc, const DeclWithType * mem, const Expr * agg,225 MemberExpr::NoOpConstruction overloadSelector )226 : Expr( loc ), member( mem ), aggregate( agg ) {227 assert( member );228 assert( aggregate );229 assert( aggregate->result );230 (void) overloadSelector;231 }232 233 224 bool MemberExpr::get_lvalue() const { 234 225 // This is actually wrong by C, but it works with our current set-up. … … 388 379 stmts.emplace_back( new ExprStmt{ loc, tupleExpr } ); 389 380 stmtExpr = new StmtExpr{ loc, new CompoundStmt{ loc, std::move(stmts) } }; 390 }391 392 TupleAssignExpr::TupleAssignExpr(393 const CodeLocation & loc, const Type * result, const StmtExpr * s )394 : Expr( loc, result ), stmtExpr() {395 stmtExpr = s;396 381 } 397 382 -
src/AST/Expr.hpp
r5ddb8bf r81da3da4 35 35 template<typename node_t> friend node_t * shallowCopy(const node_t * node); 36 36 37 38 class ConverterOldToNew;39 class ConverterNewToOld;40 41 37 namespace ast { 42 38 … … 439 435 MemberExpr * clone() const override { return new MemberExpr{ *this }; } 440 436 MUTATE_FRIEND 441 442 // Custructor overload meant only for AST conversion443 enum NoOpConstruction { NoOpConstructionChosen };444 MemberExpr( const CodeLocation & loc, const DeclWithType * mem, const Expr * agg,445 NoOpConstruction overloadSelector );446 friend class ::ConverterOldToNew;447 friend class ::ConverterNewToOld;448 437 }; 449 438 … … 458 447 ConstantExpr( 459 448 const CodeLocation & loc, const Type * ty, const std::string & r, 460 std::optional<unsigned long long>i )461 : Expr( loc, ty ), rep( r ), ival( i ) , underlyer(ty){}449 const std::optional<unsigned long long> & i ) 450 : Expr( loc, ty ), rep( r ), ival( i ) {} 462 451 463 452 /// Gets the integer value of this constant, if one is appropriate to its type. … … 483 472 484 473 std::optional<unsigned long long> ival; 485 486 // Intended only for legacy support of roundtripping the old AST.487 // Captures the very-locally inferred type, before the resolver modifies the type of this ConstantExpression.488 // In the old AST it's constExpr->constant.type489 ptr<Type> underlyer;490 friend class ::ConverterOldToNew;491 friend class ::ConverterNewToOld;492 474 }; 493 475 … … 779 761 const Expr * accept( Visitor & v ) const override { return v.visit( this ); } 780 762 781 friend class ::ConverterOldToNew;782 783 763 private: 784 764 TupleAssignExpr * clone() const override { return new TupleAssignExpr{ *this }; } 785 TupleAssignExpr( const CodeLocation & loc, const Type * result, const StmtExpr * s );786 787 765 MUTATE_FRIEND 788 766 };
Note:
See TracChangeset
for help on using the changeset viewer.