forked from jrsoftware/issrc
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathScriptCompiler.pas
588 lines (530 loc) · 21.1 KB
/
ScriptCompiler.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
unit ScriptCompiler;
{
Inno Setup
Copyright (C) 1997-2018 Jordan Russell
Portions by Martijn Laan
For conditions of distribution and use, see LICENSE.TXT.
Script compiler
}
interface
uses
Classes, Generics.Collections, uPSUtils;
type
TScriptCompilerOnLineToLineInfo = procedure(const Line: LongInt; var Filename: String; var FileLine: LongInt) of object;
TScriptCompilerOnUsedLine = procedure(const Filename: String; const Line, Position: LongInt; const IsProcExit: Boolean) of object;
TScriptCompilerOnUsedVariable = procedure(const Filename: String; const Line, Col, Param1, Param2, Param3: LongInt; const Param4: AnsiString) of object;
TScriptCompilerOnError = procedure(const Msg: String; const ErrorFilename: String; const ErrorLine: LongInt) of object;
TScriptCompilerOnWarning = procedure(const Msg: String) of object;
TScriptCompiler = class
private
FNamingAttribute: String;
FObsoleteFunctionWarnings: TDictionary<String, String>;
FExports, FUsedLines: TList;
FFunctionsFound: TStringList;
FScriptText: AnsiString;
FOnLineToLineInfo: TScriptCompilerOnLineToLineInfo;
FOnUsedLine: TScriptCompilerOnUsedLine;
FOnUsedVariable: TScriptCompilerOnUsedVariable;
FOnError: TScriptCompilerOnError;
FOnWarning: TScriptCompilerOnWarning;
function FindExport(const Name, Decl: String; const IgnoreIndex: Integer): Integer;
function GetExportCount: Integer;
procedure PSPositionToLineCol(Position: LongInt; var Line, Col: LongInt);
procedure TriggerWarning(const Position: LongInt; const WarningType, WarningMessage: String);
public
constructor Create;
destructor Destroy; override;
procedure AddExport(const Name, Decl: String; const AllowNamingAttribute, Required: Boolean; const RequiredFilename: String; const RequiredLine: LongInt);
function CheckExports: Boolean;
function Compile(const ScriptText: String; var CompiledScriptText, CompiledScriptDebugInfo: tbtString): Boolean;
property ExportCount: Integer read GetExportCount;
function ExportFound(const Name: String): Boolean;
function FunctionFound(const Name: String): Boolean;
function IsObsoleteFunction(const Name: String): String;
property NamingAttribute: String write FNamingAttribute;
property OnLineToLineInfo: TScriptCompilerOnLineToLineInfo write FOnLineToLineInfo;
property OnUsedLine: TScriptCompilerOnUsedLine write FOnUsedLine;
property OnUsedVariable: TScriptCompilerOnUsedVariable write FOnUsedVariable;
property OnError: TScriptCompilerOnError write FOnError;
property OnWarning: TScriptCompilerOnWarning write FOnWarning;
end;
implementation
uses
SysUtils, Generics.Defaults,
uPSCompiler, uPSC_dll,
ScriptClasses_C, ScriptFunc_C;
type
TScriptExport = class
Name, Decl: String;
AllowNamingAttribute: Boolean;
Required: Boolean;
RequiredFilename: String;
RequiredLine: LongInt;
Exported: Boolean;
end;
{---}
function PSPascalCompilerOnExternalProc(Sender: TPSPascalCompiler; Decl: TPSParametersDecl; const Name, FExternal: tbtstring): TPSRegProc;
var
S: String;
P: Integer;
begin
S := String(FExternal) + ' ';
P := Pos(' setuponly ', S);
if P > 0 then begin
Delete(S, P+1, Length('setuponly '));
Insert('setup:', S, Pos('@', S)+1);
end
else begin
P := Pos(' uninstallonly ', S);
if P > 0 then begin
Delete(S, P+1, Length('uninstallonly '));
Insert('uninstall:', S, Pos('@', S)+1);
end;
end;
if Pos('@uninstall:files:', S) <> 0 then begin
Sender.MakeError('', ecCustomError, '"uninstallonly" cannot be used with "files:"');
Result := nil;
Exit;
end;
Result := DllExternalProc(Sender, Decl, Name, tbtstring(TrimRight(S)));
end;
function PSPascalCompilerOnApplyAttributeToProc(Sender: TPSPascalCompiler; aProc: TPSProcedure; Attr: TPSAttribute): Boolean;
var
ScriptCompiler: TScriptCompiler;
AttrValue: String;
ScriptExport: TScriptExport;
B: Boolean;
I: Integer;
begin
ScriptCompiler := TScriptCompiler(Sender.ID);
if CompareText(String(Attr.AType.Name), ScriptCompiler.FNamingAttribute) = 0 then begin
if aProc.ClassType <> TPSInternalProcedure then begin
with Sender.MakeError('', ecCustomError, tbtstring(Format('"%s" attribute cannot be used on external function or procedure', [ScriptCompiler.FNamingAttribute]))) do
SetCustomPos(Attr.DeclarePos, Attr.DeclareRow, Attr.DeclareCol);
Result := False;
end else if Attr.Count <> 1 then begin
with Sender.MakeError('', ecCustomError, tbtstring(Format('"%s" attribute value not found', [ScriptCompiler.FNamingAttribute]))) do
SetCustomPos(Attr.DeclarePos, Attr.DeclareRow, Attr.DeclareCol);
Result := False;
end else begin
if ScriptCompiler.FindExport(String(TPSInternalProcedure(aProc).Name), '', -1) <> -1 then begin
{ Don't allow attributes on functions already matching an export (by their name) so that we don't have to deal with this later. }
with Sender.MakeError('', ecCustomError, tbtstring(Format('"%s" attribute not allowed for function or procedure "%s"', [ScriptCompiler.FNamingAttribute, String(TPSInternalProcedure(aProc).Name)]))) do
SetCustomPos(Attr.DeclarePos, Attr.DeclareRow, Attr.DeclareCol);
Result := False;
end else begin
AttrValue := String(GetString(Attr.Values[0], B));
I := ScriptCompiler.FindExport(AttrValue, String(Sender.MakeDecl(TPSInternalProcedure(aProc).Decl)), -1);
if I <> -1 then begin
{ The name from the attribute and the function prototype are both ok. }
ScriptExport := ScriptCompiler.FExports[I];
if not ScriptExport.AllowNamingAttribute then begin
with Sender.MakeError('', ecCustomError, tbtstring(Format('"%s" attribute value "%s" not allowed', [ScriptCompiler.FNamingAttribute, AttrValue]))) do
SetCustomPos(Attr.DeclarePos, Attr.DeclareRow, Attr.DeclareCol);
Result := False;
end else begin
ScriptExport.Exported := True;
Result := True;
end;
end else if ScriptCompiler.FindExport(AttrValue, '', -1) <> -1 then begin
{ The name from the attribute is ok but the function prototype is not. }
with Sender.MakeError('', ecCustomError, tbtstring(Format('Invalid function or procedure prototype for attribute value "%s"', [AttrValue]))) do
SetCustomPos(TPSInternalProcedure(aProc).DeclarePos, TPSInternalProcedure(aProc).DeclareRow, TPSInternalProcedure(aProc).DeclareCol);
Result := False;
end else begin
{ The name from the attribute is not ok. }
with Sender.MakeError('', ecCustomError, tbtstring(Format('"%s" attribute value "%s" invalid', [ScriptCompiler.FNamingAttribute, AttrValue]))) do
SetCustomPos(Attr.DeclarePos, Attr.DeclareRow, Attr.DeclareCol);
Result := False;
end;
end;
end;
end else
Result := True;
end;
function PSPascalCompilerOnApplyAttributeToType(Sender: TPSPascalCompiler; aType: TPSType; Attr: TPSAttribute): Boolean;
var
NamingAttribute: String;
begin
NamingAttribute := TScriptCompiler(Sender.ID).FNamingAttribute;
if CompareText(String(Attr.AType.Name), NamingAttribute) = 0 then begin
with Sender.MakeError('', ecCustomError, tbtstring(Format('"%s" attribute cannot be used on types', [NamingAttribute]))) do
SetCustomPos(Attr.DeclarePos, Attr.DeclareRow, Attr.DeclareCol);
Result := False;
end else
Result := True;
end;
function PSPascalCompilerOnUses(Sender: TPSPascalCompiler; const Name: tbtstring): Boolean;
var
NamingAttribute: String;
begin
if Name = 'SYSTEM' then begin
RegisterDll_Compiletime(Sender);
Sender.OnExternalProc := PSPascalCompilerOnExternalProc;
ScriptClassesLibraryRegister_C(Sender);
ScriptFuncLibraryRegister_C(Sender, TScriptCompiler(Sender.ID).FObsoleteFunctionWarnings);
NamingAttribute := TScriptCompiler(Sender.ID).FNamingAttribute;
if NamingAttribute <> '' then begin
with Sender.AddAttributeType do begin
OrgName := tbtstring(NamingAttribute);
with AddField do begin
FieldOrgName := 'Name';
FieldType := Sender.FindType('String');
end;
OnApplyAttributeToProc := PSPascalCompilerOnApplyAttributeToProc;
OnApplyAttributeToType := PSPascalCompilerOnApplyAttributeToType;
end;
end;
Result := True;
end else begin
Sender.MakeError('', ecUnknownIdentifier, '');
Result := False;
end;
end;
function PSPascalCompilerOnExportCheck(Sender: TPSPascalCompiler; Proc: TPSInternalProcedure; const ProcDecl: tbtstring): Boolean;
var
ScriptCompiler: TScriptCompiler;
ScriptExport: TScriptExport;
I: Integer;
begin
ScriptCompiler := TScriptCompiler(Sender.ID);
ScriptCompiler.FFunctionsFound.Add(String(Proc.Name));
{ Try and see if the function name matches an export and if so,
see if one of the prototypes for that name matches. }
I := ScriptCompiler.FindExport(String(Proc.Name), String(Procdecl), -1);
if I <> -1 then begin
{ The function name is a match and the function prototype is ok. }
ScriptExport := ScriptCompiler.FExports[I];
ScriptExport.Exported := True;
Result := True;
end else if ScriptCompiler.FindExport(String(Proc.Name), '', -1) <> -1 then begin
{ The function name is a match but the function prototype is not. }
with Sender.MakeError('', ecCustomError, tbtstring(Format('Invalid prototype for ''%s''', [Proc.OriginalName]))) do
SetCustomPos(Proc.DeclarePos, Proc.DeclareRow, Proc.DeclareCol);
Result := False;
end else
Result := True; { The function name is not a match - this is a user function. }
end;
function PSPascalCompilerOnBeforeOutput(Sender: TPSPascalCompiler): Boolean;
var
ScriptCompiler: TScriptCompiler;
ScriptExport: TScriptExport;
I: Integer;
Decl: TPSParametersDecl;
Msg: String;
begin
ScriptCompiler := Sender.ID;
Result := True;
{ Try and see if required but non found exports match any built in function
names and if so, see if the prototypes also match }
for I := 0 to ScriptCompiler.FExports.Count-1 do begin
ScriptExport := ScriptCompiler.FExports[I];
if ScriptExport.Required and not ScriptExport.Exported then begin
Decl := Sender.UseExternalProc(tbtstring(ScriptExport.Name));
if Decl <> nil then begin
if CompareText(ScriptExport.Decl, String(Sender.MakeDecl(Decl))) = 0 then
ScriptExport.Exported := True
else begin
if Assigned(ScriptCompiler.FOnError) then begin
Msg := Format('Function or procedure ''%s'' prototype is incompatible', [ScriptExport.Name]);
ScriptCompiler.FOnError(Msg, ScriptExport.RequiredFilename, ScriptExport.RequiredLine);
end;
Result := False;
end;
end;
end;
end;
end;
function PSPascalCompilerOnWriteLine2(Sender: TPSPascalCompiler; Position: Cardinal; IsProcExit: Boolean): Boolean;
var
ScriptCompiler: TScriptCompiler;
Filename: String;
Line, Col: LongInt;
begin
ScriptCompiler := Sender.ID;
if Assigned(ScriptCompiler.FOnUsedLine) then begin
ScriptCompiler.PSPositionToLineCol(Position, Line, Col);
if ScriptCompiler.FUsedLines.IndexOf(Pointer(Line)) = -1 then begin
ScriptCompiler.FUsedLines.Add(Pointer(Line));
Filename := '';
if Assigned(ScriptCompiler.FOnLineToLineInfo) then
ScriptCompiler.FOnLineToLineInfo(Line, Filename, Line);
ScriptCompiler.FOnUsedLine(Filename, Line, Position, IsProcExit);
Result := True;
end else
Result := False;
end else
Result := True;
end;
procedure PSPascalCompilerOnUseVariable(Sender: TPSPascalCompiler; VarType: TPSVariableType; VarNo: Longint; ProcNo, Position: Cardinal; const PropData: tbtstring);
var
ScriptCompiler: TScriptCompiler;
Filename: String;
Line, Col: LongInt;
begin
ScriptCompiler := Sender.ID;
if Assigned(ScriptCompiler.FOnUsedVariable) then begin
ScriptCompiler.PSPositionToLineCol(Position, Line, Col);
Filename := '';
if Assigned(ScriptCompiler.FOnLineToLineInfo) then
ScriptCompiler.FOnLineToLineInfo(Line, Filename, Line);
ScriptCompiler.FOnUsedVariable(Filename, Line, Col, LongInt(VarType), ProcNo, VarNo, PropData);
end;
end;
procedure PSPascalCompilerOnUseRegProc(Sender: TPSPascalCompiler; Position: Cardinal; const Name: tbtstring);
var
ScriptCompiler: TScriptCompiler;
WarningMessage: String;
begin
ScriptCompiler := Sender.ID;
if Assigned(ScriptCompiler.FOnWarning) then begin
WarningMessage := ScriptCompiler.IsObsoleteFunction(String(Name));
if WarningMessage <> '' then
ScriptCompiler.TriggerWarning(Position, 'Hint', WarningMessage);
end;
end;
{---}
constructor TScriptCompiler.Create;
begin
FObsoleteFunctionWarnings := TDictionary<String, String>.Create(TIStringComparer.Ordinal);
FExports := TList.Create();
FUsedLines := TList.Create();
FFunctionsFound := TStringList.Create();
end;
destructor TScriptCompiler.Destroy;
var
I: Integer;
begin
FFunctionsFound.Free();
FUsedLines.Free();
for I := 0 to FExports.Count-1 do
TScriptExport(FExports[I]).Free();
FExports.Free();
FObsoleteFunctionWarnings.Free();
end;
procedure TScriptCompiler.PSPositionToLineCol(Position: LongInt; var Line, Col: LongInt);
function FindNewLine(const S: AnsiString; const Start: Integer): Integer;
var
I: Integer;
begin
for I := Start to Length(S) do
if S[I] = #10 then begin
Result := I - Start + 1;
Exit;
end;
Result := 0;
end;
var
LineStartPosition, LineLength: LongInt;
begin
Inc(Position);
Line := 1;
LineStartPosition := 1;
LineLength := FindNewLine(FScriptText, LineStartPosition);
while (LineLength <> 0) and (Position > LineLength) do begin
Inc(Line);
Inc(LineStartPosition, LineLength);
Dec(Position, LineLength);
LineLength := FindNewLine(FScriptText, LineStartPosition);
end;
{$IFDEF UNICODE}
{ Convert Position from the UTF8 encoded ANSI string index to a UTF-16 string index }
Position := Length(UTF8ToString(Copy(FScriptText, LineStartPosition, Position - 1))) + 1;
{$ENDIF}
Col := Position;
end;
procedure TScriptCompiler.TriggerWarning(const Position: LongInt; const WarningType, WarningMessage: String);
var
Line, Col: LongInt;
Filename, Msg: String;
begin
PSPositionToLineCol(Position, Line, Col);
Filename := '';
if Assigned(FOnLineToLineInfo) then
FOnLineToLineInfo(Line, Filename, Line);
Msg := '';
if Filename <> '' then
Msg := Msg + Filename + ', ';
Msg := Msg + Format('Line %d, Column %d: [%s] %s', [Line, Col, WarningType, WarningMessage]);
FOnWarning(Msg);
end;
procedure TScriptCompiler.AddExport(const Name, Decl: String; const AllowNamingAttribute, Required: Boolean; const RequiredFilename: String; const RequiredLine: LongInt);
var
ScriptExport: TScriptExport;
I: Integer;
begin
I := FindExport(Name, Decl, -1);
if I <> -1 then begin
ScriptExport := FExports[I];
if Required and not ScriptExport.Required then begin
ScriptExport.Required := True;
ScriptExport.RequiredFilename := RequiredFilename;
ScriptExport.RequiredLine := RequiredLine;
end;
ScriptExport.AllowNamingAttribute := ScriptExport.AllowNamingAttribute and AllowNamingAttribute;
Exit;
end;
ScriptExport := TScriptExport.Create();
ScriptExport.Name := Name;
ScriptExport.Decl := Decl;
ScriptExport.AllowNamingAttribute := AllowNamingAttribute;
ScriptExport.Required := Required;
if Required then begin
ScriptExport.RequiredFilename := RequiredFilename;
ScriptExport.RequiredLine := RequiredLine;
end;
FExports.Add(ScriptExport);
end;
function TScriptCompiler.FindExport(const Name, Decl: String; const IgnoreIndex: Integer): Integer;
var
ScriptExport: TScriptExport;
I: Integer;
begin
for I := 0 to FExports.Count-1 do begin
ScriptExport := FExports[I];
if ((Name = '') or (CompareText(ScriptExport.Name, Name) = 0)) and
((Decl = '') or (CompareText(ScriptExport.Decl, Decl) = 0)) and
((IgnoreIndex = -1) or (I <> IgnoreIndex)) then begin
Result := I;
Exit;
end;
end;
Result := -1;
end;
function TScriptCompiler.CheckExports: Boolean;
var
ScriptExport: TScriptExport;
I: Integer;
Msg: String;
begin
Result := True;
for I := 0 to FExports.Count-1 do begin
ScriptExport := FExports[I];
if ScriptExport.Required and not ScriptExport.Exported then begin
if Assigned(FOnError) then begin
{ Either the function wasn't present or it was present but matched another export }
if FindExport(ScriptExport.Name, '', I) <> -1 then
Msg := Format('Required function or procedure ''%s'' found but not with a compatible prototype', [ScriptExport.Name])
else
Msg := Format('Required function or procedure ''%s'' not found', [ScriptExport.Name]);
FOnError(Msg, ScriptExport.RequiredFilename, ScriptExport.RequiredLine);
end;
Result := False;
Exit;
end;
end;
end;
function TScriptCompiler.Compile(const ScriptText: String; var CompiledScriptText, CompiledScriptDebugInfo: tbtString): Boolean;
var
PSPascalCompiler: TPSPascalCompiler;
L, Line, Col: LongInt;
Filename, Msg: String;
I: Integer;
begin
Result := False;
{$IFDEF UNICODE}
FScriptText := UTF8Encode(ScriptText);
{$ELSE}
FScriptText := ScriptText;
{$ENDIF}
for I := 0 to FExports.Count-1 do
TScriptExport(FExports[I]).Exported := False;
FFunctionsFound.Clear;
PSPascalCompiler := TPSPascalCompiler.Create();
try
PSPascalCompiler.ID := Self;
PSPascalCompiler.AllowNoBegin := True;
PSPascalCompiler.AllowNoEnd := True;
PSPascalCompiler.BooleanShortCircuit := True;
{$IFDEF UNICODE}
PSPascalCompiler.AllowDuplicateRegister := False;
PSPascalCompiler.UTF8Decode := True;
{$ENDIF}
PSPascalCompiler.AttributesOpenTokenID := CSTI_Less;
PSPascalCompiler.AttributesCloseTokenID := CSTI_Greater;
PSPascalCompiler.OnUses := PSPascalCompilerOnUses;
PSPascalCompiler.OnExportCheck := PSPascalCompilerOnExportCheck;
PSPascalCompiler.OnBeforeOutput := PSPascalCompilerOnBeforeOutput;
DefaultCC := ClStdCall;
FUsedLines.Clear();
PSPascalCompiler.OnWriteLine2 := PSPascalCompilerOnWriteLine2;
PSPascalCompiler.OnUseVariable := PSPascalCompilerOnUseVariable;
PSPascalCompiler.OnUseRegProc := PSPascalCompilerOnUseRegProc;
if not PSPascalCompiler.Compile(FScriptText) then begin
if Assigned(FOnError) then begin
for L := 0 to PSPascalCompiler.MsgCount-1 do begin
if PSPascalCompiler.Msg[L] is TPSPascalCompilerError then begin
PSPositionToLineCol(PSPascalCompiler.Msg[L].Pos, Line, Col);
Filename := '';
if Assigned(FOnLineToLineInfo) then
FOnLineToLineInfo(Line, Filename, Line);
Msg := Format('Column %d:'#13#10'%s', [Col, PSPascalCompiler.Msg[L].ShortMessageToString]);
FOnError(Msg, Filename, Line);
Break;
end;
end;
end;
Exit;
end else begin
if not CheckExports() then
Exit;
if not PSPascalCompiler.GetOutput(CompiledScriptText) then begin
if Assigned(FOnError) then begin
Msg := 'GetOutput failed';
FOnError(Msg, '', 0);
end;
Exit;
end;
if not PSPascalCompiler.GetDebugOutput(CompiledScriptDebugInfo) then begin
if Assigned(FOnError) then begin
Msg := 'GetDebugOutput failed';
FOnError(Msg, '', 0);
end;
Exit;
end;
if Assigned(FOnWarning) then
for L := 0 to PSPascalCompiler.MsgCount-1 do
TriggerWarning(PSPascalCompiler.Msg[L].Pos,
String(PSPascalCompiler.Msg[L].ErrorType),
String(PSPascalCompiler.Msg[L].ShortMessageToString));
end;
Result := True;
finally
PSPascalCompiler.Free();
end;
end;
function TScriptCompiler.ExportFound(const Name: String): Boolean;
var
ScriptExport: TScriptExport;
I: Integer;
begin
for I := 0 to FExports.Count-1 do begin
ScriptExport := FExports[I];
if CompareText(ScriptExport.Name, Name) = 0 then begin
Result := ScriptExport.Exported;
Exit;
end;
end;
Result := False;
end;
function TScriptCompiler.FunctionFound(const Name: String): Boolean;
var
I: Integer;
begin
Result := False;
for I := 0 to FFunctionsFound.Count-1 do begin
if CompareText(FFunctionsFound[I], Name) = 0 then begin
Result := True;
Break;
end;
end;
end;
function TScriptCompiler.GetExportCount: Integer;
begin
Result := FExports.Count;
end;
function TScriptCompiler.IsObsoleteFunction(const Name: String): String;
begin
FObsoleteFunctionWarnings.TryGetValue(Name, Result);
end;
end.