MCPcopy Create free account
hub / github.com/SakuraEngine/SakuraEngine / compile_and_run

Function compile_and_run

tools/dascript_aot/aot_cc/src/main.cpp:269–343  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

267}
268
269bool compile_and_run ( const string & fn, const string & mainFnName, bool outputProgramCode, bool dryRun, const char * introFile = nullptr ) {
270 auto access = get_file_access((char*)(projectFile.empty() ? nullptr : projectFile.c_str()));
271 if ( introFile ) {
272 auto fileInfo = make_unique<TextFileInfo>(introFile, uint32_t(strlen(introFile)), false);
273 access->setFileInfo("____intro____", das::move(fileInfo));
274 }
275 bool success = false;
276 ModuleGroup dummyGroup;
277 CodeOfPolicies policies;
278 policies.debugger = debuggerRequired;
279 if ( debuggerRequired ) {
280 policies.debug_module = getDasRoot() + "/daslib/debug.das";
281 }
282 if ( !policies.debugger && profilerRequired ) {
283 policies.profiler = true;
284 policies.profile_module = getDasRoot() + "/daslib/profiler.das";
285 }
286 policies.fail_on_no_aot = false;
287 policies.fail_on_lack_of_aot_export = false;
288 if ( auto program = compileDaScript(fn,access,tout,dummyGroup,false,policies) ) {
289 if ( program->failed() ) {
290 for ( auto & err : program->errors ) {
291 tout << reportError(err.at, err.what, err.extra, err.fixme, err.cerr );
292 }
293 if ( pauseAfterErrors ) {
294 getchar();
295 }
296 } else {
297 if ( outputProgramCode )
298 tout << *program << "\n";
299 smart_ptr<Context> pctx ( get_context(program->getContextStackSize()) );
300 if ( !program->simulate(*pctx, tout) ) {
301 tout << "failed to simulate\n";
302 for ( auto & err : program->errors ) {
303 tout << reportError(err.at, err.what, err.extra, err.fixme, err.cerr );
304 }
305 } else if ( program->thisModule->isModule ) {
306 tout<< "WARNING: program is setup as both module, and endpoint.\n";
307 } else if ( dryRun ) {
308 success = true;
309 tout << "dry run: " << fn << "\n";
310 } else {
311 auto fnVec = pctx->findFunctions(mainFnName.c_str());
312 das::vector<SimFunction *> fnMVec;
313 for ( auto fnAS : fnVec ) {
314 if ( verifyCall<void>(fnAS->debugInfo, dummyGroup) || verifyCall<bool>(fnAS->debugInfo, dummyGroup) ) {
315 fnMVec.push_back(fnAS);
316 }
317 }
318 if ( fnMVec.size()==0 ) {
319 tout << "function '" << mainFnName << "' not found\n";
320 } else if ( fnMVec.size()>1 ) {
321 tout << "too many options for '" << mainFnName << "'\ncandidates are:\n";
322 for ( auto fnAS : fnMVec ) {
323 tout << "\t" << fnAS->mangledName << "\n";
324 }
325 } else {
326 success = true;

Callers 1

MAIN_FUNC_NAMEFunction · 0.70

Calls 15

get_file_accessFunction · 0.85
getDasRootFunction · 0.85
compileDaScriptFunction · 0.85
reportErrorFunction · 0.85
get_contextFunction · 0.85
setFileInfoMethod · 0.80
getContextStackSizeMethod · 0.80
findFunctionsMethod · 0.80
evalWithCatchMethod · 0.80
getExceptionMethod · 0.80
moveFunction · 0.50
emptyMethod · 0.45

Tested by

no test coverage detected