Torque2D Reference
Loading...
Searching...
No Matches
Compiler Namespace Reference

Classes

struct  CompilerIdentTable
struct  CompilerStringTable
struct  CompilerFloatTable
struct  ConsoleParser
 List of parsers for the compiler. More...

Typedefs

typedef const char *(* fnGetCurrentFile) ()
 Function for GetCurrentFile from the lexer.
typedef S32(* fnGetCurrentLine) ()
 Function for GetCurrentLine from the lexer.
typedef S32(* fnParse) ()
 Function for Parse from the lexer.
typedef void(* fnRestart) (FILE *input_file)
 Function for Restart from the lexer.
typedef void(* fnSetScanBuffer) (const char *sb, const char *fn)
 Function for SetScanBuffer from the lexer.

Enumerations

enum  CompiledInstructions {
  OP_FUNC_DECL , OP_CREATE_OBJECT , OP_ADD_OBJECT , OP_END_OBJECT ,
  OP_JMPIFFNOT , OP_JMPIFNOT , OP_JMPIFF , OP_JMPIF ,
  OP_JMPIFNOT_NP , OP_JMPIF_NP , OP_JMP , OP_RETURN ,
  OP_CMPEQ , OP_CMPGR , OP_CMPGE , OP_CMPLT ,
  OP_CMPLE , OP_CMPNE , OP_XOR , OP_MOD ,
  OP_BITAND , OP_BITOR , OP_NOT , OP_NOTF ,
  OP_ONESCOMPLEMENT , OP_SHR , OP_SHL , OP_AND ,
  OP_OR , OP_ADD , OP_SUB , OP_MUL ,
  OP_DIV , OP_NEG , OP_SETCURVAR , OP_SETCURVAR_CREATE ,
  OP_SETCURVAR_ARRAY , OP_SETCURVAR_ARRAY_CREATE , OP_LOADVAR_UINT , OP_LOADVAR_FLT ,
  OP_LOADVAR_STR , OP_SAVEVAR_UINT , OP_SAVEVAR_FLT , OP_SAVEVAR_STR ,
  OP_SETCUROBJECT , OP_SETCUROBJECT_NEW , OP_SETCUROBJECT_INTERNAL , OP_SETCURFIELD ,
  OP_SETCURFIELD_ARRAY , OP_LOADFIELD_UINT , OP_LOADFIELD_FLT , OP_LOADFIELD_STR ,
  OP_SAVEFIELD_UINT , OP_SAVEFIELD_FLT , OP_SAVEFIELD_STR , OP_STR_TO_UINT ,
  OP_STR_TO_FLT , OP_STR_TO_NONE , OP_FLT_TO_UINT , OP_FLT_TO_STR ,
  OP_FLT_TO_NONE , OP_UINT_TO_FLT , OP_UINT_TO_STR , OP_UINT_TO_NONE ,
  OP_LOADIMMED_UINT , OP_LOADIMMED_FLT , OP_TAG_TO_STR , OP_LOADIMMED_STR ,
  OP_DOCBLOCK_STR , OP_LOADIMMED_IDENT , OP_CALLFUNC_RESOLVE , OP_CALLFUNC ,
  OP_ADVANCE_STR , OP_ADVANCE_STR_APPENDCHAR , OP_ADVANCE_STR_COMMA , OP_ADVANCE_STR_NUL ,
  OP_REWIND_STR , OP_TERMINATE_REWIND_STR , OP_COMPARE_STR , OP_PUSH ,
  OP_PUSH_FRAME , OP_BREAK , OP_INVALID
}
 The opcodes for the TorqueScript VM. More...

Functions

U32 precompileBlock (StmtNode *block, U32 loopCount)
U32 compileBlock (StmtNode *block, U32 *codeStream, U32 ip, U32 continuePoint, U32 breakPoint)
F64 consoleStringToNumber (const char *str, StringTableEntry file, U32 line)
CodeBlockgetBreakCodeBlock ()
void setBreakCodeBlock (CodeBlock *cb)
void evalSTEtoCode (StringTableEntry ste, U32 ip, U32 *codeStream)
void compileSTEtoCode (StringTableEntry ste, U32 ip, U32 *codeStream)
CompilerStringTablegetCurrentStringTable ()
CompilerStringTablegetGlobalStringTable ()
CompilerStringTablegetFunctionStringTable ()
void setCurrentStringTable (CompilerStringTable *cst)
CompilerFloatTablegetCurrentFloatTable ()
CompilerFloatTablegetGlobalFloatTable ()
CompilerFloatTablegetFunctionFloatTable ()
void setCurrentFloatTable (CompilerFloatTable *cst)
CompilerIdentTablegetIdentTable ()
void precompileIdent (StringTableEntry ident)
void resetTables ()
void * consoleAlloc (U32 size)
void consoleAllocReset ()
StringTableEntry CodeToSTE (U32 *code, U32 ip)
void freeConsoleParserList (void)
 Free the console parser list.
