2009-05-08 13:28:41 +00:00
|
|
|
/*
|
|
|
|
* OpenClonk, http://www.openclonk.org
|
|
|
|
*
|
2010-12-23 00:01:24 +00:00
|
|
|
* Copyright (c) 2001, 2004, 2006, 2009-2010 Peter Wortmann
|
|
|
|
* Copyright (c) 2001-2002, 2004, 2006-2007 Sven Eberhardt
|
2013-01-09 23:23:06 +00:00
|
|
|
* Copyright (c) 2004, 2006-2012 Günther Brammer
|
2009-06-05 13:41:20 +00:00
|
|
|
* Copyright (c) 2006 Armin Burgmeier
|
|
|
|
* Copyright (c) 2007 Matthes Bender
|
2010-12-23 00:01:24 +00:00
|
|
|
* Copyright (c) 2009 Nicolas Hake
|
2011-09-01 10:47:54 +00:00
|
|
|
* Copyright (c) 2010 Martin Plicht
|
2009-05-08 13:28:41 +00:00
|
|
|
* Copyright (c) 2001-2009, RedWolf Design GmbH, http://www.clonk.de
|
|
|
|
*
|
|
|
|
* Portions might be copyrighted by other authors who have contributed
|
|
|
|
* to OpenClonk.
|
|
|
|
*
|
|
|
|
* Permission to use, copy, modify, and/or distribute this software for any
|
|
|
|
* purpose with or without fee is hereby granted, provided that the above
|
|
|
|
* copyright notice and this permission notice appear in all copies.
|
|
|
|
* See isc_license.txt for full license and disclaimer.
|
|
|
|
*
|
|
|
|
* "Clonk" is a registered trademark of Matthes Bender.
|
|
|
|
* See clonk_trademark_license.txt for full license.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef INC_C4Aul
|
|
|
|
#define INC_C4Aul
|
|
|
|
|
|
|
|
#include <C4ValueMap.h>
|
|
|
|
#include <C4Id.h>
|
|
|
|
#include <C4Script.h>
|
|
|
|
#include <C4StringTable.h>
|
2012-02-13 17:00:35 +00:00
|
|
|
#include "C4AulFunc.h"
|
2009-11-12 15:57:37 +00:00
|
|
|
#include <string>
|
2009-10-25 23:09:34 +00:00
|
|
|
#include <vector>
|
2009-05-08 13:28:41 +00:00
|
|
|
|
|
|
|
// consts
|
2010-03-28 17:58:21 +00:00
|
|
|
#define C4AUL_MAX_Identifier 100 // max length of function identifiers
|
2009-05-08 13:28:41 +00:00
|
|
|
|
|
|
|
// generic C4Aul error class
|
|
|
|
class C4AulError
|
2010-03-28 17:58:21 +00:00
|
|
|
{
|
|
|
|
protected:
|
2010-12-22 03:26:37 +00:00
|
|
|
StdCopyStrBuf sMessage;
|
2010-03-28 17:58:21 +00:00
|
|
|
|
|
|
|
public:
|
2010-12-22 03:26:37 +00:00
|
|
|
bool shown;
|
2010-03-28 17:58:21 +00:00
|
|
|
C4AulError();
|
|
|
|
virtual ~C4AulError() { } // destructor
|
2011-03-05 15:50:22 +00:00
|
|
|
void show(); // present error message
|
2010-03-28 17:58:21 +00:00
|
|
|
};
|
2009-05-08 13:28:41 +00:00
|
|
|
|
|
|
|
// parse error
|
|
|
|
class C4AulParseError : public C4AulError
|
2010-03-28 17:58:21 +00:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
C4AulParseError(C4AulScript *pScript, const char *pMsg, const char *pIdtf = NULL, bool Warn = false); // constructor
|
2012-04-12 19:03:14 +00:00
|
|
|
C4AulParseError(class C4AulParse * state, const char *pMsg, const char *pIdtf = NULL, bool Warn = false); // constructor
|
2010-03-28 17:58:21 +00:00
|
|
|
};
|
2009-05-08 13:28:41 +00:00
|
|
|
|
|
|
|
// execution error
|
|
|
|
class C4AulExecError : public C4AulError
|
2010-03-28 17:58:21 +00:00
|
|
|
{
|
|
|
|
public:
|
2012-05-15 01:11:23 +00:00
|
|
|
C4AulExecError(const char *szError);
|
2010-03-28 17:58:21 +00:00
|
|
|
};
|
2009-05-08 13:28:41 +00:00
|
|
|
|
|
|
|
// function access
|
|
|
|
enum C4AulAccess
|
2010-03-28 17:58:21 +00:00
|
|
|
{
|
2009-05-08 13:28:41 +00:00
|
|
|
AA_PRIVATE,
|
|
|
|
AA_PROTECTED,
|
|
|
|
AA_PUBLIC,
|
|
|
|
AA_GLOBAL
|
2010-03-28 17:58:21 +00:00
|
|
|
};
|
2009-05-08 13:28:41 +00:00
|
|
|
|
|
|
|
// byte code chunk type
|
|
|
|
// some special script functions defined hard-coded to reduce the exec context
|
|
|
|
enum C4AulBCCType
|
2010-03-28 17:58:21 +00:00
|
|
|
{
|
2010-04-07 13:04:19 +00:00
|
|
|
AB_ARRAYA, // array or proplist access
|
|
|
|
AB_ARRAYA_SET,
|
2010-08-14 23:53:18 +00:00
|
|
|
AB_PROP, // proplist access with static key
|
|
|
|
AB_PROP_SET,
|
2010-04-05 15:41:36 +00:00
|
|
|
AB_ARRAY_SLICE, // array slicing
|
2010-08-03 20:47:45 +00:00
|
|
|
AB_ARRAY_SLICE_SET,
|
2011-05-02 19:53:58 +00:00
|
|
|
AB_DUP, // duplicate value from stack
|
|
|
|
AB_STACK_SET, // copy top of stack to stack
|
|
|
|
AB_POP_TO, // pop top of stack to stack
|
2010-08-14 23:53:18 +00:00
|
|
|
AB_LOCALN, // a property of this
|
2010-04-07 13:04:19 +00:00
|
|
|
AB_LOCALN_SET,
|
|
|
|
AB_GLOBALN, // a named global
|
|
|
|
AB_GLOBALN_SET,
|
|
|
|
AB_PAR, // Par statement
|
2012-06-18 02:07:36 +00:00
|
|
|
AB_THIS, // this()
|
2010-03-28 17:58:21 +00:00
|
|
|
AB_FUNC, // function
|
2009-05-08 13:28:41 +00:00
|
|
|
|
2010-04-26 20:16:45 +00:00
|
|
|
AB_PARN_CONTEXT,
|
|
|
|
AB_VARN_CONTEXT,
|
|
|
|
|
2009-05-08 13:28:41 +00:00
|
|
|
// prefix
|
2010-04-07 13:04:19 +00:00
|
|
|
AB_Inc, // ++
|
|
|
|
AB_Dec, // --
|
2010-03-28 17:58:21 +00:00
|
|
|
AB_BitNot, // ~
|
|
|
|
AB_Not, // !
|
|
|
|
AB_Neg, // -
|
2009-05-08 13:28:41 +00:00
|
|
|
|
|
|
|
// postfix
|
2010-03-28 17:58:21 +00:00
|
|
|
AB_Pow, // **
|
|
|
|
AB_Div, // /
|
|
|
|
AB_Mul, // *
|
|
|
|
AB_Mod, // %
|
|
|
|
AB_Sub, // -
|
|
|
|
AB_Sum, // +
|
|
|
|
AB_LeftShift, // <<
|
|
|
|
AB_RightShift, // >>
|
|
|
|
AB_LessThan, // <
|
|
|
|
AB_LessThanEqual, // <=
|
|
|
|
AB_GreaterThan, // >
|
|
|
|
AB_GreaterThanEqual, // >=
|
2012-06-10 22:47:28 +00:00
|
|
|
AB_Identical, // ===
|
|
|
|
AB_NotIdentical, // !==
|
2010-03-28 17:58:21 +00:00
|
|
|
AB_Equal, // ==
|
|
|
|
AB_NotEqual, // !=
|
|
|
|
AB_BitAnd, // &
|
|
|
|
AB_BitXOr, // ^
|
|
|
|
AB_BitOr, // |
|
|
|
|
|
|
|
|
AB_CALL, // direct object call
|
|
|
|
AB_CALLFS, // failsafe direct call
|
|
|
|
AB_STACK, // push nulls / pop
|
|
|
|
AB_INT, // constant: int
|
|
|
|
AB_BOOL, // constant: bool
|
|
|
|
AB_STRING, // constant: string
|
2010-09-09 00:18:19 +00:00
|
|
|
AB_CPROPLIST, // constant: proplist
|
|
|
|
AB_CARRAY, // constant: array
|
2011-09-24 23:20:18 +00:00
|
|
|
AB_CFUNCTION, // constant: function
|
2010-03-28 17:58:21 +00:00
|
|
|
AB_NIL, // constant: nil
|
2011-04-09 19:35:16 +00:00
|
|
|
AB_NEW_ARRAY, // semi-constant: array
|
|
|
|
AB_NEW_PROPLIST, // create a new proplist
|
2010-03-28 17:58:21 +00:00
|
|
|
AB_JUMP, // jump
|
2012-04-15 13:44:01 +00:00
|
|
|
AB_JUMPAND, // jump if convertible to false, else pop the stack
|
|
|
|
AB_JUMPOR, // jump if convertible to true, else pop the stack
|
|
|
|
AB_JUMPNNIL, // jump if not nil, else pop the stack
|
2010-03-28 17:58:21 +00:00
|
|
|
AB_CONDN, // conditional jump (negated, pops stack)
|
|
|
|
AB_COND, // conditional jump (pops stack)
|
2009-05-08 13:28:41 +00:00
|
|
|
AB_FOREACH_NEXT, // foreach: next element
|
2010-03-28 17:58:21 +00:00
|
|
|
AB_RETURN, // return statement
|
|
|
|
AB_ERR, // parse error at this position
|
|
|
|
AB_DEBUG, // debug break
|
|
|
|
AB_EOFN, // end of function
|
|
|
|
};
|
2009-05-08 13:28:41 +00:00
|
|
|
|
|
|
|
// byte code chunk
|
|
|
|
struct C4AulBCC
|
2010-03-28 17:58:21 +00:00
|
|
|
{
|
|
|
|
C4AulBCCType bccType; // chunk type
|
2009-05-09 13:17:24 +00:00
|
|
|
union
|
2010-03-28 17:58:21 +00:00
|
|
|
{
|
2009-05-09 13:17:24 +00:00
|
|
|
int32_t i;
|
|
|
|
C4String * s;
|
2010-09-09 00:18:19 +00:00
|
|
|
C4PropList * p;
|
|
|
|
C4ValueArray * a;
|
2009-05-09 13:17:24 +00:00
|
|
|
C4AulFunc * f;
|
|
|
|
intptr_t X;
|
2010-10-25 21:48:08 +00:00
|
|
|
} Par; // extra info
|
2010-03-28 17:58:21 +00:00
|
|
|
};
|
2009-05-08 13:28:41 +00:00
|
|
|
|
|
|
|
// execution context
|
2012-06-03 22:03:49 +00:00
|
|
|
struct C4AulScriptContext
|
2010-03-28 17:58:21 +00:00
|
|
|
{
|
2012-06-03 22:03:49 +00:00
|
|
|
C4PropList *Obj;
|
2009-05-08 13:28:41 +00:00
|
|
|
C4Value *Return;
|
|
|
|
C4Value *Pars;
|
|
|
|
C4Value *Vars;
|
|
|
|
C4AulScriptFunc *Func;
|
|
|
|
C4AulBCC *CPos;
|
|
|
|
time_t tTime; // initialized only by profiler if active
|
|
|
|
|
|
|
|
void dump(StdStrBuf Dump = StdStrBuf(""));
|
2010-01-13 17:07:58 +00:00
|
|
|
StdStrBuf ReturnDump(StdStrBuf Dump = StdStrBuf(""));
|
2010-03-28 17:58:21 +00:00
|
|
|
};
|
2009-05-08 13:28:41 +00:00
|
|
|
|
|
|
|
// script function class
|
|
|
|
class C4AulScriptFunc : public C4AulFunc
|
2010-03-28 17:58:21 +00:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
C4AulFunc *OwnerOverloaded; // overloaded owner function; if present
|
2012-05-27 22:31:55 +00:00
|
|
|
void SetOverloaded(C4AulFunc *);
|
2010-03-28 17:58:21 +00:00
|
|
|
C4AulScriptFunc *SFunc() { return this; } // type check func...
|
|
|
|
protected:
|
2012-10-21 16:14:32 +00:00
|
|
|
void AddBCC(C4AulBCCType eType, intptr_t = 0, const char * SPos = 0); // add byte code chunk and advance
|
|
|
|
void RemoveLastBCC();
|
|
|
|
void ClearCode();
|
|
|
|
int GetCodePos() const { return Code.size(); }
|
|
|
|
C4AulBCC *GetCodeByPos(int iPos) { return &Code[iPos]; }
|
|
|
|
C4AulBCC *GetLastCode() { return Code.empty() ? NULL : &Code.back(); }
|
|
|
|
std::vector<C4AulBCC> Code;
|
|
|
|
std::vector<const char *> PosForCode;
|
2013-11-02 12:38:26 +00:00
|
|
|
int ParCount;
|
|
|
|
C4V_Type ParType[C4AUL_MAX_Par]; // parameter types
|
2010-03-28 17:58:21 +00:00
|
|
|
|
|
|
|
public:
|
|
|
|
const char *Script; // script pos
|
|
|
|
C4ValueMapNames VarNamed; // list of named vars in this function
|
|
|
|
C4ValueMapNames ParNamed; // list of named pars in this function
|
2013-11-02 12:38:26 +00:00
|
|
|
void AddPar(const char * Idtf)
|
|
|
|
{
|
|
|
|
assert(ParCount < C4AUL_MAX_Par);
|
|
|
|
assert(ParCount == ParNamed.iSize);
|
|
|
|
ParNamed.AddName(Idtf);
|
|
|
|
++ParCount;
|
|
|
|
}
|
2011-10-13 16:01:02 +00:00
|
|
|
C4ScriptHost *pOrgScript; // the orginal script (!= Owner if included or appended)
|
2010-03-28 17:58:21 +00:00
|
|
|
|
2012-02-01 02:49:50 +00:00
|
|
|
C4AulScriptFunc(C4AulScript *pOwner, C4ScriptHost *pOrgScript, const char *pName, const char *Script);
|
|
|
|
C4AulScriptFunc(C4AulScript *pOwner, const C4AulScriptFunc &FromFunc); // copy script/code, etc from given func
|
2012-05-27 22:31:55 +00:00
|
|
|
~C4AulScriptFunc();
|
2009-05-08 13:28:41 +00:00
|
|
|
|
2012-01-26 23:42:41 +00:00
|
|
|
void ParseFn(C4AulScriptContext* context = NULL);
|
2009-05-08 13:28:41 +00:00
|
|
|
|
2013-11-02 12:38:26 +00:00
|
|
|
virtual bool GetPublic() const { return true; }
|
|
|
|
virtual int GetParCount() const { return ParCount; }
|
|
|
|
virtual const C4V_Type *GetParType() const { return ParType; }
|
|
|
|
virtual C4V_Type GetRetType() const { return C4V_Any; }
|
2012-05-27 21:35:23 +00:00
|
|
|
virtual C4Value Exec(C4PropList * p, C4Value pPars[], bool fPassErrors=false); // execute func
|
2009-05-08 13:28:41 +00:00
|
|
|
|
2010-12-22 01:10:58 +00:00
|
|
|
int GetLineOfCode(C4AulBCC * bcc);
|
|
|
|
C4AulBCC * GetCode();
|
2009-05-08 13:28:41 +00:00
|
|
|
|
2010-03-28 17:58:21 +00:00
|
|
|
time_t tProfileTime; // internally set by profiler
|
2009-05-08 13:28:41 +00:00
|
|
|
|
2012-04-12 19:03:14 +00:00
|
|
|
friend class C4AulParse;
|
2012-02-02 00:16:14 +00:00
|
|
|
friend class C4ScriptHost;
|
2010-03-28 17:58:21 +00:00
|
|
|
};
|
2009-05-08 13:28:41 +00:00
|
|
|
|
2010-03-28 17:58:21 +00:00
|
|
|
class C4AulFuncMap
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
C4AulFuncMap();
|
|
|
|
~C4AulFuncMap();
|
2012-05-27 22:53:41 +00:00
|
|
|
C4AulFunc * GetFirstFunc(C4String * Name);
|
2010-03-28 17:58:21 +00:00
|
|
|
C4AulFunc * GetNextSNFunc(const C4AulFunc * After);
|
|
|
|
private:
|
2012-05-27 22:53:41 +00:00
|
|
|
enum { HashSize = 1025 };
|
|
|
|
C4AulFunc * Funcs[HashSize];
|
2010-03-28 17:58:21 +00:00
|
|
|
int FuncCnt;
|
|
|
|
static unsigned int Hash(const char * Name);
|
|
|
|
protected:
|
2012-05-27 22:53:41 +00:00
|
|
|
void Add(C4AulFunc * func);
|
2010-03-28 17:58:21 +00:00
|
|
|
void Remove(C4AulFunc * func);
|
2009-05-08 13:28:41 +00:00
|
|
|
friend class C4AulFunc;
|
2012-01-26 23:20:55 +00:00
|
|
|
friend class C4ScriptHost;
|
2009-05-08 13:28:41 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
// aul script state
|
|
|
|
enum C4AulScriptState
|
2010-03-28 17:58:21 +00:00
|
|
|
{
|
|
|
|
ASS_ERROR, // erroneous script
|
|
|
|
ASS_NONE, // nothing
|
|
|
|
ASS_PREPARSED, // function list built; CodeSize set
|
|
|
|
ASS_LINKED, // includes and appends resolved
|
|
|
|
ASS_PARSED // byte code generated
|
|
|
|
};
|
2009-05-08 13:28:41 +00:00
|
|
|
|
|
|
|
|
|
|
|
// script profiler entry
|
|
|
|
class C4AulProfiler
|
2010-03-28 17:58:21 +00:00
|
|
|
{
|
|
|
|
private:
|
|
|
|
// map entry
|
|
|
|
struct Entry
|
2009-05-08 13:28:41 +00:00
|
|
|
{
|
2010-03-28 17:58:21 +00:00
|
|
|
C4AulScriptFunc *pFunc;
|
|
|
|
time_t tProfileTime;
|
|
|
|
|
|
|
|
bool operator < (const Entry &e2) const { return tProfileTime < e2.tProfileTime ; }
|
2009-05-08 13:28:41 +00:00
|
|
|
};
|
|
|
|
|
2010-03-28 17:58:21 +00:00
|
|
|
// items
|
|
|
|
std::vector<Entry> Times;
|
|
|
|
|
|
|
|
public:
|
|
|
|
void CollectEntry(C4AulScriptFunc *pFunc, time_t tProfileTime);
|
|
|
|
void Show();
|
|
|
|
|
|
|
|
static void Abort();
|
|
|
|
static void StartProfiling(C4AulScript *pScript);
|
|
|
|
static void StopProfiling();
|
|
|
|
};
|
|
|
|
|
2009-05-08 13:28:41 +00:00
|
|
|
|
|
|
|
// script class
|
|
|
|
class C4AulScript
|
2010-03-28 17:58:21 +00:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
C4AulScript(); // constructor
|
|
|
|
virtual ~C4AulScript(); // destructor
|
2011-10-24 15:02:27 +00:00
|
|
|
virtual void Clear(); // remove script, byte code and children
|
2012-06-07 19:07:31 +00:00
|
|
|
void Reg2List(C4AulScriptEngine *pEngine); // reg to linked list
|
|
|
|
void Unreg(); // remove from list
|
2010-03-28 17:58:21 +00:00
|
|
|
virtual bool Delete() { return true; } // allow deletion on pure class
|
|
|
|
|
|
|
|
StdCopyStrBuf ScriptName; // script name
|
|
|
|
|
2012-08-08 23:17:26 +00:00
|
|
|
virtual C4PropListStatic * GetPropList() { return 0; }
|
2011-10-13 16:01:02 +00:00
|
|
|
virtual C4ScriptHost * GetScriptHost() { return 0; }
|
2010-03-28 17:58:21 +00:00
|
|
|
|
2011-09-29 01:49:21 +00:00
|
|
|
C4Value DirectExec(C4Object *pObj, const char *szScript, const char *szContext, bool fPassErrors = false, C4AulScriptContext* context = NULL); // directly parse uncompiled script (WARG! CYCLES!)
|
2012-05-15 17:32:58 +00:00
|
|
|
virtual void ResetProfilerTimes(); // zero all profiler times of owned functions
|
|
|
|
virtual void CollectProfilerTimes(class C4AulProfiler &rProfiler);
|
2010-03-28 17:58:21 +00:00
|
|
|
|
|
|
|
bool IsReady() { return State == ASS_PARSED; } // whether script calls may be done
|
|
|
|
|
|
|
|
// helper functions
|
2012-05-25 22:22:22 +00:00
|
|
|
void Warn(const char *pMsg, ...) GNUC_FORMAT_ATTRIBUTE_O;
|
2010-03-28 17:58:21 +00:00
|
|
|
|
|
|
|
friend class C4AulParseError;
|
|
|
|
friend class C4AulFunc;
|
|
|
|
friend class C4AulScriptFunc;
|
|
|
|
friend class C4AulScriptEngine;
|
2012-04-12 19:03:14 +00:00
|
|
|
friend class C4AulParse;
|
2011-10-13 16:01:02 +00:00
|
|
|
friend class C4AulDebug;
|
|
|
|
friend class C4ScriptHost;
|
2010-03-28 17:58:21 +00:00
|
|
|
|
|
|
|
// Translate a string using the script's lang table
|
|
|
|
std::string Translate(const std::string &text) const;
|
|
|
|
|
|
|
|
protected:
|
2010-10-25 21:48:08 +00:00
|
|
|
C4LangStringTable *stringTable;
|
|
|
|
|
|
|
|
C4AulScriptEngine *Engine; //owning engine
|
2012-06-07 19:07:31 +00:00
|
|
|
C4AulScript *Prev, *Next; // tree structure
|
2010-10-25 21:48:08 +00:00
|
|
|
|
|
|
|
C4AulScriptState State; // script state
|
|
|
|
|
2011-02-06 20:37:19 +00:00
|
|
|
virtual bool ReloadScript(const char *szPath, const char *szLanguage); // reload given script
|
2011-10-13 16:01:02 +00:00
|
|
|
virtual bool Parse();
|
2012-06-07 19:07:31 +00:00
|
|
|
virtual bool ResolveIncludes(C4DefList *rDefs);
|
|
|
|
virtual bool ResolveAppends(C4DefList *rDefs);
|
|
|
|
virtual void UnLink();
|
2010-03-28 17:58:21 +00:00
|
|
|
};
|
2009-05-08 13:28:41 +00:00
|
|
|
|
|
|
|
// holds all C4AulScripts
|
|
|
|
class C4AulScriptEngine : public C4AulScript
|
2010-03-28 17:58:21 +00:00
|
|
|
{
|
|
|
|
protected:
|
|
|
|
C4AulFuncMap FuncLookUp;
|
2012-07-25 23:27:52 +00:00
|
|
|
C4Value GlobalPropList;
|
2012-06-07 19:07:31 +00:00
|
|
|
C4AulScript *Child0, *ChildL; // tree structure
|
2009-05-08 13:28:41 +00:00
|
|
|
|
2010-03-28 17:58:21 +00:00
|
|
|
public:
|
|
|
|
int warnCnt, errCnt; // number of warnings/errors
|
|
|
|
int lineCnt; // line count parsed
|
|
|
|
|
|
|
|
C4ValueMapNames GlobalNamedNames;
|
|
|
|
C4ValueMapData GlobalNamed;
|
|
|
|
|
|
|
|
// global constants (such as "static const C4D_Structure = 2;")
|
|
|
|
// cannot share var lists, because it's so closely tied to the data lists
|
|
|
|
// constants are used by the Parser only, anyway, so it's not
|
|
|
|
// necessary to pollute the global var list here
|
|
|
|
C4ValueMapNames GlobalConstNames;
|
|
|
|
C4ValueMapData GlobalConsts;
|
|
|
|
|
|
|
|
C4AulScriptEngine(); // constructor
|
|
|
|
~C4AulScriptEngine(); // destructor
|
|
|
|
void Clear(); // clear data
|
|
|
|
void Link(C4DefList *rDefs); // link and parse all scripts
|
|
|
|
void ReLink(C4DefList *rDefs); // unlink + relink and parse all scripts
|
2012-08-08 23:17:26 +00:00
|
|
|
virtual C4PropListStatic * GetPropList();
|
2010-03-28 17:58:21 +00:00
|
|
|
using C4AulScript::ReloadScript;
|
2011-02-06 20:37:19 +00:00
|
|
|
bool ReloadScript(const char *szScript, C4DefList *pDefs, const char *szLanguage); // search script and reload + relink, if found
|
2012-05-27 22:53:41 +00:00
|
|
|
C4AulFunc * GetFirstFunc(C4String * Name)
|
2010-03-28 17:58:21 +00:00
|
|
|
{ return FuncLookUp.GetFirstFunc(Name); }
|
|
|
|
C4AulFunc * GetNextSNFunc(const C4AulFunc * After)
|
|
|
|
{ return FuncLookUp.GetNextSNFunc(After); }
|
|
|
|
|
|
|
|
// For the list of functions in the PropertyDlg
|
2012-05-18 15:49:38 +00:00
|
|
|
std::list<const char*> GetFunctionNames(C4PropList *);
|
2012-01-25 03:15:39 +00:00
|
|
|
void ResetProfilerTimes(); // zero all profiler times of owned functions
|
|
|
|
void CollectProfilerTimes(class C4AulProfiler &rProfiler);
|
2010-03-28 17:58:21 +00:00
|
|
|
|
|
|
|
void RegisterGlobalConstant(const char *szName, const C4Value &rValue); // creates a new constants or overwrites an old one
|
|
|
|
bool GetGlobalConstant(const char *szName, C4Value *pTargetValue); // check if a constant exists; assign value to pTargetValue if not NULL
|
|
|
|
|
2011-03-26 22:59:35 +00:00
|
|
|
bool Denumerate(C4ValueNumbers *);
|
2010-03-28 17:58:21 +00:00
|
|
|
void UnLink(); // called when a script is being reloaded (clears string table)
|
|
|
|
|
|
|
|
// Compile scenario script data (without strings and constants)
|
2011-03-26 22:59:35 +00:00
|
|
|
void CompileFunc(StdCompiler *pComp, C4ValueNumbers * numbers);
|
2009-05-08 13:28:41 +00:00
|
|
|
|
2010-03-28 17:58:21 +00:00
|
|
|
friend class C4AulFunc;
|
2012-01-26 23:20:55 +00:00
|
|
|
friend class C4ScriptHost;
|
2012-04-12 19:03:14 +00:00
|
|
|
friend class C4AulParse;
|
2010-03-28 17:58:21 +00:00
|
|
|
friend class C4AulDebug;
|
2012-01-25 03:15:39 +00:00
|
|
|
friend class C4AulScript;
|
2010-03-28 17:58:21 +00:00
|
|
|
};
|
2009-05-08 13:28:41 +00:00
|
|
|
|
2009-06-05 15:21:11 +00:00
|
|
|
extern C4AulScriptEngine ScriptEngine;
|
2009-05-08 13:28:41 +00:00
|
|
|
#endif
|