Units
Class Hierarchy
Classes, Interfaces and Objects
Types
Variables
Constants
Functions and Procedures
Identifiers

Unit ifps3utl

Description

Misc Types and functions

This unit contains types and functions used by the compiler and executer

Bytecode Format:
Address Space
0..GlobalVarCount -1 = GlobalVars
IFPSAddrStackStart div 2 .. IFPSAddrStackStart -1 = negative stack
IFPSAddrStackStart... = positive stack


TIFPSVariable = packed record
VarType: Byte;
case VarType of
0: Address: LongWord;
1: TypeNo: LongWord; Data: TData
2: Address_: LongWord; RecFieldNo: Longword;
3: Address__: LongWord; ReadRecFieldNoFrom: LongWord;
end;
TIFPSHeader = packed record
HDR: LongWord;
IFPSBuildNo: LongWord;
TypeCount: LongWord;
ProcCount: LongWord;
VarCount: LongWord;
MainProcNo: LongWord;
ImportTableSize: LongWord; // Set to zero, always
Types: array[0..typcount-1] of TIFPSType;
procs: Array[0..proccount-1] of TIFPSProc;
var: array[0..varcount-1] of TIFPSVar;
ImportTable: array[0..Importtablesize-1] of TIFPSImportItem;

end;
// Import table isn't used yet
TIFPSAttributes = packed record
Count: Longint;
Attributes: array[0..Count-1] of TIFPSAttribute;
end;

TIFPSAttribute = packed record
AttribName: string;
FieldCount: Longint;
TypeNo: LongWord; Data: TData;
end;

TIFPSType = packed record
BaseType: TIFPSBaseType;

Record:
TypeCount: Longword;
Types: array[0..TypeCount-1] of LongWord;
Array:
SubType: LongWord;
BaseType and 128:
Export: Name: MyString;

Attributes: TIFPSAttributes;
end;
TIFPSProc = packed record
Flags: Byte;
Flags:
1 = Imported; (nameLen: Byte; Name: array[0..namelen-1] of byte) else (Offset, Length: Longint);
2 = Export; (only for internal procs); Name, Decl: MyString;
3 = Imported2; nameLen: Byte; Name: array[0..namelen-1] of byte; ParamsLength: Longint; Params: array[0..paramslength-1]of byte;
4 = With attributes (attr: TIFPSAttributes)

end;

TIFPSVar = packed record
TypeNo: LongWord;
Flags: Byte;

1 = Exported; Name: MyString

end;


DebugData:
#0+ Proc0Name+#1+Proc1Name+#1+Proc2Name+#1#0
#1+ Var0Name+#1+Var1Name+#1+Var2Name+#1#0
#2+ MI2S(FuncNo)+ Param0Name+#1+Param0Name+#1#0
#3+ MI2S(FuncNo)+ Var1Name+#1+Var1Name+#1#0
#4+ FileName + #1 + MI2S(FuncNo)+ MI2S(Pos)+ MI2s(Position)+MI2S(Row)+MI2s(Col)

Classes, Interfaces and Objects

NameDescription
Class TIfList TIfList is the list class used in IFPS3
Class TIfPascalParser TIfPacalParser is the parser used to parse the scripts
Class TIfStringList TIFStringList is the string list class used by IFPS3

Functions and Procedures

Overview

function FastLowerCase(const s: String): string;
function FastUpperCase(const s: String): string;
function FloatToStr(E: Extended): string;
function Fw(const S: string): string;
function GRFW(var s: string): string;
function GRLW(var s: string): string;
function IntToStr(I: LongInt): string;
function MakeHash(const s: string): Longint;
function StrToFloat(const s: string): Extended;
function StrToInt(const S: string): LongInt;
function StrToIntDef(const S: string; Def: LongInt): LongInt;

Description

function FastLowerCase(const s: String): string;

Fast lowercase

function FastUpperCase(const s: String): string;

Fast uppercase

function FloatToStr(E: Extended): string;

Convert a float to a string

function Fw(const S: string): string;

Return the first word of a string

function GRFW(var s: string): string;

Get the first word and remove it

function GRLW(var s: string): string;

 

function IntToStr(I: LongInt): string;

Integer to string conversion

function MakeHash(const s: string): Longint;

Make a hash of a string

function StrToFloat(const s: string): Extended;

 

function StrToInt(const S: string): LongInt;

String to integer

function StrToIntDef(const S: string; Def: LongInt): LongInt;

String to integer

Types

NameDescription
IPointer  
PPointerList PPointerList is pointing to an array of pointers
tbtchar Chat type
tbtCurrency Currency
TbtDouble Double
TbtExtended Extended
TbtS16 Smallint
TbtS32 Integer/Longint
tbts64 An 8 byte signed integer (int64)
TbtS8 Shortint
TbtSingle Single
TbtString String/Pchar
TbtU16 word
TbtU32 Cardinal/Longword
TbtU8 Byte
tbtwidechar widechar type
tbtwidestring widestring type
TIFParserErrorEvent  
TIFParserErrorKind TIFParserErrorKind is used to store the parser error
TIfPasToken TIFPasToken is used to store the type of the current token
TIFPSBaseType TIFPSBaseType is the most basic type -type
TIFPSCallingConvention calling convention type
TIFPSVariableType OnUseVariable TIFPSVariableType is used in TIFPSComp.OnUseVariable event
TPointerList An array of pointers

Constants

