parser.cxx

changeset 21
ae602e667879
parent 20
d7b13805d1e0
child 22
b48e10ca8832
equal deleted inserted replaced
20:d7b13805d1e0 21:ae602e667879
173 w->Write (DH_MAINLOOP); 173 w->Write (DH_MAINLOOP);
174 w->Write (DH_ENDMAINLOOP); 174 w->Write (DH_ENDMAINLOOP);
175 } 175 }
176 176
177 // If we added strings here, we need to write a list of them. 177 // If we added strings here, we need to write a list of them.
178 unsigned int stringcount = g_StringTable->Count(); 178 unsigned int stringcount = CountStringTable ();
179 printf ("Write %u strings\n", stringcount);
180 if (stringcount) { 179 if (stringcount) {
181 w->Write<long> (DH_STRINGLIST); 180 w->Write<long> (DH_STRINGLIST);
182 w->Write<long> (stringcount); 181 w->Write<long> (stringcount);
183 182 for (unsigned int a = 0; a < stringcount; a++)
184 for (unsigned int a = 0; a < stringcount; a++) { 183 w->WriteString (g_StringTable[a]);
185 printf ("Write string: `%s`\n", g_StringTable->table[a]); 184 }
186 w->WriteString (g_StringTable->table[a]); 185 printf ("%u string%s written\n", stringcount, (stringcount != 1) ? "s" : "");
187 }
188 }
189 } 186 }
190 187
191 void ScriptReader::ParseCommand (CommandDef* comm, ObjWriter* w) { 188 void ScriptReader::ParseCommand (CommandDef* comm, ObjWriter* w) {
192 // If this was defined at top-level, we stop right at square one! 189 // If this was defined at top-level, we stop right at square one!
193 if (g_CurMode == MODE_TOPLEVEL) 190 if (g_CurMode == MODE_TOPLEVEL)
226 w->Write<long> (BoolValue ()); 223 w->Write<long> (BoolValue ());
227 break; 224 break;
228 case RETURNVAL_STRING: 225 case RETURNVAL_STRING:
229 MustString(); 226 MustString();
230 w->Write<long> (DH_PUSHSTRINGINDEX); 227 w->Write<long> (DH_PUSHSTRINGINDEX);
231 w->Write<long> (g_StringTable->Push (token.chars())); 228 w->Write<long> (PushToStringTable (token.chars()));
232 break; 229 break;
233 } 230 }
234 231
235 if (curarg < comm->numargs - 1) { 232 if (curarg < comm->numargs - 1) {
236 MustNext (","); 233 MustNext (",");

mercurial