Changeset 8d7bef2 for src/Parser
- Timestamp:
- Mar 20, 2018, 5:12:25 PM (6 years ago)
- Branches:
- new-env, with_gc
- Children:
- 7e4b44db
- Parents:
- 68f9c43
- Location:
- src/Parser
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
src/Parser/ParseNode.h
r68f9c43 r8d7bef2 124 124 125 125 virtual void print( std::ostream &os, __attribute__((unused)) int indent = 0 ) const override { 126 os << expr .get()<< std::endl;126 os << expr << std::endl; 127 127 } 128 128 void printOneLine( __attribute__((unused)) std::ostream &os, __attribute__((unused)) int indent = 0 ) const {} 129 129 130 130 template<typename T> 131 bool isExpressionType() const { return nullptr != dynamic_cast<T>(expr .get()); }132 133 Expression * build() const { return const_cast<ExpressionNode *>(this)->expr.release(); }131 bool isExpressionType() const { return nullptr != dynamic_cast<T>(expr); } 132 133 Expression * build() const { return expr; } 134 134 private: 135 135 bool extension = false; 136 std::unique_ptr<Expression>expr;136 Expression* expr; 137 137 }; // ExpressionNode 138 138 … … 352 352 353 353 virtual StatementNode * clone() const final { assert( false ); return nullptr; } 354 Statement * build() const { return const_cast<StatementNode *>(this)->stmt.release(); }354 Statement * build() const { return stmt; } 355 355 356 356 virtual StatementNode * add_label( const std::string * name, DeclarationNode * attr = nullptr ) { … … 364 364 365 365 virtual void print( std::ostream &os, __attribute__((unused)) int indent = 0 ) const override { 366 os << stmt .get()<< std::endl;366 os << stmt << std::endl; 367 367 } 368 368 private: 369 std::unique_ptr<Statement>stmt;369 Statement* stmt; 370 370 }; // StatementNode 371 371 -
src/Parser/StatementNode.cc
r68f9c43 r8d7bef2 16 16 #include <cassert> // for assert, strict_dynamic_cast, assertf 17 17 #include <list> // for list 18 #include <memory> // for unique_ptr19 18 #include <string> // for string 20 19 … … 50 49 agg = decl; 51 50 } // if 52 stmt .reset( new DeclStmt( maybeMoveBuild< Declaration >(agg) ) );51 stmt = new DeclStmt{ maybeMoveBuild< Declaration >(agg) }; 53 52 } // StatementNode::StatementNode 54 53 … … 58 57 for ( StatementNode * curr = prev; curr != nullptr; curr = (StatementNode *)curr->get_next() ) { 59 58 StatementNode *node = strict_dynamic_cast< StatementNode * >(curr); 60 assert( dynamic_cast< CaseStmt * >(node->stmt .get()) );59 assert( dynamic_cast< CaseStmt * >(node->stmt) ); 61 60 prev = curr; 62 61 } // for … … 66 65 buildMoveList( stmt, stmts ); 67 66 // splice any new Statements to end of current Statements 68 CaseStmt * caseStmt = dynamic_cast< CaseStmt * >(node->stmt .get());67 CaseStmt * caseStmt = dynamic_cast< CaseStmt * >(node->stmt); 69 68 caseStmt->get_statements().splice( caseStmt->get_statements().end(), stmts ); 70 69 return this;
Note: See TracChangeset
for help on using the changeset viewer.