- Timestamp:
- Jun 25, 2019, 11:26:30 AM (5 years ago)
- Branches:
- ADT, arm-eh, ast-experimental, enum, forall-pointer-decay, jacob/cs343-translation, master, new-ast, new-ast-unique-expr, pthread-emulation, qualifiedEnum
- Children:
- bcb311b
- Parents:
- 28af389
- Location:
- src/AST
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
src/AST/Node.cpp
r28af389 r9ea38de 17 17 #include "Fwd.hpp" 18 18 19 #include <csignal> // MEMORY DEBUG -- for raise 19 20 #include <iostream> 20 21 … … 28 29 29 30 #include "Print.hpp" 31 32 /// MEMORY DEBUG -- allows breaking on construction/destruction of dynamically chosen object. 33 /// Process to use in GDB: 34 /// break ast::Node::_trap() 35 /// run 36 /// set variable MEM_TRAP_OBJ = <target> 37 /// disable <first breakpoint> 38 /// continue 39 void * MEM_TRAP_OBJ = nullptr; 40 41 void ast::Node::_trap() { 42 if ( this == MEM_TRAP_OBJ ) std::raise(SIGTRAP); 43 } 30 44 31 45 template< typename node_t, enum ast::Node::ref_type ref_t > -
src/AST/Node.hpp
r28af389 r9ea38de 30 30 /// Keeps both strong and weak reference counts. 31 31 class Node { 32 /// call to debug on node creation/deletion 33 void _trap(); 32 34 public: 33 35 // override defaults to ensure assignment doesn't 34 36 // change/share reference counts 35 Node() = default;36 Node(const Node&) : strong_count(0), weak_count(0) { }37 Node(Node&&) : strong_count(0), weak_count(0) { }37 Node() { _trap(); } 38 Node(const Node&) : strong_count(0), weak_count(0) { _trap(); } 39 Node(Node&&) : strong_count(0), weak_count(0) { _trap(); } 38 40 Node& operator= (const Node&) = delete; 39 41 Node& operator= (Node&&) = delete; 40 virtual ~Node() = default;42 virtual ~Node() { _trap(); } 41 43 42 44 virtual const Node * accept( Visitor & v ) const = 0; -
src/AST/Pass.hpp
r28af389 r9ea38de 209 209 /// Internal RAII guard for symbol table features 210 210 struct guard_symtab { 211 guard_symtab( Pass<pass_t> & pass ): pass( pass ) { __pass::symtab::enter(pass , 0); }212 ~guard_symtab() { __pass::symtab::leave(pass , 0); }211 guard_symtab( Pass<pass_t> & pass ): pass( pass ) { __pass::symtab::enter(pass.pass, 0); } 212 ~guard_symtab() { __pass::symtab::leave(pass.pass, 0); } 213 213 Pass<pass_t> & pass; 214 214 }; … … 216 216 /// Internal RAII guard for scope features 217 217 struct guard_scope { 218 guard_scope( Pass<pass_t> & pass ): pass( pass ) { __pass::scope::enter(pass , 0); }219 ~guard_scope() { __pass::scope::leave(pass , 0); }218 guard_scope( Pass<pass_t> & pass ): pass( pass ) { __pass::scope::enter(pass.pass, 0); } 219 ~guard_scope() { __pass::scope::leave(pass.pass, 0); } 220 220 Pass<pass_t> & pass; 221 221 }; -
src/AST/Pass.impl.hpp
r28af389 r9ea38de 429 429 guard_symtab guard { *this }; 430 430 // implicit add __func__ identifier as specified in the C manual 6.4.2.2 431 static ast:: ObjectDecl func(432 node->location, "__func__",433 new ast::ArrayType (434 new ast::BasicType ( ast::BasicType::Char, ast::CV::Qualifiers( ast::CV::Const ) ),431 static ast::ptr< ast::ObjectDecl > func{ new ast::ObjectDecl{ 432 CodeLocation{}, "__func__", 433 new ast::ArrayType{ 434 new ast::BasicType{ ast::BasicType::Char, ast::CV::Const }, 435 435 nullptr, VariableLen, DynamicDim 436 )437 );438 __pass::symtab::addId( pass, 0, &func );436 } 437 } }; 438 __pass::symtab::addId( pass, 0, func ); 439 439 VISIT( 440 440 maybe_accept( node, &FunctionDecl::type ); … … 610 610 VISIT({ 611 611 // do not enter a new scope if inFunction is true - needs to check old state before the assignment 612 auto guard1 = makeFuncGuard( [this, inFunction = this->inFunction]() {613 if ( ! inFunction ) __pass::symtab::enter(pass, 0);614 }, [this, inFunction = this->inFunction]() {615 if ( ! inFunction ) __pass::symtab::leave(pass, 0);612 auto guard1 = makeFuncGuard( [this, inFunctionCpy = this->inFunction]() { 613 if ( ! inFunctionCpy ) __pass::symtab::enter(pass, 0); 614 }, [this, inFunctionCpy = this->inFunction]() { 615 if ( ! inFunctionCpy ) __pass::symtab::leave(pass, 0); 616 616 }); 617 617 ValueGuard< bool > guard2( inFunction ); -
src/AST/Pass.proto.hpp
r28af389 r9ea38de 270 270 // Some simple scoping rules 271 271 template<typename pass_t> 272 static inline auto enter( pass_t & pass, int ) -> decltype( pass.symtab .enterScope(), void() ) {272 static inline auto enter( pass_t & pass, int ) -> decltype( pass.symtab, void() ) { 273 273 pass.symtab.enterScope(); 274 274 } … … 278 278 279 279 template<typename pass_t> 280 static inline auto leave( pass_t & pass, int ) -> decltype( pass.symtab .leaveScope(), void() ) {280 static inline auto leave( pass_t & pass, int ) -> decltype( pass.symtab, void() ) { 281 281 pass.symtab.leaveScope(); 282 282 }
Note: See TracChangeset
for help on using the changeset viewer.