Torque2D Reference
Loading...
Searching...
No Matches
CodeBlock Class Reference

#include <codeBlock.h>

Public Member Functions

 CodeBlock ()
 ~CodeBlock ()
void addToCodeList ()
void removeFromCodeList ()
void calcBreakList ()
void clearAllBreaks ()
void setAllBreaks ()
U32 findFirstBreakLine (U32 lineNumber)
void clearBreakpoint (U32 lineNumber)
bool setBreakpoint (U32 lineNumber)
void findBreakLine (U32 ip, U32 &line, U32 &instruction)
void getFunctionArgs (char buffer[1024], U32 offset)
const char * getFileLine (U32 ip)
bool read (StringTableEntry fileName, Stream &st)
bool compile (const char *dsoName, StringTableEntry fileName, const char *script)
void incRefCount ()
void decRefCount ()
const char * compileExec (StringTableEntry fileName, const char *script, bool noCalls, int setFrame=-1)
const char * exec (U32 offset, const char *fnName, Namespace *ns, U32 argc, const char **argv, bool noCalls, StringTableEntry packageName, S32 setFrame=-1)

Static Public Member Functions

static CodeBlockgetCurrentBlock ()
static CodeBlockgetCodeBlockList ()
static StringTableEntry getCurrentCodeBlockName ()
static StringTableEntry getCurrentCodeBlockFullPath ()
static StringTableEntry getCurrentCodeBlockModName ()
static CodeBlockfind (StringTableEntry)

Public Attributes

StringTableEntry name
StringTableEntry fullPath
StringTableEntry modPath
char * globalStrings
char * functionStrings
F64 * globalFloats
F64 * functionFloats
U32 codeSize
U32 * code
U32 refCount
U32 lineBreakPairCount
U32 * lineBreakPairs
U32 breakListSize
U32 * breakList
CodeBlocknextFile
StringTableEntry mRoot

Static Public Attributes

static U32 smBreakLineCount = 0
static bool smInFunction = false
static Compiler::ConsoleParsersmCurrentParser = NULL

Detailed Description

Core TorqueScript code management class.

This class represents a block of code, usually mapped directly to a file.

Constructor & Destructor Documentation

◆ CodeBlock()

CodeBlock ( )

◆ ~CodeBlock()

~CodeBlock ( )

Member Function Documentation

◆ addToCodeList()

void addToCodeList ( )

◆ calcBreakList()

void calcBreakList ( )

◆ clearAllBreaks()

void clearAllBreaks ( )

◆ clearBreakpoint()

void clearBreakpoint ( U32 lineNumber)

◆ compile()

bool compile ( const char * dsoName,
StringTableEntry fileName,
const char * script )

◆ compileExec()

const char * compileExec ( StringTableEntry fileName,
const char * script,
bool noCalls,
int setFrame = -1 )

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
fileNameThe file name, including path and extension, for the block of code or an empty string.
scriptThe script code to compile and execute.
noCallsSkips calling functions from the script.
setFrameA 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()

void decRefCount ( )

◆ exec()

const char * exec ( U32 offset,
const char * fnName,
Namespace * ns,
U32 argc,
const char ** argv,
bool noCalls,
StringTableEntry packageName,
S32 setFrame = -1 )

Executes the existing code in the CodeBlock. The return string is any result of the code executed, if any, or an empty string.

Parameters
offsetThe instruction offset to start executing from.
fnNameThe name of the function to execute or null.
nsThe namespace of the function to execute or null.
argcThe number of parameters passed to the function or zero to execute code outside of a function.
argvThe function parameter list.
noCallsSkips calling functions from the script.
setFrameA 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.
packageNameThe code package name or null.

◆ find()

CodeBlock * find ( StringTableEntry name)
static

◆ findBreakLine()

void findBreakLine ( U32 ip,
U32 & line,
U32 & instruction )

◆ findFirstBreakLine()

U32 findFirstBreakLine ( U32 lineNumber)

Returns the first breakable line or 0 if none was found.

Parameters
lineNumberThe one based line number.

◆ getCodeBlockList()

CodeBlock * getCodeBlockList ( )
inlinestatic

◆ getCurrentBlock()

CodeBlock * getCurrentBlock ( )
inlinestatic

◆ getCurrentCodeBlockFullPath()

StringTableEntry getCurrentCodeBlockFullPath ( )
static

◆ getCurrentCodeBlockModName()

StringTableEntry getCurrentCodeBlockModName ( )
static

◆ getCurrentCodeBlockName()

StringTableEntry getCurrentCodeBlockName ( )
static

◆ getFileLine()

const char * getFileLine ( U32 ip)

◆ getFunctionArgs()

void getFunctionArgs ( char buffer[1024],
U32 offset )

◆ incRefCount()

void incRefCount ( )

◆ read()

bool read ( StringTableEntry fileName,
Stream & st )

◆ removeFromCodeList()

void removeFromCodeList ( )

◆ setAllBreaks()

void setAllBreaks ( )

◆ setBreakpoint()

bool setBreakpoint ( U32 lineNumber)

Set a OP_BREAK instruction on a line. If a break is not possible on that line it returns false.

Parameters
lineNumberThe one based line number.

Member Data Documentation

◆ breakList

U32* breakList

◆ breakListSize

U32 breakListSize

◆ code

U32* code

◆ codeSize

U32 codeSize

◆ fullPath

StringTableEntry fullPath

◆ functionFloats

F64* functionFloats

◆ functionStrings

char* functionStrings

◆ globalFloats

F64* globalFloats

◆ globalStrings

char* globalStrings

◆ lineBreakPairCount

U32 lineBreakPairCount

◆ lineBreakPairs

U32* lineBreakPairs

◆ modPath

StringTableEntry modPath

◆ mRoot

StringTableEntry mRoot

◆ name

StringTableEntry name

◆ nextFile

CodeBlock* nextFile

◆ refCount

U32 refCount

◆ smBreakLineCount

U32 smBreakLineCount = 0
static

◆ smCurrentParser

ConsoleParser * smCurrentParser = NULL
static

◆ smInFunction

bool smInFunction = false
static

The documentation for this class was generated from the following files: