Changeset 7edd5c1
- Timestamp:
- May 9, 2022, 11:38:08 AM (3 years ago)
- Branches:
- ADT, ast-experimental, master, pthread-emulation, qualifiedEnum
- Children:
- 00675a1
- Parents:
- bd1d279
- Location:
- src
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
src/AST/Convert.cpp
rbd1d279 r7edd5c1 93 93 }; 94 94 95 96 97 98 95 template<typename T> 96 Getter<T> get() { 97 return Getter<T>{ *this }; 98 } 99 99 100 100 Label makeLabel(Statement * labelled, const ast::Label& label) { … … 1651 1651 // GET_ACCEPT_1(type, FunctionType), 1652 1652 std::move(forall), 1653 std::move(assertions), 1653 1654 std::move(paramVars), 1654 1655 std::move(returnVars), … … 1664 1665 cache.emplace( old, decl ); 1665 1666 1666 decl->assertions = std::move(assertions);1667 1667 decl->withExprs = GET_ACCEPT_V(withExprs, Expr); 1668 1668 decl->stmts = GET_ACCEPT_1(statements, CompoundStmt); -
src/AST/Copy.cpp
rbd1d279 r7edd5c1 10 10 // Created On : Thr Nov 11 9:16:00 2019 11 11 // Last Modified By : Andrew Beach 12 // Last Modified On : T hr Nov 11 9:28:00 202113 // Update Count : 012 // Last Modified On : Tue May 3 16:28:00 2022 13 // Update Count : 1 14 14 // 15 15 … … 77 77 } 78 78 79 void postvisit( const UniqueExpr * node ) { 80 readonlyInsert( &node->object ); 81 } 82 79 83 void postvisit( const MemberExpr * node ) { 80 84 readonlyInsert( &node->member ); -
src/AST/Decl.cpp
rbd1d279 r7edd5c1 9 9 // Author : Aaron B. Moss 10 10 // Created On : Thu May 9 10:00:00 2019 11 // Last Modified By : Peter A. Buhr12 // Last Modified On : T ue Jan 12 16:54:55 202113 // Update Count : 2 311 // Last Modified By : Andrew Beach 12 // Last Modified On : Thu May 5 12:10:00 2022 13 // Update Count : 24 14 14 // 15 15 … … 53 53 // --- FunctionDecl 54 54 55 FunctionDecl::FunctionDecl( const CodeLocation & loc, const std::string & name, 55 FunctionDecl::FunctionDecl( const CodeLocation & loc, const std::string & name, 56 56 std::vector<ptr<TypeDecl>>&& forall, 57 57 std::vector<ptr<DeclWithType>>&& params, std::vector<ptr<DeclWithType>>&& returns, … … 74 74 } 75 75 this->type = ftype; 76 } 77 78 FunctionDecl::FunctionDecl( const CodeLocation & location, const std::string & name, 79 std::vector<ptr<TypeDecl>>&& forall, std::vector<ptr<DeclWithType>>&& assertions, 80 std::vector<ptr<DeclWithType>>&& params, std::vector<ptr<DeclWithType>>&& returns, 81 CompoundStmt * stmts, Storage::Classes storage, Linkage::Spec linkage, 82 std::vector<ptr<Attribute>>&& attrs, Function::Specs fs, bool isVarArgs) 83 : DeclWithType( location, name, storage, linkage, std::move(attrs), fs ), 84 params( std::move(params) ), returns( std::move(returns) ), 85 type_params( std::move( forall) ), assertions( std::move( assertions ) ), 86 type( nullptr ), stmts( stmts ) { 87 FunctionType * type = new FunctionType( (isVarArgs) ? VariableArgs : FixedArgs ); 88 for ( auto & param : this->params ) { 89 type->params.emplace_back( param->get_type() ); 90 } 91 for ( auto & ret : this->returns ) { 92 type->returns.emplace_back( ret->get_type() ); 93 } 94 for ( auto & param : this->type_params ) { 95 type->forall.emplace_back( new TypeInstType( param ) ); 96 } 97 for ( auto & assertion : this->assertions ) { 98 type->assertions.emplace_back( 99 new VariableExpr( assertion->location, assertion ) ); 100 } 101 this->type = type; 76 102 } 77 103 -
src/AST/Decl.hpp
rbd1d279 r7edd5c1 9 9 // Author : Aaron B. Moss 10 10 // Created On : Thu May 9 10:00:00 2019 11 // Last Modified By : Peter A. Buhr12 // Last Modified On : Fri Mar 12 18:25:05 202113 // Update Count : 3 211 // Last Modified By : Andrew Beach 12 // Last Modified On : Thu May 5 12:09:00 2022 13 // Update Count : 33 14 14 // 15 15 … … 135 135 std::vector< ptr<Expr> > withExprs; 136 136 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 137 143 FunctionDecl( const CodeLocation & loc, const std::string & name, std::vector<ptr<TypeDecl>>&& forall, 138 144 std::vector<ptr<DeclWithType>>&& params, std::vector<ptr<DeclWithType>>&& returns, 139 145 CompoundStmt * stmts, Storage::Classes storage = {}, Linkage::Spec linkage = Linkage::C, 140 146 std::vector<ptr<Attribute>>&& attrs = {}, Function::Specs fs = {}, bool isVarArgs = false); 141 // : DeclWithType( loc, name, storage, linkage, std::move(attrs), fs ), params(std::move(params)), returns(std::move(returns)), 142 // stmts( stmts ) {} 147 148 FunctionDecl( const CodeLocation & location, const std::string & name, 149 std::vector<ptr<TypeDecl>>&& forall, std::vector<ptr<DeclWithType>>&& assertions, 150 std::vector<ptr<DeclWithType>>&& params, std::vector<ptr<DeclWithType>>&& returns, 151 CompoundStmt * stmts, Storage::Classes storage = {}, Linkage::Spec linkage = Linkage::C, 152 std::vector<ptr<Attribute>>&& attrs = {}, Function::Specs fs = {}, bool isVarArgs = false); 143 153 144 154 const Type * get_type() const override; -
src/AST/Expr.hpp
rbd1d279 r7edd5c1 784 784 public: 785 785 ptr<Expr> expr; 786 ptr<ObjectDecl> object;786 readonly<ObjectDecl> object; 787 787 ptr<VariableExpr> var; 788 788 unsigned long long id; -
src/AST/Node.hpp
rbd1d279 r7edd5c1 10 10 // Created On : Wed May 8 10:27:04 2019 11 11 // Last Modified By : Andrew Beach 12 // Last Modified On : Fri Mar 25 10:33:00 202213 // Update Count : 712 // Last Modified On : Mon May 9 10:20:00 2022 13 // Update Count : 8 14 14 // 15 15 … … 49 49 50 50 bool unique() const { return strong_count == 1; } 51 bool isManaged() const {return strong_count > 0; } 51 bool isManaged() const { return strong_count > 0; } 52 bool isReferenced() const { return weak_count > 0; } 52 53 53 54 private: -
src/AST/Stmt.cpp
rbd1d279 r7edd5c1 9 9 // Author : Aaron B. Moss 10 10 // Created On : Wed May 8 13:00:00 2019 11 // Last Modified By : Peter A. Buhr12 // Last Modified On : Wed Feb 2 19:01:20 202213 // Update Count : 311 // Last Modified By : Andrew Beach 12 // Last Modified On : Tue May 3 15:18:20 2022 13 // Update Count : 4 14 14 // 15 15 16 16 #include "Stmt.hpp" 17 17 18 18 #include "Copy.hpp" 19 19 #include "DeclReplacer.hpp" 20 20 #include "Type.hpp" … … 23 23 24 24 // --- CompoundStmt 25 CompoundStmt::CompoundStmt( const CompoundStmt& other ) : Stmt(other), kids(other.kids) { 25 CompoundStmt::CompoundStmt( const CompoundStmt& other ) : Stmt(other), kids() { 26 // Statements can have weak references to them, if that happens inserting 27 // the original node into the new list will put the original node in a 28 // bad state, where it cannot be mutated. To avoid this, just perform an 29 // additional shallow copy on the statement. 30 for ( const Stmt * kid : other.kids ) { 31 if ( kid->isReferenced() ) { 32 kids.emplace_back( ast::shallowCopy( kid ) ); 33 } else { 34 kids.emplace_back( kid ); 35 } 36 } 37 26 38 // when cloning a compound statement, we may end up cloning declarations which 27 39 // are referred to by VariableExprs throughout the block. Cloning a VariableExpr -
src/Validate/Autogen.cpp
rbd1d279 r7edd5c1 350 350 name, 351 351 std::move( type_params ), 352 std::move( assertions ), 352 353 std::move( params ), 353 354 std::move( returns ), … … 360 361 // Auto-generated routines are inline to avoid conflicts. 361 362 ast::Function::Specs( ast::Function::Inline ) ); 362 decl->assertions = std::move( assertions );363 363 decl->fixUniqueId(); 364 364 return decl;
Note: See TracChangeset
for help on using the changeset viewer.