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

Function compile

tests/daS/dasTestAnnotation/annotation_compiler.cpp:39–180  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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

Callers 1

das_aot_mainFunction · 0.70

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