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

Class TIFPSPascalCompiler

Unit

ifpscomp

Declaration

type TIFPSPascalCompiler = class

Description

The actual compiler

Fields

 NameDescription
Protected FAllowNoBegin  
Protected FAllowNoEnd  
Protected FAllowUnit  
Protected FAutoFreeList  
Protected FAvailableTypes  
Protected FBooleanType  
Protected FBreakOffsets  
Protected FClasses  
Protected FConstants  
Protected FContinueOffsets  
Protected FDebugOutput  
Protected FGlobalBlock  
Protected FID  
Protected FIsUnit  
Protected FMessages  
Protected FOnExportCheck  
Protected FOnExternalProc  
Protected FOnUses  
Protected FOnUseVariable  
Protected FOnWriteLine  
Protected FOutput  
Protected FParser  
Protected FProcs  
Protected FRegProcs  
Protected FUsedTypes  
Protected FVars  

Methods

Overview

Public constructor Create;
Public destructor Destroy; override;
Public function AddClass(InheritsFrom: TIFPSCompileTimeClass; aClass: TClass): TIFPSCompileTimeClass;
Public function AddClassN(InheritsFrom: TIFPSCompileTimeClass; const aClass: string): TIFPSCompileTimeClass;
Public function AddConstant(const Name: string; FType: Cardinal): TIFPSConstant;
Public function AddConstantN(const Name, FType: string): TIFPSConstant;
Public function AddDelphiFunction(const Decl: string): TIFPSRegProc;
Public function AddExportVariableN(const Name, FType: string): TIFPSVar;
Public function AddFunction(const Header: string): TIFPSRegProc;
Public procedure AddToFreeList(Obj: TObject);
Public function AddType(const Name: string; const BaseType: TIFPSBaseType): TIFPSType;
Public function AddTypeCopy(const Name: string; TypeNo: Cardinal): TIFPSType;
Public function AddTypeCopyN(const Name, FType: string): TIFPSType;
Public function AddTypeS(const Name, Decl: string): TIFPSType;
Public function AddUsedExportVariableN(const Name, FType: string): TIFPSVar;
Protected function AddUsedFunction(var Proc: TIFPSInternalProcedure): Cardinal;
Protected function AddUsedFunction2(var Proc: TIFPSExternalProcedure): Cardinal;
Public function AddUsedVariable(const Name: string; FType: Cardinal): TIFPSVar;
Public function AddUsedVariableN(const Name, FType: string): TIFPSVar;
Public function AddVariable(const Name: string; FType: Cardinal): TIFPSVar;
Public function AddVariableN(const Name, FType: string): TIFPSVar;
Protected function AT2UT(L: Cardinal): Cardinal;
Protected function CheckCompatProc(P: TIFPSType; ProcNo: Cardinal): Boolean;
Public procedure Clear;
Public function Compile(const s: string): Boolean;
Protected procedure Debug_SavePosition(ProcNo: Cardinal; Proc: TIFPSInternalProcedure);
Protected procedure Debug_WriteParams(ProcNo: Cardinal; Proc: TIFPSInternalProcedure);
Protected procedure DefineStandardProcedures;
Protected procedure DefineStandardTypes;
Protected function DoTypeBlock(FParser: TIfPascalParser): Boolean;
Protected function DoVarBlock(proc: TIFPSInternalProcedure): Boolean;
Public function FindClass(const aClass: string): TIFPSCompileTimeClass;
Protected function FindProc(const Name: string): Cardinal;
Public function FindType(const Name: string): Cardinal;
Protected function GetAvailableType(No: Cardinal): TIFPSType;
Protected function GetAvailableTypeCount: Cardinal;
Public function GetDebugOutput(var s: string): Boolean;
Protected function GetInt(FUseTypes: TIFList; Src: PIfRVariant; var s: Boolean): Longint;
Protected function GetInt64(FUseTypes: TIfList; Src: PIfRVariant; var s: Boolean): Int64;
Protected function GetMsg(l: Longint): TIFPSPascalCompilerMessage;
Protected function GetMsgCount: Longint;
Public function GetOutput(var s: string): Boolean;
Protected function GetReal(FUseTypes: TIFList; Src: PIfRVariant; var s: Boolean): Extended;
Protected function GetString(FUseTypes: TIFList; Src: PIfRVariant; var s: Boolean): string;
Protected function GetType(BaseType: TIFPSBaseType): Cardinal;
Protected function GetTypeCopyLink(p: TIFPSType): TIFPSType;
Protected function GetTypeCopyLinkInt(L: Cardinal): Cardinal;
Protected function GetUInt(FUseTypes: TIFList; Src: PIfRVariant; var s: Boolean): Cardinal;
Protected function GetUsedType(No: Cardinal): TIFPSType;
Protected function GetUsedTypeCount: Cardinal;
Protected function GetWideString(FUseTypes: TIfList; Src: PIfRVariant; var s: Boolean): WideString;
Protected function IsDuplicate(const s: string): Boolean;
Protected function IsIntBoolType(FTypeNo: Cardinal): Boolean;
Protected function MakeDecl(decl: string): string;
Public function MakeError(const Module: string; E: TIFPSPascalCompilerErrorType; const Param: string): TIFPSPascalCompilerMessage;
Protected function MakeExportDecl(decl: string): string;
Public function MakeHint(const Module: string; E: TIFPSPascalCompilerHintType; const Param: string): TIFPSPascalCompilerMessage;
Public function MakeWarning(const Module: string; E: TIFPSPascalCompilerWarningType; const Param: string): TIFPSPascalCompilerMessage;
Protected function NewProc(const OriginalName, Name: string): TIFPSInternalProcedure;
Protected procedure ParserError(Parser: TObject; Kind: TIFParserErrorKind);
Protected function PreCalc(FUseTypes: TIFList; Var1Mod: Byte; var1: PIFRVariant; Var2Mod: Byte; Var2: PIfRVariant; Cmd: TIFPSBinOperatorType; Pos, Row, Col: Cardinal): Boolean;
Protected function ProcessFunction(AlwaysForward: Boolean): Boolean;
Protected function ProcessLabel(Proc: TIFPSInternalProcedure): Boolean;
Protected function ProcessLabelForwards(Proc: TIFPSInternalProcedure): Boolean;
Protected function ProcessSub(BlockInfo: TIFPSBlockInfo): Boolean;
Protected function ReadConstant(FParser: TIfPascalParser; StopOn: TIfPasToken): PIfRVariant;
Protected function ReadType(const Name: string; FParser: TIfPascalParser): Cardinal;
Protected procedure ReplaceTypes(var s: string);
Protected procedure UpdateRecordFields(r: TIFPSType);
Protected function UseAvailableType(No: Cardinal): Cardinal;
Protected procedure WriteDebugData(const s: string);

