Browse Source

* moved handle_staticfield_access() from pexpr to nutils so it can
be reused elsewhere
* moved check_hints() from htypechk to symsym (so it can be called
from nutils, and it's also more about symbols than about types)

git-svn-id: branches/jvmbackend@18722 -

Jonas Maebe 14 years ago
parent
commit
1c74072748
4 changed files with 55 additions and 52 deletions
  1. 0 22
      compiler/htypechk.pas
  2. 32 0
      compiler/nutils.pas
  3. 0 30
      compiler/pexpr.pas
  4. 23 0
      compiler/symsym.pas

+ 0 - 22
compiler/htypechk.pas

@@ -170,8 +170,6 @@ interface
 
 
     function allowenumop(nt:tnodetype):boolean;
     function allowenumop(nt:tnodetype):boolean;
 
 
-    procedure check_hints(const srsym: tsym; const symoptions: tsymoptions; const deprecatedmsg : pshortstring);
-
     procedure check_ranges(const location: tfileposinfo; source: tnode; destdef: tdef);
     procedure check_ranges(const location: tfileposinfo; source: tnode; destdef: tdef);
 
 
 implementation
 implementation
@@ -2942,26 +2940,6 @@ implementation
       end;
       end;
 
 
 
 
-    procedure check_hints(const srsym: tsym; const symoptions: tsymoptions; const deprecatedmsg : pshortstring);
-      begin
-        if not assigned(srsym) then
-          internalerror(200602051);
-        if sp_hint_deprecated in symoptions then
-          if (sp_has_deprecated_msg in symoptions) and (deprecatedmsg <> nil) then
-            Message2(sym_w_deprecated_symbol_with_msg,srsym.realname,deprecatedmsg^)
-          else
-            Message1(sym_w_deprecated_symbol,srsym.realname);
-        if sp_hint_experimental in symoptions then
-          Message1(sym_w_experimental_symbol,srsym.realname);
-        if sp_hint_platform in symoptions then
-          Message1(sym_w_non_portable_symbol,srsym.realname);
-        if sp_hint_library in symoptions then
-          Message1(sym_w_library_symbol,srsym.realname);
-        if sp_hint_unimplemented in symoptions then
-          Message1(sym_w_non_implemented_symbol,srsym.realname);
-      end;
-
-
     procedure check_ranges(const location: tfileposinfo; source: tnode; destdef: tdef);
     procedure check_ranges(const location: tfileposinfo; source: tnode; destdef: tdef);
       begin
       begin
         if not(cs_check_ordinal_size in current_settings.localswitches) then
         if not(cs_check_ordinal_size in current_settings.localswitches) then

+ 32 - 0
compiler/nutils.pas

@@ -95,6 +95,10 @@ interface
     procedure propaccesslist_to_node(var p1:tnode;st:TSymtable;pl:tpropaccesslist);
     procedure propaccesslist_to_node(var p1:tnode;st:TSymtable;pl:tpropaccesslist);
     function node_to_propaccesslist(p1:tnode):tpropaccesslist;
     function node_to_propaccesslist(p1:tnode):tpropaccesslist;
 
 
+    { checks whether sym is a static field and if so, translates the access
+      to the appropriate node tree }
+    function handle_staticfield_access(sym: tsym; nested: boolean; var p1: tnode): boolean;
+
     { returns true if n is an array element access of a bitpacked array with
     { returns true if n is an array element access of a bitpacked array with
       elements of the which the vitsize mod 8 <> 0, or if is a field access
       elements of the which the vitsize mod 8 <> 0, or if is a field access
       with bitsize mod 8 <> 0 or bitoffset mod 8 <> 0 of an element in a
       with bitsize mod 8 <> 0 or bitoffset mod 8 <> 0 of an element in a
@@ -994,6 +998,34 @@ implementation
       end;
       end;
 
 
 
 
+    function handle_staticfield_access(sym: tsym; nested: boolean; var p1: tnode): boolean;
+      var
+        static_name: shortstring;
+        srsymtable: tsymtable;
+      begin
+        result:=false;
+        { generate access code }
+        if (sp_static in sym.symoptions) then
+          begin
+            result:=true;
+            if not nested then
+              static_name:=lower(sym.owner.name^)+'_'+sym.name
+            else
+             static_name:=lower(generate_nested_name(sym.owner,'_'))+'_'+sym.name;
+            if sym.owner.defowner.typ=objectdef then
+              searchsym_in_class(tobjectdef(sym.owner.defowner),tobjectdef(sym.owner.defowner),static_name,sym,srsymtable,true)
+            else
+              searchsym_in_record(trecorddef(sym.owner.defowner),static_name,sym,srsymtable);
+            if assigned(sym) then
+              check_hints(sym,sym.symoptions,sym.deprecatedmsg);
+            p1.free;
+            p1:=nil;
+            { static syms are always stored as absolutevarsym to handle scope and storage properly }
+            propaccesslist_to_node(p1,nil,tabsolutevarsym(sym).ref);
+          end;
+      end;
+
+
     function is_bitpacked_access(n: tnode): boolean;
     function is_bitpacked_access(n: tnode): boolean;
       begin
       begin
         case n.nodetype of
         case n.nodetype of

+ 0 - 30
compiler/pexpr.pas

@@ -1026,36 +1026,6 @@ implementation
       end;
       end;
 
 
 
 
-    { checks whether sym is a static field and if so, translates the access
-      to the appropriate node tree }
-    function handle_staticfield_access(sym: tsym; nested: boolean; var p1: tnode): boolean;
-      var
-        static_name: shortstring;
-        srsymtable: tsymtable;
-      begin
-        result:=false;
-        { generate access code }
-        if (sp_static in sym.symoptions) then
-          begin
-            result:=true;
-            if not nested then
-              static_name:=lower(sym.owner.name^)+'_'+sym.name
-            else
-             static_name:=lower(generate_nested_name(sym.owner,'_'))+'_'+sym.name;
-            if sym.owner.defowner.typ=objectdef then
-              searchsym_in_class(tobjectdef(sym.owner.defowner),tobjectdef(sym.owner.defowner),static_name,sym,srsymtable,true)
-            else
-              searchsym_in_record(trecorddef(sym.owner.defowner),static_name,sym,srsymtable);
-            if assigned(sym) then
-              check_hints(sym,sym.symoptions,sym.deprecatedmsg);
-            p1.free;
-            p1:=nil;
-            { static syms are always stored as absolutevarsym to handle scope and storage properly }
-            propaccesslist_to_node(p1,nil,tabsolutevarsym(sym).ref);
-          end;
-      end;
-
-
     { the following procedure handles the access to a property symbol }
     { the following procedure handles the access to a property symbol }
     procedure handle_propertysym(propsym : tpropertysym;st : TSymtable;var p1 : tnode);
     procedure handle_propertysym(propsym : tpropertysym;st : TSymtable;var p1 : tnode);
       var
       var

+ 23 - 0
compiler/symsym.pas

@@ -343,6 +343,7 @@ interface
     { generate internal static field name based on regular field name }
     { generate internal static field name based on regular field name }
     function internal_static_field_name(const fieldname: TSymStr): TSymStr;
     function internal_static_field_name(const fieldname: TSymStr): TSymStr;
 
 
+    procedure check_hints(const srsym: tsym; const symoptions: tsymoptions; const deprecatedmsg : pshortstring);
 
 
 implementation
 implementation
 
 
@@ -375,6 +376,28 @@ implementation
         result:='$_static_'+fieldname;
         result:='$_static_'+fieldname;
       end;
       end;
 
 
+
+    procedure check_hints(const srsym: tsym; const symoptions: tsymoptions; const deprecatedmsg : pshortstring);
+      begin
+        if not assigned(srsym) then
+          internalerror(200602051);
+        if sp_hint_deprecated in symoptions then
+          if (sp_has_deprecated_msg in symoptions) and (deprecatedmsg <> nil) then
+            Message2(sym_w_deprecated_symbol_with_msg,srsym.realname,deprecatedmsg^)
+          else
+            Message1(sym_w_deprecated_symbol,srsym.realname);
+        if sp_hint_experimental in symoptions then
+          Message1(sym_w_experimental_symbol,srsym.realname);
+        if sp_hint_platform in symoptions then
+          Message1(sym_w_non_portable_symbol,srsym.realname);
+        if sp_hint_library in symoptions then
+          Message1(sym_w_library_symbol,srsym.realname);
+        if sp_hint_unimplemented in symoptions then
+          Message1(sym_w_non_implemented_symbol,srsym.realname);
+      end;
+
+
+
 {****************************************************************************
 {****************************************************************************
                           TSYM (base for all symtypes)
                           TSYM (base for all symtypes)
 ****************************************************************************}
 ****************************************************************************}