forked from jasder/antlr
Found a solution to make RVO in ATNDeserializer work.
Visual Studio needs a move constructor. The move assignment is not enough. No need for the copy constructor anymore, so it can go.
This commit is contained in:
parent
0e5b501aa8
commit
e79f917437
|
@ -20,6 +20,7 @@ using namespace antlrcpptest;
|
|||
using namespace org::antlr::v4::runtime;
|
||||
|
||||
int main(int argc, const char * argv[]) {
|
||||
|
||||
ANTLRInputStream input(L"divideŴ and conquer");
|
||||
TLexer lexer(&input);
|
||||
CommonTokenStream tokens(&lexer);
|
||||
|
@ -27,7 +28,7 @@ int main(int argc, const char * argv[]) {
|
|||
TParser parser(&tokens);
|
||||
std::shared_ptr<tree::ParseTree> tree = parser.main();
|
||||
|
||||
std::wstring s = tree->toStringTree(&parser);
|
||||
std::wstring s = tree->toStringTree(&parser) + L"\n";
|
||||
OutputDebugString(s.data());
|
||||
|
||||
return 0;
|
||||
|
|
|
@ -49,19 +49,16 @@ using namespace antlrcpp;
|
|||
ATN::ATN() : ATN(ATNType::LEXER, 0) {
|
||||
}
|
||||
|
||||
/**
|
||||
* Required to be defined (even though not used) as we have an explicit move assignment operator.
|
||||
*/
|
||||
ATN::ATN(const ATN &other) {
|
||||
states = other.states;
|
||||
decisionToState = other.decisionToState;
|
||||
ruleToStartState = other.ruleToStartState;
|
||||
ruleToStopState = other.ruleToStopState;
|
||||
grammarType = other.grammarType;
|
||||
maxTokenType = other.maxTokenType;
|
||||
ruleToTokenType = other.ruleToTokenType;
|
||||
ruleToActionIndex = other.ruleToActionIndex;
|
||||
modeToStartState = other.modeToStartState;
|
||||
ATN::ATN(ATN &&other) {
|
||||
states = std::move(other.states);
|
||||
decisionToState = std::move(other.decisionToState);
|
||||
ruleToStartState = std::move(other.ruleToStartState);
|
||||
ruleToStopState = std::move(other.ruleToStopState);
|
||||
grammarType = std::move(other.grammarType);
|
||||
maxTokenType = std::move(other.maxTokenType);
|
||||
ruleToTokenType = std::move(other.ruleToTokenType);
|
||||
ruleToActionIndex = std::move(other.ruleToActionIndex);
|
||||
modeToStartState = std::move(other.modeToStartState);
|
||||
}
|
||||
|
||||
ATN::ATN(ATNType grammarType, size_t maxTokenType) : grammarType(grammarType), maxTokenType(maxTokenType) {
|
||||
|
@ -69,7 +66,7 @@ ATN::ATN(ATNType grammarType, size_t maxTokenType) : grammarType(grammarType), m
|
|||
|
||||
ATN::~ATN() {
|
||||
for (ATNState *state : states) {
|
||||
//delete state;
|
||||
delete state;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -45,7 +45,7 @@ namespace atn {
|
|||
|
||||
/// Used for runtime deserialization of ATNs from strings.
|
||||
ATN();
|
||||
ATN(const ATN &other);
|
||||
ATN(ATN &&other);
|
||||
ATN(ATNType grammarType, size_t maxTokenType);
|
||||
~ATN();
|
||||
|
||||
|
|
Loading…
Reference in New Issue