Description

Public constructor Create;

Create

Public destructor Destroy; override;

Destroy the current instance of the script compiler

Public function AddClass(InheritsFrom: TIFPSCompileTimeClass; aClass: TClass): TIFPSCompileTimeClass;

Add a class

Public function AddClassN(InheritsFrom: TIFPSCompileTimeClass; const aClass: string): TIFPSCompileTimeClass;

Add a class without using the actual class

Public function AddConstant(const Name: string; FType: Cardinal): TIFPSConstant;

Add a constant

Public function AddConstantN(const Name, FType: string): TIFPSConstant;

Add a constant

Public function AddDelphiFunction(const Decl: string): TIFPSRegProc;

Add a function and make it possible to directly call this function

Public function AddExportVariableN(const Name, FType: string): TIFPSVar;

Add a variable and export it

Public function AddFunction(const Header: string): TIFPSRegProc;

Add a function

Public procedure AddToFreeList(Obj: TObject);

Add an object to the auto-free list

Public function AddType(const Name: string; const BaseType: TIFPSBaseType): TIFPSType;

add a type

Public function AddTypeCopy(const Name: string; TypeNo: Cardinal): TIFPSType;

Add a type copy type

Public function AddTypeCopyN(const Name, FType: string): TIFPSType;

Add a type copy type

Public function AddTypeS(const Name, Decl: string): TIFPSType;

Add a type declared in a string

Public function AddUsedExportVariableN(const Name, FType: string): TIFPSVar;

Add an used variable and export it

Protected function AddUsedFunction(var Proc: TIFPSInternalProcedure): Cardinal;

 

Protected function AddUsedFunction2(var Proc: TIFPSExternalProcedure): Cardinal;

 

Public function AddUsedVariable(const Name: string; FType: Cardinal): TIFPSVar;

Add an used variable

Public function AddUsedVariableN(const Name, FType: string): TIFPSVar;

add an used variable (with named type)

Public function AddVariable(const Name: string; FType: Cardinal): TIFPSVar;

Add a variable

Public function AddVariableN(const Name, FType: string): TIFPSVar;

Add a variable

Protected function AT2UT(L: Cardinal): Cardinal;

 

Protected function CheckCompatProc(P: TIFPSType; ProcNo: Cardinal): Boolean;

 

Public procedure Clear;

Clear the current data

Public function Compile(const s: string): Boolean;

Compile a script (s)

Protected procedure Debug_SavePosition(ProcNo: Cardinal; Proc: TIFPSInternalProcedure);

 

Protected procedure Debug_WriteParams(ProcNo: Cardinal; Proc: TIFPSInternalProcedure);

 

Protected procedure DefineStandardProcedures;

 

Protected procedure DefineStandardTypes;

 

Protected function DoTypeBlock(FParser: TIfPascalParser): Boolean;

 

Protected function DoVarBlock(proc: TIFPSInternalProcedure): Boolean;

 

Public function FindClass(const aClass: string): TIFPSCompileTimeClass;

Find a class

Protected function FindProc(const Name: string): Cardinal;

 

Public function FindType(const Name: string): Cardinal;

Search for a type

Protected function GetAvailableType(No: Cardinal): TIFPSType;

 

Protected function GetAvailableTypeCount: Cardinal;

 

Public function GetDebugOutput(var s: string): Boolean;

Return the debugger output

