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

Function compile

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

Source from the content-addressed store, hash-verified

34}
35
36bool compile ( const string & fn, const string & cppFn, bool dryRun ) {
37 auto access = get_file_access((char*)(projectFile.empty() ? nullptr : projectFile.c_str()));
38 ModuleGroup dummyGroup;
39 CodeOfPolicies policies;
40 policies.aot = false;
41 policies.aot_module = true;
42 policies.fail_on_lack_of_aot_export = true;
43 if ( auto program = compileDaScript(fn,access,tout,dummyGroup,false,policies) ) {
44 if ( program->failed() ) {
45 tout << "failed to compile\n";
46 for ( auto & err : program->errors ) {
47 tout << reportError(err.at, err.what, err.extra, err.fixme, err.cerr);
48 }
49 return false;
50 } else {
51 smart_ptr<Context> pctx ( get_context(program->getContextStackSize()) );
52 if ( !program->simulate(*pctx, tout) ) {
53 tout << "failed to simulate\n";
54 for ( auto & err : program->errors ) {
55 tout << reportError(err.at, err.what, err.extra, err.fixme, err.cerr);
56 }
57 return false;
58 }
59 // AOT time
60 TextWriter tw;
61 bool noAotOption = program->options.getBoolOption("no_aot",false);
62 bool noAotModule = false;
63 // header
64 tw << "#include \"daScript/misc/platform.h\"\n\n";
65
66 tw << "#include \"daScript/simulate/simulate.h\"\n";
67 tw << "#include \"daScript/simulate/aot.h\"\n";
68 tw << "#include \"daScript/simulate/aot_library.h\"\n";
69 tw << "\n";
70 // lets comment on required modules
71 program->library.foreach([&](Module * mod){
72 if ( mod->name=="" ) {
73 // nothing, its main program module. i.e ::
74 } else {
75 if ( mod->name=="$" ) {
76 tw << " // require builtin\n";
77 } else {
78 tw << " // require " << mod->name << "\n";
79 }
80 if ( mod->aotRequire(tw)==ModuleAotType::no_aot ) {
81 tw << " // AOT disabled due to this module\n";
82 noAotModule = true;
83 }
84 }
85 return true;
86 },"*");
87 if (dryRun) {
88 tout << "dry run success, no changes will be written\n";
89 return true;
90 }
91 if (noAotOption) {
92 TextWriter noTw;
93 if (!noAotModule)

Callers 2

das_aot_mainFunction · 0.70
compileMethod · 0.50

Calls 15

get_file_accessFunction · 0.85
compileDaScriptFunction · 0.85
reportErrorFunction · 0.85
get_contextFunction · 0.85
getContextStackSizeMethod · 0.80
getBoolOptionMethod · 0.80
aotCppMethod · 0.80
registerAotCppMethod · 0.80
validateAotCppMethod · 0.80
saveToFileFunction · 0.70
emptyMethod · 0.45
c_strMethod · 0.45

Tested by

no test coverage detected