1
0
Fork 1
mirror of https://github.com/TES3MP/openmw-tes3mp.git synced 2025-01-15 20:19:56 +00:00
openmw-tes3mp/monster/vm/init.d
nkorslund 714b724bf2 - added -debug option
- removed all logging and output per default
- updated to latest monster, bullet and ogre versions


git-svn-id: https://openmw.svn.sourceforge.net/svnroot/openmw/trunk@102 ea6a568a-9f4f-0410-981a-c910a81bb256
2009-05-09 16:08:00 +00:00

144 lines
3.2 KiB
D

/*
Monster - an advanced game scripting language
Copyright (C) 2007-2009 Nicolay Korslund
Email: <korslund@gmail.com>
WWW: http://monster.snaptoad.com/
This file (init.d) is part of the Monster script language package.
Monster is distributed as free software: you can redistribute it
and/or modify it under the terms of the GNU General Public License
version 3, as published by the Free Software Foundation.
This program is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public License
version 3 along with this program. If not, see
http://www.gnu.org/licenses/ .
*/
// This module makes sure that the library is initialized in all
// cases.
module monster.vm.init;
import monster.compiler.tokenizer;
import monster.compiler.properties;
import monster.compiler.scopes;
import monster.vm.thread;
import monster.vm.stack;
import monster.vm.arrays;
import monster.vm.vm;
import monster.vm.dbg;
import monster.modules.all;
import monster.options;
version(Tango)
{}
else
{
// D runtime stuff
version(Posix)
{
extern (C) void _STI_monitor_staticctor();
//extern (C) void _STD_monitor_staticdtor();
extern (C) void _STI_critical_init();
//extern (C) void _STD_critical_term();
}
version(Win32)
{
extern (C) void _minit();
}
extern (C) void gc_init();
//extern (C) void gc_term();
extern (C) void _moduleCtor();
//extern (C) void _moduleDtor();
extern (C) void _moduleUnitTests();
//extern (C) bool no_catch_exceptions;
} // end version(Tango) .. else
bool initHasRun = false;
bool stHasRun = false;
static this()
{
assert(!stHasRun);
stHasRun = true;
// While we're here, run the initializer right away if it hasn't run
// already.
if(!initHasRun)
doMonsterInit();
}
void doMonsterInit()
{
// Prevent recursion
assert(!initHasRun, "doMonsterInit should never run more than once");
initHasRun = true;
// First check if D has been initialized.
if(!stHasRun)
{
// Nope. This is normal though if we're running as a C++
// library. We have to init the D runtime manually.
// But this is not supported in Tango at the moment.
version(Tango)
{
assert(0, "tango-compiled C++ library not supported yet");
}
else
{
version (Posix)
{
_STI_monitor_staticctor();
_STI_critical_init();
}
gc_init();
version (Win32)
{
_minit();
}
_moduleCtor();
_moduleUnitTests();
}
}
assert(stHasRun, "D library initializion failed");
// Next, initialize the Monster library
// Initialize the debugger structure
dbg.init();
// Initialize compiler constructs
initTokenizer();
initProperties();
// initScope depends on doVMInit setting vm.vfs
vm.doVMInit();
initScope();
// The rest of the VM
scheduler.init();
stack.init();
arrays.initialize();
// Load modules
static if(loadModules)
initAllModules();
}