29 #include "../../idlib/precompiled.h"
32 #include "../Game_local.h"
206 if (
this == basetype ) {
210 if ( superType == basetype ) {
228 if (
this == &matchtype ) {
259 if (
this == &matchfunc ) {
295 throw idCompileError(
"idTypeDef::AddFunctionParm : tried to add parameter on non-function type" );
312 throw idCompileError(
"idTypeDef::AddField : tried to add field to non-object type" );
371 throw idCompileError(
"idTypeDef::SuperClass : tried to get superclass of a non-object type" );
386 throw idCompileError(
"idTypeDef::ReturnType: tried to get return type on non-function type" );
401 throw idCompileError(
"idTypeDef::SetReturnType: tried to set return type on non-function type" );
416 throw idCompileError(
"idTypeDef::FieldType: tried to get field type on non-field type" );
431 throw idCompileError(
"idTypeDef::SetFieldType: tried to set return type on non-function type" );
446 throw idCompileError(
"idTypeDef::PointerType: tried to get pointer type on non-pointer" );
461 throw idCompileError(
"idTypeDef::SetPointerType: tried to set type on non-pointer" );
482 assert( parmNumber >= 0 );
493 assert( parmNumber >= 0 );
529 assert( funcNumber >= 0 );
582 name->RemoveDef(
this );
618 for( def = otherScope; def !=
NULL; def = def->
scope ) {
619 if ( def ==
scope ) {
637 value.functionPtr = func;
649 *
value.objectPtrPtr = object;
752 jumpto = instructionPointer +
value.jumpOffset;
758 if (
value.functionPtr->eventdef ) {
779 len = strlen(
value.stringPtr );
780 ch =
value.stringPtr;
781 for( i = 0; i <
len; i++, ch++ ) {
783 file->
Printf(
"%c", *ch );
784 }
else if ( *ch ==
'\n' ) {
787 file->
Printf(
"\\x%.2x", static_cast<int>( *ch ) );
794 file->
Printf(
"'%s'",
value.vectorPtr->ToString() );
802 file->
Printf(
"vtable[ %d ]",
value.virtualFunction );
846 if ( d->next == def ) {
926 if ( typeName.
Length() == 0 ) {
931 savefile->
Error(
"idScriptObject::Restore: failed to restore object of type '%s'.", typeName.
c_str() );
934 savefile->
ReadInt( (
int &)size );
935 if ( size !=
type->Size() ) {
936 savefile->
Error(
"idScriptObject::Restore: size of object '%s' doesn't match size in save game.", typeName.
c_str() );
957 if ( newtype !=
type ) {
960 gameLocal.
Warning(
"idScriptObject::SetType: Unknown type '%s'", typeName );
965 gameLocal.
Warning(
"idScriptObject::SetType: Can't create object of type '%s'. Must be an object type.", newtype->
Name() );
996 memset(
data, 0, size );
1024 return type->Name();
1095 return &
data[ pos ];
1138 newtype =
new idTypeDef( etype, edef, ename, esize, aux );
1156 for( i =
types.
Num() - 1; i >= 0; i-- ) {
1181 for( i =
types.
Num() - 1; i >= 0; i-- ) {
1270 def_x =
AllocDef( type, element, scope, constant );
1273 def_y =
AllocDef( type, element, scope, constant );
1274 def_y->value.ptrOffset = def_x->value.ptrOffset +
type_float.Size();
1277 def_z =
AllocDef( type, element, scope, constant );
1278 def_z->value.ptrOffset = def_y->value.ptrOffset +
type_float.Size();
1292 def->
value = def_x->value;
1354 }
else if ( def->
scope != scope ) {
1361 if ( !bestDef || ( depth < bestDepth ) ) {
1368 if ( bestDef && type && ( bestDef->
TypeDef() !=
type ) ) {
1369 throw idCompileError(
va(
"Type mismatch on redeclaration of %s", name ) );
1423 if ( def == a || def == b ) {
1429 if ( def->
scope != scope ) {
1438 return AllocDef( type, name, scope,
false );
1464 pos = fullname.
Find(
"::",
true, start );
1469 idStr namespaceName = fullname.
Mid( start, pos - start );
1470 def =
GetDef(
NULL, namespaceName, namespaceDef );
1482 def =
GetDef(
NULL, funcName, namespaceDef );
1557 idStr defName(
"$" );
1600 statement->
file = 0;
1602 statement->
a =
NULL;
1603 statement->
b =
NULL;
1604 statement->
c =
NULL;
1633 statement = &
statements[ instructionPointer ];
1637 if ( statement->
a ) {
1639 statement->
a->
PrintInfo( file, instructionPointer );
1642 if ( statement->
b ) {
1644 statement->
b->
PrintInfo( file, instructionPointer );
1647 if ( statement->
c ) {
1649 statement->
c->
PrintInfo( file, instructionPointer );
1662 int instructionPointer;
1677 for( instructionPointer = 0; instructionPointer < func->
numStatements; instructionPointer++ ) {
1739 memused += stringspace;
1741 for( i = 0; i <
types.
Num(); i++ ) {
1750 memallocated = funcMem + memused +
sizeof(
idProgram );
1820 result =
CompileText( functionName, text,
false );
1918 if ( defaultScript && *defaultScript ) {
1969 for ( i = 0; i <
num; i++ ) {
1975 while( index >= 0 ) {
1985 int saved_checksum, checksum;
1987 savefile->
ReadInt( saved_checksum );
1990 if ( saved_checksum != checksum ) {
2010 unsigned short linenumber;
2011 unsigned short file;
2014 statementBlock_t *statementList =
new statementBlock_t[
statements.Num() ];
2016 memset( statementList, 0, (
sizeof(statementBlock_t) *
statements.Num() ) );
2025 statementList[
i].a = -1;
2030 statementList[
i].b = -1;
2035 statementList[
i].c = -1;
2038 statementList[
i].linenumber =
statements[
i].linenumber;
2044 delete [] statementList;
2104 if ( !strippedName.
Length() ) {
void SetName(const char *newname)
GLsizei const GLfloat * value
byte * GetVariable(const char *name, etype_t etype) const
bool CompileText(const char *source, const char *text, bool console)
idVarDef * GetDefList(const char *name) const
void WriteString(const char *string)
idCVar g_disasm("g_disasm","0", CVAR_GAME|CVAR_BOOL,"disassemble script into base/script/disasm.txt on the local drive when script is compiled")
assert(prefInfo.fullscreenBtn)
idVarDef def_string & type_string
int Cmp(const char *text) const
static opcode_t opcodes[]
size_t Allocated(void) const
int Next(const int index) const
idTypeDef * GetTypeDef(void) const
int DepthOfScope(const idVarDef *otherScope) const
void Printf(const char *fmt,...) const id_attribute((format(printf
statement_t * AllocStatement(void)
bool SetType(const char *typeName)
void Save(idSaveGame *savefile) const
const char * GetTypeName(void) const
statement_t & GetStatement(int index)
idVarDef * GetDef(const idTypeDef *type, const char *name, const idVarDef *scope) const
void SetNum(int newnum, bool resize=true)
idList< idVarDefName * > varDefNames
virtual int ReadFile(const char *relativePath, void **buffer, ID_TIME_T *timestamp=NULL)=0
void operator=(const idTypeDef &other)
void void void void void Error(const char *fmt,...) const id_attribute((format(printf
void Disassemble(void) const
idTypeDef(const idTypeDef &other)
bool HasObject(void) const
void Write(const void *buffer, int len)
const idEventDef * eventdef
idVarDef def_object & type_object
idFileSystem * fileSystem
void SetGranularity(int newgranularity)
idVarDef def_field & type_field
int GetFilenum(const char *name)
void SetPointerType(idTypeDef *type)
GLint GLint GLsizei GLsizei GLsizei depth
idVarDef def_namespace & type_namespace
void PrintInfo(idFile *file, int instructionPointer) const
void CompileFile(const char *filename)
GLuint GLuint GLsizei GLenum type
void AddDef(idVarDef *def)
idVarDef def_scriptevent & type_scriptevent
int NumParameters(void) const
virtual void FreeFile(void *buffer)=0
const char * Name(void) const
const char * Name(void) const
void RemoveDef(idVarDef *def)
void FinishCompilation(void)
int First(const int key) const
idVarDef def_void & type_void
const char * GlobalName(void) const
void FreeDef(idVarDef *d, const idVarDef *scope)
size_t Allocated(void) const
const function_t * GetFunction(int funcNumber) const
idStaticList< function_t, MAX_FUNCS > functions
idVarDef def_vector & type_vector
idList< idVarDef * > varDefs
void void void Warning(const char *fmt,...) const id_attribute((format(printf
GLsizei GLsizei GLcharARB * source
idHashIndex varDefNameHash
void SetString(const char *string, bool constant)
const char * GetFilename(int num)
const char * GetParmName(int parmNumber) const
idTypeDef * TypeDef(void) const
void SetReturnType(idTypeDef *type)
idVarDef def_virtualfunction
void void Read(void *buffer, int len)
int GetFunctionNumber(const function_t *func) const
const function_t * CompileFunction(const char *functionName, const char *text)
idVarDef def_float & type_float
const char * Name(void) const
idVarDef def_boolean & type_boolean
bool MatchesType(const idTypeDef &matchtype) const
idVarDef * AllocDef(idTypeDef *type, const char *name, idVarDef *scope, bool constant)
idTypeDef * ReturnType(void) const
void void DPrintf(const char *fmt,...) const id_attribute((format(printf
void AddFunction(const function_t *func)
virtual idFile * OpenFileByMode(const char *relativePath, fsMode_t mode)=0
idList< idTypeDef * > parmTypes
GLsizei GLsizei GLenum GLenum const GLvoid * data
size_t MemoryUsed(void) const
void SetEntity(const char *name, idEntity *ent)
static void Copynz(char *dest, const char *src, int destsize)
initialized_t initialized
idVarDef def_entity & type_entity
int NumFunctions(void) const
size_t Allocated(void) const
bool MatchesVirtualFunction(const idTypeDef &matchfunc) const
void DeleteContents(bool clear)
unsigned long MD4_BlockChecksum(const void *data, int length)
void AddField(idTypeDef *fieldtype, const char *name)
const char * Right(int len, idStr &result) const
void AddDefToNameList(idVarDef *def, const char *name)
idVarDef def_virtualfunction & type_virtualfunction
int Find(const char c, int start=0, int end=-1) const
const function_t * GetConstructor(void) const
idTypeDef * GetParmType(int parmNumber) const
GLubyte GLubyte GLubyte a
void Error(const char *fmt,...) id_attribute((format(printf
idTypeDef * SuperClass(void) const
idVarDef def_pointer & type_pointer
byte variables[MAX_GLOBALS]
void ReturnEntity(idEntity *ent)
void SetFieldType(idTypeDef *type)
bool Inherits(const idTypeDef *basetype) const
void WriteInt(const int value)
idStaticList< statement_t, MAX_STATEMENTS > statements
virtual const char * RelativePathToOSPath(const char *relativePath, const char *basePath="fs_devpath")=0
int GenerateKey(const char *string, bool caseSensitive=true) const
idTypeDef * AllocType(idTypeDef &type)
idTypeDef * GetType(idTypeDef &type, bool allocate)
void CompileFile(const char *text, const char *filename, bool console)
void SetName(const char *name)
idVarDef * FindFreeResultDef(idTypeDef *type, const char *name, idVarDef *scope, const idVarDef *a, const idVarDef *b)
idList< const function_t * > functions
int Append(const type &obj)
const char * Mid(int start, int len, idStr &result) const
static WindowRef ValidModeCallbackProc inCallback OSStatus err
idVarDef def_function & type_function
unsigned short linenumber
idTypeDef * FindType(const char *name)
void SetValue(const eval_t &value, bool constant)
int AddUnique(const type &obj)
static void Restart(void)
char error[MAX_STRING_CHARS]
bool RemoveIndex(int index)
void DisassembleStatement(idFile *file, int instructionPointer) const
const function_t * GetFunction(const char *name) const
const function_t * GetDestructor(void) const
void AddFunctionParm(idTypeDef *parmtype, const char *name)
idVarDef * Next(void) const
void WriteByte(const byte value)
idVarDef def_argsize & type_argsize
const char * c_str(void) const
idVarDef * returnStringDef
void Startup(const char *defaultScript)
idVarDef def_jumpoffset & type_jumpoffset
idList< idTypeDef * > types
function_t * FindFunction(const char *name) const
idTypeDef * PointerType(void) const
void Add(const int key, const int index)
size_t Allocated(void) const
void * Mem_Alloc(const int size)
int CalculateChecksum(void) const
char * va(const char *fmt,...)
function_t & AllocFunction(idVarDef *def)
virtual void CloseFile(idFile *f)=0
const char *const RESULT_STRING
virtual const char * OSPathToRelativePath(const char *OSPath)=0
idVarDef(idTypeDef *typeptr=NULL)
void BeginCompilation(void)
void Restore(idRestoreGame *savefile)
void Save(idSaveGame *savefile) const
bool Restore(idRestoreGame *savefile)
void ReadString(idStr &string)
int sprintf(idStr &string, const char *fmt,...)
void SetFunction(function_t *func)
virtual int Printf(const char *fmt,...) id_attribute((format(printf
idStaticList< byte, MAX_GLOBALS > variableDefaults
void ReadByte(byte &value)
void SetObject(idScriptObject *object)
idTypeDef * FieldType(void) const
static bool CharIsPrintable(int c)