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

Class TIFPS3CompExec

Unit

IFPS3CompExec

Declaration

type TIFPS3CompExec = class(TComponent)

Description

TIFPS3CompExec can be used for compiling and executing scripts

Methods

Overview

Public constructor Create(AOwner: TComponent); override;
Public destructor Destroy; override;
Public function AddFunction(Ptr: Pointer; const Decl: string): Boolean;
Public function AddFunctionEx(Ptr: Pointer; const Decl: string; CallingConv: TDelphiCallingConvention): Boolean;
Public function AddMethod(Slf, Ptr: Pointer; const Decl: string): Boolean;
Public function AddMethodEx(Slf, Ptr: Pointer; const Decl: string; CallingConv: TDelphiCallingConvention): Boolean;
Public function AddRegisteredPTRVariable(const VarName, VarType: string): Boolean;
Public function AddRegisteredVariable(const VarName, VarType: string): Boolean;
Public function Compile: Boolean; virtual;
Public function CompilerErrorToStr(I: Longint): string;
Public function Execute: Boolean; virtual;
Public function ExecuteFunction(const Params: array of Variant; const ProcName: string): Variant;
Public procedure GetCompiled(var data: string);
Public function GetProcMethod(const ProcName: string): TMethod;
Public function GetVariable(const Name: string): PIFVariant;
Public function LoadExec: Boolean;
Public procedure SetCompiled(const Data: string);
Public procedure SetPointerToData(const VarName: string; Data: Pointer; aType: TIFTypeRec);
Public function SetVarToInstance(const VarName: string; cl: TObject): Boolean;
Public procedure Stop; virtual;
Public function TranslatePositionPos(Proc, Position: Cardinal; var Pos: Cardinal; var fn: string): Boolean;
Public function TranslatePositionRC(Proc, Position: Cardinal; var Row, Col: Cardinal; var fn: string): Boolean;

Description

Public constructor Create(AOwner: TComponent); override;

Create an instance of the CompExec component

Public destructor Destroy; override;

Dstroy the CompExec component

Public function AddFunction(Ptr: Pointer; const Decl: string): Boolean;

Add a function to the script engine, with cdRegister as a calling convention

Public function AddFunctionEx(Ptr: Pointer; const Decl: string; CallingConv: TDelphiCallingConvention): Boolean;

Add a function to the script engine

Public function AddMethod(Slf, Ptr: Pointer; const Decl: string): Boolean;

Add a method to the script engine, with cdRegister as a calling convention

Public function AddMethodEx(Slf, Ptr: Pointer; const Decl: string; CallingConv: TDelphiCallingConvention): Boolean;

Add a method to the script engine, slf should be the self pointer, ptr should be the procedural pointer, for example: Form1.Show
AddMethod(Form1, @TForm1.Show, 'procedure Show;', cdRegister);

Public function AddRegisteredPTRVariable(const VarName, VarType: string): Boolean;

Add a variable to the script engine that can be used at runtime with the SetPointerToData function

Public function AddRegisteredVariable(const VarName, VarType: string): Boolean;

Add a variable to the script engine that can be used at runtime with the GetVariable function

Public function Compile: Boolean; virtual;

Compile the script

Public function CompilerErrorToStr(I: Longint): string;

Convert a compiler message to a string

Public function Execute: Boolean; virtual;

Execute the compiled script

Public function ExecuteFunction(const Params: array of Variant; const ProcName: string): Variant;

Execute a function

Public procedure GetCompiled(var data: string);

Returns the compiled data, first call Compile

Public function GetProcMethod(const ProcName: string): TMethod;

Get proc as TMethod, cast this to a method pointer and call it

Public function GetVariable(const Name: string): PIFVariant;

Returns the variable with the name Name

Public function LoadExec: Boolean;

Load data into the exec, you only need to call this when SuppressLoadData is true

Public procedure SetCompiled(const Data: string);

Load compiled data in the script engine

Public procedure SetPointerToData(const VarName: string; Data: Pointer; aType: TIFTypeRec);

Set a pointer variable to data

Public function SetVarToInstance(const VarName: string; cl: TObject): Boolean;

Set a variable to an object instance

Public procedure Stop; virtual;

Stop the script

Public function TranslatePositionPos(Proc, Position: Cardinal; var Pos: Cardinal; var fn: string): Boolean;

Translate a Proc+ByteCode position into an offset in the script

Public function TranslatePositionRC(Proc, Position: Cardinal; var Row, Col: Cardinal; var fn: string): Boolean;