bool addConsoleParser (const char *ext, fnGetCurrentFile gcf, fnGetCurrentLine gcl, fnParse p, fnRestart r, fnSetScanBuffer ssb, bool def=false)
 Add a console parser to the list.
ConsoleParsergetParserForFile (const char *filename)
 Get the parser for a particular file based on its extension.

Variables

CompilerStringTablegCurrentStringTable
CompilerStringTable gGlobalStringTable
CompilerStringTable gFunctionStringTable
CompilerFloatTablegCurrentFloatTable
CompilerFloatTable gGlobalFloatTable
CompilerFloatTable gFunctionFloatTable
DataChunker gConsoleAllocator
CompilerIdentTable gIdentTable
CodeBlockgCurBreakBlock
void(* STEtoCode )(StringTableEntry ste, U32 ip, U32 *codeStream) = evalSTEtoCode
bool gSyntaxError = false

Typedef Documentation

◆ fnGetCurrentFile

typedef const char *(* fnGetCurrentFile) ()

Function for GetCurrentFile from the lexer.

◆ fnGetCurrentLine

typedef S32(* fnGetCurrentLine) ()

Function for GetCurrentLine from the lexer.

◆ fnParse

typedef S32(* fnParse) ()

Function for Parse from the lexer.

◆ fnRestart

typedef void(* fnRestart) (FILE *input_file)

Function for Restart from the lexer.

◆ fnSetScanBuffer

typedef void(* fnSetScanBuffer) (const char *sb, const char *fn)

Function for SetScanBuffer from the lexer.

Enumeration Type Documentation

◆ CompiledInstructions

The opcodes for the TorqueScript VM.

Enumerator
OP_FUNC_DECL 
OP_CREATE_OBJECT 
OP_ADD_OBJECT 
OP_END_OBJECT 
OP_JMPIFFNOT 
OP_JMPIFNOT 
OP_JMPIFF 
OP_JMPIF 
OP_JMPIFNOT_NP 
OP_JMPIF_NP 
OP_JMP 
OP_RETURN 
OP_CMPEQ 
OP_CMPGR 
OP_CMPGE 
OP_CMPLT 
OP_CMPLE 
OP_CMPNE 
OP_XOR 
OP_MOD 
OP_BITAND 
OP_BITOR 
OP_NOT 
OP_NOTF 
OP_ONESCOMPLEMENT 
OP_SHR 
OP_SHL 
OP_AND 
OP_OR 
OP_ADD 
OP_SUB 
OP_MUL 
OP_DIV 
OP_NEG 
OP_SETCURVAR 
OP_SETCURVAR_CREATE 
OP_SETCURVAR_ARRAY 
OP_SETCURVAR_ARRAY_CREATE 
OP_LOADVAR_UINT 
OP_LOADVAR_FLT 
OP_LOADVAR_STR 
OP_SAVEVAR_UINT 
OP_SAVEVAR_FLT 
OP_SAVEVAR_STR 
OP_SETCUROBJECT 
OP_SETCUROBJECT_NEW 
OP_SETCUROBJECT_INTERNAL 
OP_SETCURFIELD 
OP_SETCURFIELD_ARRAY 
OP_LOADFIELD_UINT 
OP_LOADFIELD_FLT 
OP_LOADFIELD_STR 
OP_SAVEFIELD_UINT 
OP_SAVEFIELD_FLT 
OP_SAVEFIELD_STR 
OP_STR_TO_UINT 
OP_STR_TO_FLT 
OP_STR_TO_NONE 
OP_FLT_TO_UINT 
OP_FLT_TO_STR 
OP_FLT_TO_NONE 
OP_UINT_TO_FLT 
OP_UINT_TO_STR 
OP_UINT_TO_NONE 
OP_LOADIMMED_UINT 
OP_LOADIMMED_FLT 
OP_TAG_TO_STR 
OP_LOADIMMED_STR 
OP_DOCBLOCK_STR 
OP_LOADIMMED_IDENT 
OP_CALLFUNC_RESOLVE 
OP_CALLFUNC 
OP_ADVANCE_STR 
OP_ADVANCE_STR_APPENDCHAR 
OP_ADVANCE_STR_COMMA 
OP_ADVANCE_STR_NUL 
OP_REWIND_STR 
OP_TERMINATE_REWIND_STR 
OP_COMPARE_STR 
OP_PUSH 
OP_PUSH_FRAME 
OP_BREAK 
OP_INVALID 

