Compiler

Engine/source/console/astNodes.cpp

More...

Classes:

Public Enumerations

enum
CompiledInstructions {
  OP_FUNC_DECL 
  OP_CREATE_OBJECT 
  OP_ADD_OBJECT 
  OP_END_OBJECT 
  OP_FINISH_OBJECT 
  OP_JMPIFFNOT 
  OP_JMPIFNOT 
  OP_JMPIFF 
  OP_JMPIF 
  OP_JMPIFNOT_NP 
  OP_JMPIF_NP 
  OP_JMP 
  OP_RETURN 
  OP_RETURN_VOID 
  OP_RETURN_FLT 
  OP_RETURN_UINT 
  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_INC 
  OP_DEC 
  OP_SETCURVAR 
  OP_SETCURVAR_CREATE 
  OP_SETCURVAR_ARRAY 
  OP_SETCURVAR_ARRAY_VARLOOKUP 
  OP_SETCURVAR_ARRAY_CREATE 
  OP_SETCURVAR_ARRAY_CREATE_VARLOOKUP 
  OP_LOADVAR_UINT 
  OP_LOADVAR_FLT 
  OP_LOADVAR_STR 
  OP_LOADVAR_VAR 
  OP_SAVEVAR_UINT 
  OP_SAVEVAR_FLT 
  OP_SAVEVAR_STR 
  OP_SAVEVAR_VAR 
  OP_SETCUROBJECT 
  OP_SETCUROBJECT_NEW 
  OP_SETCUROBJECT_INTERNAL 
  OP_SETCURFIELD 
  OP_SETCURFIELD_ARRAY 
  OP_SETCURFIELD_TYPE 
  OP_SETCURFIELD_ARRAY_VAR 
  OP_SETCURFIELD_THIS 
  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_COPYVAR_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_CALLFUNC_POINTER 
  OP_CALLFUNC_THIS 
  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_UINT 
  OP_PUSH_FLT 
  OP_PUSH_VAR 
  OP_PUSH_THIS 
  OP_PUSH_FRAME 
  OP_ASSERT 
  OP_BREAK 
  OP_ITER_BEGIN 
  OP_ITER_BEGIN_STR 
  OP_ITER 
  OP_ITER_END 
  OP_INVALID 
  MAX_OP_CODELEN 
}

The opcodes for the TorqueScript VM.

Public Typedefs

const char *(*
fnGetCurrentFile )()

Function for GetCurrentFile from the lexer.

S32(*
fnGetCurrentLine )()

Function for GetCurrentLine from the lexer.

S32(*
fnParse )()

Function for Parse from the lexer.

void(*
fnRestart )(FILE *input_file)

Function for Restart from the lexer.

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

Function for SetScanBuffer from the lexer.

Public Functions

bool

Add a console parser to the list.

compileBlock(StmtNode * block, CodeStream & codeStream, U32 ip)

Free the console parser list.

getParserForFile(const char * filename)

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

bool
bool
isThisVar(ExprNode * objectExpr)
optimizeThisPointer(CodeStream & codeStream, ExprNode * arrayExpr, U32 & ip, StringTableEntry slotName)

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

Detailed Description

Public Enumerations

CompiledInstructions

Enumerator

OP_FUNC_DECL
OP_CREATE_OBJECT
OP_ADD_OBJECT
OP_END_OBJECT
OP_FINISH_OBJECT
OP_JMPIFFNOT
OP_JMPIFNOT
OP_JMPIFF
OP_JMPIF
OP_JMPIFNOT_NP
OP_JMPIF_NP
OP_JMP
OP_RETURN
OP_RETURN_VOID
OP_RETURN_FLT
OP_RETURN_UINT
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_INC
OP_DEC
OP_SETCURVAR
OP_SETCURVAR_CREATE
OP_SETCURVAR_ARRAY
OP_SETCURVAR_ARRAY_VARLOOKUP
OP_SETCURVAR_ARRAY_CREATE
OP_SETCURVAR_ARRAY_CREATE_VARLOOKUP
OP_LOADVAR_UINT
OP_LOADVAR_FLT
OP_LOADVAR_STR
OP_LOADVAR_VAR
OP_SAVEVAR_UINT
OP_SAVEVAR_FLT
OP_SAVEVAR_STR
OP_SAVEVAR_VAR
OP_SETCUROBJECT
OP_SETCUROBJECT_NEW
OP_SETCUROBJECT_INTERNAL
OP_SETCURFIELD
OP_SETCURFIELD_ARRAY
OP_SETCURFIELD_TYPE
OP_SETCURFIELD_ARRAY_VAR
OP_SETCURFIELD_THIS
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_COPYVAR_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_CALLFUNC_POINTER
OP_CALLFUNC_THIS
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_UINT
OP_PUSH_FLT
OP_PUSH_VAR
OP_PUSH_THIS
OP_PUSH_FRAME
OP_ASSERT
OP_BREAK
OP_ITER_BEGIN

Prepare foreach iterator.

OP_ITER_BEGIN_STR

Prepare foreach$ iterator.

OP_ITER

Enter foreach loop.

OP_ITER_END

End foreach loop.

OP_INVALID
MAX_OP_CODELEN

The amount of op codes.

The opcodes for the TorqueScript VM.

Public 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.

Public Variables

DataChunker gConsoleAllocator 
CompilerFloatTable * gCurrentFloatTable 
CompilerStringTable * gCurrentStringTable 
ConsoleParser * gDefaultParser 
CompilerFloatTable gFunctionFloatTable 
CompilerStringTable gFunctionStringTable 
CompilerFloatTable gGlobalFloatTable 
CompilerStringTable gGlobalStringTable 
CompilerIdentTable gIdentTable 
ConsoleParser * gParserList 
bool gSyntaxError 
bool OnlyOneThisOptimization 
void(* STEtoCode )(StringTableEntry ste, U32 ip, U32 *ptr)

Public Functions

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

Add a console parser to the list.

Parameters:

ext

Filename extension

gcf

GetCurrentFile function

gcl

GetCurrentLine function

p

Parse function

r

Restart function

ssb

SetScanBuffer function

def

true if this is the default parser (Note: set this only on the .tscript parser!)

return:

true for success, false for failure (out of memory)

see:

FreeConsoleParserList(), ConsoleParser

CodeToSTE(U32 * code, U32 ip)

compileBlock(StmtNode * block, CodeStream & codeStream, U32 ip)

compileSTEtoCode(StringTableEntry ste, U32 ip, U32 * ptr)

consoleAlloc(U32 size)

consoleAllocReset()

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

evalSTEtoCode(StringTableEntry ste, U32 ip, U32 * ptr)

freeConsoleParserList(void )

Free the console parser list.

see:

AddConsoleParser()

getCurrentFloatTable()

getCurrentStringTable()

getFunctionFloatTable()

getFunctionStringTable()

getGlobalFloatTable()

getGlobalStringTable()

getIdentTable()

getParserForFile(const char * filename)

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

Parameters:

filename

Filename of file to obtain parser for

isSimpleVarLookup(ExprNode * arrayExpr, StringTableEntry & varName)

isThisVar(ExprNode * objectExpr)

optimizeThisPointer(CodeStream & codeStream, ExprNode * arrayExpr, U32 & ip, StringTableEntry slotName)

precompileIdent(StringTableEntry ident)

resetTables()

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

setCurrentFloatTable(CompilerFloatTable * cst)

setCurrentStringTable(CompilerStringTable * cst)