MCPcopy Create free account
hub / github.com/aardappel/lobster / RunCompiledCodeMain

Function RunCompiledCodeMain

dev/src/compiler.cpp:797–845  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

795#endif
796
797extern "C" int RunCompiledCodeMain(int argc, const char *const *argv, const VMMetaData *vmmeta,
798 const lobster::fun_base_t *vtables,
799 void *custom_pre_init, const char *aux_src_path) {
800 #ifdef _MSC_VER
801 _CrtSetDbgFlag(_CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF);
802 InitUnhandledExceptionFilter(argc, (char **)argv);
803 #endif
804 #ifdef USE_EXCEPTION_HANDLING
805 try
806 #endif
807 {
808 NativeRegistry nfr;
809 RegisterCoreLanguageBuiltins(nfr);
810 if (custom_pre_init) ((void (*)(NativeRegistry &))(custom_pre_init))(nfr);
811 auto loader = EnginePreInit(nfr);
812 min_output_level = OUTPUT_WARN;
813 InitPlatform(GetMainDirFromExePath(argv[0]), aux_src_path, false, loader);
814 auto from_lpak = true;
815 uint64_t src_hash = 0;
816 if (!LoadPakDir("default.lpak", src_hash)) {
817 // FIXME: this is optional, we don't know if the compiled code wants to load this
818 // file, so we don't error or even warn if this file can't be found.
819 from_lpak = false;
820 }
821 auto vmargs = VMArgs {
822 nfr,
823 from_lpak ? string{} : StripDirPart(string_view_nt(argv[0])),
824 vmmeta,
825 {},
826 vtables,
827 nullptr,
828 false,
829 RUNTIME_ASSERT
830 };
831 for (int arg = 1; arg < argc; arg++) { vmargs.program_args.push_back(argv[arg]); }
832 lobster::VMAllocator vma(std::move(vmargs));
833 if (from_lpak && src_hash != vma.vm->vma.meta->src_hash) {
834 THROW_OR_ABORT("lpak file from different version of the source code than the compiled code");
835 }
836 vma.vm->EvalProgram();
837 }
838 #ifdef USE_EXCEPTION_HANDLING
839 catch (string &s) {
840 LOG_ERROR(s);
841 return 1;
842 }
843 #endif
844 return 0;
845}
846
847bool Type::Equal(const Type &o, bool allow_unresolved) const {
848 if (this == &o) return true;

Callers

nothing calls this directly

Calls 11

InitPlatformFunction · 0.85
GetMainDirFromExePathFunction · 0.85
LoadPakDirFunction · 0.85
StripDirPartFunction · 0.85
string_view_ntClass · 0.85
THROW_OR_ABORTFunction · 0.85
EvalProgramMethod · 0.80
EnginePreInitFunction · 0.70
push_backMethod · 0.45

Tested by

no test coverage detected