-
Notifications
You must be signed in to change notification settings - Fork 0
/
uPSRuntime.pas
12567 lines (11706 loc) · 398 KB
/
uPSRuntime.pas
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
unit uPSRuntime;
{$I PascalScript.inc}
{
RemObjects Pascal Script III
Copyright (C) 2000-2009 by Carlo Kok ([email protected])
}
interface
uses
SysUtils, uPSUtils{$IFDEF DELPHI6UP}, variants{$ENDIF}{$IFNDEF PS_NOIDISPATCH}{$IFDEF DELPHI3UP}, ActiveX, Windows{$ELSE}, Ole2{$ENDIF}{$ENDIF};
type
TPSExec = class;
TPSStack = class;
TPSRuntimeAttributes = class;
TPSRuntimeAttribute = class;
TPSError = (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);
TPSStatus = (isNotLoaded, isLoaded, isRunning, isPaused);
PByteArray = ^TByteArray;
TByteArray = array[0..1023] of Byte;
PDWordArray = ^TDWordArray;
TDWordArray = array[0..1023] of Cardinal;
{@link(TPSProcRec)
PIFProcRec is a pointer to a TIProcRec record}
TPSProcRec = class;
TIFProcRec = TPSProcRec;
TPSExternalProcRec = class;
TIFPSExternalProcRec = TPSExternalProcRec;
TIFExternalProcRec = TPSExternalProcRec;
PIFProcRec = TPSProcRec;
PProcRec = ^TProcRec;
TPSProcPtr = function(Caller: TPSExec; p: TPSExternalProcRec; Global, Stack: TPSStack): Boolean;
TPSFreeProc = procedure (Caller: TPSExec; p: PProcRec);
TPSProcRec = class
private
FAttributes: TPSRuntimeAttributes;
public
constructor Create(Owner: TPSExec);
destructor Destroy; override;
property Attributes: TPSRuntimeAttributes read FAttributes;
end;
TPSExternalProcRec = class(TPSProcRec)
private
FExt1: Pointer;
FExt2: Pointer;
FName: tbtstring;
FProcPtr: TPSProcPtr;
FDecl: tbtstring;
public
property Name: tbtstring read FName write FName;
property Decl: tbtstring read FDecl write FDecl;
property Ext1: Pointer read FExt1 write FExt1;
property Ext2: Pointer read FExt2 write FExt2;
property ProcPtr: TPSProcPtr read FProcPtr write FProcPtr;
end;
TPSInternalProcRec = class(TPSProcRec)
private
FData: PByteArray;
FLength: Cardinal;
FExportNameHash: Longint;
FExportDecl: tbtstring;
FExportName: tbtstring;
public
property Data: PByteArray read FData;
property Length: Cardinal read FLength;
property ExportNameHash: Longint read FExportNameHash;
property ExportName: tbtstring read FExportName write FExportName;
property ExportDecl: tbtstring read FExportDecl write FExportDecl;
destructor Destroy; override;
end;
TProcRec = record
Name: ShortString;
Hash: Longint;
ProcPtr: TPSProcPtr;
FreeProc: TPSFreeProc;
Ext1, Ext2: Pointer;
end;
PBTReturnAddress = ^TBTReturnAddress;
TBTReturnAddress = packed record
ProcNo: TPSInternalProcRec;
Position, StackBase: Cardinal;
end;
TPSTypeRec = class
private
FExportNameHash: Longint;
FExportName: tbtstring;
FBaseType: TPSBaseType;
FAttributes: TPSRuntimeAttributes;
protected
FRealSize: Cardinal;
public
property RealSize: Cardinal read FRealSize;
property BaseType: TPSBaseType read FBaseType write FBaseType;
property ExportName: tbtstring read FExportName write FExportName;
property ExportNameHash: Longint read FExportNameHash write FExportNameHash;
property Attributes: TPSRuntimeAttributes read FAttributes write FAttributes;
procedure CalcSize; virtual;
constructor Create(Owner: TPSExec);
destructor Destroy; override;
end;
TPSTypeRec_ProcPtr = class(TPSTypeRec)
private
FParamInfo: tbtstring;
public
property ParamInfo: tbtstring read FParamInfo write FParamInfo;
procedure CalcSize; override;
end;
PIFTypeRec = TPSTypeRec;
TPSTypeRec_Class = class(TPSTypeRec)
private
FCN: tbtstring;
public
property CN: tbtstring read FCN write FCN;
end;
{$IFNDEF PS_NOINTERFACES}
TPSTypeRec_Interface = class(TPSTypeRec)
private
FGuid: TGUID;
public
property Guid: TGUID read FGuid write FGuid;
end;
{$ENDIF}
TPSTypeRec_Array = class(TPSTypeRec)
private
FArrayType: TPSTypeRec;
public
property ArrayType: TPSTypeRec read FArrayType write FArrayType;
procedure CalcSize; override;
end;
TPSTypeRec_StaticArray = class(TPSTypeRec_Array)
private
FSize: Longint;
FStartOffset: LongInt;
public
property Size: Longint read FSize write FSize;
property StartOffset: LongInt read FStartOffset write FStartOffset;
procedure CalcSize; override;
end;
TPSTypeRec_Set = class(TPSTypeRec)
private
FBitSize: Longint;
FByteSize: Longint;
public
{The number of bytes this would require (same as realsize)}
property aByteSize: Longint read FByteSize write FByteSize;
property aBitSize: Longint read FBitSize write FBitSize;
procedure CalcSize; override;
end;
TPSTypeRec_Record = class(TPSTypeRec)
private
FFieldTypes: TPSList;
FRealFieldOffsets: TPSList;
public
property FieldTypes: TPSList read FFieldTypes;
property RealFieldOffsets: TPSList read FRealFieldOffsets;
procedure CalcSize; override;
constructor Create(Owner: TPSExec);
destructor Destroy; override;
end;
PPSVariant = ^TPSVariant;
PIFVariant = PPSVariant;
TPSVariant = packed record
FType: TPSTypeRec;
end;
PPSVariantData = ^TPSVariantData;
TPSVariantData = packed record
VI: TPSVariant;
Data: array[0..0] of Byte;
end;
PPSVariantU8 = ^TPSVariantU8;
TPSVariantU8 = packed record
VI: TPSVariant;
Data: tbtU8;
end;
PPSVariantS8 = ^TPSVariantS8;
TPSVariantS8 = packed record
VI: TPSVariant;
Data: tbts8;
end;
PPSVariantU16 = ^TPSVariantU16;
TPSVariantU16 = packed record
VI: TPSVariant;
Data: tbtU16;
end;
PPSVariantS16 = ^TPSVariantS16;
TPSVariantS16 = packed record
VI: TPSVariant;
Data: tbts16;
end;
PPSVariantU32 = ^TPSVariantU32;
TPSVariantU32 = packed record
VI: TPSVariant;
Data: tbtU32;
end;
PPSVariantS32 = ^TPSVariantS32;
TPSVariantS32 = packed record
VI: TPSVariant;
Data: tbts32;
end;
{$IFNDEF PS_NOINT64}
PPSVariantS64 = ^TPSVariantS64;
TPSVariantS64 = packed record
VI: TPSVariant;
Data: tbts64;
end;
{$ENDIF}
PPSVariantAChar = ^TPSVariantAChar;
TPSVariantAChar = packed record
VI: TPSVariant;
Data: tbtChar;
end;
{$IFNDEF PS_NOWIDESTRING}
PPSVariantWChar = ^TPSVariantWChar;
TPSVariantWChar = packed record
VI: TPSVariant;
Data: tbtWideChar;
end;
{$ENDIF}
PPSVariantAString = ^TPSVariantAString;
TPSVariantAString = packed record
VI: TPSVariant;
Data: tbtString;
end;
{$IFNDEF PS_NOWIDESTRING}
PPSVariantWString = ^TPSVariantWString;
TPSVariantWString = {$IFNDEF DELPHI2009UP}packed {$ENDIF}record
VI: TPSVariant;
Data: tbtWideString;
end;
PPSVariantUString = ^TPSVariantUString;
TPSVariantUString = {$IFNDEF DELPHI2009UP}packed {$ENDIF}record
VI: TPSVariant;
Data: tbtunicodestring;
end;
{$ENDIF}
PPSVariantSingle = ^TPSVariantSingle;
TPSVariantSingle = packed record
VI: TPSVariant;
Data: tbtsingle;
end;
PPSVariantDouble = ^TPSVariantDouble;
TPSVariantDouble = packed record
VI: TPSVariant;
Data: tbtDouble;
end;
PPSVariantExtended = ^TPSVariantExtended;
TPSVariantExtended = packed record
VI: TPSVariant;
Data: tbtExtended;
end;
PPSVariantCurrency = ^TPSVariantCurrency;
TPSVariantCurrency = packed record
VI: TPSVariant;
Data: tbtCurrency;
end;
PPSVariantSet = ^TPSVariantSet;
TPSVariantSet = packed record
VI: TPSVariant;
Data: array[0..0] of Byte;
end;
{$IFNDEF PS_NOINTERFACES}
PPSVariantInterface = ^TPSVariantInterface;
TPSVariantInterface = packed record
VI: TPSVariant;
Data: IUnknown;
end;
{$ENDIF}
PPSVariantClass = ^TPSVariantClass;
TPSVariantClass = packed record
VI: TPSVariant;
Data: TObject;
end;
PPSVariantRecord = ^TPSVariantRecord;
TPSVariantRecord = packed record
VI: TPSVariant;
data: array[0..0] of byte;
end;
PPSVariantDynamicArray = ^TPSVariantDynamicArray;
TPSVariantDynamicArray = packed record
VI: TPSVariant;
Data: Pointer;
end;
PPSVariantStaticArray = ^TPSVariantStaticArray;
TPSVariantStaticArray = packed record
VI: TPSVariant;
data: array[0..0] of byte;
end;
PPSVariantPointer = ^TPSVariantPointer;
TPSVariantPointer = packed record
VI: TPSVariant;
DataDest: Pointer;
DestType: TPSTypeRec;
FreeIt: LongBool;
end;
PPSVariantReturnAddress = ^TPSVariantReturnAddress;
TPSVariantReturnAddress = packed record
VI: TPSVariant;
Addr: TBTReturnAddress;
end;
PPSVariantVariant = ^TPSVariantVariant;
TPSVariantVariant = packed record
VI: TPSVariant;
Data: Variant;
end;
PPSVariantProcPtr = ^TPSVariantProcPtr;
TPSVariantProcPtr = packed record
VI: TPSVariant;
ProcNo: Cardinal;
Self: Pointer;
Ptr: Pointer;
{
ProcNo = 0 means Self/Ptr become active (Ptr = nil means it's nil)
}
end;
TPSVarFreeType = (
vtNone,
vtTempVar
);
TPSResultData = packed record
P: Pointer;
aType: TPSTypeRec;
FreeType: TPSVarFreeType;
end;
PPSResource = ^TPSResource;
TPSResource = record
Proc: Pointer;
P: Pointer;
end;
TPSAttributeUseProc = function (Sender: TPSExec; const AttribType: tbtstring; Attr: TPSRuntimeAttribute): Boolean;
TPSAttributeType = class
private
FTypeName: tbtstring;
FUseProc: TPSAttributeUseProc;
FTypeNameHash: Longint;
public
property UseProc: TPSAttributeUseProc read FUseProc write FUseProc;
property TypeName: tbtstring read FTypeName write FTypeName;
property TypeNameHash: Longint read FTypeNameHash write FTypeNameHash;
end;
PClassItem = ^TClassItem;
TClassItem = record
FName: tbtstring;
FNameHash: Longint;
b: byte;
case byte of
0: (Ptr: Pointer);
1: (PointerInList: Pointer);
3: (FReadFunc, FWriteFunc: Pointer); {Property Helper}
4: (Ptr2: Pointer);
5: (PointerInList2: Pointer);
6: (); {Property helper, like 3}
7: (); {Property helper that will pass it's name}
end;
PPSVariantIFC = ^TPSVariantIFC;
{Temporary variant into record}
TPSVariantIFC = packed record
Dta: Pointer;
aType: TPSTypeRec;
VarParam: Boolean;
end;
PIFPSVariantIFC = PPSVariantIFC;
TIFPSVariantIFC = TPSVariantIFC;
TPSRuntimeAttribute = class(TObject)
private
FValues: TPSStack;
FAttribType: tbtstring;
FOwner: TPSRuntimeAttributes;
FAttribTypeHash: Longint;
function GetValue(I: Longint): PIFVariant;
function GetValueCount: Longint;
public
property Owner: TPSRuntimeAttributes read FOwner;
property AttribType: tbtstring read FAttribType write FAttribType;
property AttribTypeHash: Longint read FAttribTypeHash write FAttribTypeHash;
property ValueCount: Longint read GetValueCount;
property Value[I: Longint]: PIFVariant read GetValue;
function AddValue(aType: TPSTypeRec): PPSVariant;
procedure DeleteValue(i: Longint);
procedure AdjustSize;
constructor Create(Owner: TPSRuntimeAttributes);
destructor Destroy; override;
end;
TPSRuntimeAttributes = class(TObject)
private
FAttributes: TPSList;
FOwner: TPSExec;
function GetCount: Longint;
function GetItem(I: Longint): TPSRuntimeAttribute;
public
property Owner: TPSExec read FOwner;
property Count: Longint read GetCount;
property Items[I: Longint]: TPSRuntimeAttribute read GetItem; default;
procedure Delete(I: Longint);
function Add: TPSRuntimeAttribute;
function FindAttribute(const Name: tbtstring): TPSRuntimeAttribute;
constructor Create(AOwner: TPSExec);
destructor Destroy; override;
end;
TPSOnGetNVariant = function (Sender: TPSExec; const Name: tbtstring): Variant;
TPSOnSetNVariant = procedure (Sender: TPSExec; const Name: tbtstring; V: Variant);
TPSOnLineEvent = procedure(Sender: TPSExec);
TPSOnSpecialProcImport = function (Sender: TPSExec; p: TPSExternalProcRec; Tag: Pointer): Boolean;
TPSOnException = procedure (Sender: TPSExec; ExError: TPSError; const ExParam: tbtstring; ExObject: TObject; ProcNo, Position: Cardinal);
TPSExec = class(TObject)
Private
FOnGetNVariant: TPSOnGetNVariant;
FOnSetNVariant: TPSOnSetNVariant;
FId: Pointer;
FJumpFlag: Boolean;
FCallCleanup: Boolean;
FOnException: TPSOnException;
function ReadData(var Data; Len: Cardinal): Boolean;
function ReadLong(var b: Cardinal): Boolean;
function DoCalc(var1, Var2: Pointer; var1Type, var2type: TPSTypeRec; CalcType: Cardinal): Boolean;
function DoBooleanCalc(var1, Var2, into: Pointer; var1Type, var2type, intotype: TPSTypeRec; Cmd: Cardinal): Boolean;
function SetVariantValue(dest, Src: Pointer; desttype, srctype: TPSTypeRec): Boolean;
function ReadVariable(var Dest: TPSResultData; UsePointer: Boolean): Boolean;
function DoBooleanNot(Dta: Pointer; aType: TPSTypeRec): Boolean;
function DoMinus(Dta: Pointer; aType: TPSTypeRec): Boolean;
function DoIntegerNot(Dta: Pointer; aType: TPSTypeRec): Boolean;
procedure RegisterStandardProcs;
Protected
FReturnAddressType: TPSTypeRec;
FVariantType: TPSTypeRec;
FVariantArrayType: TPSTypeRec;
FAttributeTypes: TPSList;
FExceptionStack: TPSList;
FResources: TPSList;
FExportedVars: TPSList;
FTypes: TPSList;
FProcs: TPSList;
FGlobalVars: TPSStack;
FTempVars: TPSStack;
FStack: TPSStack;
FMainProc: Cardinal;
FStatus: TPSStatus;
FCurrProc: TPSInternalProcRec;
FData: PByteArray;
FDataLength: Cardinal;
FCurrentPosition: Cardinal;
FCurrStackBase: Cardinal;
FOnRunLine: TPSOnLineEvent;
FSpecialProcList: TPSList;
FRegProcs: TPSList;
ExObject: TObject;
ExProc: Cardinal;
ExPos: Cardinal;
ExEx: TPSError;
ExParam: tbtstring;
function InvokeExternalMethod(At: TPSTypeRec_ProcPtr; Slf, Ptr: Pointer): Boolean;
function InnerfuseCall(_Self, Address: Pointer; CallingConv: TPSCallingConvention; Params: TPSList; res: PPSVariantIFC): Boolean;
procedure RunLine; virtual;
function ImportProc(const Name: ShortString; proc: TPSExternalProcRec): Boolean; Virtual;
procedure ExceptionProc(proc, Position: Cardinal; Ex: TPSError; const s: tbtstring; NewObject: TObject); Virtual;
function FindSpecialProcImport(P: TPSOnSpecialProcImport): pointer;
Public
function LastEx: TPSError;
function LastExParam: tbtstring;
function LastExProc: Integer;
function LastExPos: Integer;
procedure CMD_Err(EC: TPSError);
procedure CMD_Err2(EC: TPSError; const Param: tbtstring);
procedure CMD_Err3(EC: TPSError; const Param: tbtstring; ExObject: TObject);
property Id: Pointer read FID write FID;
class function About: tbtstring;
function RunProc(Params: TPSList; ProcNo: Cardinal): Boolean;
function RunProcP(const Params: array of Variant; const Procno: Cardinal): Variant;
function RunProcPVar(var Params: array of Variant; const Procno: Cardinal): Variant;
function RunProcPN(const Params: array of Variant; const ProcName: tbtstring): Variant;
function FindType(StartAt: Cardinal; BaseType: TPSBaseType; var l: Cardinal): PIFTypeRec;
function FindType2(BaseType: TPSBaseType): PIFTypeRec;
function GetTypeNo(l: Cardinal): PIFTypeRec;
function GetType(const Name: tbtstring): Cardinal;
function GetProc(const Name: tbtstring): Cardinal;
function GetVar(const Name: tbtstring): Cardinal;
function GetVar2(const Name: tbtstring): PIFVariant;
function GetVarNo(C: Cardinal): PIFVariant;
function GetProcNo(C: Cardinal): PIFProcRec;
function GetProcCount: Cardinal;
function GetVarCount: Longint;
function GetTypeCount: Longint;
constructor Create;
destructor Destroy; Override;
function RunScript: Boolean;
function LoadData(const s: tbtstring): Boolean; virtual;
procedure Clear; Virtual;
procedure Cleanup; Virtual;
procedure Stop; Virtual;
procedure Pause; Virtual;
property CallCleanup: Boolean read FCallCleanup write FCallCleanup;
property Status: TPSStatus Read FStatus;
property OnRunLine: TPSOnLineEvent Read FOnRunLine Write FOnRunLine;
procedure ClearspecialProcImports;
procedure AddSpecialProcImport(const FName: tbtstring; P: TPSOnSpecialProcImport; Tag: Pointer);
function RegisterFunctionName(const Name: tbtstring; ProcPtr: TPSProcPtr;
Ext1, Ext2: Pointer): PProcRec;
procedure RegisterDelphiFunction(ProcPtr: Pointer; const Name: tbtstring; CC: TPSCallingConvention);
procedure RegisterDelphiMethod(Slf, ProcPtr: Pointer; const Name: tbtstring; CC: TPSCallingConvention);
function GetProcAsMethod(const ProcNo: Cardinal): TMethod;
function GetProcAsMethodN(const ProcName: tbtstring): TMethod;
procedure RegisterAttributeType(useproc: TPSAttributeUseProc; const TypeName: tbtstring);
procedure ClearFunctionList;
property ExceptionProcNo: Cardinal Read ExProc;
property ExceptionPos: Cardinal Read ExPos;
property ExceptionCode: TPSError Read ExEx;
property ExceptionString: tbtstring read ExParam;
property ExceptionObject: TObject read ExObject write ExObject;
procedure AddResource(Proc, P: Pointer);
function IsValidResource(Proc, P: Pointer): Boolean;
procedure DeleteResource(P: Pointer);
function FindProcResource(Proc: Pointer): Pointer;
function FindProcResource2(Proc: Pointer; var StartAt: Longint): Pointer;
procedure RaiseCurrentException;
property OnException: TPSOnException read FOnException write FOnException;
property OnGetNVariant: TPSOnGetNVariant read FOnGetNVariant write FOnGetNVariant;
property OnSetNVariant: TPSOnSetNVariant read FOnSetNVariant write FOnSetNVariant;
end;
TPSStack = class(TPSList)
private
FDataPtr: Pointer;
FCapacity,
FLength: Longint;
function GetItem(I: Longint): PPSVariant;
procedure SetCapacity(const Value: Longint);
procedure AdjustLength;
public
property DataPtr: Pointer read FDataPtr;
property Capacity: Longint read FCapacity write SetCapacity;
property Length: Longint read FLength;
constructor Create;
destructor Destroy; override;
procedure Clear; {$IFDEF DELPHI5UP} reintroduce;{$ELSE} override; {$ENDIF}
function Push(TotalSize: Longint): PPSVariant;
function PushType(aType: TPSTypeRec): PPSVariant;
procedure Pop;
function GetInt(ItemNo: Longint): Longint;
function GetUInt(ItemNo: Longint): Cardinal;
{$IFNDEF PS_NOINT64}
function GetInt64(ItemNo: Longint): Int64;
{$ENDIF}
function GetString(ItemNo: Longint): string; // calls the native method
function GetAnsiString(ItemNo: Longint): tbtstring;
{$IFNDEF PS_NOWIDESTRING}
function GetWideString(ItemNo: Longint): tbtWideString;
function GetUnicodeString(ItemNo: Longint): tbtunicodestring;
{$ENDIF}
function GetReal(ItemNo: Longint): Extended;
function GetCurrency(ItemNo: Longint): Currency;
function GetBool(ItemNo: Longint): Boolean;
function GetClass(ItemNo: Longint): TObject;
procedure SetInt(ItemNo: Longint; const Data: Longint);
procedure SetUInt(ItemNo: Longint; const Data: Cardinal);
{$IFNDEF PS_NOINT64}
procedure SetInt64(ItemNo: Longint; const Data: Int64);
{$ENDIF}
procedure SetString(ItemNo: Longint; const Data: string);
procedure SetAnsiString(ItemNo: Longint; const Data: tbtstring);
{$IFNDEF PS_NOWIDESTRING}
procedure SetWideString(ItemNo: Longint; const Data: tbtWideString);
procedure SetUnicodeString(ItemNo: Longint; const Data: tbtunicodestring);
{$ENDIF}
procedure SetReal(ItemNo: Longint; const Data: Extended);
procedure SetCurrency(ItemNo: Longint; const Data: Currency);
procedure SetBool(ItemNo: Longint; const Data: Boolean);
procedure SetClass(ItemNo: Longint; const Data: TObject);
property Items[I: Longint]: PPSVariant read GetItem; default;
end;
function PSErrorToString(x: TPSError; const Param: tbtstring): tbtstring;
function TIFErrorToString(x: TPSError; const Param: tbtstring): tbtstring;
function CreateHeapVariant(aType: TPSTypeRec): PPSVariant;
procedure DestroyHeapVariant(v: PPSVariant);
procedure FreePIFVariantList(l: TPSList);
procedure FreePSVariantList(l: TPSList);
const
ENoError = ERNoError;
function PIFVariantToVariant(Src: PIFVariant; var Dest: Variant): Boolean;
function VariantToPIFVariant(Exec: TPSExec; const Src: Variant; Dest: PIFVariant): Boolean;
function PSGetRecField(const avar: TPSVariantIFC; Fieldno: Longint): TPSVariantIFC;
function PSGetArrayField(const avar: TPSVariantIFC; Fieldno: Longint): TPSVariantIFC;
function NewTPSVariantRecordIFC(avar: PPSVariant; Fieldno: Longint): TPSVariantIFC;
function NewTPSVariantIFC(avar: PPSVariant; varparam: boolean): TPSVariantIFC;
function NewPPSVariantIFC(avar: PPSVariant; varparam: boolean): PPSVariantIFC;
procedure DisposePPSVariantIFC(aVar: PPSVariantIFC);
procedure DisposePPSVariantIFCList(list: TPSList);
function PSGetObject(Src: Pointer; aType: TPSTypeRec): TObject;
function PSGetUInt(Src: Pointer; aType: TPSTypeRec): Cardinal;
{$IFNDEF PS_NOINT64}
function PSGetInt64(Src: Pointer; aType: TPSTypeRec): Int64;
{$ENDIF}
function PSGetReal(Src: Pointer; aType: TPSTypeRec): Extended;
function PSGetCurrency(Src: Pointer; aType: TPSTypeRec): Currency;
function PSGetInt(Src: Pointer; aType: TPSTypeRec): Longint;
function PSGetString(Src: Pointer; aType: TPSTypeRec): string;
function PSGetAnsiString(Src: Pointer; aType: TPSTypeRec): tbtString;
{$IFNDEF PS_NOWIDESTRING}
function PSGetWideString(Src: Pointer; aType: TPSTypeRec): tbtWideString;
function PSGetUnicodeString(Src: Pointer; aType: TPSTypeRec): tbtunicodestring;
{$ENDIF}
procedure PSSetObject(Src: Pointer; aType: TPSTypeRec; var Ok: Boolean; Const val: TObject);
procedure PSSetUInt(Src: Pointer; aType: TPSTypeRec; var Ok: Boolean; const Val: Cardinal);
{$IFNDEF PS_NOINT64}
procedure PSSetInt64(Src: Pointer; aType: TPSTypeRec; var Ok: Boolean; const Val: Int64);
{$ENDIF}
procedure PSSetReal(Src: Pointer; aType: TPSTypeRec; var Ok: Boolean; const Val: Extended);
procedure PSSetCurrency(Src: Pointer; aType: TPSTypeRec; var Ok: Boolean; const Val: Currency);
procedure PSSetInt(Src: Pointer; aType: TPSTypeRec; var Ok: Boolean; const Val: Longint);
procedure PSSetString(Src: Pointer; aType: TPSTypeRec; var Ok: Boolean; const Val: String);
procedure PSSetAnsiString(Src: Pointer; aType: TPSTypeRec; var Ok: Boolean; const Val: tbtString);
{$IFNDEF PS_NOWIDESTRING}
procedure PSSetWideString(Src: Pointer; aType: TPSTypeRec; var Ok: Boolean; const Val: tbtWideString);
procedure PSSetUnicodeString(Src: Pointer; aType: TPSTypeRec; var Ok: Boolean; const Val: tbtunicodestring);
{$ENDIF}
procedure VNSetPointerTo(const Src: TPSVariantIFC; Data: Pointer; aType: TPSTypeRec);
function VNGetUInt(const Src: TPSVariantIFC): Cardinal;
{$IFNDEF PS_NOINT64}
function VNGetInt64(const Src: TPSVariantIFC): Int64;
{$ENDIF}
function VNGetReal(const Src: TPSVariantIFC): Extended;
function VNGetCurrency(const Src: TPSVariantIFC): Currency;
function VNGetInt(const Src: TPSVariantIFC): Longint;
function VNGetString(const Src: TPSVariantIFC): String;
function VNGetAnsiString(const Src: TPSVariantIFC): tbtString;
{$IFNDEF PS_NOWIDESTRING}
function VNGetWideString(const Src: TPSVariantIFC): tbtWideString;
function VNGetUnicodeString(const Src: TPSVariantIFC): tbtunicodestring;
{$ENDIF}
procedure VNSetUInt(const Src: TPSVariantIFC; const Val: Cardinal);
{$IFNDEF PS_NOINT64}
procedure VNSetInt64(const Src: TPSVariantIFC; const Val: Int64);
{$ENDIF}
procedure VNSetReal(const Src: TPSVariantIFC; const Val: Extended);
procedure VNSetCurrency(const Src: TPSVariantIFC; const Val: Currency);
procedure VNSetInt(const Src: TPSVariantIFC; const Val: Longint);
procedure VNSetString(const Src: TPSVariantIFC; const Val: String);
procedure VNSetAnsiString(const Src: TPSVariantIFC; const Val: tbtString);
{$IFNDEF PS_NOWIDESTRING}
procedure VNSetWideString(const Src: TPSVariantIFC; const Val: tbtWideString);
procedure VNSetUnicodeString(const Src: TPSVariantIFC; const Val: tbtunicodestring);
{$ENDIF}
function VGetUInt(const Src: PIFVariant): Cardinal;
{$IFNDEF PS_NOINT64}
function VGetInt64(const Src: PIFVariant): Int64;
{$ENDIF}
function VGetReal(const Src: PIFVariant): Extended;
function VGetCurrency(const Src: PIFVariant): Currency;
function VGetInt(const Src: PIFVariant): Longint;
function VGetString(const Src: PIFVariant): String;
function VGetAnsiString(const Src: PIFVariant): tbtString;
{$IFNDEF PS_NOWIDESTRING}
function VGetWideString(const Src: PIFVariant): tbtWideString;
function VGetUnicodeString(const Src: PIFVariant): tbtunicodestring;
{$ENDIF}
procedure VSetPointerTo(const Src: PIFVariant; Data: Pointer; aType: TPSTypeRec);
procedure VSetUInt(const Src: PIFVariant; const Val: Cardinal);
{$IFNDEF PS_NOINT64}
procedure VSetInt64(const Src: PIFVariant; const Val: Int64);
{$ENDIF}
procedure VSetReal(const Src: PIFVariant; const Val: Extended);
procedure VSetCurrency(const Src: PIFVariant; const Val: Currency);
procedure VSetInt(const Src: PIFVariant; const Val: Longint);
procedure VSetString(const Src: PIFVariant; const Val: string);
procedure VSetAnsiString(const Src: PIFVariant; const Val: tbtString);
{$IFNDEF PS_NOWIDESTRING}
procedure VSetWideString(const Src: PIFVariant; const Val: tbtWideString);
procedure VSetUnicodeString(const Src: PIFVariant; const Val: tbtunicodestring);
{$ENDIF}
type
EPSException = class(Exception)
private
FProcPos: Cardinal;
FProcNo: Cardinal;
FExec: TPSExec;
public
constructor Create(const Error: tbtstring; Exec: TPSExec; Procno, ProcPos: Cardinal);
property ProcNo: Cardinal read FProcNo;
property ProcPos: Cardinal read FProcPos;
property Exec: TPSExec read FExec;
end;
TPSRuntimeClass = class
protected
FClassName: tbtstring;
FClassNameHash: Longint;
FClassItems: TPSList;
FClass: TClass;