Browse Source

* a symbol might be specified using a partial namespace path as long as the missing part is a namespace symbol,
so handle that correctly in try_consume_unitsym()

git-svn-id: trunk@38918 -

svenbarth 7 years ago
parent
commit
8bc0b604db
1 changed files with 55 additions and 12 deletions
  1. 55 12
      compiler/pbase.pas

+ 55 - 12
compiler/pbase.pas

@@ -259,11 +259,52 @@ implementation
         hmodule: tmodule;
         hmodule: tmodule;
         ns:ansistring;
         ns:ansistring;
         nssym:tsym;
         nssym:tsym;
+        nsitem : TCmdStrListItem;
+
+        procedure consume_namespace;
+          begin
+            while assigned(srsym) and (srsym.typ=namespacesym) do
+              begin
+                { we have a namespace. the next identifier should be either a namespace or a unit }
+                searchsym_in_module(hmodule,ns+'.'+pattern,srsym,srsymtable);
+                if assigned(srsym) and (srsym.typ in [namespacesym,unitsym]) then
+                  begin
+                    ns:=ns+'.'+pattern;
+                    nssym:=srsym;
+                    consume(_ID);
+                    consume(_POINT);
+                  end;
+              end;
+            { check if there is a hidden unit with this pattern in the namespace }
+            if not assigned(srsym) and
+               assigned(nssym) and (nssym.typ=namespacesym) and assigned(tnamespacesym(nssym).unitsym) then
+              srsym:=tnamespacesym(nssym).unitsym;
+          end;
+
       begin
       begin
         result:=false;
         result:=false;
         tokentoconsume:=_ID;
         tokentoconsume:=_ID;
         is_specialize:=false;
         is_specialize:=false;
 
 
+        if not assigned(srsym) and (pattern<>'') and (namespacelist.count>0) then
+          begin
+            hmodule:=get_module(current_filepos.moduleindex);
+            if not assigned(hmodule) then
+              internalerror(2018050301);
+
+            nsitem:=TCmdStrListItem(namespacelist.first);
+            while assigned(nsitem) do
+              begin
+                ns:=upper(nsitem.str)+'.'+sympattern;
+
+                if searchsym_in_module(hmodule,ns,srsym,srsymtable) and
+                    (srsym.typ in [unitsym,namespacesym]) then
+                  break;
+
+                nsitem:=TCmdStrListItem(nsitem.next);
+              end;
+          end;
+
         if assigned(srsym) and (srsym.typ in [unitsym,namespacesym]) then
         if assigned(srsym) and (srsym.typ in [unitsym,namespacesym]) then
           begin
           begin
             if not(srsym.owner.symtabletype in [staticsymtable,globalsymtable]) then
             if not(srsym.owner.symtabletype in [staticsymtable,globalsymtable]) then
@@ -284,22 +325,24 @@ implementation
                   begin
                   begin
                     ns:=srsym.name;
                     ns:=srsym.name;
                     nssym:=srsym;
                     nssym:=srsym;
-                    while assigned(srsym) and (srsym.typ=namespacesym) do
+                    consume_namespace;
+                    if not assigned(srsym) and (namespacelist.count>0) then
                       begin
                       begin
-                        { we have a namespace. the next identifier should be either a namespace or a unit }
-                        searchsym_in_module(hmodule,ns+'.'+pattern,srsym,srsymtable);
-                        if assigned(srsym) and (srsym.typ in [namespacesym,unitsym]) then
+                        nsitem:=TCmdStrListItem(namespacelist.first);
+                        while assigned(nsitem) do
                           begin
                           begin
-                            ns:=ns+'.'+pattern;
-                            nssym:=srsym;
-                            consume(_ID);
-                            consume(_POINT);
+                            ns:=upper(nsitem.str)+'.'+nssym.name;
+
+                            if searchsym_in_module(hmodule,ns,srsym,srsymtable) and
+                                (srsym.typ in [unitsym,namespacesym]) then
+                              begin
+                                consume_namespace;
+                                break;
+                              end;
+
+                            nsitem:=TCmdStrListItem(nsitem.next);
                           end;
                           end;
                       end;
                       end;
-                    { check if there is a hidden unit with this pattern in the namespace }
-                    if not assigned(srsym) and
-                       assigned(nssym) and (nssym.typ=namespacesym) and assigned(tnamespacesym(nssym).unitsym) then
-                      srsym:=tnamespacesym(nssym).unitsym;
                     if assigned(srsym) and (srsym.typ<>unitsym) then
                     if assigned(srsym) and (srsym.typ<>unitsym) then
                       internalerror(201108260);
                       internalerror(201108260);
                     if not assigned(srsym) then
                     if not assigned(srsym) then