Browse Source

fcl-passrc: allow override basetypenames, fixed analyzer tpasargument

git-svn-id: trunk@35853 -
Mattias Gaertner 8 years ago
parent
commit
a63cdac0f3
2 changed files with 34 additions and 29 deletions
  1. 32 29
      packages/fcl-passrc/src/pasresolver.pp
  2. 2 0
      packages/fcl-passrc/src/pasuseanalyzer.pas

+ 32 - 29
packages/fcl-passrc/src/pasresolver.pp

@@ -1397,6 +1397,8 @@ type
     function ResolvedElCanBeVarParam(const ResolvedEl: TPasResolverResult): boolean;
     function ResolvedElIsClassInstance(const ResolvedEl: TPasResolverResult): boolean;
     // uility functions
+    function GetTypeDescription(const R: TPasResolverResult; AddPath: boolean = false): string; virtual;
+    function GetBaseDescription(const R: TPasResolverResult; AddPath: boolean = false): string; virtual;
     function GetPasPropertyType(El: TPasProperty): TPasType;
     function GetPasPropertyAncestor(El: TPasProperty): TPasProperty;
     function GetPasPropertyGetter(El: TPasProperty): TPasElement;
@@ -9010,27 +9012,6 @@ end;
 procedure TPasResolver.RaiseIncompatibleTypeRes(id: int64; MsgNumber: integer;
   const Args: array of const; const GotType, ExpType: TPasResolverResult;
   ErrorEl: TPasElement);
-
-  function GetTypeDsc(const R: TPasResolverResult; AddPath: boolean = false): string;
-  begin
-    Result:=GetTypeDesc(R.TypeEl,AddPath);
-    if R.IdentEl=R.TypeEl then
-      begin
-      if R.TypeEl.ElementTypeName<>'' then
-        Result:=R.TypeEl.ElementTypeName+' '+Result
-      else
-        Result:='type '+Result;
-      end;
-  end;
-
-  function GetBaseDecs(const R: TPasResolverResult; AddPath: boolean = false): string;
-  begin
-    if R.BaseType=btContext then
-      Result:=GetTypeDsc(R,AddPath)
-    else
-      Result:=BaseTypeNames[R.BaseType];
-  end;
-
 var
   GotDesc, ExpDesc: String;
 begin
@@ -9039,25 +9020,25 @@ begin
   {$ENDIF}
   if GotType.BaseType<>ExpType.BaseType then
     begin
-    GotDesc:=GetBaseDecs(GotType);
+    GotDesc:=GetBaseDescription(GotType);
     if ExpType.BaseType=btNil then
       ExpDesc:=BaseTypeNames[btPointer]
     else
-      ExpDesc:=GetBaseDecs(ExpType);
+      ExpDesc:=GetBaseDescription(ExpType);
     if GotDesc=ExpDesc then
       begin
-      GotDesc:=GetBaseDecs(GotType,true);
-      ExpDesc:=GetBaseDecs(ExpType,true);
+      GotDesc:=GetBaseDescription(GotType,true);
+      ExpDesc:=GetBaseDescription(ExpType,true);
       end;
     end
   else if (GotType.TypeEl<>nil) and (ExpType.TypeEl<>nil) then
     begin
-    GotDesc:=GetTypeDsc(GotType);
-    ExpDesc:=GetTypeDsc(ExpType);
+    GotDesc:=GetTypeDescription(GotType);
+    ExpDesc:=GetTypeDescription(ExpType);
     if GotDesc=ExpDesc then
       begin
-      GotDesc:=GetTypeDsc(GotType,true);
-      ExpDesc:=GetTypeDsc(ExpType,true);
+      GotDesc:=GetTypeDescription(GotType,true);
+      ExpDesc:=GetTypeDescription(ExpType,true);
       end;
     end
   else
@@ -9996,6 +9977,28 @@ begin
     exit(true);
 end;
 
+function TPasResolver.GetTypeDescription(const R: TPasResolverResult;
+  AddPath: boolean): string;
+begin
+  Result:=GetTypeDesc(R.TypeEl,AddPath);
+  if R.IdentEl=R.TypeEl then
+    begin
+    if R.TypeEl.ElementTypeName<>'' then
+      Result:=R.TypeEl.ElementTypeName+' '+Result
+    else
+      Result:='type '+Result;
+    end;
+end;
+
+function TPasResolver.GetBaseDescription(const R: TPasResolverResult;
+  AddPath: boolean): string;
+begin
+  if R.BaseType=btContext then
+    Result:=GetTypeDescription(R,AddPath)
+  else
+    Result:=BaseTypeNames[R.BaseType];
+end;
+
 function TPasResolver.GetPasPropertyType(El: TPasProperty): TPasType;
 begin
   Result:=nil;

+ 2 - 0
packages/fcl-passrc/src/pasuseanalyzer.pas

@@ -636,6 +636,8 @@ begin
   if C=TPasUnresolvedSymbolRef then
   else if (C=TPasVariable) or (C=TPasConst) then
     UsePublished(TPasVariable(El).VarType)
+  else if (C=TPasArgument) then
+    UsePublished(TPasArgument(El).ArgType)
   else if C=TPasProperty then
     begin
     // published property