Rename all member variables to follow the style guidelines (prefixed with the 'm') - class CodeBlock

This commit is contained in:
bank 2014-05-12 17:43:14 +04:00
parent 47dbce1499
commit cf3eb26e6f
6 changed files with 302 additions and 302 deletions

View file

@ -82,10 +82,10 @@ void StmtNode::addBreakLine(U32 ip)
U32 line = CodeBlock::smBreakLineCount * 2; U32 line = CodeBlock::smBreakLineCount * 2;
CodeBlock::smBreakLineCount++; CodeBlock::smBreakLineCount++;
if(getBreakCodeBlock()->lineBreakPairs) if(getBreakCodeBlock()->mLineBreakPairs)
{ {
getBreakCodeBlock()->lineBreakPairs[line] = dbgLineNumber; getBreakCodeBlock()->mLineBreakPairs[line] = dbgLineNumber;
getBreakCodeBlock()->lineBreakPairs[line+1] = ip; getBreakCodeBlock()->mLineBreakPairs[line+1] = ip;
} }
} }

View file

@ -42,21 +42,21 @@ ConsoleParser *CodeBlock::smCurrentParser = NULL;
CodeBlock::CodeBlock() CodeBlock::CodeBlock()
{ {
globalStrings = NULL; mGlobalStrings = NULL;
functionStrings = NULL; mFunctionStrings = NULL;
functionStringsMaxLen = 0; mFunctionStringsMaxLen = 0;
globalStringsMaxLen = 0; mGlobalStringsMaxLen = 0;
globalFloats = NULL; mGlobalFloats = NULL;
functionFloats = NULL; mFunctionFloats = NULL;
lineBreakPairs = NULL; mLineBreakPairs = NULL;
breakList = NULL; mBreakList = NULL;
breakListSize = 0; mBreakListSize = 0;
refCount = 0; mRefCount = 0;
code = NULL; mCode = NULL;
name = NULL; mName = NULL;
fullPath = NULL; mFullPath = NULL;
modPath = NULL; mModPath = NULL;
} }
CodeBlock::~CodeBlock() CodeBlock::~CodeBlock()
@ -64,18 +64,18 @@ CodeBlock::~CodeBlock()
// Make sure we aren't lingering in the current code block... // Make sure we aren't lingering in the current code block...
AssertFatal(smCurrentCodeBlock != this, "CodeBlock::~CodeBlock - Caught lingering in smCurrentCodeBlock!") AssertFatal(smCurrentCodeBlock != this, "CodeBlock::~CodeBlock - Caught lingering in smCurrentCodeBlock!")
if(name) if(mName)
removeFromCodeList(); removeFromCodeList();
delete[] const_cast<char*>(globalStrings); delete[] const_cast<char*>(mGlobalStrings);
delete[] const_cast<char*>(functionStrings); delete[] const_cast<char*>(mFunctionStrings);
functionStringsMaxLen = 0; mFunctionStringsMaxLen = 0;
globalStringsMaxLen = 0; mGlobalStringsMaxLen = 0;
delete[] globalFloats; delete[] mGlobalFloats;
delete[] functionFloats; delete[] mFunctionFloats;
delete[] code; delete[] mCode;
delete[] breakList; delete[] mBreakList;
} }
//------------------------------------------------------------------------- //-------------------------------------------------------------------------
@ -83,7 +83,7 @@ CodeBlock::~CodeBlock()
StringTableEntry CodeBlock::getCurrentCodeBlockName() StringTableEntry CodeBlock::getCurrentCodeBlockName()
{ {
if (CodeBlock::getCurrentBlock()) if (CodeBlock::getCurrentBlock())
return CodeBlock::getCurrentBlock()->name; return CodeBlock::getCurrentBlock()->mName;
else else
return NULL; return NULL;
} }
@ -91,7 +91,7 @@ StringTableEntry CodeBlock::getCurrentCodeBlockName()
StringTableEntry CodeBlock::getCurrentCodeBlockFullPath() StringTableEntry CodeBlock::getCurrentCodeBlockFullPath()
{ {
if (CodeBlock::getCurrentBlock()) if (CodeBlock::getCurrentBlock())
return CodeBlock::getCurrentBlock()->fullPath; return CodeBlock::getCurrentBlock()->mFullPath;
else else
return NULL; return NULL;
} }
@ -99,15 +99,15 @@ StringTableEntry CodeBlock::getCurrentCodeBlockFullPath()
StringTableEntry CodeBlock::getCurrentCodeBlockModName() StringTableEntry CodeBlock::getCurrentCodeBlockModName()
{ {
if (CodeBlock::getCurrentBlock()) if (CodeBlock::getCurrentBlock())
return CodeBlock::getCurrentBlock()->modPath; return CodeBlock::getCurrentBlock()->mModPath;
else else
return NULL; return NULL;
} }
CodeBlock *CodeBlock::find(StringTableEntry name) CodeBlock *CodeBlock::find(StringTableEntry name)
{ {
for(CodeBlock *walk = CodeBlock::getCodeBlockList(); walk; walk = walk->nextFile) for(CodeBlock *walk = CodeBlock::getCodeBlockList(); walk; walk = walk->mNextFile)
if(walk->name == name) if(walk->mName == name)
return walk; return walk;
return NULL; return NULL;
} }
@ -117,39 +117,39 @@ CodeBlock *CodeBlock::find(StringTableEntry name)
void CodeBlock::addToCodeList() void CodeBlock::addToCodeList()
{ {
// remove any code blocks with my name // remove any code blocks with my name
for(CodeBlock **walk = &smCodeBlockList; *walk;walk = &((*walk)->nextFile)) for(CodeBlock **walk = &smCodeBlockList; *walk;walk = &((*walk)->mNextFile))
{ {
if((*walk)->name == name) if((*walk)->mName == mName)
{ {
*walk = (*walk)->nextFile; *walk = (*walk)->mNextFile;
break; break;
} }
} }
nextFile = smCodeBlockList; mNextFile = smCodeBlockList;
smCodeBlockList = this; smCodeBlockList = this;
} }
void CodeBlock::clearAllBreaks() void CodeBlock::clearAllBreaks()
{ {
if(!lineBreakPairs) if(!mLineBreakPairs)
return; return;
for(U32 i = 0; i < lineBreakPairCount; i++) for(U32 i = 0; i < mLineBreakPairCount; i++)
{ {
U32 *p = lineBreakPairs + i * 2; U32 *p = mLineBreakPairs + i * 2;
code[p[1]] = p[0] & 0xFF; mCode[p[1]] = p[0] & 0xFF;
} }
} }
void CodeBlock::clearBreakpoint(U32 lineNumber) void CodeBlock::clearBreakpoint(U32 lineNumber)
{ {
if(!lineBreakPairs) if(!mLineBreakPairs)
return; return;
for(U32 i = 0; i < lineBreakPairCount; i++) for(U32 i = 0; i < mLineBreakPairCount; i++)
{ {
U32 *p = lineBreakPairs + i * 2; U32 *p = mLineBreakPairs + i * 2;
if((p[0] >> 8) == lineNumber) if((p[0] >> 8) == lineNumber)
{ {
code[p[1]] = p[0] & 0xFF; mCode[p[1]] = p[0] & 0xFF;
return; return;
} }
} }
@ -157,26 +157,26 @@ void CodeBlock::clearBreakpoint(U32 lineNumber)
void CodeBlock::setAllBreaks() void CodeBlock::setAllBreaks()
{ {
if(!lineBreakPairs) if(!mLineBreakPairs)
return; return;
for(U32 i = 0; i < lineBreakPairCount; i++) for(U32 i = 0; i < mLineBreakPairCount; i++)
{ {
U32 *p = lineBreakPairs + i * 2; U32 *p = mLineBreakPairs + i * 2;
code[p[1]] = OP_BREAK; mCode[p[1]] = OP_BREAK;
} }
} }
bool CodeBlock::setBreakpoint(U32 lineNumber) bool CodeBlock::setBreakpoint(U32 lineNumber)
{ {
if(!lineBreakPairs) if(!mLineBreakPairs)
return false; return false;
for(U32 i = 0; i < lineBreakPairCount; i++) for(U32 i = 0; i < mLineBreakPairCount; i++)
{ {
U32 *p = lineBreakPairs + i * 2; U32 *p = mLineBreakPairs + i * 2;
if((p[0] >> 8) == lineNumber) if((p[0] >> 8) == lineNumber)
{ {
code[p[1]] = OP_BREAK; mCode[p[1]] = OP_BREAK;
return true; return true;
} }
} }
@ -186,12 +186,12 @@ bool CodeBlock::setBreakpoint(U32 lineNumber)
U32 CodeBlock::findFirstBreakLine(U32 lineNumber) U32 CodeBlock::findFirstBreakLine(U32 lineNumber)
{ {
if(!lineBreakPairs) if(!mLineBreakPairs)
return 0; return 0;
for(U32 i = 0; i < lineBreakPairCount; i++) for(U32 i = 0; i < mLineBreakPairCount; i++)
{ {
U32 *p = lineBreakPairs + i * 2; U32 *p = mLineBreakPairs + i * 2;
U32 line = (p[0] >> 8); U32 line = (p[0] >> 8);
if( lineNumber <= line ) if( lineNumber <= line )
@ -210,11 +210,11 @@ struct LinePair
void CodeBlock::findBreakLine(U32 ip, U32 &line, U32 &instruction) void CodeBlock::findBreakLine(U32 ip, U32 &line, U32 &instruction)
{ {
U32 min = 0; U32 min = 0;
U32 max = lineBreakPairCount - 1; U32 max = mLineBreakPairCount - 1;
LinePair *p = (LinePair *) lineBreakPairs; LinePair *p = (LinePair *) mLineBreakPairs;
U32 found; U32 found;
if(!lineBreakPairCount || p[min].ip > ip || p[max].ip < ip) if(!mLineBreakPairCount || p[min].ip > ip || p[max].ip < ip)
{ {
line = 0; line = 0;
instruction = OP_INVALID; instruction = OP_INVALID;
@ -255,17 +255,17 @@ const char *CodeBlock::getFileLine(U32 ip)
U32 line, inst; U32 line, inst;
findBreakLine(ip, line, inst); findBreakLine(ip, line, inst);
dSprintf(nameBuffer, sizeof(nameBuffer), "%s (%d)", name ? name : "<input>", line); dSprintf(nameBuffer, sizeof(nameBuffer), "%s (%d)", mName ? mName : "<input>", line);
return nameBuffer; return nameBuffer;
} }
void CodeBlock::removeFromCodeList() void CodeBlock::removeFromCodeList()
{ {
for(CodeBlock **walk = &smCodeBlockList; *walk; walk = &((*walk)->nextFile)) for(CodeBlock **walk = &smCodeBlockList; *walk; walk = &((*walk)->mNextFile))
{ {
if(*walk == this) if(*walk == this)
{ {
*walk = nextFile; *walk = mNextFile;
// clear out all breakpoints // clear out all breakpoints
clearAllBreaks(); clearAllBreaks();
@ -286,9 +286,9 @@ void CodeBlock::calcBreakList()
S32 line = -1; S32 line = -1;
U32 seqCount = 0; U32 seqCount = 0;
U32 i; U32 i;
for(i = 0; i < lineBreakPairCount; i++) for(i = 0; i < mLineBreakPairCount; i++)
{ {
U32 lineNumber = lineBreakPairs[i * 2]; U32 lineNumber = mLineBreakPairs[i * 2];
if(lineNumber == U32(line + 1)) if(lineNumber == U32(line + 1))
seqCount++; seqCount++;
else else
@ -303,23 +303,23 @@ void CodeBlock::calcBreakList()
if(seqCount) if(seqCount)
size++; size++;
breakList = new U32[size]; mBreakList = new U32[size];
breakListSize = size; mBreakListSize = size;
line = -1; line = -1;
seqCount = 0; seqCount = 0;
size = 0; size = 0;
for(i = 0; i < lineBreakPairCount; i++) for(i = 0; i < mLineBreakPairCount; i++)
{ {
U32 lineNumber = lineBreakPairs[i * 2]; U32 lineNumber = mLineBreakPairs[i * 2];
if(lineNumber == U32(line + 1)) if(lineNumber == U32(line + 1))
seqCount++; seqCount++;
else else
{ {
if(seqCount) if(seqCount)
breakList[size++] = seqCount; mBreakList[size++] = seqCount;
breakList[size++] = lineNumber - getMax(0, line) - 1; mBreakList[size++] = lineNumber - getMax(0, line) - 1;
seqCount = 1; seqCount = 1;
} }
@ -327,12 +327,12 @@ void CodeBlock::calcBreakList()
} }
if(seqCount) if(seqCount)
breakList[size++] = seqCount; mBreakList[size++] = seqCount;
for(i = 0; i < lineBreakPairCount; i++) for(i = 0; i < mLineBreakPairCount; i++)
{ {
U32 *p = lineBreakPairs + i * 2; U32 *p = mLineBreakPairs + i * 2;
p[0] = (p[0] << 8) | code[p[1]]; p[0] = (p[0] << 8) | mCode[p[1]];
} }
// Let the telnet debugger know that this code // Let the telnet debugger know that this code
@ -347,27 +347,27 @@ bool CodeBlock::read(StringTableEntry fileName, Stream &st)
const StringTableEntry exePath = Platform::getMainDotCsDir(); const StringTableEntry exePath = Platform::getMainDotCsDir();
const StringTableEntry cwd = Platform::getCurrentDirectory(); const StringTableEntry cwd = Platform::getCurrentDirectory();
name = fileName; mName = fileName;
if(fileName) if(fileName)
{ {
fullPath = NULL; mFullPath = NULL;
if(Platform::isFullPath(fileName)) if(Platform::isFullPath(fileName))
fullPath = fileName; mFullPath = fileName;
if(dStrnicmp(exePath, fileName, dStrlen(exePath)) == 0) if(dStrnicmp(exePath, fileName, dStrlen(exePath)) == 0)
name = StringTable->insert(fileName + dStrlen(exePath) + 1, true); mName = StringTable->insert(fileName + dStrlen(exePath) + 1, true);
else if(dStrnicmp(cwd, fileName, dStrlen(cwd)) == 0) else if(dStrnicmp(cwd, fileName, dStrlen(cwd)) == 0)
name = StringTable->insert(fileName + dStrlen(cwd) + 1, true); mName = StringTable->insert(fileName + dStrlen(cwd) + 1, true);
if(fullPath == NULL) if(mFullPath == NULL)
{ {
char buf[1024]; char buf[1024];
fullPath = StringTable->insert(Platform::makeFullPathName(fileName, buf, sizeof(buf)), true); mFullPath = StringTable->insert(Platform::makeFullPathName(fileName, buf, sizeof(buf)), true);
} }
modPath = Con::getModNameFromPath(fileName); mModPath = Con::getModNameFromPath(fileName);
} }
// //
@ -377,53 +377,53 @@ bool CodeBlock::read(StringTableEntry fileName, Stream &st)
st.read(&size); st.read(&size);
if(size) if(size)
{ {
globalStrings = new char[size]; mGlobalStrings = new char[size];
globalStringsMaxLen = size; mGlobalStringsMaxLen = size;
st.read(size, globalStrings); st.read(size, mGlobalStrings);
} }
globalSize = size; globalSize = size;
st.read(&size); st.read(&size);
if(size) if(size)
{ {
functionStrings = new char[size]; mFunctionStrings = new char[size];
functionStringsMaxLen = size; mFunctionStringsMaxLen = size;
st.read(size, functionStrings); st.read(size, mFunctionStrings);
} }
st.read(&size); st.read(&size);
if(size) if(size)
{ {
globalFloats = new F64[size]; mGlobalFloats = new F64[size];
for(U32 i = 0; i < size; i++) for(U32 i = 0; i < size; i++)
st.read(&globalFloats[i]); st.read(&mGlobalFloats[i]);
} }
st.read(&size); st.read(&size);
if(size) if(size)
{ {
functionFloats = new F64[size]; mFunctionFloats = new F64[size];
for(U32 i = 0; i < size; i++) for(U32 i = 0; i < size; i++)
st.read(&functionFloats[i]); st.read(&mFunctionFloats[i]);
} }
U32 codeSize; U32 codeSize;
st.read(&codeSize); st.read(&codeSize);
st.read(&lineBreakPairCount); st.read(&mLineBreakPairCount);
U32 totSize = codeSize + lineBreakPairCount * 2; U32 totSize = codeSize + mLineBreakPairCount * 2;
code = new U32[totSize]; mCode = new U32[totSize];
for(i = 0; i < codeSize; i++) for(i = 0; i < codeSize; i++)
{ {
U8 b; U8 b;
st.read(&b); st.read(&b);
if(b == 0xFF) if(b == 0xFF)
st.read(&code[i]); st.read(&mCode[i]);
else else
code[i] = b; mCode[i] = b;
} }
for(i = codeSize; i < totSize; i++) for(i = codeSize; i < totSize; i++)
st.read(&code[i]); st.read(&mCode[i]);
lineBreakPairs = code + codeSize; mLineBreakPairs = mCode + codeSize;
// StringTable-ize our identifiers. // StringTable-ize our identifiers.
U32 identCount; U32 identCount;
@ -434,7 +434,7 @@ bool CodeBlock::read(StringTableEntry fileName, Stream &st)
st.read(&offset); st.read(&offset);
StringTableEntry ste; StringTableEntry ste;
if(offset < globalSize) if(offset < globalSize)
ste = StringTable->insert(globalStrings + offset); ste = StringTable->insert(mGlobalStrings + offset);
else else
ste = StringTable->insert(""); ste = StringTable->insert("");
U32 count; U32 count;
@ -443,11 +443,11 @@ bool CodeBlock::read(StringTableEntry fileName, Stream &st)
{ {
U32 ip; U32 ip;
st.read(&ip); st.read(&ip);
code[ip] = *((U32 *) &ste); mCode[ip] = *((U32 *) &ste);
} }
} }
if(lineBreakPairCount) if(mLineBreakPairCount)
calcBreakList(); calcBreakList();
return true; return true;
@ -501,13 +501,13 @@ bool CodeBlock::compile(const char *codeFileName, StringTableEntry fileName, con
setBreakCodeBlock(this); setBreakCodeBlock(this);
if(gStatementList) if(gStatementList)
codeSize = precompileBlock(gStatementList, 0) + 1; mCodeSize = precompileBlock(gStatementList, 0) + 1;
else else
codeSize = 1; mCodeSize = 1;
lineBreakPairCount = smBreakLineCount; mLineBreakPairCount = smBreakLineCount;
code = new U32[codeSize + smBreakLineCount * 2]; mCode = new U32[mCodeSize + smBreakLineCount * 2];
lineBreakPairs = code + codeSize; mLineBreakPairs = mCode + mCodeSize;
// Write string table data... // Write string table data...
getGlobalStringTable().write(st); getGlobalStringTable().write(st);
@ -520,34 +520,34 @@ bool CodeBlock::compile(const char *codeFileName, StringTableEntry fileName, con
smBreakLineCount = 0; smBreakLineCount = 0;
U32 lastIp; U32 lastIp;
if(gStatementList) if(gStatementList)
lastIp = compileBlock(gStatementList, code, 0, 0, 0); lastIp = compileBlock(gStatementList, mCode, 0, 0, 0);
else else
lastIp = 0; lastIp = 0;
if(lastIp != codeSize - 1) if(lastIp != mCodeSize - 1)
Con::errorf(ConsoleLogEntry::General, "CodeBlock::compile - precompile size mismatch, a precompile/compile function pair is probably mismatched."); Con::errorf(ConsoleLogEntry::General, "CodeBlock::compile - precompile size mismatch, a precompile/compile function pair is probably mismatched.");
code[lastIp++] = OP_RETURN; mCode[lastIp++] = OP_RETURN;
U32 totSize = codeSize + smBreakLineCount * 2; U32 totSize = mCodeSize + smBreakLineCount * 2;
st.write(codeSize); st.write(mCodeSize);
st.write(lineBreakPairCount); st.write(mLineBreakPairCount);
// Write out our bytecode, doing a bit of compression for low numbers. // Write out our bytecode, doing a bit of compression for low numbers.
U32 i; U32 i;
for(i = 0; i < codeSize; i++) for(i = 0; i < mCodeSize; i++)
{ {
if(code[i] < 0xFF) if(mCode[i] < 0xFF)
st.write(U8(code[i])); st.write(U8(mCode[i]));
else else
{ {
st.write(U8(0xFF)); st.write(U8(0xFF));
st.write(code[i]); st.write(mCode[i]);
} }
} }
// Write the break info... // Write the break info...
for(i = codeSize; i < totSize; i++) for(i = mCodeSize; i < totSize; i++)
st.write(code[i]); st.write(mCode[i]);
getIdentTable().write(st); getIdentTable().write(st);
@ -568,33 +568,33 @@ const char *CodeBlock::compileExec(StringTableEntry fileName, const char *inStri
STEtoU32 = evalSTEtoU32; STEtoU32 = evalSTEtoU32;
consoleAllocReset(); consoleAllocReset();
name = fileName; mName = fileName;
if(fileName) if(fileName)
{ {
const StringTableEntry exePath = Platform::getMainDotCsDir(); const StringTableEntry exePath = Platform::getMainDotCsDir();
const StringTableEntry cwd = Platform::getCurrentDirectory(); const StringTableEntry cwd = Platform::getCurrentDirectory();
fullPath = NULL; mFullPath = NULL;
if(Platform::isFullPath(fileName)) if(Platform::isFullPath(fileName))
fullPath = fileName; mFullPath = fileName;
if(dStrnicmp(exePath, fileName, dStrlen(exePath)) == 0) if(dStrnicmp(exePath, fileName, dStrlen(exePath)) == 0)
name = StringTable->insert(fileName + dStrlen(exePath) + 1, true); mName = StringTable->insert(fileName + dStrlen(exePath) + 1, true);
else if(dStrnicmp(cwd, fileName, dStrlen(cwd)) == 0) else if(dStrnicmp(cwd, fileName, dStrlen(cwd)) == 0)
name = StringTable->insert(fileName + dStrlen(cwd) + 1, true); mName = StringTable->insert(fileName + dStrlen(cwd) + 1, true);
if(fullPath == NULL) if(mFullPath == NULL)
{ {
char buf[1024]; char buf[1024];
fullPath = StringTable->insert(Platform::makeFullPathName(fileName, buf, sizeof(buf)), true); mFullPath = StringTable->insert(Platform::makeFullPathName(fileName, buf, sizeof(buf)), true);
} }
modPath = Con::getModNameFromPath(fileName); mModPath = Con::getModNameFromPath(fileName);
} }
if(name) if(mName)
addToCodeList(); addToCodeList();
gStatementList = NULL; gStatementList = NULL;
@ -620,33 +620,33 @@ const char *CodeBlock::compileExec(StringTableEntry fileName, const char *inStri
smBreakLineCount = 0; smBreakLineCount = 0;
setBreakCodeBlock(this); setBreakCodeBlock(this);
codeSize = precompileBlock(gStatementList, 0) + 1; mCodeSize = precompileBlock(gStatementList, 0) + 1;
lineBreakPairCount = smBreakLineCount; mLineBreakPairCount = smBreakLineCount;
globalStrings = getGlobalStringTable().build(); mGlobalStrings = getGlobalStringTable().build();
globalStringsMaxLen = getGlobalStringTable().totalLen; mGlobalStringsMaxLen = getGlobalStringTable().totalLen;
functionStrings = getFunctionStringTable().build(); mFunctionStrings = getFunctionStringTable().build();
functionStringsMaxLen = getFunctionStringTable().totalLen; mFunctionStringsMaxLen = getFunctionStringTable().totalLen;
globalFloats = getGlobalFloatTable().build(); mGlobalFloats = getGlobalFloatTable().build();
functionFloats = getFunctionFloatTable().build(); mFunctionFloats = getFunctionFloatTable().build();
code = new U32[codeSize + lineBreakPairCount * 2]; mCode = new U32[mCodeSize + mLineBreakPairCount * 2];
lineBreakPairs = code + codeSize; mLineBreakPairs = mCode + mCodeSize;
smBreakLineCount = 0; smBreakLineCount = 0;
U32 lastIp = compileBlock(gStatementList, code, 0, 0, 0); U32 lastIp = compileBlock(gStatementList, mCode, 0, 0, 0);
code[lastIp++] = OP_RETURN; mCode[lastIp++] = OP_RETURN;
consoleAllocReset(); consoleAllocReset();
if(lineBreakPairCount && fileName) if(mLineBreakPairCount && fileName)
calcBreakList(); calcBreakList();
if(lastIp != codeSize) if(lastIp != mCodeSize)
Con::warnf(ConsoleLogEntry::General, "precompile size mismatch, precompile: %d compile: %d", codeSize, lastIp); Con::warnf(ConsoleLogEntry::General, "precompile size mismatch, precompile: %d compile: %d", mCodeSize, lastIp);
return exec(0, fileName, NULL, 0, 0, noCalls, NULL, setFrame); return exec(0, fileName, NULL, 0, 0, noCalls, NULL, setFrame);
} }
@ -655,13 +655,13 @@ const char *CodeBlock::compileExec(StringTableEntry fileName, const char *inStri
void CodeBlock::incRefCount() void CodeBlock::incRefCount()
{ {
refCount++; mRefCount++;
} }
void CodeBlock::decRefCount() void CodeBlock::decRefCount()
{ {
refCount--; mRefCount--;
if(!refCount) if(!mRefCount)
delete this; delete this;
} }
@ -671,10 +671,10 @@ String CodeBlock::getFunctionArgs( U32 ip )
{ {
StringBuilder str; StringBuilder str;
U32 fnArgc = code[ ip + 5 ]; U32 fnArgc = mCode[ ip + 5 ];
for( U32 i = 0; i < fnArgc; ++ i ) for( U32 i = 0; i < fnArgc; ++ i )
{ {
StringTableEntry var = U32toSTE( code[ ip + i + 6 ] ); StringTableEntry var = U32toSTE( mCode[ ip + i + 6 ] );
if( i != 0 ) if( i != 0 )
str.append( ", " ); str.append( ", " );
@ -696,18 +696,18 @@ String CodeBlock::getFunctionArgs( U32 ip )
void CodeBlock::dumpInstructions( U32 startIp, bool upToReturn ) void CodeBlock::dumpInstructions( U32 startIp, bool upToReturn )
{ {
U32 ip = startIp; U32 ip = startIp;
while( ip < codeSize ) while( ip < mCodeSize )
{ {
switch( code[ ip ++ ] ) switch( mCode[ ip ++ ] )
{ {
case OP_FUNC_DECL: case OP_FUNC_DECL:
{ {
StringTableEntry fnName = U32toSTE(code[ip]); StringTableEntry fnName = U32toSTE(mCode[ip]);
StringTableEntry fnNamespace = U32toSTE(code[ip+1]); StringTableEntry fnNamespace = U32toSTE(mCode[ip+1]);
StringTableEntry fnPackage = U32toSTE(code[ip+2]); StringTableEntry fnPackage = U32toSTE(mCode[ip+2]);
bool hasBody = bool(code[ip+3]); bool hasBody = bool(mCode[ip+3]);
U32 newIp = code[ ip + 4 ]; U32 newIp = mCode[ ip + 4 ];
U32 argc = code[ ip + 5 ]; U32 argc = mCode[ ip + 5 ];
Con::printf( "%i: OP_FUNC_DECL name=%s nspace=%s package=%s hasbody=%i newip=%i argc=%i", Con::printf( "%i: OP_FUNC_DECL name=%s nspace=%s package=%s hasbody=%i newip=%i argc=%i",
ip - 1, fnName, fnNamespace, fnPackage, hasBody, newIp, argc ); ip - 1, fnName, fnNamespace, fnPackage, hasBody, newIp, argc );
@ -720,12 +720,12 @@ void CodeBlock::dumpInstructions( U32 startIp, bool upToReturn )
case OP_CREATE_OBJECT: case OP_CREATE_OBJECT:
{ {
StringTableEntry objParent = U32toSTE(code[ip ]); StringTableEntry objParent = U32toSTE(mCode[ip ]);
bool isDataBlock = code[ip + 1]; bool isDataBlock = mCode[ip + 1];
bool isInternal = code[ip + 2]; bool isInternal = mCode[ip + 2];
bool isSingleton = code[ip + 3]; bool isSingleton = mCode[ip + 3];
U32 lineNumber = code[ip + 4]; U32 lineNumber = mCode[ip + 4];
U32 failJump = code[ip + 5]; U32 failJump = mCode[ip + 5];
Con::printf( "%i: OP_CREATE_OBJECT objParent=%s isDataBlock=%i isInternal=%i isSingleton=%i lineNumber=%i failJump=%i", Con::printf( "%i: OP_CREATE_OBJECT objParent=%s isDataBlock=%i isInternal=%i isSingleton=%i lineNumber=%i failJump=%i",
ip - 1, objParent, isDataBlock, isInternal, isSingleton, lineNumber, failJump ); ip - 1, objParent, isDataBlock, isInternal, isSingleton, lineNumber, failJump );
@ -736,14 +736,14 @@ void CodeBlock::dumpInstructions( U32 startIp, bool upToReturn )
case OP_ADD_OBJECT: case OP_ADD_OBJECT:
{ {
bool placeAtRoot = code[ip++]; bool placeAtRoot = mCode[ip++];
Con::printf( "%i: OP_ADD_OBJECT placeAtRoot=%i", ip - 1, placeAtRoot ); Con::printf( "%i: OP_ADD_OBJECT placeAtRoot=%i", ip - 1, placeAtRoot );
break; break;
} }
case OP_END_OBJECT: case OP_END_OBJECT:
{ {
bool placeAtRoot = code[ip++]; bool placeAtRoot = mCode[ip++];
Con::printf( "%i: OP_END_OBJECT placeAtRoot=%i", ip - 1, placeAtRoot ); Con::printf( "%i: OP_END_OBJECT placeAtRoot=%i", ip - 1, placeAtRoot );
break; break;
} }
@ -756,49 +756,49 @@ void CodeBlock::dumpInstructions( U32 startIp, bool upToReturn )
case OP_JMPIFFNOT: case OP_JMPIFFNOT:
{ {
Con::printf( "%i: OP_JMPIFFNOT ip=%i", ip - 1, code[ ip ] ); Con::printf( "%i: OP_JMPIFFNOT ip=%i", ip - 1, mCode[ ip ] );
++ ip; ++ ip;
break; break;
} }
case OP_JMPIFNOT: case OP_JMPIFNOT:
{ {
Con::printf( "%i: OP_JMPIFNOT ip=%i", ip - 1, code[ ip ] ); Con::printf( "%i: OP_JMPIFNOT ip=%i", ip - 1, mCode[ ip ] );
++ ip; ++ ip;
break; break;
} }
case OP_JMPIFF: case OP_JMPIFF:
{ {
Con::printf( "%i: OP_JMPIFF ip=%i", ip - 1, code[ ip ] ); Con::printf( "%i: OP_JMPIFF ip=%i", ip - 1, mCode[ ip ] );
++ ip; ++ ip;
break; break;
} }
case OP_JMPIF: case OP_JMPIF:
{ {
Con::printf( "%i: OP_JMPIF ip=%i", ip - 1, code[ ip ] ); Con::printf( "%i: OP_JMPIF ip=%i", ip - 1, mCode[ ip ] );
++ ip; ++ ip;
break; break;
} }
case OP_JMPIFNOT_NP: case OP_JMPIFNOT_NP:
{ {
Con::printf( "%i: OP_JMPIFNOT_NP ip=%i", ip - 1, code[ ip ] ); Con::printf( "%i: OP_JMPIFNOT_NP ip=%i", ip - 1, mCode[ ip ] );
++ ip; ++ ip;
break; break;
} }
case OP_JMPIF_NP: case OP_JMPIF_NP:
{ {
Con::printf( "%i: OP_JMPIF_NP ip=%i", ip - 1, code[ ip ] ); Con::printf( "%i: OP_JMPIF_NP ip=%i", ip - 1, mCode[ ip ] );
++ ip; ++ ip;
break; break;
} }
case OP_JMP: case OP_JMP:
{ {
Con::printf( "%i: OP_JMP ip=%i", ip - 1, code[ ip ] ); Con::printf( "%i: OP_JMP ip=%i", ip - 1, mCode[ ip ] );
++ ip; ++ ip;
break; break;
} }
@ -957,7 +957,7 @@ void CodeBlock::dumpInstructions( U32 startIp, bool upToReturn )
case OP_SETCURVAR: case OP_SETCURVAR:
{ {
StringTableEntry var = U32toSTE(code[ip]); StringTableEntry var = U32toSTE(mCode[ip]);
Con::printf( "%i: OP_SETCURVAR var=%s", ip - 1, var ); Con::printf( "%i: OP_SETCURVAR var=%s", ip - 1, var );
ip++; ip++;
@ -966,7 +966,7 @@ void CodeBlock::dumpInstructions( U32 startIp, bool upToReturn )
case OP_SETCURVAR_CREATE: case OP_SETCURVAR_CREATE:
{ {
StringTableEntry var = U32toSTE(code[ip]); StringTableEntry var = U32toSTE(mCode[ip]);
Con::printf( "%i: OP_SETCURVAR_CREATE var=%s", ip - 1, var ); Con::printf( "%i: OP_SETCURVAR_CREATE var=%s", ip - 1, var );
ip++; ip++;
@ -1042,7 +1042,7 @@ void CodeBlock::dumpInstructions( U32 startIp, bool upToReturn )
case OP_SETCURFIELD: case OP_SETCURFIELD:
{ {
StringTableEntry curField = U32toSTE(code[ip]); StringTableEntry curField = U32toSTE(mCode[ip]);
Con::printf( "%i: OP_SETCURFIELD field=%s", ip - 1, curField ); Con::printf( "%i: OP_SETCURFIELD field=%s", ip - 1, curField );
++ ip; ++ ip;
} }
@ -1055,7 +1055,7 @@ void CodeBlock::dumpInstructions( U32 startIp, bool upToReturn )
case OP_SETCURFIELD_TYPE: case OP_SETCURFIELD_TYPE:
{ {
U32 type = code[ ip ]; U32 type = mCode[ ip ];
Con::printf( "%i: OP_SETCURFIELD_TYPE type=%i", ip - 1, type ); Con::printf( "%i: OP_SETCURFIELD_TYPE type=%i", ip - 1, type );
++ ip; ++ ip;
break; break;
@ -1153,7 +1153,7 @@ void CodeBlock::dumpInstructions( U32 startIp, bool upToReturn )
case OP_LOADIMMED_UINT: case OP_LOADIMMED_UINT:
{ {
U32 val = code[ ip ]; U32 val = mCode[ ip ];
Con::printf( "%i: OP_LOADIMMED_UINT val=%i", ip - 1, val ); Con::printf( "%i: OP_LOADIMMED_UINT val=%i", ip - 1, val );
++ ip; ++ ip;
break; break;
@ -1161,7 +1161,7 @@ void CodeBlock::dumpInstructions( U32 startIp, bool upToReturn )
case OP_LOADIMMED_FLT: case OP_LOADIMMED_FLT:
{ {
F64 val = functionFloats[ code[ ip ] ]; F64 val = mFunctionFloats[ mCode[ ip ] ];
Con::printf( "%i: OP_LOADIMMED_FLT val=%f", ip - 1, val ); Con::printf( "%i: OP_LOADIMMED_FLT val=%f", ip - 1, val );
++ ip; ++ ip;
break; break;
@ -1169,7 +1169,7 @@ void CodeBlock::dumpInstructions( U32 startIp, bool upToReturn )
case OP_TAG_TO_STR: case OP_TAG_TO_STR:
{ {
const char* str = functionStrings + code[ ip ]; const char* str = mFunctionStrings + mCode[ ip ];
Con::printf( "%i: OP_TAG_TO_STR str=%s", ip - 1, str ); Con::printf( "%i: OP_TAG_TO_STR str=%s", ip - 1, str );
++ ip; ++ ip;
break; break;
@ -1177,7 +1177,7 @@ void CodeBlock::dumpInstructions( U32 startIp, bool upToReturn )
case OP_LOADIMMED_STR: case OP_LOADIMMED_STR:
{ {
const char* str = functionStrings + code[ ip ]; const char* str = mFunctionStrings + mCode[ ip ];
Con::printf( "%i: OP_LOADIMMED_STR str=%s", ip - 1, str ); Con::printf( "%i: OP_LOADIMMED_STR str=%s", ip - 1, str );
++ ip; ++ ip;
break; break;
@ -1185,7 +1185,7 @@ void CodeBlock::dumpInstructions( U32 startIp, bool upToReturn )
case OP_DOCBLOCK_STR: case OP_DOCBLOCK_STR:
{ {
const char* str = functionStrings + code[ ip ]; const char* str = mFunctionStrings + mCode[ ip ];
Con::printf( "%i: OP_DOCBLOCK_STR str=%s", ip - 1, str ); Con::printf( "%i: OP_DOCBLOCK_STR str=%s", ip - 1, str );
++ ip; ++ ip;
break; break;
@ -1193,7 +1193,7 @@ void CodeBlock::dumpInstructions( U32 startIp, bool upToReturn )
case OP_LOADIMMED_IDENT: case OP_LOADIMMED_IDENT:
{ {
StringTableEntry str = U32toSTE( code[ ip ] ); StringTableEntry str = U32toSTE( mCode[ ip ] );
Con::printf( "%i: OP_LOADIMMED_IDENT str=%s", ip - 1, str ); Con::printf( "%i: OP_LOADIMMED_IDENT str=%s", ip - 1, str );
++ ip; ++ ip;
break; break;
@ -1201,9 +1201,9 @@ void CodeBlock::dumpInstructions( U32 startIp, bool upToReturn )
case OP_CALLFUNC_RESOLVE: case OP_CALLFUNC_RESOLVE:
{ {
StringTableEntry fnNamespace = U32toSTE(code[ip+1]); StringTableEntry fnNamespace = U32toSTE(mCode[ip+1]);
StringTableEntry fnName = U32toSTE(code[ip]); StringTableEntry fnName = U32toSTE(mCode[ip]);
U32 callType = code[ip+2]; U32 callType = mCode[ip+2];
Con::printf( "%i: OP_CALLFUNC_RESOLVE name=%s nspace=%s callType=%s", ip - 1, fnName, fnNamespace, Con::printf( "%i: OP_CALLFUNC_RESOLVE name=%s nspace=%s callType=%s", ip - 1, fnName, fnNamespace,
callType == FuncCallExprNode::FunctionCall ? "FunctionCall" callType == FuncCallExprNode::FunctionCall ? "FunctionCall"
@ -1215,9 +1215,9 @@ void CodeBlock::dumpInstructions( U32 startIp, bool upToReturn )
case OP_CALLFUNC: case OP_CALLFUNC:
{ {
StringTableEntry fnNamespace = U32toSTE(code[ip+1]); StringTableEntry fnNamespace = U32toSTE(mCode[ip+1]);
StringTableEntry fnName = U32toSTE(code[ip]); StringTableEntry fnName = U32toSTE(mCode[ip]);
U32 callType = code[ip+2]; U32 callType = mCode[ip+2];
Con::printf( "%i: OP_CALLFUNC name=%s nspace=%s callType=%s", ip - 1, fnName, fnNamespace, Con::printf( "%i: OP_CALLFUNC name=%s nspace=%s callType=%s", ip - 1, fnName, fnNamespace,
callType == FuncCallExprNode::FunctionCall ? "FunctionCall" callType == FuncCallExprNode::FunctionCall ? "FunctionCall"
@ -1235,7 +1235,7 @@ void CodeBlock::dumpInstructions( U32 startIp, bool upToReturn )
case OP_ADVANCE_STR_APPENDCHAR: case OP_ADVANCE_STR_APPENDCHAR:
{ {
char ch = code[ ip ]; char ch = mCode[ ip ];
Con::printf( "%i: OP_ADVANCE_STR_APPENDCHAR char=%c", ip - 1, ch ); Con::printf( "%i: OP_ADVANCE_STR_APPENDCHAR char=%c", ip - 1, ch );
++ ip; ++ ip;
break; break;
@ -1285,7 +1285,7 @@ void CodeBlock::dumpInstructions( U32 startIp, bool upToReturn )
case OP_ASSERT: case OP_ASSERT:
{ {
const char* message = functionStrings + code[ ip ]; const char* message = mFunctionStrings + mCode[ ip ];
Con::printf( "%i: OP_ASSERT message=%s", ip - 1, message ); Con::printf( "%i: OP_ASSERT message=%s", ip - 1, message );
++ ip; ++ ip;
break; break;
@ -1299,8 +1299,8 @@ void CodeBlock::dumpInstructions( U32 startIp, bool upToReturn )
case OP_ITER_BEGIN: case OP_ITER_BEGIN:
{ {
StringTableEntry varName = U32toSTE( code[ ip ] ); StringTableEntry varName = U32toSTE( mCode[ ip ] );
U32 failIp = code[ ip + 1 ]; U32 failIp = mCode[ ip + 1 ];
Con::printf( "%i: OP_ITER_BEGIN varName=%s failIp=%i", varName, failIp ); Con::printf( "%i: OP_ITER_BEGIN varName=%s failIp=%i", varName, failIp );
@ -1309,8 +1309,8 @@ void CodeBlock::dumpInstructions( U32 startIp, bool upToReturn )
case OP_ITER_BEGIN_STR: case OP_ITER_BEGIN_STR:
{ {
StringTableEntry varName = U32toSTE( code[ ip ] ); StringTableEntry varName = U32toSTE( mCode[ ip ] );
U32 failIp = code[ ip + 1 ]; U32 failIp = mCode[ ip + 1 ];
Con::printf( "%i: OP_ITER_BEGIN varName=%s failIp=%i", varName, failIp ); Con::printf( "%i: OP_ITER_BEGIN varName=%s failIp=%i", varName, failIp );
@ -1319,7 +1319,7 @@ void CodeBlock::dumpInstructions( U32 startIp, bool upToReturn )
case OP_ITER: case OP_ITER:
{ {
U32 breakIp = code[ ip ]; U32 breakIp = mCode[ ip ];
Con::printf( "%i: OP_ITER breakIp=%i", breakIp ); Con::printf( "%i: OP_ITER breakIp=%i", breakIp );

View file

@ -60,28 +60,28 @@ public:
CodeBlock(); CodeBlock();
~CodeBlock(); ~CodeBlock();
StringTableEntry name; StringTableEntry mName;
StringTableEntry fullPath; StringTableEntry mFullPath;
StringTableEntry modPath; StringTableEntry mModPath;
char *globalStrings; char *mGlobalStrings;
char *functionStrings; char *mFunctionStrings;
U32 functionStringsMaxLen; U32 mFunctionStringsMaxLen;
U32 globalStringsMaxLen; U32 mGlobalStringsMaxLen;
F64 *globalFloats; F64 *mGlobalFloats;
F64 *functionFloats; F64 *mFunctionFloats;
U32 codeSize; U32 mCodeSize;
U32 *code; U32 *mCode;
U32 refCount; U32 mRefCount;
U32 lineBreakPairCount; U32 mLineBreakPairCount;
U32 *lineBreakPairs; U32 *mLineBreakPairs;
U32 breakListSize; U32 mBreakListSize;
U32 *breakList; U32 *mBreakList;
CodeBlock *nextFile; CodeBlock *mNextFile;
void addToCodeList(); void addToCodeList();
void removeFromCodeList(); void removeFromCodeList();

View file

@ -422,8 +422,8 @@ const char *CodeBlock::exec(U32 ip, const char *functionName, Namespace *thisNam
if(argv) if(argv)
{ {
// assume this points into a function decl: // assume this points into a function decl:
U32 fnArgc = code[ip + 5]; U32 fnArgc = mCode[ip + 5];
thisFunctionName = U32toSTE(code[ip]); thisFunctionName = U32toSTE(mCode[ip]);
argc = getMin(argc-1, fnArgc); // argv[0] is func name argc = getMin(argc-1, fnArgc); // argv[0] is func name
if(gEvalState.traceOn) if(gEvalState.traceOn)
{ {
@ -458,20 +458,20 @@ const char *CodeBlock::exec(U32 ip, const char *functionName, Namespace *thisNam
popFrame = true; popFrame = true;
for(i = 0; i < argc; i++) for(i = 0; i < argc; i++)
{ {
StringTableEntry var = U32toSTE(code[ip + i + 6]); StringTableEntry var = U32toSTE(mCode[ip + i + 6]);
gEvalState.setCurVarNameCreate(var); gEvalState.setCurVarNameCreate(var);
gEvalState.setStringVariable(argv[i+1]); gEvalState.setStringVariable(argv[i+1]);
} }
ip = ip + fnArgc + 6; ip = ip + fnArgc + 6;
curFloatTable = functionFloats; curFloatTable = mFunctionFloats;
curStringTable = functionStrings; curStringTable = mFunctionStrings;
curStringTableLen = functionStringsMaxLen; curStringTableLen = mFunctionStringsMaxLen;
} }
else else
{ {
curFloatTable = globalFloats; curFloatTable = mGlobalFloats;
curStringTable = globalStrings; curStringTable = mGlobalStrings;
curStringTableLen = globalStringsMaxLen; curStringTableLen = mGlobalStringsMaxLen;
// If requested stack frame isn't available, request a new one // If requested stack frame isn't available, request a new one
// (this prevents assert failures when creating local // (this prevents assert failures when creating local
@ -537,10 +537,10 @@ const char *CodeBlock::exec(U32 ip, const char *functionName, Namespace *thisNam
CodeBlock *saveCodeBlock = smCurrentCodeBlock; CodeBlock *saveCodeBlock = smCurrentCodeBlock;
smCurrentCodeBlock = this; smCurrentCodeBlock = this;
if(this->name) if(this->mName)
{ {
Con::gCurrentFile = this->name; Con::gCurrentFile = this->mName;
Con::gCurrentRoot = this->modPath; Con::gCurrentRoot = this->mModPath;
} }
const char * val; const char * val;
@ -551,7 +551,7 @@ const char *CodeBlock::exec(U32 ip, const char *functionName, Namespace *thisNam
for(;;) for(;;)
{ {
U32 instruction = code[ip++]; U32 instruction = mCode[ip++];
nsEntry = NULL; nsEntry = NULL;
breakContinue: breakContinue:
switch(instruction) switch(instruction)
@ -559,11 +559,11 @@ breakContinue:
case OP_FUNC_DECL: case OP_FUNC_DECL:
if(!noCalls) if(!noCalls)
{ {
fnName = U32toSTE(code[ip]); fnName = U32toSTE(mCode[ip]);
fnNamespace = U32toSTE(code[ip+1]); fnNamespace = U32toSTE(mCode[ip+1]);
fnPackage = U32toSTE(code[ip+2]); fnPackage = U32toSTE(mCode[ip+2]);
bool hasBody = ( code[ ip + 3 ] & 0x01 ) != 0; bool hasBody = ( mCode[ ip + 3 ] & 0x01 ) != 0;
U32 lineNumber = code[ ip + 3 ] >> 1; U32 lineNumber = mCode[ ip + 3 ] >> 1;
Namespace::unlinkPackages(); Namespace::unlinkPackages();
ns = Namespace::find(fnNamespace, fnPackage); ns = Namespace::find(fnNamespace, fnPackage);
@ -586,18 +586,18 @@ breakContinue:
//Con::printf("Adding function %s::%s (%d)", fnNamespace, fnName, ip); //Con::printf("Adding function %s::%s (%d)", fnNamespace, fnName, ip);
} }
ip = code[ip + 4]; ip = mCode[ip + 4];
break; break;
case OP_CREATE_OBJECT: case OP_CREATE_OBJECT:
{ {
// Read some useful info. // Read some useful info.
objParent = U32toSTE(code[ip ]); objParent = U32toSTE(mCode[ip ]);
bool isDataBlock = code[ip + 1]; bool isDataBlock = mCode[ip + 1];
bool isInternal = code[ip + 2]; bool isInternal = mCode[ip + 2];
bool isSingleton = code[ip + 3]; bool isSingleton = mCode[ip + 3];
U32 lineNumber = code[ip + 4]; U32 lineNumber = mCode[ip + 4];
failJump = code[ip + 5]; failJump = mCode[ip + 5];
// If we don't allow calls, we certainly don't allow creating objects! // If we don't allow calls, we certainly don't allow creating objects!
// Moved this to after failJump is set. Engine was crashing when // Moved this to after failJump is set. Engine was crashing when
@ -790,7 +790,7 @@ breakContinue:
currentNewObject->setDeclarationLine(lineNumber); currentNewObject->setDeclarationLine(lineNumber);
// Set the file that this object was created in // Set the file that this object was created in
currentNewObject->setFilename(name); currentNewObject->setFilename(mName);
// Does it have a parent object? (ie, the copy constructor : syntax, not inheriance) // Does it have a parent object? (ie, the copy constructor : syntax, not inheriance)
if(*objParent) if(*objParent)
@ -859,7 +859,7 @@ breakContinue:
curNSDocBlock = NULL; curNSDocBlock = NULL;
// Do we place this object at the root? // Do we place this object at the root?
bool placeAtRoot = code[ip++]; bool placeAtRoot = mCode[ip++];
// Con::printf("Adding object %s", currentNewObject->getName()); // Con::printf("Adding object %s", currentNewObject->getName());
@ -962,7 +962,7 @@ breakContinue:
{ {
// If we're not to be placed at the root, make sure we clean up // If we're not to be placed at the root, make sure we clean up
// our group reference. // our group reference.
bool placeAtRoot = code[ip++]; bool placeAtRoot = mCode[ip++];
if(!placeAtRoot) if(!placeAtRoot)
_UINT--; _UINT--;
break; break;
@ -983,7 +983,7 @@ breakContinue:
ip++; ip++;
break; break;
} }
ip = code[ip]; ip = mCode[ip];
break; break;
case OP_JMPIFNOT: case OP_JMPIFNOT:
if(intStack[_UINT--]) if(intStack[_UINT--])
@ -991,7 +991,7 @@ breakContinue:
ip++; ip++;
break; break;
} }
ip = code[ip]; ip = mCode[ip];
break; break;
case OP_JMPIFF: case OP_JMPIFF:
if(!floatStack[_FLT--]) if(!floatStack[_FLT--])
@ -999,7 +999,7 @@ breakContinue:
ip++; ip++;
break; break;
} }
ip = code[ip]; ip = mCode[ip];
break; break;
case OP_JMPIF: case OP_JMPIF:
if(!intStack[_UINT--]) if(!intStack[_UINT--])
@ -1007,7 +1007,7 @@ breakContinue:
ip ++; ip ++;
break; break;
} }
ip = code[ip]; ip = mCode[ip];
break; break;
case OP_JMPIFNOT_NP: case OP_JMPIFNOT_NP:
if(intStack[_UINT]) if(intStack[_UINT])
@ -1016,7 +1016,7 @@ breakContinue:
ip++; ip++;
break; break;
} }
ip = code[ip]; ip = mCode[ip];
break; break;
case OP_JMPIF_NP: case OP_JMPIF_NP:
if(!intStack[_UINT]) if(!intStack[_UINT])
@ -1025,10 +1025,10 @@ breakContinue:
ip++; ip++;
break; break;
} }
ip = code[ip]; ip = mCode[ip];
break; break;
case OP_JMP: case OP_JMP:
ip = code[ip]; ip = mCode[ip];
break; break;
// This fixes a bug when not explicitly returning a value. // This fixes a bug when not explicitly returning a value.
@ -1170,7 +1170,7 @@ breakContinue:
break; break;
case OP_SETCURVAR: case OP_SETCURVAR:
var = U32toSTE(code[ip]); var = U32toSTE(mCode[ip]);
ip++; ip++;
// If a variable is set, then these must be NULL. It is necessary // If a variable is set, then these must be NULL. It is necessary
@ -1190,7 +1190,7 @@ breakContinue:
break; break;
case OP_SETCURVAR_CREATE: case OP_SETCURVAR_CREATE:
var = U32toSTE(code[ip]); var = U32toSTE(mCode[ip]);
ip++; ip++;
// See OP_SETCURVAR // See OP_SETCURVAR
@ -1289,7 +1289,7 @@ breakContinue:
if(set) if(set)
{ {
StringTableEntry intName = StringTable->insert(STR.getStringValue()); StringTableEntry intName = StringTable->insert(STR.getStringValue());
bool recurse = code[ip-1]; bool recurse = mCode[ip-1];
SimObject *obj = set->findObjectByInternalName(intName, recurse); SimObject *obj = set->findObjectByInternalName(intName, recurse);
intStack[_UINT+1] = obj ? obj->getId() : 0; intStack[_UINT+1] = obj ? obj->getId() : 0;
_UINT++; _UINT++;
@ -1310,7 +1310,7 @@ breakContinue:
// Save the previous field for parsing vector fields. // Save the previous field for parsing vector fields.
prevField = curField; prevField = curField;
dStrcpy( prevFieldArray, curFieldArray ); dStrcpy( prevFieldArray, curFieldArray );
curField = U32toSTE(code[ip]); curField = U32toSTE(mCode[ip]);
curFieldArray[0] = 0; curFieldArray[0] = 0;
ip++; ip++;
break; break;
@ -1321,7 +1321,7 @@ breakContinue:
case OP_SETCURFIELD_TYPE: case OP_SETCURFIELD_TYPE:
if(curObject) if(curObject)
curObject->setDataFieldType(code[ip], curField, curFieldArray); curObject->setDataFieldType(mCode[ip], curField, curFieldArray);
ip++; ip++;
break; break;
@ -1449,34 +1449,34 @@ breakContinue:
break; break;
case OP_LOADIMMED_UINT: case OP_LOADIMMED_UINT:
intStack[_UINT+1] = code[ip++]; intStack[_UINT+1] = mCode[ip++];
_UINT++; _UINT++;
break; break;
case OP_LOADIMMED_FLT: case OP_LOADIMMED_FLT:
floatStack[_FLT+1] = curFloatTable[code[ip]]; floatStack[_FLT+1] = curFloatTable[mCode[ip]];
ip++; ip++;
_FLT++; _FLT++;
break; break;
case OP_TAG_TO_STR: case OP_TAG_TO_STR:
code[ip-1] = OP_LOADIMMED_STR; mCode[ip-1] = OP_LOADIMMED_STR;
// it's possible the string has already been converted // it's possible the string has already been converted
if(U8(curStringTable[code[ip]]) != StringTagPrefixByte) if(U8(curStringTable[mCode[ip]]) != StringTagPrefixByte)
{ {
U32 id = GameAddTaggedString(curStringTable + code[ip]); U32 id = GameAddTaggedString(curStringTable + mCode[ip]);
dSprintf(curStringTable + code[ip] + 1, 7, "%d", id); dSprintf(curStringTable + mCode[ip] + 1, 7, "%d", id);
*(curStringTable + code[ip]) = StringTagPrefixByte; *(curStringTable + mCode[ip]) = StringTagPrefixByte;
} }
case OP_LOADIMMED_STR: case OP_LOADIMMED_STR:
STR.setStringValue(curStringTable + code[ip++]); STR.setStringValue(curStringTable + mCode[ip++]);
break; break;
case OP_DOCBLOCK_STR: case OP_DOCBLOCK_STR:
{ {
// If the first word of the doc is '\class' or '@class', then this // If the first word of the doc is '\class' or '@class', then this
// is a namespace doc block, otherwise it is a function doc block. // is a namespace doc block, otherwise it is a function doc block.
const char* docblock = curStringTable + code[ip++]; const char* docblock = curStringTable + mCode[ip++];
const char* sansClass = dStrstr( docblock, "@class" ); const char* sansClass = dStrstr( docblock, "@class" );
if( !sansClass ) if( !sansClass )
@ -1504,13 +1504,13 @@ breakContinue:
break; break;
case OP_LOADIMMED_IDENT: case OP_LOADIMMED_IDENT:
STR.setStringValue(U32toSTE(code[ip++])); STR.setStringValue(U32toSTE(mCode[ip++]));
break; break;
case OP_CALLFUNC_RESOLVE: case OP_CALLFUNC_RESOLVE:
// This deals with a function that is potentially living in a namespace. // This deals with a function that is potentially living in a namespace.
fnNamespace = U32toSTE(code[ip+1]); fnNamespace = U32toSTE(mCode[ip+1]);
fnName = U32toSTE(code[ip]); fnName = U32toSTE(mCode[ip]);
// Try to look it up. // Try to look it up.
ns = Namespace::find(fnNamespace); ns = Namespace::find(fnNamespace);
@ -1535,7 +1535,7 @@ breakContinue:
// or just on the object. // or just on the object.
S32 routingId = 0; S32 routingId = 0;
fnName = U32toSTE(code[ip]); fnName = U32toSTE(mCode[ip]);
//if this is called from inside a function, append the ip and codeptr //if this is called from inside a function, append the ip and codeptr
if( gEvalState.getStackDepth() > 0 ) if( gEvalState.getStackDepth() > 0 )
@ -1544,7 +1544,7 @@ breakContinue:
gEvalState.getCurrentFrame().ip = ip - 1; gEvalState.getCurrentFrame().ip = ip - 1;
} }
U32 callType = code[ip+2]; U32 callType = mCode[ip+2];
ip += 3; ip += 3;
STR.getArgcArgv(fnName, &callArgc, &callArgv); STR.getArgcArgv(fnName, &callArgc, &callArgv);
@ -1682,19 +1682,19 @@ breakContinue:
{ {
S32 result = nsEntry->cb.mIntCallbackFunc(gEvalState.thisObject, callArgc, callArgv); S32 result = nsEntry->cb.mIntCallbackFunc(gEvalState.thisObject, callArgc, callArgv);
STR.popFrame(); STR.popFrame();
if(code[ip] == OP_STR_TO_UINT) if(mCode[ip] == OP_STR_TO_UINT)
{ {
ip++; ip++;
intStack[++_UINT] = result; intStack[++_UINT] = result;
break; break;
} }
else if(code[ip] == OP_STR_TO_FLT) else if(mCode[ip] == OP_STR_TO_FLT)
{ {
ip++; ip++;
floatStack[++_FLT] = result; floatStack[++_FLT] = result;
break; break;
} }
else if(code[ip] == OP_STR_TO_NONE) else if(mCode[ip] == OP_STR_TO_NONE)
ip++; ip++;
else else
STR.setIntValue(result); STR.setIntValue(result);
@ -1704,19 +1704,19 @@ breakContinue:
{ {
F64 result = nsEntry->cb.mFloatCallbackFunc(gEvalState.thisObject, callArgc, callArgv); F64 result = nsEntry->cb.mFloatCallbackFunc(gEvalState.thisObject, callArgc, callArgv);
STR.popFrame(); STR.popFrame();
if(code[ip] == OP_STR_TO_UINT) if(mCode[ip] == OP_STR_TO_UINT)
{ {
ip++; ip++;
intStack[++_UINT] = (S64)result; intStack[++_UINT] = (S64)result;
break; break;
} }
else if(code[ip] == OP_STR_TO_FLT) else if(mCode[ip] == OP_STR_TO_FLT)
{ {
ip++; ip++;
floatStack[++_FLT] = result; floatStack[++_FLT] = result;
break; break;
} }
else if(code[ip] == OP_STR_TO_NONE) else if(mCode[ip] == OP_STR_TO_NONE)
ip++; ip++;
else else
STR.setFloatValue(result); STR.setFloatValue(result);
@ -1724,7 +1724,7 @@ breakContinue:
} }
case Namespace::Entry::VoidCallbackType: case Namespace::Entry::VoidCallbackType:
nsEntry->cb.mVoidCallbackFunc(gEvalState.thisObject, callArgc, callArgv); nsEntry->cb.mVoidCallbackFunc(gEvalState.thisObject, callArgc, callArgv);
if( code[ ip ] != OP_STR_TO_NONE && Con::getBoolVariable( "$Con::warnVoidAssignment", true ) ) if( mCode[ ip ] != OP_STR_TO_NONE && Con::getBoolVariable( "$Con::warnVoidAssignment", true ) )
Con::warnf(ConsoleLogEntry::General, "%s: Call to %s in %s uses result of void function call.", getFileLine(ip-4), fnName, functionName); Con::warnf(ConsoleLogEntry::General, "%s: Call to %s in %s uses result of void function call.", getFileLine(ip-4), fnName, functionName);
STR.popFrame(); STR.popFrame();
@ -1734,19 +1734,19 @@ breakContinue:
{ {
bool result = nsEntry->cb.mBoolCallbackFunc(gEvalState.thisObject, callArgc, callArgv); bool result = nsEntry->cb.mBoolCallbackFunc(gEvalState.thisObject, callArgc, callArgv);
STR.popFrame(); STR.popFrame();
if(code[ip] == OP_STR_TO_UINT) if(mCode[ip] == OP_STR_TO_UINT)
{ {
ip++; ip++;
intStack[++_UINT] = result; intStack[++_UINT] = result;
break; break;
} }
else if(code[ip] == OP_STR_TO_FLT) else if(mCode[ip] == OP_STR_TO_FLT)
{ {
ip++; ip++;
floatStack[++_FLT] = result; floatStack[++_FLT] = result;
break; break;
} }
else if(code[ip] == OP_STR_TO_NONE) else if(mCode[ip] == OP_STR_TO_NONE)
ip++; ip++;
else else
STR.setIntValue(result); STR.setIntValue(result);
@ -1764,7 +1764,7 @@ breakContinue:
STR.advance(); STR.advance();
break; break;
case OP_ADVANCE_STR_APPENDCHAR: case OP_ADVANCE_STR_APPENDCHAR:
STR.advanceChar(code[ip++]); STR.advanceChar(mCode[ip++]);
break; break;
case OP_ADVANCE_STR_COMMA: case OP_ADVANCE_STR_COMMA:
@ -1798,13 +1798,13 @@ breakContinue:
{ {
if( !intStack[_UINT--] ) if( !intStack[_UINT--] )
{ {
const char *message = curStringTable + code[ip]; const char *message = curStringTable + mCode[ip];
U32 breakLine, inst; U32 breakLine, inst;
findBreakLine( ip - 1, breakLine, inst ); findBreakLine( ip - 1, breakLine, inst );
if ( PlatformAssert::processAssert( PlatformAssert::Fatal, if ( PlatformAssert::processAssert( PlatformAssert::Fatal,
name ? name : "eval", mName ? mName : "eval",
breakLine, breakLine,
message ) ) message ) )
{ {
@ -1844,8 +1844,8 @@ breakContinue:
case OP_ITER_BEGIN: case OP_ITER_BEGIN:
{ {
StringTableEntry varName = U32toSTE( code[ ip ] ); StringTableEntry varName = U32toSTE( mCode[ ip ] );
U32 failIp = code[ ip + 1 ]; U32 failIp = mCode[ ip + 1 ];
IterStackRecord& iter = iterStack[ _ITER ]; IterStackRecord& iter = iterStack[ _ITER ];
@ -1886,7 +1886,7 @@ breakContinue:
case OP_ITER: case OP_ITER:
{ {
U32 breakIp = code[ ip ]; U32 breakIp = mCode[ ip ];
IterStackRecord& iter = iterStack[ _ITER - 1 ]; IterStackRecord& iter = iterStack[ _ITER - 1 ];
if( iter.mIsStringIter ) if( iter.mIsStringIter )
@ -2001,18 +2001,18 @@ execFinished:
} }
else else
{ {
delete[] globalStrings; delete[] mGlobalStrings;
globalStringsMaxLen = 0; mGlobalStringsMaxLen = 0;
delete[] globalFloats; delete[] mGlobalFloats;
globalStrings = NULL; mGlobalStrings = NULL;
globalFloats = NULL; mGlobalFloats = NULL;
} }
smCurrentCodeBlock = saveCodeBlock; smCurrentCodeBlock = saveCodeBlock;
if(saveCodeBlock && saveCodeBlock->name) if(saveCodeBlock && saveCodeBlock->mName)
{ {
Con::gCurrentFile = saveCodeBlock->name; Con::gCurrentFile = saveCodeBlock->mName;
Con::gCurrentRoot = saveCodeBlock->modPath; Con::gCurrentRoot = saveCodeBlock->mModPath;
} }
decRefCount(); decRefCount();

View file

@ -2158,8 +2158,8 @@ DefineConsoleMethod( SimObject, dumpMethods, ArrayObject*, (),,
str.append( e->getPrototypeString() ); str.append( e->getPrototypeString() );
str.append( '\n' ); str.append( '\n' );
if( e->mCode && e->mCode->fullPath ) if( e->mCode && e->mCode->mFullPath )
str.append( e->mCode->fullPath ); str.append( e->mCode->mFullPath );
str.append( '\n' ); str.append( '\n' );
if( e->mCode ) if( e->mCode )
str.append( String::ToString( e->mFunctionLineNumber ) ); str.append( String::ToString( e->mFunctionLineNumber ) );

View file

@ -382,7 +382,7 @@ void TelnetDebugger::executionStopped(CodeBlock *code, U32 lineNumber)
return; return;
} }
Breakpoint **bp = findBreakpoint(code->name, lineNumber); Breakpoint **bp = findBreakpoint(code->mName, lineNumber);
if(!bp) if(!bp)
return; return;
@ -396,7 +396,7 @@ void TelnetDebugger::executionStopped(CodeBlock *code, U32 lineNumber)
{ {
brk->curCount = 0; brk->curCount = 0;
if(brk->clearOnHit) if(brk->clearOnHit)
removeBreakpoint(code->name, lineNumber); removeBreakpoint(code->mName, lineNumber);
breakProcess(); breakProcess();
} }
} }
@ -455,8 +455,8 @@ void TelnetDebugger::sendBreak()
{ {
CodeBlock *code = gEvalState.stack[i]->code; CodeBlock *code = gEvalState.stack[i]->code;
const char *file = "<none>"; const char *file = "<none>";
if (code && code->name && code->name[0]) if (code && code->mName && code->mName[0])
file = code->name; file = code->mName;
Namespace *ns = gEvalState.stack[i]->scopeNamespace; Namespace *ns = gEvalState.stack[i]->scopeNamespace;
scope[0] = 0; scope[0] = 0;
@ -580,7 +580,7 @@ void TelnetDebugger::addAllBreakpoints(CodeBlock *code)
{ {
// TODO: This assumes that the OS file names are case // TODO: This assumes that the OS file names are case
// insensitive... Torque needs a dFilenameCmp() function. // insensitive... Torque needs a dFilenameCmp() function.
if( dStricmp( cur->fileName, code->name ) == 0 ) if( dStricmp( cur->fileName, code->mName ) == 0 )
{ {
cur->code = code; cur->code = code;
@ -774,7 +774,7 @@ void TelnetDebugger::setBreakOnNextStatement( bool enabled )
if ( enabled ) if ( enabled )
{ {
// Apply breaks on all the code blocks. // Apply breaks on all the code blocks.
for(CodeBlock *walk = CodeBlock::getCodeBlockList(); walk; walk = walk->nextFile) for(CodeBlock *walk = CodeBlock::getCodeBlockList(); walk; walk = walk->mNextFile)
walk->setAllBreaks(); walk->setAllBreaks();
mBreakOnNextStatement = true; mBreakOnNextStatement = true;
} }
@ -782,7 +782,7 @@ void TelnetDebugger::setBreakOnNextStatement( bool enabled )
{ {
// Clear all the breaks on the codeblocks // Clear all the breaks on the codeblocks
// then go reapply the breakpoints. // then go reapply the breakpoints.
for(CodeBlock *walk = CodeBlock::getCodeBlockList(); walk; walk = walk->nextFile) for(CodeBlock *walk = CodeBlock::getCodeBlockList(); walk; walk = walk->mNextFile)
walk->clearAllBreaks(); walk->clearAllBreaks();
for(Breakpoint *w = mBreakpoints; w; w = w->next) for(Breakpoint *w = mBreakpoints; w; w = w->next)
{ {
@ -878,10 +878,10 @@ void TelnetDebugger::evaluateExpression(const char *tag, S32 frame, const char *
void TelnetDebugger::dumpFileList() void TelnetDebugger::dumpFileList()
{ {
send("FILELISTOUT "); send("FILELISTOUT ");
for(CodeBlock *walk = CodeBlock::getCodeBlockList(); walk; walk = walk->nextFile) for(CodeBlock *walk = CodeBlock::getCodeBlockList(); walk; walk = walk->mNextFile)
{ {
send(walk->name); send(walk->mName);
if(walk->nextFile) if(walk->mNextFile)
send(" "); send(" ");
} }
send("\r\n"); send("\r\n");
@ -894,11 +894,11 @@ void TelnetDebugger::dumpBreakableList(const char *fileName)
char buffer[MaxCommandSize]; char buffer[MaxCommandSize];
if(file) if(file)
{ {
dSprintf(buffer, MaxCommandSize, "BREAKLISTOUT %s %d", fileName, file->breakListSize >> 1); dSprintf(buffer, MaxCommandSize, "BREAKLISTOUT %s %d", fileName, file->mBreakListSize >> 1);
send(buffer); send(buffer);
for(U32 i = 0; i < file->breakListSize; i += 2) for(U32 i = 0; i < file->mBreakListSize; i += 2)
{ {
dSprintf(buffer, MaxCommandSize, " %d %d", file->breakList[i], file->breakList[i+1]); dSprintf(buffer, MaxCommandSize, " %d %d", file->mBreakList[i], file->mBreakList[i+1]);
send(buffer); send(buffer);
} }
send("\r\n"); send("\r\n");