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 FAttributeTypes  
Protected FAutoFreeList  
Protected FBooleanShortCircuit  
Protected FBreakOffsets  
Protected FClasses  
Protected FConstants  
Protected FContinueOffsets  
Protected FCurrUsedTypeNo  
Protected FDebugOutput  
Protected FDefaultBoolType  
Protected FGlobalBlock  
Protected FID  
Protected FInterfaces  
Protected FIsUnit  
Protected FMessages  
Protected FOnBeforeCleanup  
Protected FOnBeforeOutput  
Protected FOnExportCheck  
Protected FOnExternalProc  
Protected FOnTranslateLineInfo  
Protected FOnUses  
Protected FOnUseVariable  
Protected FOnWriteLine  
Protected FOutput  
Protected FParser  
Protected FProcs  
Protected FRegProcs  
Protected FTypes  
Protected FVars  

Methods

Overview

Public constructor Create;
Public destructor Destroy; override;
Public function AddAttributeType: TIFPSAttributeType;
Public function AddClass(InheritsFrom: TIFPSCompileTimeClass; aClass: TClass): TIFPSCompileTimeClass;
Public function AddClassN(InheritsFrom: TIFPSCompileTimeClass; const aClass: string): TIFPSCompileTimeClass;
Public function AddConstant(const Name: string; FType: TIFPSType): TIFPSConstant;
Public function AddConstantN(const Name, FType: string): TIFPSConstant;
Public function AddDelphiFunction(const Decl: string): TIFPSRegProc;
Public function AddFunction(const Header: string): TIFPSRegProc;
Public function AddInterface(InheritedFrom: TIFPSInterface; Guid: TGuid; const Name: string): TIFPSInterface;
Public procedure AddToFreeList(Obj: TObject);
Public function AddType(const Name: string; const BaseType: TIFPSBaseType): TIFPSType;
Public function AddTypeCopy(const Name: string; TypeNo: TIFPSType): TIFPSType;
Public function AddTypeCopyN(const Name, FType: string): TIFPSType;
Public function AddTypeS(const Name, Decl: string): TIFPSType;
Protected function AddUsedFunction(var Proc: TIFPSInternalProcedure): Cardinal;
Protected function AddUsedFunction2(var Proc: TIFPSExternalProcedure): Cardinal;
Public function AddUsedPtrVariable(const Name: string; FType: TIFPSType): TIFPSVar;
Public function AddUsedPtrVariableN(const Name, FType: string): TIFPSVar;
Public function AddUsedVariable(const Name: string; FType: TIFPSType): TIFPSVar;
Public function AddUsedVariableN(const Name, FType: string): TIFPSVar;
Public function AddVariable(const Name: string; FType: TIFPSType): TIFPSVar;
Public function AddVariableN(const Name, FType: string): TIFPSVar;
Protected function ApplyAttribsToFunction(func: TIFPSProcedure): boolean;
Protected function at2ut(p: TIFPSType): TIFPSType;
Protected function CheckCompatProc(P: TIFPSType; ProcNo: Cardinal): Boolean;
Protected procedure CheckForUnusedVars(Func: TIFPSInternalProcedure);
Public procedure Clear;
Public function Compile(const s: string): Boolean;
Protected procedure Debug_SavePosition(ProcNo: Cardinal; Proc: TIFPSInternalProcedure);
Protected procedure Debug_WriteLine(BlockInfo: TIFPSBlockInfo);
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;
Protected function FindBaseType(BaseType: TIFPSBaseType): TIFPSType;
Public function FindClass(const aClass: string): TIFPSCompileTimeClass;
Public function FindInterface(const Name: string): TIFPSInterface;
Public function FindProc(const Name: string): Cardinal;
Public function FindType(const Name: string): TIFPSType;
Public function GetDebugOutput(var s: string): Boolean;
Protected function GetMsg(l: Longint): TIFPSPascalCompilerMessage;
Protected function GetMsgCount: Longint;
Public function GetOutput(var s: string): Boolean;
Public function GetProc(I: Longint): TIFPSProcedure;
Public function GetProcCount: Longint;
Public function GetType(I: Longint): TIFPSType;
Protected function GetTypeCopyLink(p: TIFPSType): TIFPSType;
Public function GetTypeCount: Longint;
Protected function GetTypeNo(BlockInfo: TIFPSBlockInfo; p: TIFPSValue): TIFPSType;
Public function GetVar(I: Longint): TIFPSVar;
Public function GetVarCount: Longint;
Protected function GetWideString(Src: PIfRVariant; var s: Boolean): WideString;
Protected function IsBoolean(aType: TIFPSType): Boolean;
Protected function IsCompatibleType(p1, p2: TIFPSType; Cast: Boolean): Boolean;
Protected function IsDuplicate(const s: string; const check: TIFPSDuplicCheck): Boolean;
Protected function IsIntBoolType(aType: TIFPSType): Boolean;
Protected function IsProcDuplicLabel(Proc: TIFPSInternalProcedure; const s: string): Boolean;
Protected function IsVarInCompatible(ft1, ft2: TIFPSType): Boolean;
Protected function MakeDecl(decl: TIFPSParametersDecl): string;
Public function MakeError(const Module: string; E: TIFPSPascalCompilerErrorType; const Param: string): TIFPSPascalCompilerMessage;
Protected function MakeExportDecl(decl: TIFPSParametersDecl): 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(FUseUsedTypes: Boolean; Var1Mod: Byte; var1: PIFRVariant; Var2Mod: Byte; Var2: PIfRVariant; Cmd: TIFPSBinOperatorType; Pos, Row, Col: Cardinal): Boolean;
Protected function ProcessFunction(AlwaysForward: Boolean; Att: TIFPSAttributes): Boolean;
Protected function ProcessLabel(Proc: TIFPSInternalProcedure): Boolean;
Protected function ProcessLabelForwards(Proc: TIFPSInternalProcedure): Boolean;
Protected function ProcessSub(BlockInfo: TIFPSBlockInfo): Boolean;
Protected function ProcIsDuplic(Decl: TIFPSParametersDecl; const FunctionName, FunctionParamNames: string; const s: string; Func: TIFPSInternalProcedure): Boolean;
Protected function ReadAttributes(Dest: TIFPSAttributes): Boolean;
Protected function ReadConstant(FParser: TIfPascalParser; StopOn: TIfPasToken): PIfRVariant;
Protected function ReadInteger(const s: string): PIfRVariant;
Protected function ReadReal(const s: string): PIfRVariant;
Protected function ReadString: PIfRVariant;
Protected function ReadType(const Name: string; FParser: TIfPascalParser): TIFPSType;
Protected function ReadTypeAddProcedure(const Name: string; FParser: TIfPascalParser): TIFPSType;
Protected procedure UseProc(procdecl: TIFPSParametersDecl);
Protected function ValidateParameters(BlockInfo: TIFPSBlockInfo; Params: TIFPSParameters; ParamTypes: TIFPSParametersDecl): boolean;
Protected function VarIsDuplicate(Proc: TIFPSInternalProcedure; const VarNames, s: string): Boolean;
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 AddAttributeType: TIFPSAttributeType;

