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-2004 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 AnsiUppercase(s : string) : string;
Function AnsiLowercase(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;
function StrToInt64(s: string): int64; // only when int64 is available
function Int64ToStr(i: Int64): string; // only when int64 is available
function SizeOf(c: const): Longint;


type
TVarType = Word;
varEmpty = varempty;
varNull = varnull;
varSmallint = varsmallint;
varInteger = varinteger;
varSingle = varsingle;
varDouble = vardouble;
varCurrency = varcurrency;
varDate = vardate;
varOleStr = varolestr;
varDispatch = vardispatch;
varError = varerror;
varBoolean = varboolean;
varVariant = varvariant;
varUnknown = varunknown;
varShortInt = varshortint;
// D6+ varByte = varbyte;
// D6+ varWord = varword;
// D6+ varLongWord = varlongword;
// D6+ varInt64 = varint64;
// D6+ varStrArg = varstrarg;
varString = varstring;
varAny = varany;
varTypeMask = vartypemask;
varArray = vararray;
varByRef = varByRef;

function Unassigned: Variant;
function Null: Variant;
function VarType(const V: Variant): TVarType;

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, erInterfaceNotSupported, 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;


function IDispatchInvoke(Self: IDispatch; PropertySet: Boolean; const Name: WideString; Par: array of variant): variant;

Classes, Interfaces and Objects

NameDescription
Class EIFPSCompilerException Compiler exception
Class TIFPSArrayType Array type information
Class TIFPSAttribute An attribute
Class TIFPSAttributes A collection of attributes
Class TIFPSAttributeType An attribute type
Class TIFPSAttributeTypeField An attribute type field
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 TIFPSDelphiClassItem an item of a delphi class
Class TIFPSDelphiClassItemConstructor delphi class constructor type info
Class TIFPSDelphiClassItemMethod delphi class method type info
Class TIFPSDelphiClassItemProperty delphi class property type info
Class TIFPSEnumType an TIFPSEnumType holds information for enumerated types
Class TIFPSExternalProcedure An external procedure
Class TIFPSInterface Interface type info
Class TIFPSInterfaceMethod Interface Method type info
Class TIFPSInterfaceType TIFPSClassType is used to store interface type information for the script engine
Class TIFPSInternalProcedure TIFPSInternalProcedure stores information for scripted procedures
Class TIFPSParameter TIFPSParameter is used to store parameter info
Class TIFPSParameterDecl  
Class TIFPSParameters TIFPSParameters is a list of TIFPSParameter
Class TIFPSParametersDecl  
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 ExportCheck(Sender: TIFPSPascalCompiler; Proc: TIFPSInternalProcedure; Types: array of TIFPSBaseType; Modes: array of TIFPSParameterMode): Boolean;
function IFPS3_mi2s(i: Cardinal): string;
function ParseMethod(Owner: TIFPSPascalCompiler; const FClassName: string; Decl: string; var OrgName: string; DestDecl: TIFPSParametersDecl; 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 ExportCheck(Sender: TIFPSPascalCompiler; Proc: TIFPSInternalProcedure; Types: array of TIFPSBaseType; Modes: array of TIFPSParameterMode): Boolean;

Check the proc definition. Types[0] is the result type (or 0). Modes specify the parameter passing mode (in, var). High(Types) should always be 1 more than High(Modes).

function IFPS3_mi2s(i: Cardinal): string;

This function returns

function ParseMethod(Owner: TIFPSPascalCompiler; const FClassName: string; Decl: string; var OrgName: string; DestDecl: TIFPSParametersDecl; var Func: TPMFuncType): Boolean;

Parse a method header

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

Set the export name of a global variable

Types

NameDescription
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
TIFPSApplyAttributeToProc Event function
TIFPSApplyAttributeToType Event function
TIFPSBinOperatorType The kind of binairy operand
TIFPSDuplicCheck  
TIFPSOnExportCheck See TIFPSPascalCompiler.OnExportCheck
TIFPSOnExternalProc See TIFPSPascalCompiler.OnExternalProc
TIFPSOnNotify  
TIFPSOnTranslateLineInfoProc See TIFPSPascalCompiler.OnTranslateLineInfo
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

NameDescription
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>