Skip to content

Commit

Permalink
Merge pull request #3009 from xTachyon/bettercpp
Browse files Browse the repository at this point in the history
Serialized ATN const array generates horrible machine code fix
  • Loading branch information
parrt authored Mar 4, 2021
2 parents dc460a0 + 76975c1 commit 0f8bddc
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 9 deletions.
1 change: 1 addition & 0 deletions contributors.txt
Original file line number Diff line number Diff line change
Expand Up @@ -289,3 +289,4 @@ YYYY/MM/DD, github id, Full name, email
2021/02/21, namasikanam, Xingyu Xie, namasikanam@gmail.com
2021/02/27, khmarbaise, Karl Heinz Marbaise, github@soebes.com
2021/03/02, hackeris
2021/03/03, xTachyon, Damian Andrei, xTachyon@users.noreply.github.com
10 changes: 1 addition & 9 deletions tool/resources/org/antlr/v4/tool/templates/codegen/Cpp/Cpp.stg
Original file line number Diff line number Diff line change
Expand Up @@ -422,22 +422,14 @@ static std::vector\<uint16_t> _serializedATN;

// Constructs the serialized ATN and writes init code for static member vars.
SerializedATN(model) ::= <<
<if (rest(model.segments))>
<model.segments: {segment | static uint16_t serializedATNSegment<i0>[] = {
<model.segments: {segment | static const uint16_t serializedATNSegment<i0>[] = {
<segment; wrap={<\n> }>
\};}; separator="\n">

<model.segments: {segment | _serializedATN.insert(_serializedATN.end(), serializedATNSegment<i0>,
serializedATNSegment<i0> + sizeof(serializedATNSegment<i0>) / sizeof(serializedATNSegment<i0>[0]));
}>

<else>
<! only one segment, can be inlined !>
_serializedATN = {
<model.serialized; wrap = {<\n>}>
};
<endif>

atn::ATNDeserializer deserializer;
_atn = deserializer.deserialize(_serializedATN);

Expand Down

0 comments on commit 0f8bddc

Please sign in to comment.