Merge pull request #82 from velter/patch-8
Proposal to prevent duplicate definition
This commit is contained in:
commit
390ee15ad1
@ -923,6 +923,7 @@ type
|
||||
FAllowNoBegin: Boolean;
|
||||
FAllowNoEnd: Boolean;
|
||||
FAllowUnit: Boolean;
|
||||
FAllowDuplicateRegister : Boolean;
|
||||
FBooleanShortCircuit: Boolean;
|
||||
FDebugOutput: tbtString;
|
||||
FOnExternalProc: TPSOnExternalProc;
|
||||
@ -1177,6 +1178,7 @@ type
|
||||
|
||||
property AllowNoEnd: Boolean read FAllowNoEnd write FAllowNoEnd;
|
||||
|
||||
property AllowDuplicateRegister : Boolean read FAllowDuplicateRegister write FAllowDuplicateRegister;
|
||||
|
||||
property BooleanShortCircuit: Boolean read FBooleanShortCircuit write FBooleanShortCircuit;
|
||||
|
||||
@ -1804,7 +1806,6 @@ const
|
||||
RPS_AbstractClass = 'Abstract Class Construction';
|
||||
RPS_UnknownWarning = 'Unknown warning';
|
||||
|
||||
|
||||
{$IFDEF DEBUG }
|
||||
RPS_UnableToRegister = 'Unable to register %s';
|
||||
{$ENDIF}
|
||||
@ -2383,6 +2384,9 @@ begin
|
||||
raise EPSCompilerException.Create(RPS_OnUseEventOnly);
|
||||
end;
|
||||
|
||||
if not(AllowDuplicateRegister) and IsDuplicate(FastUpperCase(Name),[dcTypes, dcProcs, dcVars]) then
|
||||
Raise EPSCompilerException.CreateFmt(RPS_DuplicateIdent, [Name]);
|
||||
|
||||
case BaseType of
|
||||
btProcPtr: Result := TPSProceduralType.Create;
|
||||
BtTypeCopy: Result := TPSTypeLink.Create;
|
||||
@ -12271,6 +12275,7 @@ begin
|
||||
FParser.OnParserError := ParserError;
|
||||
FAutoFreeList := TPSList.Create;
|
||||
FOutput := '';
|
||||
FAllowDuplicateRegister := true;
|
||||
{$IFDEF PS_USESSUPPORT}
|
||||
FAllowUnit := true;
|
||||
{$ENDIF}
|
||||
@ -12419,6 +12424,10 @@ begin
|
||||
FType := GetTypeCopyLink(FType);
|
||||
if FType = nil then
|
||||
Raise EPSCompilerException.CreateFmt(RPS_UnableToRegisterConst, [name]);
|
||||
|
||||
if not(AllowDuplicateRegister) and IsDuplicate(FastUpperCase(Name),[dcProcs, dcVars, dcConsts]) then
|
||||
Raise EPSCompilerException.CreateFmt(RPS_DuplicateIdent, [Name]);
|
||||
|
||||
pc := TPSConstant.Create;
|
||||
pc.OrgName := name;
|
||||
pc.Name := FastUppercase(name);
|
||||
@ -13380,6 +13389,10 @@ begin
|
||||
if FProcs = nil then raise EPSCompilerException.Create(RPS_OnUseEventOnly);
|
||||
Parser := TPSPascalParser.Create;
|
||||
Parser.SetText(Decl);
|
||||
|
||||
if not(AllowDuplicateRegister) and (FindType(Name)<>nil) then
|
||||
Raise EPSCompilerException.CreateFmt(RPS_DuplicateIdent, [Name]);
|
||||
|
||||
Result := ReadType(Name, Parser);
|
||||
if Result<>nil then
|
||||
begin
|
||||
@ -13487,6 +13500,9 @@ begin
|
||||
if not ParseMethod(Self, '', Decl, DOrgName, pDecl, FT) then
|
||||
Raise EPSCompilerException.CreateFmt(RPS_UnableToRegisterFunction, [Decl]);
|
||||
|
||||
if (FindProc(DOrgName)<>InvalidVal) and not(FAllowDuplicateRegister) then
|
||||
Raise EPSCompilerException.CreateFmt(RPS_DuplicateIdent, [Decl]);
|
||||
|
||||
p := TPSRegProc.Create;
|
||||
P.Name := FastUppercase(DOrgName);
|
||||
p.OrgName := DOrgName;
|
||||
@ -13520,6 +13536,9 @@ var
|
||||
begin
|
||||
if FProcs = nil then raise EPSCompilerException.Create(RPS_OnUseEventOnly);
|
||||
f := FindType(Name);
|
||||
if (f<>nil) and not(FAllowDuplicateRegister) then
|
||||
Raise EPSCompilerException.CreateFmt(RPS_DuplicateIdent, [Name]);
|
||||
|
||||
if (f <> nil) and (f is TPSInterfaceType) then
|
||||
begin
|
||||
result := TPSInterfaceType(f).Intf;
|
||||
@ -13556,7 +13575,8 @@ var
|
||||
begin
|
||||
if FProcs = nil then raise EPSCompilerException.Create(RPS_OnUseEventOnly);
|
||||
Result := FindClass(tbtstring(aClass.ClassName));
|
||||
if Result <> nil then exit;
|
||||
if (Result<>nil) and not(FAllowDuplicateRegister) then
|
||||
Raise EPSCompilerException.CreateFmt(RPS_DuplicateIdent, [aClass.ClassName]);
|
||||
f := AddType(tbtstring(aClass.ClassName), btClass);
|
||||
Result := TPSCompileTimeClass.CreateC(aClass, Self, f);
|
||||
Result.FInheritsFrom := InheritsFrom;
|
||||
@ -13571,6 +13591,8 @@ var
|
||||
begin
|
||||
if FProcs = nil then raise EPSCompilerException.Create(RPS_OnUseEventOnly);
|
||||
Result := FindClass(aClass);
|
||||
if (Result<>nil) and (Result.FInheritsFrom<>nil) and not(FAllowDuplicateRegister) then
|
||||
Raise EPSCompilerException.CreateFmt(RPS_DuplicateIdent, [aClass]);
|
||||
if Result <> nil then
|
||||
begin
|
||||
if InheritsFrom <> nil then
|
||||
|
Loading…
Reference in New Issue
Block a user