| 405 | } |
| 406 | |
| 407 | void fxStringAccessorGetter(txMachine* the) |
| 408 | { |
| 409 | txSlot* string = C_NULL; |
| 410 | txID id = the->scratch.value.at.id; |
| 411 | txIndex index = the->scratch.value.at.index; |
| 412 | if ((mxThis->kind == XS_STRING_KIND) || (mxThis->kind == XS_STRING_X_KIND)) |
| 413 | string = mxThis; |
| 414 | else { |
| 415 | txSlot* instance = fxToInstance(the, mxThis); |
| 416 | while (instance) { |
| 417 | if ((instance->flag & XS_EXOTIC_FLAG) && (instance->next->ID == XS_STRING_BEHAVIOR)) { |
| 418 | string = instance->next; |
| 419 | break; |
| 420 | } |
| 421 | instance = fxGetPrototype(the, instance); |
| 422 | } |
| 423 | } |
| 424 | if (string) { |
| 425 | if (id == mxID(_length)) { |
| 426 | mxResult->value.integer = fxCacheUnicodeLength(the, string->value.string); |
| 427 | mxResult->kind = XS_INTEGER_KIND; |
| 428 | } |
| 429 | else { |
| 430 | txInteger from = fxCacheUnicodeToUTF8Offset(the, string->value.string, index); |
| 431 | if (from >= 0) { |
| 432 | txInteger to = fxUnicodeToUTF8Offset(string->value.string + from, 1); |
| 433 | if (to >= 0) { |
| 434 | to += from; |
| 435 | mxResult->value.string = fxNewChunk(the, to - from + 1); |
| 436 | c_memcpy(mxResult->value.string, string->value.string + from, to - from); |
| 437 | mxResult->value.string[to - from] = 0; |
| 438 | mxResult->kind = XS_STRING_KIND; |
| 439 | } |
| 440 | } |
| 441 | } |
| 442 | } |
| 443 | } |
| 444 | |
| 445 | void fxStringAccessorSetter(txMachine* the) |
| 446 | { |
nothing calls this directly
no test coverage detected