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

Function fxDebugEvalExpression

xs/sources/xsDebug.c:358–486  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

356}
357
358txBoolean fxDebugEvalExpression(txMachine* the, txSlot* frame, txSlot* expression, txSlot* result)
359{
360 txBoolean success = 0;
361 if (mxIsFunction(expression->value.reference)) {
362 txSlot* scope = C_NULL;
363 if (frame == the->frame)
364 scope = the->scope;
365 else {
366 txSlot* current = the->frame;
367 while (current->next != frame)
368 current = current->next;
369 if (current)
370 scope = current->value.frame.scope;
371 else
372 scope = C_NULL;
373 }
374
375 txSlot* _this = frame + 3;
376 txSlot* environment = mxFrameToEnvironment(frame);
377 txSlot* function = frame + 2;
378 txSlot* home = (function->kind == XS_REFERENCE_KIND) ? mxFunctionInstanceHome(function->value.reference) : C_NULL;
379 txSlot* closures;
380 txSlot* property;
381
382 the->debugEval = 1;
383
384 mxOverflow(-5);
385 /* THIS */
386 mxPushSlot(_this);
387 /* FUNCTION */
388 mxPushSlot(function);
389 /* RESULT */
390 mxPushUndefined();
391 /* FRAME */
392 (--the->stack)->next = the->frame;
393 the->stack->ID = 0;
394 the->stack->flag = XS_C_FLAG | (frame->flag & (XS_STRICT_FLAG | XS_FIELD_FLAG));
395 the->stack->kind = XS_FRAME_KIND;
396 the->stack->value.frame.code = the->code;
397 the->stack->value.frame.scope = the->scope;
398 the->frame = the->stack;
399 /* ENVIRONMENT */
400 mxPushUndefined();
401 closures = fxNewEnvironmentInstance(the, C_NULL);
402 if (scope) {
403 txSlot* local = scope;
404 txID id;
405 property = closures->next;
406 while (local < environment) {
407 id = local->ID;
408 if ((0 < id) && (id < the->keyCount)) {
409 property = fxNextSlotProperty(the, property, local, id, local->flag);
410 }
411 local++;
412 }
413 }
414 the->scope = the->stack;
415 the->code = C_NULL;

Callers 2

fxDebugEvalFunction · 0.85
fxDebugLineFunction · 0.85

Calls 3

fxNewEnvironmentInstanceFunction · 0.85
fxNextSlotPropertyFunction · 0.85
fxEndHostFunction · 0.85

Tested by

no test coverage detected