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

# Unit ifpscomp

## Description

The compiler part of the script engine

ifpscomp is the compiler part of the script engine. It implements a pascal to byte code compiler that can be loaded with executer part of the script engine.
Innerfuse Pascal Script III
Copyright (C) 2000-2003 by Carlo Kok
Standard functions registered by the script engine.
`function floattostr(e: extended): string;
function inttostr(i: Longint): string;
function strtoint(s: string): Longint;
function strtointdef(s: string; def: Longint): Longint;
function copy(s: string; ifrom, icount: Longint): string;
function pos(substr, s: string): Longint;
procedure delete(var s: string; ifrom, icount: Longint);
procedure insert(s: string; var s2: string; ipos: Longint);
function getarraylength(var v: array): Integer;
procedure setarraylength(var v: array; i: Integer);
Function StrGet(var S : String; I : Integer) : Char;
procedure StrSet(c : Char; I : Integer; var s : String);
Function Uppercase(s : string) : string;
Function Lowercase(s : string) : string;
Function Trim(s : string) : string;
Function Length(s : String) : Longint;
procedure SetLength(var S: String; L: Longint);
Function Sin(e : Extended) : Extended;
Function Cos(e : Extended) : Extended;
Function Sqrt(e : Extended) : Extended;
Function Round(e : Extended) : Longint;
Function Trunc(e : Extended) : Longint;
Function Int(e : Extended) : Extended;
Function Pi : Extended;
Function Abs(e : Extended) : Extended;
function StrToFloat(s: string): Extended;
Function FloatToStr(e : Extended) : String;
Function Padl(s : string;I : longInt) : string;
Function Padr(s : string;I : longInt) : string;
Function Padz(s : string;I : longInt) : string;
Function Replicate(c : char;I : longInt) : string;
Function StringOfChar(c : char;I : longInt) : string;
type
TVarType = (vtNull, vtString, vtU64, vtS32, vtU32, vtS16, vtU16, vtS8, vtU8, vtSingle, vtDouble, vtExtended, vtResourcePointer, vtArray, vtRecord, vtChar, vtWideString, vtWideChar);
function VarGetType(x: Variant): TVarType;
function Null: Variant;
type
TIFException = (ErNoError, erCannotImport, erInvalidType, ErInternalError,
erInvalidHeader, erInvalidOpcode, erInvalidOpcodeParameter, erNoMainProc,
erOutOfGlobalVarsRange, erOutOfProcRange, ErOutOfRange, erOutOfStackRange,
ErTypeMismatch, erUnexpectedEof, erVersionError, ErDivideByZero, ErMathError,
erCouldNotCallProc, erOutofRecordRange, erOutOfMemory, erException,
erNullPointerException, erNullVariantError, erCustomError);
procedure RaiseLastException;
procedure RaiseException(Ex: TIFException; Param: string);
function ExceptionType: TIFException;
function ExceptionParam: string;
function ExceptionProc: Cardinal;
function ExceptionPos: Cardinal;
function ExceptionToString(er: TIFException; Param: string): string;
`

## Classes, Interfaces and Objects

Name | Description
--- | ---
Class `EIFPSCompilerException` | Compiler exception
Class `TIFPSArrayType` | Array type information
Class `TIFPSBinValueOp` | TIFPSBinValueOp stores information about binairy calculations
Class `TIFPSBlockInfo` | BlockInfo is used to store the current scope the script engine is current in. There is no need to use or create this object
Class `TIFPSClassType` | TIFPSClassType is used to store class type information for the script engine
Class `TIFPSCompileTimeClass` | Compiletime class
Class `TIFPSConstant` | TIFPSContant contains information about constants
Class `TIFPSEnumType` | an TIFPSEnumType holds information for enumerated types
Class `TIFPSExternalClass` | TIFPSExternalClass is used when external classes need to be called, External classes are virtual objects that could be anything when compiled, from integers to actual delphi classes
Class `TIFPSExternalProcedure` | An external procedure
Class `TIFPSInternalProcedure` | TIFPSInternalProcedure stores information for scripted procedures
Class `TIFPSParameter` | TIFPSParameter is used to store parameter info
Class `TIFPSParameters` | TIFPSParameters is a list of `TIFPSParameter`
Class `TIFPSPascalCompiler` | The actual compiler
Class `TIFPSPascalCompilerError` | error message class
Class `TIFPSPascalCompilerHint` | Hint message class
Class `TIFPSPascalCompilerMessage` | TIFPSPascalCompilerMessage is the base class for compiler messages
Class `TIFPSPascalCompilerWarning` | Warning message class
Class `TIFPSProceduralType` | A procedural pointer type
Class `TIFPSProcedure` | TIFPSProcedure is the base type for all procedures
Class `TIFPSProcVar` | TIFPSProcVar is used to store local variables
Class `TIFPSRecordFieldTypeDef` | TIFPSRecordFieldTypeDef is used to store record field information, see `TIFPSRecordType`
Class `TIFPSRecordType` | TIFPSRecordType is used to store information about record types
Class `TIFPSRegProc` | TIFPSRegProc contains all information needed for external function registered to the script engine.
Class `TIFPSSetType` | TIFPSSetType stores set type info
Class `TIFPSStaticArrayType` | TIFPSStaticArrayType holds information to store static arrays
Class `TIFPSSubItem` | TIFPSSubItem is a base case used when storing record or array field number information
Class `TIFPSSubNumber` | Field no constant number
Class `TIFPSSubValue` | Field no by value
Class `TIFPSType` | TIFPSType is the base class for all types
Class `TIFPSTypeLink` | a type link is an alias for another type
Class `TIFPSUnValueOp` | TIFPSUnValueOp stores information about unairy calculations
Class `TIFPSValue` | Base class for all values
Class `TIFPSValueAllocatedStackVar` | A temporary value used by the script engine
Class `TIFPSValueArray` | An array constant
Class `TIFPSValueData` | A Data value
Class `TIFPSValueGlobalVar` | A global variable
Class `TIFPSValueLocalVar` | A local variable
Class `TIFPSValueNil` | TIFPSValueNil is used to hold NIL values, that have no actual value until it's assigned to another type
Class `TIFPSValueParamVar` | A parameter variable
Class `TIFPSValueProc` | The base class for all procedure calls
Class `TIFPSValueProcNo` | A procedure by number call
Class `TIFPSValueProcPtr` | A procedural pointer
Class `TIFPSValueProcVal` | A procedure by value call
Class `TIFPSValueReplace` | TIFPSValueReplace is used internally by the script engine when it needs to replace a value with something else, usually when writing the byte code
Class `TIFPSValueVar` | The base class for all variables
Class `TIFPSVar` | TIFPSVar is used to store global variables

