MCPcopy Create free account
hub / github.com/FlaxEngine/FlaxEngine / Load

Method Load

Source/Engine/Scripting/Scripting.cpp:523–657  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

521}
522
523bool Scripting::Load()
524{
525 PROFILE_CPU();
526 PROFILE_MEM(Scripting);
527 // Note: this action can be called from main thread (due to Mono problems with assemblies actions from other threads)
528 ASSERT(IsInMainThread());
529 ScopeLock lock(BinaryModule::Locker);
530
531#if USE_CSHARP
532 // Load C# core assembly
533 ManagedBinaryModule* corlib = GetBinaryModuleCorlib();
534 corlib->CanReload = false;
535 if (corlib->Assembly->LoadCorlib())
536 {
537 LOG(Error, "Failed to load corlib C# assembly.");
538 return true;
539 }
540
541 // Initialize C# corelib types
542 {
543 const auto& corlibClasses = corlib->Assembly->GetClasses();
544 bool gotAll = true;
545#define CACHE_CORLIB_CLASS(var, name) gotAll &= corlibClasses.TryGet(StringAnsiView(name), MCore::TypeCache::var)
546 CACHE_CORLIB_CLASS(Void, "System.Void");
547 CACHE_CORLIB_CLASS(Object, "System.Object");
548 CACHE_CORLIB_CLASS(Byte, "System.Byte");
549 CACHE_CORLIB_CLASS(Boolean, "System.Boolean");
550 CACHE_CORLIB_CLASS(SByte, "System.SByte");
551 CACHE_CORLIB_CLASS(Char, "System.Char");
552 CACHE_CORLIB_CLASS(Int16, "System.Int16");
553 CACHE_CORLIB_CLASS(UInt16, "System.UInt16");
554 CACHE_CORLIB_CLASS(Int32, "System.Int32");
555 CACHE_CORLIB_CLASS(UInt32, "System.UInt32");
556 CACHE_CORLIB_CLASS(Int64, "System.Int64");
557 CACHE_CORLIB_CLASS(UInt64, "System.UInt64");
558 CACHE_CORLIB_CLASS(IntPtr, "System.IntPtr");
559 CACHE_CORLIB_CLASS(UIntPtr, "System.UIntPtr");
560 CACHE_CORLIB_CLASS(Single, "System.Single");
561 CACHE_CORLIB_CLASS(Double, "System.Double");
562 CACHE_CORLIB_CLASS(String, "System.String");
563#undef CACHE_CORLIB_CLASS
564 if (!gotAll)
565 {
566 LOG(Error, "Failed to load corlib C# assembly.");
567 for (const auto& e : corlibClasses)
568 LOG(Info, "Class: {0}", String(e.Value->GetFullName()));
569 return true;
570 }
571 }
572#endif
573
574 // Load FlaxEngine
575 auto* flaxEngineModule = (NativeBinaryModule*)GetBinaryModuleFlaxEngine();
576 if (!flaxEngineModule->Assembly->IsLoaded())
577 {
578#if USE_CSHARP
579 String flaxEnginePath = Globals::BinariesFolder / TEXT("FlaxEngine.CSharp.dll");
580#if USE_MONO_AOT

Callers 4

CompileShaderMethod · 0.45
LoadBinaryModulesMethod · 0.45
ReadJsonMethod · 0.45
FindLoadAssemblyMethod · 0.45

Calls 8

IsInMainThreadFunction · 0.85
GetBinaryModuleCorlibFunction · 0.85
onEngineLoadedFunction · 0.85
StringFunction · 0.50
LengthFunction · 0.50
LoadCorlibMethod · 0.45
IsLoadedMethod · 0.45
GetClassMethod · 0.45

Tested by

no test coverage detected