Protected function GetInt(FUseTypes: TIFList; Src: PIfRVariant; var s: Boolean): Longint;

 

Protected function GetInt64(FUseTypes: TIfList; Src: PIfRVariant; var s: Boolean): Int64;

 

Protected function GetMsg(l: Longint): TIFPSPascalCompilerMessage;

 

Protected function GetMsgCount: Longint;

 

Public function GetOutput(var s: string): Boolean;

Return the output

Protected function GetReal(FUseTypes: TIFList; Src: PIfRVariant; var s: Boolean): Extended;

 

Protected function GetString(FUseTypes: TIFList; Src: PIfRVariant; var s: Boolean): string;

 

Protected function GetType(BaseType: TIFPSBaseType): Cardinal;

 

Protected function GetTypeCopyLink(p: TIFPSType): TIFPSType;

 

Protected function GetTypeCopyLinkInt(L: Cardinal): Cardinal;

 

Protected function GetUInt(FUseTypes: TIFList; Src: PIfRVariant; var s: Boolean): Cardinal;

 

Protected function GetUsedType(No: Cardinal): TIFPSType;

 

Protected function GetUsedTypeCount: Cardinal;

 

Protected function GetWideString(FUseTypes: TIfList; Src: PIfRVariant; var s: Boolean): WideString;

 

Protected function IsDuplicate(const s: string): Boolean;

 

Protected function IsIntBoolType(FTypeNo: Cardinal): Boolean;

 

Protected function MakeDecl(decl: string): string;

 

Public function MakeError(const Module: string; E: TIFPSPascalCompilerErrorType; const Param: string): TIFPSPascalCompilerMessage;

Add an error the messages

Protected function MakeExportDecl(decl: string): string;

 

Public function MakeHint(const Module: string; E: TIFPSPascalCompilerHintType; const Param: string): TIFPSPascalCompilerMessage;

Add a hint to the messages

Public function MakeWarning(const Module: string; E: TIFPSPascalCompilerWarningType; const Param: string): TIFPSPascalCompilerMessage;

Add a warning to the messages

Protected function NewProc(const OriginalName, Name: string): TIFPSInternalProcedure;

 

Protected procedure ParserError(Parser: TObject; Kind: TIFParserErrorKind);

 

Protected function PreCalc(FUseTypes: TIFList; Var1Mod: Byte; var1: PIFRVariant; Var2Mod: Byte; Var2: PIfRVariant; Cmd: TIFPSBinOperatorType; Pos, Row, Col: Cardinal): Boolean;

 

Protected function ProcessFunction(AlwaysForward: Boolean): Boolean;

 

Protected function ProcessLabel(Proc: TIFPSInternalProcedure): Boolean;

 

Protected function ProcessLabelForwards(Proc: TIFPSInternalProcedure): Boolean;

 

Protected function ProcessSub(BlockInfo: TIFPSBlockInfo): Boolean;

 

Protected function ReadConstant(FParser: TIfPascalParser; StopOn: TIfPasToken): PIfRVariant;

 

Protected function ReadType(const Name: string; FParser: TIfPascalParser): Cardinal;

 

Protected procedure ReplaceTypes(var s: string);

 

Protected procedure UpdateRecordFields(r: TIFPSType);

 

Protected function UseAvailableType(No: Cardinal): Cardinal;

 

Protected procedure WriteDebugData(const s: string);

 

Properties

Overview

Public property AllowNoBegin: Boolean;
Public property AllowNoEnd: Boolean;
Public property AllowUnit: Boolean;
Public property ID: Pointer;
Public property IsUnit: Boolean;
Public property Msg[l: Longint]: TIFPSPascalCompilerMessage;
Public property MsgCount: Longint;
Public property OnExportCheck: TIFPSOnExportCheck;
Public property OnExternalProc: TIFPSOnExternalProc;
Public property OnUses: TIFPSOnUses;
Public property OnUseVariable: TIFPSOnUseVariable;
Public property OnWriteLine: TIFPSOnWriteLineEvent;

Description

Public property AllowNoBegin: Boolean;

Allow no main begin/end

Public property AllowNoEnd: Boolean;

Allow it to have no END on the script (only works when AllowNoBegin is true)

Public property AllowUnit: Boolean;

Allow a unit instead of program

Public property ID: Pointer;

Tag for this object, use as you like

Public property IsUnit: Boolean;

contains true if the current file is a unit

Public property Msg[l: Longint]: TIFPSPascalCompilerMessage;

The messages/warnings/errors

Public property MsgCount: Longint;

contains the number of messages

Public property OnExportCheck: TIFPSOnExportCheck;

OnExportCheck is called for each function to check if it needs to be exported and has the correct parameters

Public property OnExternalProc: TIFPSOnExternalProc;

OnExternalProc is called when an external token is found after a procedure header

Public property OnUses: TIFPSOnUses;

OnUses i scalled for each Uses and always first with 'SYSTEM' parameters

Public property OnUseVariable: TIFPSOnUseVariable;

The OnUseVariant event is called when a variable is used by the script engine

Public property OnWriteLine: TIFPSOnWriteLineEvent;

OnWriteLine is called after each line