Function Documentation

◆ addConsoleParser()

bool addConsoleParser ( const char * ext,
fnGetCurrentFile gcf,
fnGetCurrentLine gcl,
fnParse p,
fnRestart r,
fnSetScanBuffer ssb,
bool def = false )

Add a console parser to the list.

Parameters
extFilename extension
gcfGetCurrentFile function
gclGetCurrentLine function
pParse function
rRestart function
ssbSetScanBuffer function
deftrue if this is the default parser (Note: set this only on the .cs parser!)
Returns
true for success, false for failure (out of memory)
See also
FreeConsoleParserList(), ConsoleParser

◆ CodeToSTE()

StringTableEntry CodeToSTE ( U32 * code,
U32 ip )
inline

◆ compileBlock()

U32 compileBlock ( StmtNode * block,
U32 * codeStream,
U32 ip,
U32 continuePoint,
U32 breakPoint )

◆ compileSTEtoCode()

void compileSTEtoCode ( StringTableEntry ste,
U32 ip,
U32 * codeStream )

◆ consoleAlloc()

void * consoleAlloc ( U32 size)

◆ consoleAllocReset()

void consoleAllocReset ( )

◆ consoleStringToNumber()

F64 consoleStringToNumber ( const char * str,
StringTableEntry file,
U32 line )

◆ evalSTEtoCode()

void evalSTEtoCode ( StringTableEntry ste,
U32 ip,
U32 * codeStream )

◆ freeConsoleParserList()

void freeConsoleParserList ( void )

Free the console parser list.

See also
AddConsoleParser()

◆ getBreakCodeBlock()

CodeBlock * getBreakCodeBlock ( )

◆ getCurrentFloatTable()

CompilerFloatTable * getCurrentFloatTable ( )

◆ getCurrentStringTable()

CompilerStringTable * getCurrentStringTable ( )

◆ getFunctionFloatTable()

CompilerFloatTable & getFunctionFloatTable ( )

◆ getFunctionStringTable()

CompilerStringTable & getFunctionStringTable ( )

◆ getGlobalFloatTable()

CompilerFloatTable & getGlobalFloatTable ( )

◆ getGlobalStringTable()

CompilerStringTable & getGlobalStringTable ( )

◆ getIdentTable()

CompilerIdentTable & getIdentTable ( )

◆ getParserForFile()

ConsoleParser * getParserForFile ( const char * filename)

Get the parser for a particular file based on its extension.

Parameters
filenameFilename of file to obtain parser for
See also
ConsoleParser

◆ precompileBlock()

U32 precompileBlock ( StmtNode * block,
U32 loopCount )

◆ precompileIdent()

void precompileIdent ( StringTableEntry ident)

◆ resetTables()

void resetTables ( )

Helper function to reset the float, string, and ident tables to a base starting state.

◆ setBreakCodeBlock()

void setBreakCodeBlock ( CodeBlock * cb)

◆ setCurrentFloatTable()

void setCurrentFloatTable ( CompilerFloatTable * cst)

◆ setCurrentStringTable()

void setCurrentStringTable ( CompilerStringTable * cst)

Variable Documentation

◆ gConsoleAllocator

DataChunker gConsoleAllocator

◆ gCurBreakBlock

CodeBlock* gCurBreakBlock

◆ gCurrentFloatTable

CompilerFloatTable* gCurrentFloatTable

◆ gCurrentStringTable

CompilerStringTable* gCurrentStringTable

◆ gFunctionFloatTable

CompilerFloatTable gFunctionFloatTable

◆ gFunctionStringTable

CompilerStringTable gFunctionStringTable

◆ gGlobalFloatTable

CompilerFloatTable gGlobalFloatTable

◆ gGlobalStringTable

CompilerStringTable gGlobalStringTable

◆ gIdentTable

CompilerIdentTable gIdentTable

◆ gSyntaxError

bool gSyntaxError = false

◆ STEtoCode

void(* STEtoCode)(StringTableEntry ste, U32 ip, U32 *codeStream) ( StringTableEntry ste,
U32 ip,
U32 * codeStream ) = evalSTEtoCode