NameDescription
btArray An array
btChar a Char (1 byte)
btClass class
btCurrency Currency
btDouble A 8 byte float (double)
btEnum Compile time enumeration; This will be a btu32 when compiled
btExtended A 10 byte float (extended)
btInterface Interface
btPChar A PChar (internally the same as a string)
btPointer A pointer
btProcPtr Compile time procedural pointer (will be btu32 when compiled)
btRecord A record
btResourcePointer A resource pointer: Variable that can contain things from outside the script engine
btReturnAddress Executer internal type for return addresses, can not be used as a type
btS16 A 2 byte signed integer (smallint)
btS32 A 4 byte signed integer (Integer/Longint)
btS64 An 8 byte signed integer (int64)
btS8 A 1 byte signed integer (Shortint)
btSet Set
btSingle A 4 byte float (single)
btStaticArray Static array
btString A string
btType Compile time: a type
btU16 A 2 byte unsigned integer (word)
btU32 A 4 byte unsigned integer (cardinal/longword)
btU8 A 1 byte unsigned integer (byte)
btVariant A variant
btWideChar A widechar
btWideString A wide string
CM_A Script internal command: Assign command
Command: TIFPSCommand;
VarDest, // no data
VarSrc: TIFPSVariable;
cm_bn Script internal command: Boolean NOT
Command: TIFPSCommand;
Var: TIFPSVariable;
Cm_C Script internal command: Call
Command: TIFPSCommand;
ProcNo: Longword;
CM_CA Script internal command: Calculate Command
Command: TIFPSCommand;
CalcType: Byte;

0 = +
1 = -
2 = *
3 = /
4 = MOD
5 = SHL
6 = SHR
7 = AND
8 = OR
9 = XOR

VarDest, // no data
VarSrc: TIFPSVariable;

Cm_CG Script internal command: Conditional Goto
Command: TIFPSCommand;
NewPosition: LongWord; //relative to end of this instruction
Var: TIFPSVariable; // no data
Cm_CNG Script internal command: Conditional NOT Goto
Command: TIFPSCommand;
NewPosition: LongWord; // relative to end of this instruction
Var: TIFPSVariable; // no data
CM_CO Script internal command: Compare
Command: TIFPSCommand;
CompareType: Byte;

0 = >=
1 = <=
2 = >
3 = <
4 = <>
5 = =

IntoVar: TIFPSAssignment;
Compare1, Compare2: TIFPSAssigment;
Cm_cv Script internal command: Call Var
Command: TIFPSCommand;
Var: TIFPSVariable;
cm_dec Script internal command: Dec
Command: TIFPSCommand;
Var: TIFPSVariable;
cm_fg Script internal command: Flag Goto
Command: TIFPSCommand;
Where: Cardinal;
Cm_G Script internal command: Goto
Command: TIFPSCommand;
NewPosition: Longint; //relative to end of this instruction
cm_in Script internal command: Integer NOT
Command: TIFPSCommand;
Where: Cardinal;
cm_inc Script internal command: Inc
Command: TIFPSCommand;
Var: TIFPSVariable;
cm_nop Script internal command: nop
Command: TIFPSCommand;
CM_P Script internal command: Push
Command: TIFPSCommand;
Var: TIFPSVariable;
CM_PO Script internal command: Pop
Command: TIFPSCommand;
cm_poexh Script internal command: Pop Exception Handler
Command:TIFPSCommand;
Position: Byte;
0 = end of try/finally/exception block;
1 = end of first finally
2 = end of except
3 = end of second finally

Cm_Pt Script internal command: Push Type
Command: TIFPSCommand;
FType: LongWord;
cm_puexh Script internal command: Push Exception Handler
Command: TIFPSCommand;
FinallyOffset,
ExceptionOffset, // FinallyOffset or ExceptionOffset need to be set.
Finally2Offset,
EndOfBlock: Cardinal;
CM_PV Script internal command: Push Var
Command: TIFPSCommand;
Var: TIFPSVariable;
Cm_R Script internal command: Ret
Command: TIFPSCommand;
cm_sf Script internal command: Set Flag
Command: TIFPSCommand;
Var: TIFPSVariable;
DoNot: Boolean;
cm_sp Script internal command: Set Pointer
Command: TIFPSCommand;
VarDest: TIFPSVariable;
VarSrc: TIFPSVariable;
cm_spc Script internal command: Set Stack Pointer To Copy
Command: TIFPSCommand;
Where: Cardinal;
Cm_ST Script internal command: Set Stack Type
Command: TIFPSCommand;
NewType: LongWord;
OffsetFromBase: LongWord;
cm_vm Script internal command: Var Minus
Command: TIFPSCommand;
Var: TIFPSVariable;
FCapacityInc The Capacity increment that list uses
FMaxCheckCount The maximum number of "resize" operations on the list before it's recreated
IFPSAddrNegativeStackStart Start of the negative stack
IFPSAddrStackStart Start of the positive stack
IFPSCurrentBuildNo The current build of the compiler and executer.
IFPSCurrentversion The current version of the script engine
IFPSLowBuildSupport The lowest supported build by the executer.
IFPSMainProcName The name of the main proc
IFPSMainProcNameOrg The original name for the main proc, can be used for user purposes
IFPSValidHeader The header of a compiled IFPS3 binary must start with this
MaxListSize Maximum number of items in a list

Author

Carlo Kok <ck@carlo-kok.com>