Add an attribute type to the attribute type list

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: TIFPSType): 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 AddFunction(const Header: string): TIFPSRegProc;

Add a function, deprecated, use AddDelphiFunction

Public function AddInterface(InheritedFrom: TIFPSInterface; Guid: TGuid; const Name: string): TIFPSInterface;

Add an interface

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, use AddTypeS for non-basetype based types

Public function AddTypeCopy(const Name: string; TypeNo: TIFPSType): 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

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

 

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

 

Public function AddUsedPtrVariable(const Name: string; FType: TIFPSType): TIFPSVar;

Add an used pointer variable, and export it

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

add an used pointer variable , and export it

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

Add an used variable, and export it

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

add an used variable , and export it

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

Add a variable, and export it

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

Add a variable, and export it

Protected function ApplyAttribsToFunction(func: TIFPSProcedure): boolean;

 

Protected function at2ut(p: TIFPSType): TIFPSType;

 

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

 

Protected procedure CheckForUnusedVars(Func: TIFPSInternalProcedure);

 

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_WriteLine(BlockInfo: TIFPSBlockInfo);

 

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;

 

Protected function FindBaseType(BaseType: TIFPSBaseType): TIFPSType;

 

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

Find a class

Public function FindInterface(const Name: string): TIFPSInterface;

Find a class

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

 

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

