MCPcopy Create free account
hub / github.com/GaijinEntertainment/daScript / getPrerequisits

Function getPrerequisits

src/ast/ast_parse.cpp:296–472  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

294 string getDasRoot ( void );
295
296 bool getPrerequisits ( const string & fileName,
297 const FileAccessPtr & access,
298 string &modName,
299 vector<ModuleInfo> & req,
300 vector<MissingRecord> & missing,
301 vector<RequireRecord> & circular,
302 vector<RequireRecord> & notAllowed,
303 vector<FileInfo *> & chain,
304 das_set<string> & dependencies,
305 das_hash_map<string, NamelessModuleReq> & namelessReq,
306 vector<NamelessMismatch> & namelessMismatches,
307 ModuleGroup & libGroup,
308 TextWriter * log,
309 int tab,
310 bool allowPromoted,
311 const string & reqNameHint,
312 int32_t reqLineHint ) {
313 if ( auto fi = access->getFileInfo(fileName) ) {
314 ChainGuard guard(chain,fi);
315 if ( log ) {
316 *log << string(tab,'\t') << "in " << fileName << "\n";
317 }
318 vector<RequireRecord> ownReq = getAllRequire(fi, modName, chain, access);
319 for ( auto & modRec : ownReq ) {
320 string mod = modRec.name;
321 if ( log ) {
322 *log << string(tab,'\t') << "require " << mod << "\n";
323 }
324 if ( !access->canBeRequired(mod, fileName, modRec.isPublic) )
325 {
326 notAllowed.push_back({mod, modRec.line, chain, modRec.isPublic});
327 if ( log ) {
328 *log << string(tab,'\t') << "from " << fileName << " require " << mod << " - CAN'T BE REQUIRED\n";
329 }
330 return false;
331 }
332 auto info = access->getModuleInfo(mod, fileName);
333 auto module = Module::requireEx(mod, allowPromoted, info.fileName);
334 if ( !module ) {
335 if ( !info.moduleName.empty() ) {
336 mod = info.moduleName;
337 if ( log ) {
338 *log << string(tab,'\t') << " resolved as " << mod << "\n";
339 }
340 }
341 module = Module::requireEx(mod, allowPromoted, info.fileName); // try native with that name AGAIN (promoted?)
342 if ( !module ) {
343 auto it_r = find_if(req.begin(), req.end(), [&] ( const ModuleInfo & reqM ) {
344 return reqM.moduleName == mod;
345 });
346 if ( it_r==req.end() ) {
347 if ( dependencies.find(mod) != dependencies.end() ) {
348 // circular dependency
349 if ( log ) {
350 *log << string(tab,'\t') << "from " << fileName << " require " << modRec.name << " - CIRCULAR DEPENDENCY\n";
351 }
352 circular.push_back({modRec.name, modRec.line, chain, modRec.isPublic});
353 return false;

Callers 5

transform_syntaxFunction · 0.85
addExtraDependencyFunction · 0.85
compileDaScriptFunction · 0.85

Calls 15

stringClass · 0.85
getAllRequireFunction · 0.85
builtin_string_stricmpFunction · 0.85
addRequirementsFunction · 0.85
getDasRootFunction · 0.85
canBeRequiredMethod · 0.80
getFileInfoMethod · 0.45
push_backMethod · 0.45
getModuleInfoMethod · 0.45
emptyMethod · 0.45
beginMethod · 0.45

Tested by

no test coverage detected