## Functions and Procedures

### Overview

`function AddImportedClassVariable(Sender: TIFPSPascalCompiler; const VarName, VarType: string): Boolean;`
`function IFPS3_mi2s(i: Cardinal): string;`
`function ParseMethod(Owner: TIFPSPascalCompiler; const FClassName: string; const Decl: string; var DName, DStr: string; var Func: TPMFuncType): Boolean;`
`procedure SetVarExportName(P: TIFPSVar; const ExpName: string);`

### Description

`function AddImportedClassVariable(Sender: TIFPSPascalCompiler; const VarName, VarType: string): Boolean;`

Add an imported class variable, this should be assigned at runtime before executing

`function IFPS3_mi2s(i: Cardinal): string;`

This function returns

`function ParseMethod(Owner: TIFPSPascalCompiler; const FClassName: string; const Decl: string; var DName, DStr: string; var Func: TPMFuncType): Boolean;`

Parse a method header

`procedure SetVarExportName(P: TIFPSVar; const ExpName: string);`

Set the export name of a global variable

## Types

Name | Description
--- | ---
PIFPSConstant | PIFPSContant is an alias to a TIFPSConstant
PIFPSProcVar | PIFPSProcVar is an alias for `TIFPSProcVar`
PIFPSRecordFieldTypeDef | PIFPSRecordFieldTypeDef is an alias to `TIFPSRecordFieldTypeDef`
PIFPSRegProc | Pointer to a `TIFPSRegProc`
PIFPSType | PIFPSType is a alias to a `TIFPSType`
PIFPSVar | TIFPSVar is an alias for a TIFPSVar
PIfRVariant | Pointer to a `TIfRVariant` variant
TIFPSBinOperatorType | The kind of binairy operand
TIFPSExportType | The export type for this internal procedure. etExportName will only export it's name, and etExportDecl will also export it's declaration, this is required for event functions to work
TIFPSOnExportCheck | See TIFPSPascalCompiler.OnExportCheck
TIFPSOnExternalProc | See TIFPSPascalCompiler.OnExternalProc
TIFPSOnUses | See TIFPSPascalCompiler.OnUses
TIFPSOnUseVariable | See TIFPSPascalCompiler.OnUseVariable
TIFPSOnWriteLineEvent | See TIFPSPascalCompiler.OnWriteLine
TIFPSParameterMode | The mode this parameter was passed
TIFPSPascalCompilerErrorType | Is used to store the type of a compiler error
TIFPSPascalCompilerHintType | Used to store the type of a hint
TIFPSPascalCompilerWarningType | Is used to store the type of a warning
TIFPSPropType | Property type: iptRW = Read/Write; iptR= readonly; iptW= writeonly
TIFPSSubOptType | Internal type used to store the current block type
TIFPSUnOperatorType | The kind of unair operand
TIfRVariant | A compile time variant. FType is the type number of this variant. Basetype is the basetype of the variant (see `TIFPSBaseType`).
TPMFuncType | The parsed function type

## Constants

Name | Description
--- | ---
InvalidVal | Invalid value, this is returned by most functions of IFPS3 that return a cardinal, when they fail

## Author

Carlo Kok <ck@carlo-kok.com>