-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathdwsComp.pas
More file actions
6603 lines (5600 loc) · 189 KB
/
Copy pathdwsComp.pas
File metadata and controls
6603 lines (5600 loc) · 189 KB
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
{**********************************************************************}
{ }
{ "The contents of this file are subject to the Mozilla Public }
{ License Version 1.1 (the "License"); you may not use this }
{ file except in compliance with the License. You may obtain }
{ a copy of the License at http://www.mozilla.org/MPL/ }
{ }
{ Software distributed under the License is distributed on an }
{ "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express }
{ or implied. See the License for the specific language }
{ governing rights and limitations under the License. }
{ }
{ The Initial Developer of the Original Code is Matthias }
{ Ackermann. For other initial contributors, see contributors.txt }
{ Subsequent portions Copyright Creative IT. }
{ }
{ Current maintainer: Eric Grange }
{ }
{**********************************************************************}
unit dwsComp;
{$I dws.inc}
interface
uses
Classes, SysUtils, TypInfo, Variants,
dwsCompiler, dwsExprs, dwsSymbols, dwsDataContext, dwsExprList, dwsScriptSource,
dwsStack, dwsFunctions, dwsStrings, dwsLanguageExtension, dwsCompilerContext,
dwsTokenizer, dwsUtils, dwsOperators, dwsUnitSymbols, dwsXPlatform, dwsUnicode,
// Built-In functions
{$IFNDEF DWS_NO_BUILTIN_FUNCTIONS}
dwsMathFunctions, dwsStringFunctions, dwsTimeFunctions, dwsVariantFunctions,
{$ENDIF}
dwsMagicExprs, dwsErrors;
type
TDelphiWebScript = class;
// TdwsCustomLangageExtension
//
TdwsCustomLangageExtension = class (TComponent)
private
FExtension : TdwsLanguageExtension;
FScript : TDelphiWebScript;
protected
function CreateExtension : TdwsLanguageExtension; virtual; abstract;
procedure SetScript(const val : TDelphiWebScript);
procedure Notification(AComponent: TComponent; Operation: TOperation); override;
property Extension : TdwsLanguageExtension read FExtension write FExtension;
public
constructor Create(AOwner: TComponent); override;
destructor Destroy; override;
published
property Script : TDelphiWebScript read FScript write SetScript;
end;
TdwsEmptyUnit = class (TComponent, IUnknown, IdwsUnit, IdwsUnitTableFactory)
private
procedure BeforeAdditionTo(dwscript : TObject);
function GetUnitName: String;
function GetDependencies : TStringList;
function GetUnitTable(systemTable : TSystemSymbolTable;
unitSyms : TUnitMainSymbols;
operators : TOperators;
rootTable : TSymbolTable) : TUnitSymbolTable;
function GetUnitFlags : TIdwsUnitFlags;
function GetDeprecatedMessage : String;
protected
FUnitName : String;
FDependencies : TStringList;
procedure AddUnitSymbols(SymbolTable: TSymbolTable); virtual; abstract;
function GetSelf : TObject;
public
constructor Create(AOwner: TComponent); override;
destructor Destroy; override;
end;
TdwsUnitComponent = class(TdwsEmptyUnit)
private
FScript: TDelphiWebScript;
protected
procedure SetScript(const Value: TDelphiWebScript);
procedure Notification(AComponent: TComponent; Operation: TOperation); override;
public
destructor Destroy; override;
published
property Script: TDelphiWebScript read FScript write SetScript;
end;
TNeedLocalizerEvent = function (Sender : TObject) : IdwsLocalizer;
// TDelphiWebScript
//
TDelphiWebScript = class (TdwsEmptyUnit)
private
FCompiler : IdwsCompiler;
FConfig : TdwsConfiguration;
FExtensions : TdwsLanguageExtensionAggregator;
FLock : TdwsCriticalSection;
protected
function GetOnInclude: TIncludeEvent;
procedure SetOnInclude(const Value: TIncludeEvent);
function GetOnExecutionStarted : TdwsExecutionEvent;
procedure SetOnExecutionStarted(const val : TdwsExecutionEvent);
function GetOnExecutionEnded : TdwsExecutionEvent;
procedure SetOnExecutionEnded(const val : TdwsExecutionEvent);
function GetVersion: String;
procedure SetVersion(const Value: String);
function GetOnNeedUnit : TdwsOnNeedUnitEvent;
procedure SetOnNeedUnit(const val : TdwsOnNeedUnitEvent);
function GetOnResource : TdwsResourceEvent;
procedure SetOnResource(const val : TdwsResourceEvent);
procedure SetConfig(const Value: TdwsConfiguration);
procedure AddUnitSymbols(SymbolTable: TSymbolTable); override;
procedure Notification(AComponent: TComponent; Operation: TOperation); override;
procedure SetupExtensions;
public
constructor Create(AOwner: TComponent); override;
destructor Destroy; override;
procedure AddUnit(const aUnit : IdwsUnit); overload;
function RemoveUnit(const aUnit : IdwsUnit): Boolean;
function Compile(const text : String; const mainFileName : String = '') : IdwsProgram; overload;
procedure RecompileInContext(const prog : IdwsProgram; const text : String); overload;
procedure AbortCompilation;
procedure Lock;
procedure UnLock;
property Compiler : IdwsCompiler read FCompiler;
property Extensions : TdwsLanguageExtensionAggregator read FExtensions;
published
property Config : TdwsConfiguration read FConfig write SetConfig stored True;
property OnNeedUnit : TdwsOnNeedUnitEvent read GetOnNeedUnit write SetOnNeedUnit stored False;
property OnInclude : TIncludeEvent read GetOnInclude write SetOnInclude stored False;
property OnResource : TdwsResourceEvent read GetOnResource write SetOnResource;
property OnExecutionStarted : TdwsExecutionEvent read GetOnExecutionStarted write SetOnExecutionStarted;
property OnExecutionEnded : TdwsExecutionEvent read GetOnExecutionEnded write SetOnExecutionEnded;
property Version : String read GetVersion write SetVersion stored False;
end;
TLocalizeSymbolEvent = procedure (Sender : TObject; aResSymbol : TResourceStringSymbol; var result : String) of object;
TLocalizeStringEvent = procedure (Sender : TObject; const aString : String; var result : String) of object;
TGetLocalizerEvent = procedure (Sender : TObject; var localizer : IdwsLocalizer) of object;
TEventBasedLocalizer = class (TInterfacedSelfObject, IdwsLocalizer)
private
FSender : TObject;
FOnLocalizeSymbol : TLocalizeSymbolEvent;
FOnLocalizeString : TLocalizeStringEvent;
public
procedure LocalizeSymbol(aResSymbol : TResourceStringSymbol; var Result : String);
procedure LocalizeString(const aString : String; var Result : String);
property Sender : TObject read FSender write FSender;
property OnLocalizeSymbol : TLocalizeSymbolEvent read FOnLocalizeSymbol write FOnLocalizeSymbol;
property OnLocalizeString : TLocalizeStringEvent read FOnLocalizeString write FOnLocalizeString;
end;
// TdwsCustomLocalizer
//
TdwsCustomLocalizer = class (TdwsLocalizerComponent)
private
FOnLocalizeSymbol : TLocalizeSymbolEvent;
FOnLocalizeString : TLocalizeStringEvent;
FOnGetLocalizer : TGetLocalizerEvent;
public
function GetLocalizer : IdwsLocalizer; override;
published
property OnLocalizeSymbol : TLocalizeSymbolEvent read FOnLocalizeSymbol write FOnLocalizeSymbol;
property OnLocalizeString : TLocalizeStringEvent read FOnLocalizeString write FOnLocalizeString;
property OnGetLocalizer : TGetLocalizerEvent read FOnGetLocalizer write FOnGetLocalizer;
end;
// TdwsAbstractUnit
//
TdwsAbstractUnit = class(TComponent, IUnknown, IdwsUnit, IdwsUnitTableFactory)
private
FDependencies : TStringList;
FScript : TDelphiWebScript;
FUnitName : String;
FDeprecatedMessage : String;
FImplicitUse : Boolean;
function GetDependencies : TStringList;
procedure SetScript(const Value: TDelphiWebScript);
procedure SetUnitName(const Value: String);
protected
procedure Notification(AComponent: TComponent; Operation: TOperation); override;
procedure BeforeAdditionTo(dwscript : TObject);
function GetSelf : TObject;
function GetUnitName: String;
function GetUnitTable(systemTable : TSystemSymbolTable; unitSyms : TUnitMainSymbols;
operators : TOperators; rootTable : TSymbolTable) : TUnitSymbolTable; virtual; abstract;
function GetUnitFlags : TIdwsUnitFlags;
function GetDeprecatedMessage : String;
{$WARNINGS OFF}
property UnitName: String read FUnitName write SetUnitName;
{$WARNINGS ON}
property DeprecatedMessage : String read FDeprecatedMessage write FDeprecatedMessage;
property ImplicitUse : Boolean read FImplicitUse write FImplicitUse;
public
constructor Create(AOwner: TComponent); override;
destructor Destroy; override;
published
property Script: TDelphiWebScript read FScript write SetScript;
end;
TSymbolTableType = (sttDefault, sttStatic, sttLinked);
// TdwsAbstractStaticUnit
//
TdwsAbstractStaticUnit = class(TdwsAbstractUnit)
private
FStaticSymbols : Boolean;
FStaticTable : IStaticSymbolTable;
protected
function GetUnitTable(systemTable : TSystemSymbolTable; unitSyms : TUnitMainSymbols;
operators : TOperators; rootTable : TSymbolTable) : TUnitSymbolTable; override;
function CreateUnitTable(parent, rootTable: TSymbolTable; tableType: TSymbolTableType): TUnitSymbolTable; virtual;
procedure SetStaticSymbols(const Value: Boolean); // static symbols
procedure InitUnitTable(systemTable : TSystemSymbolTable; unitSyms : TUnitMainSymbols;
operators : TOperators; UnitTable: TUnitSymbolTable); virtual;
procedure AddUnitSymbols(systemTable : TSystemSymbolTable; table : TSymbolTable; operators : TOperators); virtual; abstract;
property StaticSymbols : Boolean read FStaticSymbols write SetStaticSymbols;
property StaticTable : IStaticSymbolTable read FStaticTable;
public
constructor Create(AOwner: TComponent); override;
destructor Destroy; override;
procedure BeforeDestruction; override;
function InitStaticSymbols(systemTable : TSystemSymbolTable; unitSyms : TUnitMainSymbols; operators : TOperators): Boolean;
procedure ReleaseStaticSymbols;
end;
TDataType = String;
TdwsUnit = class;
TdwsGlobal = class;
TdwsSymbol = class(TCollectionItem)
private
FName: String;
FIsGenerating: Boolean;
FUnit: TdwsUnit;
protected
procedure AssignTo(Dest: TPersistent); override;
procedure CheckName(aTable : TSymbolTable; const aName : String; overloaded : Boolean = False);
function GetDataType(systemTable : TSystemSymbolTable; aTable : TSymbolTable; const aName : String) : TTypeSymbol;
procedure Reset;
procedure SetName(const val : String);
function Parse(const Value : String): String; virtual;
property IsGenerating: Boolean read FIsGenerating write FIsGenerating;
public
constructor Create(Collection: TCollection); override;
procedure Assign(Source: TPersistent); override;
function Generate(systemTable : TSystemSymbolTable; table: TSymbolTable; parentSym: TSymbol = nil): TSymbol;
function DoGenerate(systemTable : TSystemSymbolTable; Table: TSymbolTable; ParentSym: TSymbol = nil): TSymbol; virtual; abstract;
function GetNamePath: String; override;
function GetUnit: TdwsUnit;
published
property Name: String read FName write SetName;
end;
TdwsSymbolArray = array of TdwsSymbol;
TdwsSymbolClass = class of TdwsSymbol;
TdwsCollection = class(TOwnedCollection)
private
FUnit: TdwsUnit;
protected
class function GetSymbolClass : TdwsSymbolClass; virtual; abstract;
function GetSymbols(const Name: String): TdwsSymbol;
function GetItem(Index: Integer): TdwsSymbol;
procedure SetItem(Index: Integer; Value: TdwsSymbol);
procedure Reset;
public
constructor Create(AOwner: TPersistent);
function GetOwner: TPersistent; override;
function GetUnit: TdwsUnit;
function IndexOf(const Name: String): Integer;
property Symbols[const Name: String]: TdwsSymbol read GetSymbols;
property Items[Index: Integer]: TdwsSymbol read GetItem write SetItem;
end;
TdwsVariable = class(TdwsSymbol)
private
FDataType: TDataType;
protected
function GetDisplayName: String; override;
public
procedure Assign(Source: TPersistent); override;
published
property DataType: TDataType read FDataType write FDataType;
end;
TdwsVariables = class(TdwsCollection)
protected
class function GetSymbolClass : TdwsSymbolClass; override;
function GetDisplayName: String;
public
function Add : TdwsGlobal; overload;
function Add(const name, typName : String) : TdwsGlobal; overload;
end;
TdwsVariablesClass = class of TdwsVariables;
// TdwsParameter
//
TdwsParameter = class(TdwsVariable)
private
FIsVarParam : Boolean;
FIsLazy : Boolean;
FIsWritable : Boolean;
FDefaultValue : Variant;
FHasDefaultValue : Boolean;
protected
procedure SetIsVarParam(const Value: Boolean);
procedure SetHasDefaultValue(const Value: Boolean);
procedure SetIsWritable(const Value: Boolean);
procedure SetIsLazy(const val : Boolean);
procedure SetDefaultValue(const Value: Variant);
function GetDisplayName: String; override;
function Parse(const Value : String): String; override;
public
constructor Create(Collection: TCollection); override;
procedure Assign(Source: TPersistent); override;
function DoGenerate(systemTable : TSystemSymbolTable; Table: TSymbolTable; ParentSym: TSymbol = nil): TSymbol; override;
// not supported here yet, experimental
property IsLazy : Boolean read FIsLazy write SetIsLazy default False;
published
property IsVarParam : Boolean read FIsVarParam write SetIsVarParam default False;
property IsWritable : Boolean read FIsWritable write SetIsWritable default True;
property HasDefaultValue : Boolean read FHasDefaultValue write SetHasDefaultValue default False;
property DefaultValue: Variant read FDefaultValue write SetDefaultValue;
end;
TdwsParameters = class(TdwsVariables)
protected
class function GetSymbolClass : TdwsSymbolClass; override;
public
function Add : TdwsParameter; overload; inline;
function Add(const name, typeName : String) : TdwsParameter; overload;
end;
TFuncEvalEvent = procedure(info : TProgramInfo) of object;
TFuncFastEvalEvent = function(const args : TExprBaseListExec) : Variant of object;
TInitSymbolEvent = procedure(sender : TObject; symbol : TSymbol) of object;
TInitExprEvent = procedure(sender : TObject; expr : TExprBase) of object;
TdwsCallable = class(TInterfacedSelfObject, IExecutable, ICallable)
private
FOwner : TObject;
FOnInitSymbol : TInitSymbolEvent;
FOnInitExpr : TInitExprEvent;
protected
procedure Call(exec : TdwsProgramExecution; func : TFuncSymbol); virtual; abstract;
procedure CompileTimeCheck(context : TdwsCompilerContext; expr : TFuncExprBase); virtual;
procedure InitSymbol(symbol : TSymbol; const msgs : TdwsCompileMessageList);
procedure InitExpression(expr : TExprBase);
function SubExpr(i : Integer) : TExprBase;
function SubExprCount : Integer;
function Specialize(const context : ISpecializationContext) : IExecutable;
public
constructor Create(owner : TObject);
property OnInitSymbol : TInitSymbolEvent read FOnInitSymbol write FOnInitSymbol;
property OnInitExpr : TInitExprEvent read FOnInitExpr write FOnInitExpr;
end;
TdwsFunctionCallable = class(TdwsCallable)
private
FOnEval : TFuncEvalEvent;
protected
procedure Call(exec : TdwsProgramExecution; func : TFuncSymbol); override;
public
property OnEval : TFuncEvalEvent read FOnEval write FOnEval;
end;
TdwsFunctionSymbol = class(TdwsSymbol)
private
FResultType : TDataType;
FParameters : TdwsParameters;
FDeprecated : String;
FCallable : TdwsCallable;
FOverloaded : Boolean;
protected
function GetDisplayName: String; override;
procedure SetResultType(const val : TDataType); virtual;
procedure SetParameters(const Value: TdwsParameters);
function GetOnInitExpr : TInitExprEvent;
procedure SetOnInitExpr(const val : TInitExprEvent);
function GetOnInitSymbol : TInitSymbolEvent;
procedure SetOnInitSymbol(const val : TInitSymbolEvent);
function StoreParameters : Boolean;
function Parse(const Value : String): String; override;
procedure SetMethodType(const value: TTokenType); virtual;
public
constructor Create(collection : TCollection); override;
destructor Destroy; override;
procedure Assign(Source: TPersistent); override;
function DoGenerate(systemTable : TSystemSymbolTable; Table: TSymbolTable;
ParentSym: TSymbol = nil): TSymbol; override;
function GetParameters(systemTable : TSystemSymbolTable; Table: TSymbolTable): TParamArray;
published
property Parameters : TdwsParameters read FParameters write SetParameters stored StoreParameters;
property ResultType : TDataType read FResultType write SetResultType;
property OnInitSymbol : TInitSymbolEvent read GetOnInitSymbol write SetOnInitSymbol;
property OnInitExpr : TInitExprEvent read GetOnInitExpr write SetOnInitExpr;
property Deprecated : String read FDeprecated write FDeprecated;
property Overloaded : Boolean read FOverloaded write FOverloaded default False;
end;
TdwsFunction = class(TdwsFunctionSymbol)
private
FOnFastEval : TFuncFastEvalEvent;
protected
function GetOnEval : TFuncEvalEvent;
procedure SetOnEval(const val : TFuncEvalEvent);
public
constructor Create(collection : TCollection); override;
function DoGenerate(systemTable : TSystemSymbolTable; Table: TSymbolTable; ParentSym: TSymbol = nil): TSymbol; override;
published
property OnEval : TFuncEvalEvent read GetOnEval write SetOnEval;
property OnFastEval : TFuncFastEvalEvent read FOnFastEval write FOnFastEval;
end;
TdwsFunctions = class(TdwsCollection)
protected
class function GetSymbolClass : TdwsSymbolClass; override;
public
function Add : TdwsFunction; overload; inline;
function Add(const name : String; const resultType : String = '') : TdwsFunction; overload;
end;
TdwsFunctionsClass = class of TdwsFunctions;
// It would have better sense to derive both TdwsFunctionSymbol and TdwsDelegate
// from a common ancestor.
TdwsDelegate = class(TdwsSymbol)
private
FResultType : TDataType;
FParameters : TdwsParameters;
FDeprecated : String;
protected
function GetDisplayName: String; override;
procedure SetResultType(const Value: TDataType); virtual;
procedure SetParameters(const Value: TdwsParameters);
function StoreParameters : Boolean;
function Parse(const Value : String): String; override;
public
constructor Create(Collection: TCollection); override;
destructor Destroy; override;
procedure Assign(Source: TPersistent); override;
function DoGenerate(systemTable : TSystemSymbolTable; Table: TSymbolTable; ParentSym: TSymbol = nil): TSymbol; override;
function GetParameters(systemTable : TSystemSymbolTable; Table: TSymbolTable): TParamArray;
published
property Parameters : TdwsParameters read FParameters write SetParameters stored StoreParameters;
property ResultType : TDataType read FResultType write SetResultType;
property Deprecated : String read FDeprecated write FDeprecated;
end;
TdwsDelegates = class(TdwsCollection)
protected
class function GetSymbolClass : TdwsSymbolClass; override;
public
function Add: TdwsDelegate; overload; inline;
function Add(const Name: String; const ResultType: String = '') : TdwsDelegate; overload;
end;
TdwsDelegatesClass = class of TdwsDelegates;
TdwsArray = class(TdwsSymbol)
private
FDataType: TDataType;
FLowBound: Integer;
FHighBound: Integer;
protected
procedure SetIsDynamic(const Value: Boolean);
function GetIsDynamic: Boolean;
function GetDisplayName: String; override;
function GetBoundStored: Boolean;
public
function DoGenerate(systemTable : TSystemSymbolTable; Table: TSymbolTable; ParentSym: TSymbol = nil): TSymbol;
override;
procedure Assign(Source: TPersistent); override;
published
property DataType: TDataType read FDataType write FDataType;
property LowBound: Integer read FLowBound write FLowBound stored GetBoundStored;
property HighBound: Integer read FHighBound write FHighBound stored GetBoundStored;
property IsDynamic: Boolean read GetIsDynamic write SetIsDynamic default False;
end;
TdwsArrays = class(TdwsCollection)
protected
class function GetSymbolClass : TdwsSymbolClass; override;
public
function Add : TdwsArray;
end;
TdwsArraysClass = class of TdwsArrays;
TdwsConstant = class(TdwsVariable)
protected
FValue: Variant;
function GetDisplayName: String; override;
public
procedure Assign(Source: TPersistent); override;
function DoGenerate(systemTable : TSystemSymbolTable; Table: TSymbolTable;
ParentSym: TSymbol = nil): TSymbol; override;
published
property Value: Variant read FValue write FValue;
end;
TdwsConstants = class(TdwsCollection)
protected
class function GetSymbolClass : TdwsSymbolClass; override;
function GetValues(const name : String) : Variant;
procedure SetValues(const name : String; const v : Variant);
public
function Add : TdwsConstant; inline;
property Values[const name : String] : Variant read GetValues write SetValues;
end;
TdwsConstantsClass = class of TdwsConstants;
TdwsForward = class(TdwsSymbol)
protected
function GetDisplayName: String; override;
public
function DoGenerate(systemTable : TSystemSymbolTable; Table: TSymbolTable;
ParentSym: TSymbol = nil): TSymbol; override;
end;
TdwsForwards = class(TdwsCollection)
protected
class function GetSymbolClass : TdwsSymbolClass; override;
public
function Add : TdwsForward; inline;
end;
TdwsForwardsClass = class of TdwsForwards;
TdwsField = class(TdwsVariable)
private
FVisibility : TdwsVisibility;
FDefaultValue : Variant;
FHasDefaultValue : Boolean;
protected
function GetDisplayName: String; override;
procedure SetDefaultValue(const Value: Variant);
function GetHasDefaultValue : Boolean;
function Parse(const Value : String): String; override;
public
constructor Create(Collection: TCollection); override;
function DoGenerate(systemTable : TSystemSymbolTable; Table: TSymbolTable;
ParentSym: TSymbol = nil): TSymbol; override;
published
property Visibility : TdwsVisibility read FVisibility write FVisibility default cvPublic;
property DefaultValue : Variant read FDefaultValue write SetDefaultValue stored GetHasDefaultValue;
property HasDefaultValue : Boolean read FHasDefaultValue write FHasDefaultValue default False;
end;
TdwsFields = class(TdwsCollection)
protected
class function GetSymbolClass : TdwsSymbolClass; override;
public
function Add : TdwsField;
end;
TdwsProperty = class(TdwsSymbol)
private
FDataType: TDataType;
FReadAccess: String;
FWriteAccess: String;
FParameters: TdwsParameters;
FDeprecated : String;
FIndexValue: Variant;
FIsDefault: Boolean;
FIndexType: TDataType;
FVisibility : TdwsVisibility;
procedure SetReadAccess(const Value: String);
procedure SetWriteAccess(const Value: String);
protected
function GetDisplayName: String; override;
function GetIsDefault: Boolean;
procedure SetIsDefault(Value: Boolean);
procedure SetParameters(const Value: TdwsParameters);
function StoreParameters : Boolean;
function Parse(const Value : String): String; override;
public
constructor Create(Collection: TCollection); override;
destructor Destroy; override;
procedure Assign(Source: TPersistent); override;
function DoGenerate(systemTable : TSystemSymbolTable; Table: TSymbolTable;
ParentSym: TSymbol = nil): TSymbol; override;
published
property DataType: TDataType read FDataType write FDataType;
property Deprecated : String read FDeprecated write FDeprecated;
property Visibility : TdwsVisibility read FVisibility write FVisibility default cvPublic;
property ReadAccess: String read FReadAccess write SetReadAccess;
property WriteAccess: String read FWriteAccess write SetWriteAccess;
property Parameters: TdwsParameters read FParameters write SetParameters stored StoreParameters;
property IsDefault: Boolean read GetIsDefault write SetIsDefault default False;
property IndexType: TDataType read FIndexType write FIndexType;
property IndexValue: Variant read FIndexValue write FIndexValue;
end;
TdwsProperties = class(TdwsCollection)
protected
class function GetSymbolClass : TdwsSymbolClass; override;
public
function Add : TdwsProperty;
end;
TdwsClassOperator = class(TdwsSymbol)
private
FOperator: TTokenType;
FDataType: TDataType;
FUsesAccess: String;
protected
function GetDisplayName: String; override;
public
procedure Assign(Source: TPersistent); override;
function DoGenerate(systemTable : TSystemSymbolTable; Table: TSymbolTable;
ParentSym: TSymbol = nil): TSymbol; override;
published
property DataType: TDataType read FDataType write FDataType;
property &Operator : TTokenType read FOperator write FOperator;
property UsesAccess : String read FUsesAccess write FUsesAccess;
end;
TdwsClassOperators = class(TdwsCollection)
protected
class function GetSymbolClass : TdwsSymbolClass; override;
end;
TdwsTypeSymbol = class(TCollectionItem)
private
FName: String;
protected
function GetDisplayName: String; override;
public
procedure Assign(Source: TPersistent); override;
published
property Name : String read FName write FName;
end;
TdwsTypeSymbols = class(TOwnedCollection)
public
constructor Create(AOwner: TPersistent);
function Add : TdwsTypeSymbol;
end;
TdwsOperator = class(TdwsSymbol)
private
FOperator: TTokenType;
FResultType: TDataType;
FParams : TdwsTypeSymbols;
FUsesAccess: String;
protected
function GetDisplayName: String; override;
public
constructor Create(Collection: TCollection); override;
destructor Destroy; override;
procedure Assign(Source: TPersistent); override;
function DoGenerate(systemTable : TSystemSymbolTable; Table: TSymbolTable;
ParentSym: TSymbol = nil): TSymbol; override;
published
property ResultType : TDataType read FResultType write FResultType;
property Params : TdwsTypeSymbols read FParams write FParams;
property &Operator : TTokenType read FOperator write FOperator;
property UsesAccess : String read FUsesAccess write FUsesAccess;
end;
TdwsOperators = class(TdwsCollection)
protected
class function GetSymbolClass : TdwsSymbolClass; override;
public
function Add : TdwsOperator;
end;
TdwsOperatorsClass = class of TdwsOperators;
TAssignExternalObjectEvent = procedure(Info: TProgramInfo; var ExtObject: TObject) of object;
TMethodEvalEvent = procedure(Info: TProgramInfo; ExtObject: TObject) of object;
TdwsMethodCallable = class(TdwsCallable)
private
FOnEval : TMethodEvalEvent;
protected
procedure Call(exec : TdwsProgramExecution; func : TFuncSymbol); override;
public
property OnEval : TMethodEvalEvent read FOnEval write FOnEval;
end;
TdwsMethod = class(TdwsFunctionSymbol)
private
FAttributes : TMethodAttributes;
FKind : TMethodKind;
FVisibility : TdwsVisibility;
protected
function GetDisplayName: String; override;
function GetOnEval : TMethodEvalEvent;
procedure SetOnEval(const val : TMethodEvalEvent);
procedure SetResultType(const val : TDataType); override;
procedure SetAttributes(const attribs : TMethodAttributes);
procedure SetMethodType(const value: TTokenType); override;
public
constructor Create(collection : TCollection); override;
procedure Assign(Source: TPersistent); override;
function DoGenerate(systemTable : TSystemSymbolTable; Table: TSymbolTable;
ParentSym: TSymbol = nil): TSymbol; override;
published
property Attributes: TMethodAttributes read FAttributes write SetAttributes default [];
property OnEval : TMethodEvalEvent read GetOnEval write SetOnEval;
property Visibility : TdwsVisibility read FVisibility write FVisibility default cvPublic;
property Kind: TMethodKind read FKind write FKind;
end;
TdwsMethods = class(TdwsCollection)
protected
class function GetSymbolClass : TdwsSymbolClass; override;
public
function Add : TdwsMethod; overload; inline;
function Add(const name : String; const resultType : String = '') : TdwsMethod; overload;
end;
TdwsConstructorCallable = class(TdwsCallable)
private
FOnEval : TAssignExternalObjectEvent;
protected
procedure Call(exec : TdwsProgramExecution; func : TFuncSymbol); override;
public
property OnEval : TAssignExternalObjectEvent read FOnEval write FOnEval;
end;
TdwsConstructor = class(TdwsFunctionSymbol)
private
FAttributes: TMethodAttributes;
FVisibility : TdwsVisibility;
protected
function GetResultType: String;
function GetDisplayName: String; override;
function GetOnEval : TAssignExternalObjectEvent;
procedure SetOnEval(const val : TAssignExternalObjectEvent);
procedure SetAttributes(const attribs : TMethodAttributes);
public
constructor Create(Collection: TCollection); override;
procedure Assign(Source: TPersistent); override;
function DoGenerate(systemTable : TSystemSymbolTable; Table: TSymbolTable;
ParentSym: TSymbol = nil): TSymbol; override;
published
property Visibility : TdwsVisibility read FVisibility write FVisibility default cvPublic;
property OnEval : TAssignExternalObjectEvent read GetOnEval write SetOnEval;
property Attributes: TMethodAttributes read FAttributes write SetAttributes default [];
property ResultType: String read GetResultType;
end;
TdwsConstructors = class(TdwsCollection)
protected
class function GetSymbolClass : TdwsSymbolClass; override;
public
function Add : TdwsConstructor;
end;
TdwsClassConstant = class(TdwsConstant)
private
FVisibility : TdwsVisibility;
protected
function GetDisplayName: String; override;
public
constructor Create(Collection: TCollection); override;
procedure Assign(Source: TPersistent); override;
function DoGenerate(systemTable : TSystemSymbolTable; Table: TSymbolTable;
ParentSym: TSymbol = nil): TSymbol; override;
published
property Visibility : TdwsVisibility read FVisibility write FVisibility default cvPublic;
end;
TdwsClassConstants = class(TdwsCollection)
protected
class function GetSymbolClass : TdwsSymbolClass; override;
public
function Add : TdwsClassConstant;
end;
// TdwsClass
//
TdwsClass = class(TdwsSymbol)
private
FAncestor : String;
FConstructors : TdwsConstructors;
FFields : TdwsFields;
FMethods : TdwsMethods;
FOnObjectDestroy : TObjectDestroyEvent;
FProperties : TdwsProperties;
FOperators : TdwsClassOperators;
FConstants : TdwsClassConstants;
FHelperObject : TObject;
FIsSealed : Boolean;
FIsAbstract : Boolean;
FIsStatic : Boolean;
FDeprecated : String;
protected
function GetDisplayName : String; override;
function StoreConstructors : Boolean;
function StoreFields : Boolean;
function StoreMethods : Boolean;
function StoreOperators : Boolean;
function StoreConstants : Boolean;
function StoreProperties : Boolean;
public
constructor Create(Collection: TCollection); override;
destructor Destroy; override;
procedure Assign(Source: TPersistent); override;
function DoGenerate(systemTable : TSystemSymbolTable; Table: TSymbolTable;
ParentSym: TSymbol = nil): TSymbol; override;
{: User-side helper object, freed by the TdwsClass. }
property HelperObject : TObject read FHelperObject write FHelperObject;
published
property Ancestor : String read FAncestor write FAncestor;
property IsSealed : Boolean read FIsSealed write FIsSealed default False;
property IsAbstract : Boolean read FIsAbstract write FIsAbstract default False;
property IsStatic : Boolean read FIsStatic write FIsStatic default False;
property Deprecated : String read FDeprecated write FDeprecated;
property Constructors : TdwsConstructors read FConstructors write FConstructors stored StoreConstructors;
property Fields : TdwsFields read FFields write FFields stored StoreFields;
property Methods : TdwsMethods read FMethods write FMethods stored StoreMethods;
property Operators : TdwsClassOperators read FOperators write FOperators stored StoreOperators;
property Constants : TdwsClassConstants read FConstants write FConstants stored StoreConstants;
property Properties: TdwsProperties read FProperties write FProperties stored StoreProperties;
property OnCleanUp : TObjectDestroyEvent read FOnObjectDestroy write FOnObjectDestroy;
end;
TdwsClasses = class(TdwsCollection)
protected
class function GetSymbolClass : TdwsSymbolClass; override;
public
function Add : TdwsClass;
end;
TdwsClassesClass = class of TdwsClasses;
// TdwsInterface
//
TdwsInterface = class(TdwsSymbol)
private
FAncestor : String;
FMethods : TdwsMethods;
FProperties : TdwsProperties;
protected
function GetDisplayName : String; override;
function StoreMethods : Boolean;
function StoreProperties : Boolean;
public
constructor Create(Collection: TCollection); override;
destructor Destroy; override;
procedure Assign(Source: TPersistent); override;
function DoGenerate(systemTable : TSystemSymbolTable; Table: TSymbolTable;
ParentSym: TSymbol = nil): TSymbol; override;
published
property Ancestor : String read FAncestor write FAncestor;
property Methods : TdwsMethods read FMethods write FMethods stored StoreMethods;
property Properties: TdwsProperties read FProperties write FProperties stored StoreProperties;
end;
TdwsInterfaces = class(TdwsCollection)
protected
class function GetSymbolClass : TdwsSymbolClass; override;
public
function Add : TdwsInterface;
end;