| 1469 | } |
| 1470 | |
| 1471 | txMachine* fxReadSnapshot(txSnapshot* snapshot, txString theName, void* theContext) |
| 1472 | { |
| 1473 | Atom atom; |
| 1474 | txByte byte; |
| 1475 | txByte patch; |
| 1476 | txString signature; |
| 1477 | txCreation creation; |
| 1478 | txSlot* slot; |
| 1479 | |
| 1480 | txMachine* the = (txMachine* )c_calloc(sizeof(txMachine), 1); |
| 1481 | if (the) { |
| 1482 | txJump aJump; |
| 1483 | snapshot->error = 0; |
| 1484 | aJump.nextJump = C_NULL; |
| 1485 | aJump.stack = C_NULL; |
| 1486 | aJump.scope = C_NULL; |
| 1487 | aJump.frame = C_NULL; |
| 1488 | aJump.code = C_NULL; |
| 1489 | aJump.flag = 0; |
| 1490 | the->firstJump = &aJump; |
| 1491 | if (c_setjmp(aJump.buffer) == 0) { |
| 1492 | if (gxDefaults.initializeSharedCluster) |
| 1493 | gxDefaults.initializeSharedCluster(the); |
| 1494 | |
| 1495 | the->context = theContext; |
| 1496 | fxCreateMachinePlatform(the); |
| 1497 | |
| 1498 | #ifdef mxDebug |
| 1499 | the->name = theName; |
| 1500 | #endif |
| 1501 | |
| 1502 | fxReadAtom(the, snapshot, &atom, "XS_M"); |
| 1503 | fxReadAtom(the, snapshot, &atom, "VERS"); |
| 1504 | mxThrowIf((*snapshot->read)(snapshot->stream, &byte, 1)); |
| 1505 | mxAssert(byte == XS_MAJOR_VERSION, "snapshot: invalid major version %d\n", byte); |
| 1506 | mxThrowIf((*snapshot->read)(snapshot->stream, &byte, 1)); |
| 1507 | mxAssert(byte == XS_MINOR_VERSION, "snapshot: invalid minor version %d\n", byte); |
| 1508 | mxThrowIf((*snapshot->read)(snapshot->stream, &byte, 1)); |
| 1509 | patch = byte; |
| 1510 | mxThrowIf((*snapshot->read)(snapshot->stream, &byte, 1)); |
| 1511 | #if mxBigEndian |
| 1512 | mxAssert(byte == -((txByte)sizeof(txSlot)), "snapshot: invalid architecture %d\n", byte); |
| 1513 | #else |
| 1514 | mxAssert(byte == (txByte)sizeof(txSlot), "snapshot: invalid architecture %d\n", byte); |
| 1515 | #endif |
| 1516 | |
| 1517 | fxReadAtom(the, snapshot, &atom, "SIGN"); |
| 1518 | mxAssert(atom.atomSize == snapshot->signatureLength, "snapshot: invalid signature length %d\n", atom.atomSize); |
| 1519 | signature = snapshot->signature; |
| 1520 | while (atom.atomSize) { |
| 1521 | mxThrowIf((*snapshot->read)(snapshot->stream, &byte, 1)); |
| 1522 | mxAssert(byte == *signature, "snapshot: invalid signature byte %d\n", byte); |
| 1523 | atom.atomSize--; |
| 1524 | signature++; |
| 1525 | } |
| 1526 | |
| 1527 | fxReadAtom(the, snapshot, &atom, "CREA"); |
| 1528 | mxThrowIf((*snapshot->read)(snapshot->stream, &creation, sizeof(txCreation))); |
nothing calls this directly
no test coverage detected