| 174 | } |
| 175 | |
| 176 | void fxParseJSONArray(txMachine* the, txJSONParser* theParser) |
| 177 | { |
| 178 | txSlot* sourceArray = C_NULL; |
| 179 | txSlot* sourceItem = C_NULL; |
| 180 | txSlot* valueArray; |
| 181 | txSlot* valueItem; |
| 182 | txIndex length; |
| 183 | |
| 184 | mxCheckCStack(); |
| 185 | fxParseJSONToken(the, theParser); |
| 186 | mxPush(mxArrayPrototype); |
| 187 | valueArray = fxNewArrayInstance(the); |
| 188 | valueItem = fxLastProperty(the, valueArray); |
| 189 | if (theParser->sourceFlag) { |
| 190 | mxPush(mxArrayPrototype); |
| 191 | sourceArray = fxNewArrayInstance(the); |
| 192 | sourceItem = fxLastProperty(the, sourceArray); |
| 193 | } |
| 194 | length = 0; |
| 195 | for (;;) { |
| 196 | if (theParser->token == XS_JSON_TOKEN_RIGHT_BRACKET) |
| 197 | break; |
| 198 | if (length) { |
| 199 | if (theParser->token == XS_JSON_TOKEN_COMMA) |
| 200 | fxParseJSONToken(the, theParser); |
| 201 | else |
| 202 | mxSyntaxError("%ld: missing ,", theParser->line); |
| 203 | } |
| 204 | fxParseJSONValue(the, theParser); |
| 205 | length++; |
| 206 | if (sourceItem) { |
| 207 | sourceItem->next = fxNewSlot(the); |
| 208 | sourceItem = sourceItem->next; |
| 209 | sourceItem->kind = the->stack->kind; |
| 210 | sourceItem->value = the->stack->value; |
| 211 | mxPop(); |
| 212 | } |
| 213 | valueItem->next = fxNewSlot(the); |
| 214 | valueItem = valueItem->next; |
| 215 | valueItem->kind = the->stack->kind; |
| 216 | valueItem->value = the->stack->value; |
| 217 | mxPop(); |
| 218 | } |
| 219 | valueArray->next->value.array.length = length; |
| 220 | fxCacheArray(the, valueArray); |
| 221 | if (sourceItem) { |
| 222 | sourceArray->next->value.array.length = length; |
| 223 | fxCacheArray(the, sourceArray); |
| 224 | } |
| 225 | fxParseJSONToken(the, theParser); |
| 226 | } |
| 227 | |
| 228 | void fxParseJSONToken(txMachine* the, txJSONParser* theParser) |
| 229 | { |
no test coverage detected