| 128 | } |
| 129 | |
| 130 | void fx_JSON_parse(txMachine* the) |
| 131 | { |
| 132 | volatile txJSONParser aParser = {0}; |
| 133 | if (mxArgc < 1) |
| 134 | mxSyntaxError("no buffer"); |
| 135 | fxToString(the, mxArgv(0)); |
| 136 | aParser.slot = mxArgv(0); |
| 137 | aParser.offset = 0; |
| 138 | mxPush(mxEmptyString); |
| 139 | aParser.string = the->stack; |
| 140 | aParser.line = 1; |
| 141 | if ((mxArgc > 1) && mxIsReference(mxArgv(1))) { |
| 142 | if (fxIsArray(the, mxArgv(1)->value.reference)) |
| 143 | aParser.keys = fxToJSONKeys(the, mxArgv(1)); |
| 144 | else if (mxIsCallable(mxArgv(1)->value.reference)) |
| 145 | aParser.sourceFlag = 1; |
| 146 | } |
| 147 | fxParseJSON(the, (txJSONParser*)&aParser); |
| 148 | if (aParser.sourceFlag) { |
| 149 | txSlot* valueReference = the->stack + 1; |
| 150 | txSlot* sourceReference = the->stack; |
| 151 | txSlot* instance; |
| 152 | txID id; |
| 153 | mxPush(mxObjectPrototype); |
| 154 | instance = fxNewObjectInstance(the); |
| 155 | id = fxID(the, ""); |
| 156 | mxBehaviorDefineOwnProperty(the, instance, id, 0, valueReference, XS_GET_ONLY); |
| 157 | mxPushSlot(mxArgv(1)); |
| 158 | mxCall(); |
| 159 | mxPushUndefined(); |
| 160 | fxKeyAt(the, id, 0, the->stack); |
| 161 | mxPushSlot(valueReference); |
| 162 | mxPushSlot(sourceReference); |
| 163 | fxReviveJSON(the, (txJSONParser*)&aParser, mxArgv(1)); |
| 164 | } |
| 165 | mxPullSlot(mxResult); |
| 166 | } |
| 167 | |
| 168 | void fxParseJSON(txMachine* the, txJSONParser* theParser) |
| 169 | { |
nothing calls this directly
no test coverage detected