Make ParseTreeWalker::DEFAULT provide an IterativeParseTreeWalker
as intended. The existing code intended for ParseTreeWalker::DEFAULT to provide a IterativeParseTreeWalker. However, the implementation initialized ParseTreeWalker::DEFAULT by doing a (value) copy of an IterativeParseTreeWalker, which sliced the object and therefore, unfortunately, transformed it back into a regular ParseTreeWalker. This change implements the desired behavior. Furthermore by making DEFAULT a reference, we are able to preserve the interface to existing code.
This commit is contained in:
parent
d0eaf29e51
commit
381fddebd5
|
@ -146,3 +146,4 @@ YYYY/MM/DD, github id, Full name, email
|
|||
2017/04/12, lys0716, Yishuang Lu, luyscmu@gmail.com
|
||||
2017/05/11, jimallman, Jim Allman, jim@ibang.com
|
||||
2017/05/26, waf, Will Fuqua, wafuqua@gmail.com
|
||||
2017/05/29, kosak, Corey Kosak, kosak@kosak.com
|
||||
|
|
|
@ -14,7 +14,8 @@
|
|||
using namespace antlr4::tree;
|
||||
using namespace antlrcpp;
|
||||
|
||||
ParseTreeWalker ParseTreeWalker::DEFAULT = IterativeParseTreeWalker();
|
||||
static IterativeParseTreeWalker defaultWalker;
|
||||
ParseTreeWalker &ParseTreeWalker::DEFAULT = defaultWalker;
|
||||
|
||||
void ParseTreeWalker::walk(ParseTreeListener *listener, ParseTree *t) const {
|
||||
if (is<ErrorNode *>(t)) {
|
||||
|
|
|
@ -12,7 +12,7 @@ namespace tree {
|
|||
|
||||
class ANTLR4CPP_PUBLIC ParseTreeWalker {
|
||||
public:
|
||||
static ParseTreeWalker DEFAULT;
|
||||
static ParseTreeWalker &DEFAULT;
|
||||
|
||||
virtual ~ParseTreeWalker() {};
|
||||
|
||||
|
|
Loading…
Reference in New Issue