returns process exit code: 0 on success non-zero from int main, or 1 on compile/simulate/verify/exception failure
| 246 | // 0 on success |
| 247 | // non-zero from int main, or 1 on compile/simulate/verify/exception failure |
| 248 | int compile_and_run ( const string & fn, const string & mainFnName, bool outputProgramCode, bool dryRun, bool compileOnly, const char * introFile = nullptr ) { |
| 249 | // Heap-leak tracker: arm the tail-memoize landmark so per-allocation stack |
| 250 | // captures below this frame skip re-walking ancestors. No-op when |
| 251 | // DAS_TRACK_ALLOC is off or on non-Win64. |
| 252 | das::AllocTrackingLandmark _alloc_tracker_landmark; |
| 253 | auto access = get_file_access((char*)(projectFile.empty() ? nullptr : projectFile.c_str())); |
| 254 | if ( introFile ) { |
| 255 | auto fileInfo = make_unique<TextFileInfo>(introFile, uint32_t(strlen(introFile)), false); |
| 256 | access->setFileInfo("____intro____", das::move(fileInfo)); |
| 257 | } |
| 258 | int exitCode = 1; |
| 259 | ModuleGroup dummyGroup; |
| 260 | CodeOfPolicies policies; |
| 261 | if ( debuggerRequired ) { |
| 262 | policies.debugger = true; |
| 263 | access->addExtraModule("debug", getDasRoot() + "/daslib/debug.das"); |
| 264 | } else if ( profilerRequired ) { |
| 265 | policies.profiler = true; |
| 266 | access->addExtraModule("profiler", getDasRoot() + "/daslib/profiler.das"); |
| 267 | } /*else*/ if ( jitEnabled != JitMode::None ) { |
| 268 | policies.jit_enabled = true; |
| 269 | switch (jitEnabled) { |
| 270 | case JitMode::Executable: policies.jit_exe_mode = true; break; |
| 271 | case JitMode::Dll: policies.jit_dll_mode = true; break; |
| 272 | case JitMode::Direct: break; |
| 273 | default: break; |
| 274 | } |
| 275 | if ( jitNoCache ) policies.jit_dll_mode = false; |
| 276 | access->addExtraModule("just_in_time", getDasRoot() + "/daslib/just_in_time.das"); |
| 277 | policies.jit_output_path = jitOutPath; |
| 278 | policies.dll_search_paths.emplace_back(getDasRoot() + "/lib"); |
| 279 | } |
| 280 | if ( useAot ) { |
| 281 | // don't set policies.aot here - the host program (e.g. dastest) doesn't need AOT linking |
| 282 | // the --use-aot flag (after --) tells dastest to enable AOT for test files it compiles |
| 283 | policies.fail_on_no_aot = false; |
| 284 | } else { |
| 285 | policies.fail_on_no_aot = false; |
| 286 | } |
| 287 | policies.fail_on_lack_of_aot_export = false; |
| 288 | policies.version_2_syntax = version2syntax; |
| 289 | policies.gen2_make_syntax = gen2MakeSyntax; |
| 290 | policies.scoped_stack_allocator = scopedStackAllocator; |
| 291 | policies.track_allocations = trackAllocations; |
| 292 | policies.no_lint = noLint; |
| 293 | policies.log_module_compile_time = logModuleCompileTime; |
| 294 | policies.persistent_heap = true; |
| 295 | if ( auto program = compileDaScript(fn,access,tout,dummyGroup,policies) ) { |
| 296 | if ( program->failed() ) { |
| 297 | for ( auto & err : program->errors ) { |
| 298 | tout << reportError(err.at, err.what, err.extra, err.fixme, err.cerr ); |
| 299 | } |
| 300 | if ( pauseAfterErrors ) { |
| 301 | getchar(); |
| 302 | } |
| 303 | } else { |
| 304 | if ( outputProgramCode ) |
| 305 | tout << *program << "\n"; |
no test coverage detected