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

Function transform_syntax

utils/dasFormatter/fmt.cpp:123–261  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

121}
122
123Result transform_syntax(const string &filename, const string content, format::FormatOptions options) {
124 auto src = content;
125 if (src.find("options gen2") == 0) {
126 Result res;
127 res.ok = src;
128 return res;
129 }
130 string prev;
131 vector<ModuleInfo> req;
132 vector<MissingRecord> missing;
133 vector<RequireRecord> circular, notAllowed;
134 vector<FileInfo *> chain;
135 das_set<string> dependencies;
136 ModuleGroup libGroup;
137 CodeOfPolicies policies;
138 policies.aot = false;
139 policies.aot_module = false;
140 policies.fail_on_lack_of_aot_export = false;
141 policies.version_2_syntax = false;
142
143 TextPrinter tp;
144
145 auto access = get_file_access(nullptr);
146 TextPrinter tout;
147 string moduleName;
148 das_hash_map<string, NamelessModuleReq> namelessReq;
149 vector<NamelessMismatch> namelessMismatches;
150 if (getPrerequisits(filename, access, moduleName, req, missing, circular, notAllowed, chain,
151 dependencies, namelessReq, namelessMismatches, libGroup, nullptr, 1, !policies.ignore_shared_modules)) {
152 for (auto &mod: req) {
153 if (libGroup.findModule(mod.moduleName)) {
154 continue;
155 }
156 auto program = parseDaScript(mod.fileName, mod.moduleName, access, tout, libGroup, true, true,
157 policies);
158 policies.threadlock_context |= program->options.getBoolOption("threadlock_context", false);
159 if (program->failed()) {
160 for (const auto& err: program->errors) {
161 tp << err.what << " " << err.at.describe() << '\n';
162 }
163 // return {}; // still try to compile
164 }
165 if (program->thisModule->name.empty()) {
166 program->thisModule->name = mod.moduleName;
167 program->thisModule->wasParsedNameless = true;
168 }
169 program->thisModule->fileName = mod.fileName;
170 addNewModules(libGroup, program);
171 }
172 }
173
174 int iter = 0;
175 policies.version_2_syntax = false;
176 const auto tmp_name1 = std::filesystem::temp_directory_path() / "tmp1.das";
177 {
178 std::ofstream ostream(tmp_name1);
179 ostream << src.c_str();
180 }

Callers 2

runFunction · 0.85
testFunction · 0.85

Calls 15

getPrerequisitsFunction · 0.85
parseDaScriptFunction · 0.85
stringClass · 0.85
das_yybeginFunction · 0.85
destroyFunction · 0.85
remove_semicolonsFunction · 0.85
findModuleMethod · 0.80
getBoolOptionMethod · 0.80
addNewModulesFunction · 0.70
initFunction · 0.70
findMethod · 0.45
describeMethod · 0.45

Tested by

no test coverage detected