Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Add some missing patches to the script compiler

  • Loading branch information...
commit 6dac9532861bb7f9cf5ee403f4260c0ca8216ee3 1 parent 52e0b3a
@phire phire authored Miguel Boton committed
View
13 neo/game/script/Script_Compiler.cpp
@@ -38,7 +38,7 @@ If you have questions concerning this license or the applicable additional terms
#define TOP_PRIORITY 7
bool idCompiler::punctuationValid[ 256 ];
-char *idCompiler::punctuation[] = {
+const char *idCompiler::punctuation[] = {
"+=", "-=", "*=", "/=", "%=", "&=", "|=", "++", "--",
"&&", "||", "<=", ">=", "==", "!=", "::", ";", ",",
"~", "!", "*", "/", "%", "(", ")", "-", "+",
@@ -207,7 +207,7 @@ idCompiler::idCompiler()
================
*/
idCompiler::idCompiler() {
- char **ptr;
+ const char **ptr;
int id;
// make sure we have the right # of opcodes in the table
@@ -960,8 +960,8 @@ idVarDef *idCompiler::EmitFunctionParms( int op, idVarDef *func, int startarg, i
Error( "type mismatch on parm %i of call to '%s'", arg + 1, func->Name() );
}
- if ( funcArg->Type() == ev_object ) {
- size += type_object.Size();
+ if ( funcArg->Type() == ev_object or funcArg->Type() == ev_entity) {
+ size += sizeof(int);
} else {
size += funcArg->Size();
}
@@ -2010,7 +2010,6 @@ void idCompiler::ParseObjectDef( const char *objname ) {
const char *fieldname;
idTypeDef newtype( ev_field, NULL, "", 0, NULL );
idVarDef *oldscope;
- int num;
int i;
oldscope = scope;
@@ -2038,7 +2037,6 @@ void idCompiler::ParseObjectDef( const char *objname ) {
scope = objtype->def;
// inherit all the functions
- num = parentType->NumFunctions();
for( i = 0; i < parentType->NumFunctions(); i++ ) {
const function_t *func = parentType->GetFunction( i );
objtype->AddFunction( func );
@@ -2115,7 +2113,6 @@ idCompiler::ParseFunctionDef
void idCompiler::ParseFunctionDef( idTypeDef *returnType, const char *name ) {
idTypeDef *type;
idVarDef *def;
- const idVarDef *parm;
idVarDef *oldscope;
int i;
int numParms;
@@ -2171,7 +2168,7 @@ void idCompiler::ParseFunctionDef( idTypeDef *returnType, const char *name ) {
if ( gameLocal.program.GetDef( type->GetParmType( i ), type->GetParmName( i ), def ) ) {
Error( "'%s' defined more than once in function parameters", type->GetParmName( i ) );
}
- parm = gameLocal.program.AllocDef( type->GetParmType( i ), type->GetParmName( i ), def, false );
+ gameLocal.program.AllocDef( type->GetParmType( i ), type->GetParmName( i ), def, false );
}
oldscope = scope;
View
8 neo/game/script/Script_Compiler.h
@@ -31,9 +31,9 @@ If you have questions concerning this license or the applicable additional terms
const char * const RESULT_STRING = "<RESULT>";
typedef struct opcode_s {
- char *name;
- char *opname;
- int priority;
+ const char *name;
+ const char *opname;
+ int priority;
bool rightAssociative;
idVarDef *type_a;
idVarDef *type_b;
@@ -197,7 +197,7 @@ enum {
class idCompiler {
private:
static bool punctuationValid[ 256 ];
- static char *punctuation[];
+ static const char *punctuation[];
idParser parser;
idParser *parserPtr;
View
6 neo/game/script/Script_Program.cpp
@@ -918,7 +918,7 @@ idScriptObject::Restore
*/
void idScriptObject::Restore( idRestoreGame *savefile ) {
idStr typeName;
- int size;
+ size_t size;
savefile->ReadString( typeName );
@@ -1323,7 +1323,7 @@ idVarDef *idProgram::AllocDef( idTypeDef *type, const char *name, idVarDef *scop
//
def->value.bytePtr = &variables[ numVariables ];
numVariables += def->TypeDef()->Size();
- if ( (unsigned int)numVariables > sizeof( variables ) ) {
+ if ( numVariables > sizeof( variables ) ) {
throw idCompileError( va( "Exceeded global memory size (%zu bytes)", sizeof( variables ) ) );
}
@@ -1722,7 +1722,6 @@ called after all files are compiled to report memory usage.
void idProgram::CompileStats( void ) {
int memused;
int memallocated;
- int numdefs;
int stringspace;
int funcMem;
int i;
@@ -1737,7 +1736,6 @@ void idProgram::CompileStats( void ) {
}
stringspace += fileList.Size();
- numdefs = varDefs.Num();
memused = varDefs.Num() * sizeof( idVarDef );
memused += types.Num() * sizeof( idTypeDef );
memused += stringspace;
View
6 neo/game/script/Script_Program.h
@@ -4,7 +4,7 @@
Doom 3 GPL Source Code
Copyright (C) 1999-2011 id Software LLC, a ZeniMax Media company.
-This file is part of the Doom 3 GPL Source Code ("Doom 3 Source Code").
+This file is part of the Doom 3 GPL Source Code ("Doom 3 Source Code").
Doom 3 Source Code is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -96,7 +96,7 @@ class idTypeDef {
private:
etype_t type;
idStr name;
- int size;
+ size_t size;
// function types are more complex
idTypeDef *auxType; // return type
@@ -442,7 +442,7 @@ class idProgram {
idStr filename;
int filenum;
- int numVariables;
+ size_t numVariables;
byte variables[ MAX_GLOBALS ];
idStaticList<byte,MAX_GLOBALS> variableDefaults;
idStaticList<function_t,MAX_FUNCS> functions;
Please sign in to comment.
Something went wrong with that request. Please try again.