CodeBlock
Engine/source/console/codeBlock.h
Core TorqueScript code management class.
Public Friends
class
Private Static Attributes
Public Static Attributes
Public Attributes
char *
char *
Public Static Functions
Public Functions
clearBreakpoint(U32 lineNumber)
bool
compile(const char * dsoName, StringTableEntry fileName, const char * script, bool overrideNoDso)
compileExec(StringTableEntry fileName, const char * script, bool noCalls, S32 setFrame)
Compiles and executes a block of script storing the compiled code in this CodeBlock.
dumpInstructions(U32 startIp, bool upToReturn)
exec(U32 offset, const char * fnName, Namespace * ns, U32 argc, ConsoleValueRef * argv, bool noCalls, StringTableEntry packageName, S32 setFrame)
Executes the existing code in the CodeBlock.
findBreakLine(U32 ip, U32 & line, U32 & instruction)
findFirstBreakLine(U32 lineNumber)
Returns the first breakable line or 0 if none was found.
const char *
getFileLine(U32 ip)
getFunctionArgs(U32 offset)
bool
read(StringTableEntry fileName, Stream & st)
bool
setBreakpoint(U32 lineNumber)
Set a OP_BREAK instruction on a line.
Detailed Description
Core TorqueScript code management class.
This class represents a block of code, usually mapped directly to a file.
Public Friends
Private Static Attributes
CodeBlock * smCodeBlockList
CodeBlock * smCurrentCodeBlock
Public Static Attributes
Compiler::ConsoleParser * smCurrentParser
bool smInFunction
Public Attributes
U32 * breakList
U32 breakListSize
U32 * code
U32 codeSize
StringTableEntry fullPath
F64 * functionFloats
char * functionStrings
U32 functionStringsMaxLen
F64 * globalFloats
char * globalStrings
U32 globalStringsMaxLen
U32 lineBreakPairCount
U32 * lineBreakPairs
StringTableEntry modPath
StringTableEntry name
CodeBlock * nextFile
U32 refCount
Public Static Functions
find(StringTableEntry )
getCodeBlockList()
getCurrentBlock()
getCurrentCodeBlockFullPath()
getCurrentCodeBlockModName()
getCurrentCodeBlockName()
Public Functions
CodeBlock()
~CodeBlock()
addToCodeList()
calcBreakList()
clearAllBreaks()
clearBreakpoint(U32 lineNumber)
compile(const char * dsoName, StringTableEntry fileName, const char * script, bool overrideNoDso)
compileExec(StringTableEntry fileName, const char * script, bool noCalls, S32 setFrame)
Compiles and executes a block of script storing the compiled code in this CodeBlock.
If there is no filename breakpoints will not be generated and the CodeBlock will not be added to the linked list of loaded CodeBlocks. Note that if the script contains no executable statements the CodeBlock will delete itself on return an empty string. The return string is any result of the code executed, if any, or an empty string.
Parameters:
fileName | The file name, including path and extension, for the block of code or an empty string. |
script | The script code to compile and execute. |
noCalls | Skips calling functions from the script. |
setFrame | A zero based index of the stack frame to execute the code with, zero being the top of the stack. If the the index is -1 a new frame is created. If the index is out of range the top stack frame is used. |
decRefCount()
dumpInstructions(U32 startIp, bool upToReturn)
exec(U32 offset, const char * fnName, Namespace * ns, U32 argc, ConsoleValueRef * argv, bool noCalls, StringTableEntry packageName, S32 setFrame)
Executes the existing code in the CodeBlock.
The return string is any result of the code executed, if any, or an empty string.
Parameters:
offset | The instruction offset to start executing from. |
fnName | The name of the function to execute or null. |
ns | The namespace of the function to execute or null. |
argc | The number of parameters passed to the function or zero to execute code outside of a function. |
argv | The function parameter list. |
noCalls | Skips calling functions from the script. |
setFrame | A zero based index of the stack frame to execute the code with, zero being the top of the stack. If the the index is -1 a new frame is created. If the index is out of range the top stack frame is used. |
packageName | The code package name or null. |
findBreakLine(U32 ip, U32 & line, U32 & instruction)
findFirstBreakLine(U32 lineNumber)
Returns the first breakable line or 0 if none was found.
Parameters:
lineNumber | The one based line number. |
getFileLine(U32 ip)
getFunctionArgs(U32 offset)
incRefCount()
read(StringTableEntry fileName, Stream & st)
removeFromCodeList()
setAllBreaks()
setBreakpoint(U32 lineNumber)
Set a OP_BREAK instruction on a line.
If a break is not possible on that line it returns false. Parameters:
lineNumber | The one based line number. |