forked from Mirrors/openclonk
Make the child pointers of the scriptengine C4AulScript*s again
The rope will create a C4AulScript for the rope engine functions instead of putting them into the global scope, and we might want to put C4Object-only functions into a separate C4AulScript some day, too.rope
parent
e461e50f75
commit
bd371e38c1
|
@ -53,6 +53,7 @@ C4AulScript::C4AulScript()
|
|||
Temporary = false;
|
||||
|
||||
// prepare lists
|
||||
Prev = Next = NULL;
|
||||
Engine = NULL;
|
||||
}
|
||||
|
||||
|
@ -60,10 +61,12 @@ C4AulScript::~C4AulScript()
|
|||
{
|
||||
// clear
|
||||
Clear();
|
||||
// unreg
|
||||
Unreg();
|
||||
}
|
||||
|
||||
|
||||
void C4ScriptHost::Unreg()
|
||||
void C4AulScript::Unreg()
|
||||
{
|
||||
// remove from list
|
||||
if (Prev) Prev->Next = Next; else if (Engine) Engine->Child0 = Next;
|
||||
|
@ -80,7 +83,7 @@ void C4AulScript::Clear()
|
|||
}
|
||||
|
||||
|
||||
void C4ScriptHost::Reg2List(C4AulScriptEngine *pEngine)
|
||||
void C4AulScript::Reg2List(C4AulScriptEngine *pEngine)
|
||||
{
|
||||
// already regged? (def reloaded)
|
||||
if (Engine) return;
|
||||
|
|
|
@ -286,6 +286,8 @@ public:
|
|||
C4AulScript(); // constructor
|
||||
virtual ~C4AulScript(); // destructor
|
||||
virtual void Clear(); // remove script, byte code and children
|
||||
void Reg2List(C4AulScriptEngine *pEngine); // reg to linked list
|
||||
void Unreg(); // remove from list
|
||||
virtual bool Delete() { return true; } // allow deletion on pure class
|
||||
|
||||
StdCopyStrBuf ScriptName; // script name
|
||||
|
@ -318,12 +320,15 @@ protected:
|
|||
C4LangStringTable *stringTable;
|
||||
|
||||
C4AulScriptEngine *Engine; //owning engine
|
||||
C4AulScript *Prev, *Next; // tree structure
|
||||
|
||||
C4AulScriptState State; // script state
|
||||
|
||||
virtual bool ReloadScript(const char *szPath, const char *szLanguage); // reload given script
|
||||
virtual bool Parse();
|
||||
|
||||
virtual bool ResolveIncludes(C4DefList *rDefs);
|
||||
virtual bool ResolveAppends(C4DefList *rDefs);
|
||||
virtual void UnLink();
|
||||
};
|
||||
|
||||
// holds all C4AulScripts
|
||||
|
@ -332,7 +337,7 @@ class C4AulScriptEngine : public C4AulScript
|
|||
protected:
|
||||
C4AulFuncMap FuncLookUp;
|
||||
C4PropList * GlobalPropList;
|
||||
C4ScriptHost *Child0, *ChildL; // tree structure
|
||||
C4AulScript *Child0, *ChildL; // tree structure
|
||||
|
||||
public:
|
||||
int warnCnt, errCnt; // number of warnings/errors
|
||||
|
|
|
@ -247,7 +247,7 @@ void C4AulDebug::ProcessLine(const StdStrBuf &Line)
|
|||
}
|
||||
else if (SEqualNoCase(szCmd, "LST"))
|
||||
{
|
||||
for (C4ScriptHost* script = ScriptEngine.Child0; script; script = script->Next)
|
||||
for (C4AulScript* script = ScriptEngine.Child0; script; script = script->Next)
|
||||
{
|
||||
SendLine(RelativePath(script->ScriptName));
|
||||
}
|
||||
|
@ -262,7 +262,7 @@ void C4AulDebug::ProcessLine(const StdStrBuf &Line)
|
|||
const char* lineStart = szData+1+scriptPath.getLength();
|
||||
int line = strtol(szData+1+scriptPath.getLength(), const_cast<char**>(&lineStart), 10);
|
||||
|
||||
C4ScriptHost* script;
|
||||
C4AulScript* script;
|
||||
for (script = ScriptEngine.Child0; script; script = script->Next)
|
||||
{
|
||||
if (SEqualNoCase(RelativePath(script->ScriptName), scriptPath.getData()))
|
||||
|
|
|
@ -1132,7 +1132,7 @@ void C4AulScriptEngine::ResetProfilerTimes()
|
|||
// zero all profiler times of owned functions
|
||||
C4AulScript::ResetProfilerTimes();
|
||||
// reset sub-scripts
|
||||
for (C4ScriptHost *pScript = Child0; pScript; pScript = pScript->Next)
|
||||
for (C4AulScript *pScript = Child0; pScript; pScript = pScript->Next)
|
||||
pScript->ResetProfilerTimes();
|
||||
}
|
||||
|
||||
|
@ -1141,6 +1141,6 @@ void C4AulScriptEngine::CollectProfilerTimes(C4AulProfiler &rProfiler)
|
|||
// collect all profiler times of owned functions
|
||||
C4AulScript::CollectProfilerTimes(rProfiler);
|
||||
// collect sub-scripts
|
||||
for (C4ScriptHost *pScript = Child0; pScript; pScript = pScript->Next)
|
||||
for (C4AulScript *pScript = Child0; pScript; pScript = pScript->Next)
|
||||
pScript->CollectProfilerTimes(rProfiler);
|
||||
}
|
||||
|
|
|
@ -28,6 +28,16 @@
|
|||
#include <C4Game.h>
|
||||
#include <C4GameObjects.h>
|
||||
|
||||
bool C4AulScript::ResolveIncludes(C4DefList *rDefs)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
bool C4AulScript::ResolveAppends(C4DefList *rDefs)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
// ResolveAppends and ResolveIncludes must be called both
|
||||
// for each script. ResolveAppends has to be called first!
|
||||
bool C4ScriptHost::ResolveAppends(C4DefList *rDefs)
|
||||
|
@ -116,6 +126,11 @@ bool C4ScriptHost::ResolveIncludes(C4DefList *rDefs)
|
|||
return true;
|
||||
}
|
||||
|
||||
void C4AulScript::UnLink()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void C4ScriptHost::UnLink()
|
||||
{
|
||||
// do not unlink temporary (e.g., DirectExec-script in ReloadDef)
|
||||
|
@ -137,7 +152,7 @@ void C4ScriptHost::UnLink()
|
|||
void C4AulScriptEngine::UnLink()
|
||||
{
|
||||
// unlink scripts
|
||||
for (C4ScriptHost *s = Child0; s; s = s->Next)
|
||||
for (C4AulScript *s = Child0; s; s = s->Next)
|
||||
s->UnLink();
|
||||
GetPropList()->Thaw();
|
||||
if (State > ASS_PREPARSED) State = ASS_PREPARSED;
|
||||
|
@ -159,15 +174,15 @@ void C4AulScriptEngine::Link(C4DefList *rDefs)
|
|||
{
|
||||
|
||||
// resolve appends
|
||||
for (C4ScriptHost *s = Child0; s; s = s->Next)
|
||||
for (C4AulScript *s = Child0; s; s = s->Next)
|
||||
s->ResolveAppends(rDefs);
|
||||
|
||||
// resolve includes
|
||||
for (C4ScriptHost *s = Child0; s; s = s->Next)
|
||||
for (C4AulScript *s = Child0; s; s = s->Next)
|
||||
s->ResolveIncludes(rDefs);
|
||||
|
||||
// parse the scripts to byte code
|
||||
for (C4ScriptHost *s = Child0; s; s = s->Next)
|
||||
for (C4AulScript *s = Child0; s; s = s->Next)
|
||||
s->Parse();
|
||||
|
||||
// engine is always parsed (for global funcs)
|
||||
|
@ -179,7 +194,7 @@ void C4AulScriptEngine::Link(C4DefList *rDefs)
|
|||
rDefs->CallEveryDefinition();
|
||||
|
||||
// Done modifying the proplists now
|
||||
for (C4ScriptHost *s = Child0; s; s = s->Next)
|
||||
for (C4AulScript *s = Child0; s; s = s->Next)
|
||||
s->GetPropList()->Freeze();
|
||||
GetPropList()->Freeze();
|
||||
|
||||
|
@ -221,7 +236,7 @@ void C4AulScriptEngine::ReLink(C4DefList *rDefs)
|
|||
|
||||
bool C4AulScriptEngine::ReloadScript(const char *szScript, C4DefList *pDefs, const char *szLanguage)
|
||||
{
|
||||
C4ScriptHost * s;
|
||||
C4AulScript * s;
|
||||
for (s = Child0; s; s = s->Next)
|
||||
if (s->ReloadScript(szScript, szLanguage))
|
||||
break;
|
||||
|
|
|
@ -33,7 +33,6 @@
|
|||
|
||||
C4ScriptHost::C4ScriptHost()
|
||||
{
|
||||
Prev = Next = NULL;
|
||||
Script = NULL;
|
||||
Code.clear();
|
||||
LastCode = NULL;
|
||||
|
@ -49,7 +48,6 @@ C4ScriptHost::C4ScriptHost()
|
|||
C4ScriptHost::~C4ScriptHost()
|
||||
{
|
||||
Clear();
|
||||
Unreg();
|
||||
}
|
||||
|
||||
void C4ScriptHost::Clear()
|
||||
|
|
|
@ -37,8 +37,6 @@ public:
|
|||
void Clear();
|
||||
virtual bool Load(C4Group &hGroup, const char *szFilename,
|
||||
const char *szLanguage, C4LangStringTable *pLocalTable);
|
||||
void Reg2List(C4AulScriptEngine *pEngine); // reg to linked list
|
||||
void Unreg(); // remove from list
|
||||
const char *GetScript() const { return Script.getData(); }
|
||||
virtual C4ScriptHost * GetScriptHost() { return this; }
|
||||
std::list<C4ScriptHost *> SourceScripts;
|
||||
|
@ -70,7 +68,6 @@ protected:
|
|||
bool IncludesResolved;
|
||||
|
||||
StdStrBuf Script; // script
|
||||
C4ScriptHost *Prev, *Next;
|
||||
std::vector<C4AulBCC> Code;
|
||||
std::vector<const char *> PosForCode;
|
||||
C4AulBCC * LastCode;
|
||||
|
@ -79,7 +76,6 @@ protected:
|
|||
friend class C4AulParse;
|
||||
friend class C4AulScriptFunc;
|
||||
friend class C4AulDebug;
|
||||
friend class C4AulScriptEngine;
|
||||
friend class C4DirectExecScript;
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in New Issue