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

Function fxReadSymbols

xs/tools/xslBase.c:570–618  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

568}
569
570void fxReadSymbols(txLinker* linker, txString path, txFlag flag, FILE** fileAddress)
571{
572 FILE* aFile = NULL;
573 Atom atom;
574 txByte version[4];
575 txSize symbolsSize;
576 txS1* symbolsBuffer;
577 aFile = fopen(path, "rb");
578 mxThrowElse(aFile);
579 *fileAddress = aFile;
580 mxThrowElse(fread(&atom, sizeof(atom), 1, aFile) == 1);
581 atom.atomSize = ntohl(atom.atomSize);
582 atom.atomType = ntohl(atom.atomType);
583 mxAssert(atom.atomType == XS_ATOM_INCREMENTAL);
584
585 mxThrowElse(fread(&atom, sizeof(atom), 1, aFile) == 1);
586 atom.atomSize = ntohl(atom.atomSize);
587 atom.atomType = ntohl(atom.atomType);
588 mxAssert(atom.atomType == XS_ATOM_VERSION);
589 mxThrowElse(fread(version, sizeof(version), 1, aFile) == 1);
590 mxAssert(version[0] == XS_MAJOR_VERSION);
591 mxAssert(version[1] == XS_MINOR_VERSION);
592
593 mxThrowElse(fread(&atom, sizeof(atom), 1, aFile) == 1);
594 atom.atomSize = ntohl(atom.atomSize);
595 atom.atomType = ntohl(atom.atomType);
596 mxAssert(atom.atomType == XS_ATOM_SYMBOLS);
597 symbolsSize = atom.atomSize - sizeof(atom);
598 symbolsBuffer = fxNewLinkerChunk(linker, symbolsSize);
599 mxThrowElse(fread(symbolsBuffer, symbolsSize, 1, aFile) == 1);
600 {
601 txByte* p = symbolsBuffer;
602 txID c, i = 0;
603 mxDecodeID(p, c);
604 if (flag == 0) { // incremental
605 for (; i < XS_SYMBOL_ID_COUNT; i++) {
606 fxNewLinkerSymbol(linker, (txString)p, flag, 0);
607 p += mxStringLength((char*)p) + 1;
608 }
609 }
610 i++;
611 for (; i < c; i++) {
612 fxNewLinkerSymbol(linker, (txString)p, flag, 1);
613 p += mxStringLength((char*)p) + 1;
614 }
615 }
616 fclose(aFile);
617 *fileAddress = NULL;
618}
619
620txString fxRealDirectoryPath(txLinker* linker, txString path)
621{

Callers 1

mainFunction · 0.85

Calls 2

fxNewLinkerChunkFunction · 0.85
fxNewLinkerSymbolFunction · 0.85

Tested by

no test coverage detected