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

Function PiuDebugBehavior_compile

tools/xsbug/DebugBehavior.c:410–485  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

408}
409
410void PiuDebugBehavior_compile(xsMachine* the)
411{
412 txParser _parser;
413 txParser* parser = &_parser;
414 txParserJump jump;
415 txUnsigned flags = mxProgramFlag | mxEvalFlag | mxDebugFlag | mxStrictFlag;
416 txStringStream stream;
417 txScript* script = NULL;
418 txSize size;
419 size_t stringSize;
420 txString string;
421 txByte byte;
422
423 stream.offset = 0;
424 stream.size = c_strlen(fxToString(the, mxArgv(0)));
425 stream.slot = mxArgv(0);
426 fxInitializeParser(parser, the, 1024*1024, 1993);
427 parser->firstJump = &jump;
428 jump.nextJump = C_NULL;
429 if (c_setjmp(jump.jmp_buf) == 0) {
430 fxParserTree(parser, &stream, (txGetter)fxStringGetter, flags, C_NULL);
431 fxParserHoist(parser);
432 fxParserBind(parser);
433 script = fxParserCode(parser);
434// if (parser->errorCount > 0)
435// fprintf(stderr, "%s\n", parser->errorMessage);
436
437 size = 8 + 8 + 4 + 8 + script->symbolsSize + 8 + script->codeSize;
438
439 stringSize = (size * 2) + 1;
440 if (gxBuffer == NULL) {
441 gxBuffer = c_malloc(stringSize);
442 gxBufferSize = stringSize;
443 }
444 else if (gxBufferSize < stringSize) {
445 gxBuffer = c_realloc(gxBuffer, stringSize);
446 gxBufferSize = stringSize;
447 }
448 string = gxBuffer;
449
450 size = htonl(size);
451 string = fxBinHex(string, &size, 4);
452 string = fxBinHex(string, "XS_B", 4);
453
454 size = 8 + 4;
455 size = htonl(size);
456 string = fxBinHex(string, &size, 4);
457 string = fxBinHex(string, "VERS", 4);
458 byte = XS_MAJOR_VERSION;
459 string = fxBinHex(string, &byte, 1);
460 byte = XS_MINOR_VERSION;
461 string = fxBinHex(string, &byte, 1);
462 byte = XS_PATCH_VERSION;
463 string = fxBinHex(string, &byte, 1);
464 byte = (script->hostsBuffer) ? -1 : 0;
465 string = fxBinHex(string, &byte, 1);
466
467 size = 8 + script->symbolsSize;

Callers

nothing calls this directly

Calls 8

fxToStringFunction · 0.85
fxInitializeParserFunction · 0.85
fxParserTreeFunction · 0.85
fxParserHoistFunction · 0.85
fxParserBindFunction · 0.85
fxParserCodeFunction · 0.85
fxBinHexFunction · 0.85
fxTerminateParserFunction · 0.85

Tested by

no test coverage detected