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

Function fxParserSourceMap

xs/sources/xsSourceMap.c:45–122  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

43#define mxAssert(ASSERTION,MESSAGE) if (!(ASSERTION)) { fxReportParserError(parser, parser->states[0].line, MESSAGE); return; }
44
45void fxParserSourceMap(txParser* parser, void* theStream, txGetter theGetter, txUnsigned flags, txString* name)
46{
47 txInteger line = parser->states[0].line;
48 txNode* root = parser->root;
49 txNode* object;
50 txNode* item;
51 txNode* node;
52 txPropertyAtNode* property;
53 txString id;
54 txInteger version = 0;
55 txString source = NULL;
56 txString mappings = NULL;
57
58 parser->states[0].line = 0;
59 parser->root = NULL;
60 parser->stream = theStream;
61 parser->getter = theGetter;
62
63 parser->states[2].line = 1;
64 parser->states[2].crlf = 0;
65 parser->states[2].escaped = 0;
66 parser->states[2].integer = 0;
67 parser->states[2].modifierLength = 0;
68 parser->states[2].modifier = parser->emptyString;
69 parser->states[2].number = 0;
70 parser->states[2].stringLength = 0;
71 parser->states[2].string = parser->emptyString;
72 parser->states[2].symbol = C_NULL;
73 parser->states[2].token = XS_NO_TOKEN;
74
75 parser->lookahead = 0;
76#if mxCESU8
77 parser->surrogate = 0;
78#endif
79 fxGetNextCharacter(parser);
80 fxGetNextCharacter(parser);
81 fxGetNextTokenJSON(parser);
82 fxGetNextTokenJSON(parser);
83 fxJSONValue(parser);
84 if (parser->errorCount)
85 return;
86 object = parser->root;
87 parser->states[0].line = line;
88 parser->root = root;
89
90 mxAssert(object->description->token == XS_TOKEN_OBJECT, "source map: no object");
91 mxAssert(((txObjectNode*)object)->items, "source map: no properties");
92 item = ((txObjectNode*)object)->items->first;
93 while (item) {
94 mxAssert(item->description->token == XS_TOKEN_PROPERTY_AT, "source map: no property");
95 property = (txPropertyAtNode*)item;
96 mxAssert(property->at->description->token == XS_TOKEN_STRING, "source map: no property name");
97 id = ((txStringNode*)(property->at))->value;
98 if (!c_strcmp(id, "version")) {
99 mxAssert(property->value->description->token == XS_TOKEN_INTEGER, "source map: version is no integer");
100 version = ((txIntegerNode*)(property->value))->value;
101 }
102 else if (!c_strcmp(id, "sources")) {

Callers 2

mainFunction · 0.85
fxLoadScriptFunction · 0.85

Calls 5

fxGetNextCharacterFunction · 0.85
fxGetNextTokenJSONFunction · 0.85
fxJSONValueFunction · 0.85
fxNewParserChunkClearFunction · 0.85
fxSourceMapLinesFunction · 0.85

Tested by

no test coverage detected