Search for a type

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

Return the debugger output

Protected function GetMsg(l: Longint): TIFPSPascalCompilerMessage;

 

Protected function GetMsgCount: Longint;

 

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

Return the output

Public function GetProc(I: Longint): TIFPSProcedure;

Returns procedure nr I

Public function GetProcCount: Longint;

returns the procedure count

Public function GetType(I: Longint): TIFPSType;

returns type nr I

Protected function GetTypeCopyLink(p: TIFPSType): TIFPSType;

 

Public function GetTypeCount: Longint;

returns the type count

Protected function GetTypeNo(BlockInfo: TIFPSBlockInfo; p: TIFPSValue): TIFPSType;

 

Public function GetVar(I: Longint): TIFPSVar;

Returns variable number I

Public function GetVarCount: Longint;

Returns the variable count

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

 

Protected function IsBoolean(aType: TIFPSType): Boolean;

 

Protected function IsCompatibleType(p1, p2: TIFPSType; Cast: Boolean): Boolean;

 

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

 

Protected function IsIntBoolType(aType: TIFPSType): Boolean;

 

Protected function IsProcDuplicLabel(Proc: TIFPSInternalProcedure; const s: string): Boolean;

 

Protected function IsVarInCompatible(ft1, ft2: TIFPSType): Boolean;

 

Protected function MakeDecl(decl: TIFPSParametersDecl): string;

 

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

Add an error the messages

Protected function MakeExportDecl(decl: TIFPSParametersDecl): 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(FUseUsedTypes: Boolean; Var1Mod: Byte; var1: PIFRVariant; Var2Mod: Byte; Var2: PIfRVariant; Cmd: TIFPSBinOperatorType; Pos, Row, Col: Cardinal): Boolean;

 

Protected function ProcessFunction(AlwaysForward: Boolean; Att: TIFPSAttributes): Boolean;

 

Protected function ProcessLabel(Proc: TIFPSInternalProcedure): Boolean;

 

Protected function ProcessLabelForwards(Proc: TIFPSInternalProcedure): Boolean;

 

Protected function ProcessSub(BlockInfo: TIFPSBlockInfo): Boolean;

 

Protected function ProcIsDuplic(Decl: TIFPSParametersDecl; const FunctionName, FunctionParamNames: string; const s: string; Func: TIFPSInternalProcedure): Boolean;

 

Protected function ReadAttributes(Dest: TIFPSAttributes): Boolean;

 

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

 

Protected function ReadInteger(const s: string): PIfRVariant;

 

Protected function ReadReal(const s: string): PIfRVariant;

 

Protected function ReadString: PIfRVariant;

 

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

 

Protected function ReadTypeAddProcedure(const Name: string; FParser: TIfPascalParser): TIFPSType;

 

Protected procedure UseProc(procdecl: TIFPSParametersDecl);

 

Protected function ValidateParameters(BlockInfo: TIFPSBlockInfo; Params: TIFPSParameters; ParamTypes: TIFPSParametersDecl): boolean;

 

Protected function VarIsDuplicate(Proc: TIFPSInternalProcedure; const VarNames, s: string): Boolean;

 

Protected procedure WriteDebugData(const s: string);

 

Properties

Overview

Public property AllowNoBegin: Boolean;
Public property AllowNoEnd: Boolean;
Public property AllowUnit: Boolean;
Public property BooleanShortCircuit: Boolean;
Public property ID: Pointer;
Public property IsUnit: Boolean;
Public property Msg[l: Longint]: TIFPSPascalCompilerMessage;
Public property MsgCount: Longint;
Public property OnBeforeCleanup: TIFPSOnNotify;
Public property OnBeforeOutput: TIFPSOnNotify;
Public property OnExportCheck: TIFPSOnExportCheck;
Public property OnExternalProc: TIFPSOnExternalProc;
Public property OnTranslateLineInfo: TIFPSOnTranslateLineInfoProc;
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 BooleanShortCircuit: Boolean;

 

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 OnBeforeCleanup: TIFPSOnNotify;

This event is called before the compiled trees are cleaned up

Public property OnBeforeOutput: TIFPSOnNotify;

This event is called before the compiled trees are written

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 OnTranslateLineInfo: TIFPSOnTranslateLineInfoProc;

 

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