MCPcopy Create free account
hub / github.com/Moddable-OpenSource/moddable / fxParseJSONArray

Function fxParseJSONArray

xs/sources/xsJSON.c:176–226  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

174}
175
176void 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
228void fxParseJSONToken(txMachine* the, txJSONParser* theParser)
229{

Callers 1

fxParseJSONValueFunction · 0.70

Calls 6

fxNewArrayInstanceFunction · 0.85
fxLastPropertyFunction · 0.85
fxNewSlotFunction · 0.85
fxCacheArrayFunction · 0.85
fxParseJSONTokenFunction · 0.70
fxParseJSONValueFunction · 0.70

Tested by

no test coverage detected