@@ -1777,34 +1777,29 @@ class State {
17771777 while (sin >> word) {
17781778 sentence.push_back (word);
17791779 // special treatment of string values
1780- // TODO: change this to a better implementation
1781- if (word == " (" ) {
1780+ if (word == " sval" && sentence.size () > 1 && *(sentence.rbegin () + 1 ) == " (" ) {
17821781 sin >> word;
17831782 sentence.push_back (word);
1784- if (word == " sval" ) {
1785- sin >> word;
1786- sentence.push_back (word);
1787- int len = std::stoi (word);
1788- while (true ) {
1789- if (sin.get () == ' "' ) {
1790- break ;
1791- }
1792- if (sin.eof ()) {
1793- utils::panic (" serialization" , " didn't find start of str val" );
1794- }
1783+ int len = std::stoi (word);
1784+ while (true ) {
1785+ if (sin.get () == ' "' ) {
1786+ break ;
17951787 }
1796- word = " \" " ;
1797- for (int i = 0 ; i < len - 1 ; i++) {
1798- word.push_back (sin.get ());
1799- if (sin.eof ()) {
1800- utils::panic (" serialization" , " incomplete string" );
1801- }
1788+ if (sin.eof ()) {
1789+ utils::panic (" serialization" , " didn't find start of str val" );
18021790 }
1803- if (word.back () != ' \" ' ) {
1804- utils::panic (" serialization" , " invalid string terminator" );
1791+ }
1792+ word = " \" " ;
1793+ for (int i = 0 ; i < len - 1 ; i++) {
1794+ word.push_back (sin.get ());
1795+ if (sin.eof ()) {
1796+ utils::panic (" serialization" , " incomplete string" );
18051797 }
1806- sentence.push_back (word);
18071798 }
1799+ if (word.back () != ' "' ) {
1800+ utils::panic (" serialization" , " invalid string terminator" );
1801+ }
1802+ sentence.push_back (word);
18081803 }
18091804 }
18101805 }
@@ -2179,6 +2174,7 @@ class State {
21792174 const syntax::ExprNode* getExpr () const {
21802175 return expr;
21812176 }
2177+ // TODO: record GC state?
21822178 std::string serialize () const {
21832179 // std::string source;
21842180 std::string serializedSource =
0 commit comments