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

Function fxLoadScript

xs/tools/xst.c:1146–1189  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1144}
1145
1146txScript* fxLoadScript(txMachine* the, txString path, txUnsigned flags)
1147{
1148 txParser _parser;
1149 txParser* parser = &_parser;
1150 txParserJump jump;
1151 FILE* file = NULL;
1152 txString name = NULL;
1153 char map[C_PATH_MAX];
1154 txScript* script = NULL;
1155 fxInitializeParser(parser, the, the->parserBufferSize, the->parserTableModulo);
1156 parser->firstJump = &jump;
1157 file = fopen(path, "r");
1158 if (c_setjmp(jump.jmp_buf) == 0) {
1159 mxParserThrowElse(file);
1160 parser->path = fxNewParserSymbol(parser, path);
1161 fxParserTree(parser, file, (txGetter)fgetc, flags, &name);
1162 fclose(file);
1163 file = NULL;
1164 if (name) {
1165 mxParserThrowElse(c_realpath(fxCombinePath(parser, path, name), map));
1166 parser->path = fxNewParserSymbol(parser, map);
1167 file = fopen(map, "r");
1168 mxParserThrowElse(file);
1169 fxParserSourceMap(parser, file, (txGetter)fgetc, flags, &name);
1170 fclose(file);
1171 file = NULL;
1172 if ((parser->errorCount == 0) && name) {
1173 mxParserThrowElse(c_realpath(fxCombinePath(parser, map, name), map));
1174 parser->path = fxNewParserSymbol(parser, map);
1175 }
1176 }
1177 fxParserHoist(parser);
1178 fxParserBind(parser);
1179 script = fxParserCode(parser);
1180 }
1181 if (file)
1182 fclose(file);
1183#ifdef mxInstrument
1184 if (the->peakParserSize < parser->total)
1185 the->peakParserSize = parser->total;
1186#endif
1187 fxTerminateParser(parser);
1188 return script;
1189}
1190
1191/* DEBUG */
1192

Callers 4

fx_runScriptFunction · 0.70
fxRunProgramFileFunction · 0.70
fxLoadModuleFunction · 0.70

Calls 10

fxInitializeParserFunction · 0.85
fxNewParserSymbolFunction · 0.85
fxParserTreeFunction · 0.85
c_realpathFunction · 0.85
fxCombinePathFunction · 0.85
fxParserSourceMapFunction · 0.85
fxParserHoistFunction · 0.85
fxParserBindFunction · 0.85
fxParserCodeFunction · 0.85
fxTerminateParserFunction · 0.85

Tested by

no test coverage detected