@@ -147,27 +147,27 @@ class Assembler
147147
148148 if (word == " mixin" )
149149 {
150- pushFile (std::make_shared<SourceFile>(" #mixin" , readString ()));
150+ pushFile (std::make_shared<SourceFile>(" #mixin" , readRealString ()));
151151 }
152152 else if (word == " call" )
153153 {
154154 auto rsLambda = [this ] { return readString (); };
155- pushFile (std::make_shared<SourceFile>(
156- " #call " , readString (), readList<' (' , ' )' , false >([this ] { return readString (); })));
155+ pushFile (std::make_shared<SourceFile>(" #call " , readRealString (),
156+ readList<' (' , ' )' , false >([this ] { return readRealString (); })));
157157 }
158158 else if (word == " include" )
159159 {
160- std::string s = readString ();
160+ std::string s = readRealString ();
161161 pushFile (std::make_shared<SourceFile>(s, strings.at (s)));
162162 }
163163 else if (word == " get" )
164164 {
165- std::string s = readString ();
165+ std::string s = readRealString ();
166166 pushFile (std::make_shared<SourceFile>(s, toStringLiteral (strings.at (s))));
167167 }
168168 else if (word == " set" )
169169 {
170- vars[readWord ()] = readString ();
170+ vars[readWord ()] = readRealString ();
171171 }
172172 else if (word == " unset" )
173173 {
@@ -206,7 +206,7 @@ class Assembler
206206 bool asStringLiteral = false ;
207207 if (peekChar () == ' "' )
208208 {
209- name = readString ();
209+ name = readRealString ();
210210 asStringLiteral = true ;
211211 }
212212 else
@@ -404,9 +404,9 @@ class Assembler
404404 fail ();
405405 }
406406 }
407- else if constexpr (std::is_same_v<std::string, comp>)
407+ else if constexpr (std::is_same_v<std::optional<std:: string> , comp>)
408408 {
409- if (! obj. empty () )
409+ if (obj)
410410 {
411411 fail ();
412412 }
@@ -647,7 +647,17 @@ class Assembler
647647 return strtod (w.c_str (), nullptr );
648648 }
649649
650- std::string readString ()
650+ std::string readRealString ()
651+ {
652+ auto ret = readString ();
653+ if (!ret)
654+ {
655+ throw StringException (" Null string found where real string expected" );
656+ }
657+ return *ret;
658+ }
659+
660+ std::optional<std::string> readString ()
651661 {
652662 skipWhitespace ();
653663 char c = readSymbol ();
@@ -656,7 +666,7 @@ class Assembler
656666 std::string word = readWord ();
657667 if (c == ' n' && word == " ull" )
658668 {
659- return {} ;
669+ return std:: nullopt ;
660670 }
661671 else
662672 {
@@ -714,12 +724,12 @@ class Assembler
714724
715725 ABCType kind = toABCType (word);
716726 expectSymbol (' (' );
717- std::string name = readString ();
718- int id = 0 ;
727+ std::optional<std:: string> name = readString ();
728+ int id = 0 ;
719729 if (peekChar () == ' ,' )
720730 {
721731 skipChar ();
722- std::string s = readString ();
732+ std::string s = readRealString ();
723733 auto found = std::find (namespaceLabels.begin (), namespaceLabels.end (), s);
724734 if (found != namespaceLabels.end ())
725735 {
@@ -976,7 +986,7 @@ class Assembler
976986 {
977987 ASASM::Metadata ret;
978988 ret.name = readString ();
979- std::vector<std::string> items;
989+ std::vector<std::optional<std:: string> > items;
980990 while (true )
981991 {
982992 std::string word = readWord ();
@@ -1025,7 +1035,7 @@ class Assembler
10251035 }
10261036 else if (word == " refid" )
10271037 {
1028- addUnique<addUniqueMethod>(methodsByID, readString (), ret);
1038+ addUnique<addUniqueMethod>(methodsByID, readRealString (), ret);
10291039 }
10301040 else if (word == " param" )
10311041 {
@@ -1118,7 +1128,7 @@ class Assembler
11181128 std::string word = readWord ();
11191129 if (word == " refid" )
11201130 {
1121- addUnique<addUniqueClass>(classesByID, readString (), ret);
1131+ addUnique<addUniqueClass>(classesByID, readRealString (), ret);
11221132 }
11231133 else if (word == " instance" )
11241134 {
@@ -1341,12 +1351,12 @@ class Assembler
13411351 case OPCodeArgumentType::Class:
13421352 instruction.arguments [i].classv ({});
13431353 localClassFixups.emplace_back (
1344- currentFile->position (), ret.size (), i, readString (), 0 );
1354+ currentFile->position (), ret.size (), i, readRealString (), 0 );
13451355 break ;
13461356 case OPCodeArgumentType::Method:
13471357 instruction.arguments [i].methodv ({});
13481358 localMethodFixups.emplace_back (
1349- currentFile->position (), ret.size (), i, readString (), 0 );
1359+ currentFile->position (), ret.size (), i, readRealString (), 0 );
13501360 break ;
13511361
13521362 case OPCodeArgumentType::JumpTarget:
@@ -1401,7 +1411,7 @@ class Assembler
14011411 {
14021412 ret[f.ii ].arguments [f.ai ].jumpTarget (parseLabel (f.name , labels));
14031413 }
1404- catch (std::exception& e )
1414+ catch (std::exception&)
14051415 {
14061416 setFile (f.where .load ());
14071417 throw ;
@@ -1414,7 +1424,7 @@ class Assembler
14141424 {
14151425 ret[f.ii ].arguments [f.ai ].switchTargets ()[f.si ] = parseLabel (f.name , labels);
14161426 }
1417- catch (std::exception& e )
1427+ catch (std::exception&)
14181428 {
14191429 setFile (f.where .load ());
14201430 throw ;
@@ -1443,7 +1453,7 @@ class Assembler
14431453 {
14441454 return parseLabel (word, labels);
14451455 }
1446- catch (std::exception& e )
1456+ catch (std::exception&)
14471457 {
14481458 backpedal (word.size ());
14491459 throw ;
0 commit comments