Translate a Proc+ByteCode position into an row/col in the script

Properties

Overview

Published property About: string;
Public property Comp: TIFPSPascalCompiler;
Public property CompilerMessageCount: Longint;
Public property CompilerMessages[i: Longint]: TIFPSPascalCompilerMessage;
Published property CompilerOptions: TIFPS3CompOptions;
Published property Defines: TStrings;
Public property Exec: TIFPSDebugExec;
Public property ExecErrorByteCodePosition: Cardinal;
Public property ExecErrorCode: TIFError;
Public property ExecErrorCol: Cardinal;
Public property ExecErrorFileName: string;
Public property ExecErrorParam: string;
Public property ExecErrorPosition: Cardinal;
Public property ExecErrorProcNo: Cardinal;
Public property ExecErrorRow: Cardinal;
Public property ExecErrorToString: string;
Published property MainFileName: string;
Published property OnAfterExecute: TIFPS3CompExecEvent;
Published property OnCompile: TIFPS3CompExecEvent;
Published property OnCompImport: TIFPS3ClOnCompImport;
Published property OnExecImport: TIFPS3ClOnExecImport;
Published property OnExecute: TIFPS3CompExecEvent;
Published property OnLine: TNotifyEvent;
Published property OnNeedFile: TIFPSCEOnNeedFile;
Published property OnVerifyProc: TIFPSCompExecVerifyProc;
Published property Plugins: TIFPS3CEPlugins;
Public property Running: Boolean;
Published property Script: TStrings;
Public property SuppressLoadData: Boolean;
Published property UseDebugInfo: Boolean;
Published property UsePreProcessor: Boolean;

Description

Published property About: string;

About this script engine

Public property Comp: TIFPSPascalCompiler;

PascalCompiler object

Public property CompilerMessageCount: Longint;

Returns the number of compiler messages

Public property CompilerMessages[i: Longint]: TIFPSPascalCompilerMessage;

Return compiler message number I

Published property CompilerOptions: TIFPS3CompOptions;

Compiler options

Published property Defines: TStrings;

Compiler Defines

Public property Exec: TIFPSDebugExec;

Exec object

Public property ExecErrorByteCodePosition: Cardinal;

The bytecode offset the runtime error occured in

Public property ExecErrorCode: TIFError;

Runtime errors: error code

Public property ExecErrorCol: Cardinal;

The Col in the script the error occured in, does not work when DebugInfo = False

Public property ExecErrorFileName: string;

Runtime errors: Exec Error filename

Public property ExecErrorParam: string;

Runtime errors: more information for the error

Public property ExecErrorPosition: Cardinal;

The offset in the script the error occured in, does not work when DebugInfo = False

Public property ExecErrorProcNo: Cardinal;

The procedure number the runtime error occured in

Public property ExecErrorRow: Cardinal;

The Row in the script the error occured in, does not work when DebugInfo = False

Public property ExecErrorToString: string;

Convert an errorcode + errorparam to a string

Published property MainFileName: string;

Main file name, this is only relevant to the errors

Published property OnAfterExecute: TIFPS3CompExecEvent;

OnAfterExecute is called when the script is done executing

Published property OnCompile: TIFPS3CompExecEvent;

OnCompile event is called when the script is about to be compiled

Published property OnCompImport: TIFPS3ClOnCompImport;

OnCompImport is called when you can import your functions and classes into the compiler

Published property OnExecImport: TIFPS3ClOnExecImport;

OnCompImport is called when you can import your functions and classes into the exec

Published property OnExecute: TIFPS3CompExecEvent;

OnExecute event is called when the script is about to the executed, useful for changing variables within the script

Published property OnLine: TNotifyEvent;

OnLine event, is called after each bytecode position, useful for checking messages to make sure longer scripts don't block the application

Published property OnNeedFile: TIFPSCEOnNeedFile;

OnNeedFile is called when the preprocessor is used and an include statement is used

Published property OnVerifyProc: TIFPSCompExecVerifyProc;

OnVerifyProc is called to check if a procedure matches the expected header

Published property Plugins: TIFPS3CEPlugins;

Plugins for this component

Public property Running: Boolean;

Is the script running now?

Published property Script: TStrings;

The current script

Public property SuppressLoadData: Boolean;

 

Published property UseDebugInfo: Boolean;

UseDebugInfo should be true when you want to use debug information, like position information in the script, it does make the executing a bit slower

Published property UsePreProcessor: Boolean;

Use the preprocessor, make sure the OnNeedFile event is assigned