Explorar o código

+ extend ttypesym with the possiblity to create it as unregistered
* for now all typesyms are created as registered
Note: an additional parameter instead of an overload is used for ttypesym.create as otherwise both constructors would need to be overridden in potential descendant CPU-specific classes...

git-svn-id: trunk@31591 -

svenbarth %!s(int64=10) %!d(string=hai) anos
pai
achega
d45c275ef3

+ 1 - 1
compiler/blockutl.pas

@@ -227,7 +227,7 @@ implementation
         begin
           { alias for the type to invoke the procvar, used in the symcreat
             handling of tsk_block_invoke_procvar }
-          result.localst.insert(ctypesym.create('__FPC_BLOCK_INVOKE_PV_TYPE',orgpv));
+          result.localst.insert(ctypesym.create('__FPC_BLOCK_INVOKE_PV_TYPE',orgpv,true));
           result.synthetickind:=tsk_block_invoke_procvar;
         end;
     end;

+ 2 - 2
compiler/pdecl.pas

@@ -592,7 +592,7 @@ implementation
                   sym:=tsym(symtablestack.top.Find(typename));
                   if not assigned(sym) then
                     begin
-                      sym:=ctypesym.create(orgtypename,cundefineddef.create);
+                      sym:=ctypesym.create(orgtypename,cundefineddef.create,true);
                       Include(sym.symoptions,sp_generic_dummy);
                       ttypesym(sym).typedef.typesym:=sym;
                       sym.visibility:=symtablestack.top.currentvisibility;
@@ -628,7 +628,7 @@ implementation
               { insert a new type if we don't reuse an existing symbol }
               if not assigned(newtype) then
                 begin
-                  newtype:=ctypesym.create(genorgtypename,hdef);
+                  newtype:=ctypesym.create(genorgtypename,hdef,true);
                   newtype.visibility:=symtablestack.top.currentvisibility;
                   symtablestack.top.insert(newtype);
                 end;

+ 1 - 1
compiler/pdecsub.pas

@@ -368,7 +368,7 @@ implementation
              { possible proc directives }
              if check_proc_directive(true) then
                begin
-                  dummytype:=ctypesym.create('unnamed',hdef);
+                  dummytype:=ctypesym.create('unnamed',hdef,true);
                   parse_var_proc_directives(tsym(dummytype));
                   dummytype.typedef:=nil;
                   hdef.typesym:=nil;

+ 1 - 1
compiler/pdecvar.pas

@@ -841,7 +841,7 @@ implementation
             (def.typesym=nil) and
             check_proc_directive(true) then
            begin
-              newtype:=ctypesym.create('unnamed',def);
+              newtype:=ctypesym.create('unnamed',def,true);
               parse_var_proc_directives(tsym(newtype));
               newtype.typedef:=nil;
               def.typesym:=nil;

+ 4 - 4
compiler/pgenutil.pas

@@ -841,7 +841,7 @@ uses
 
                 { First a new typesym so we can reuse this specialization and
                   references to this specialization can be handled }
-                srsym:=ctypesym.create(finalspecializename,generrordef);
+                srsym:=ctypesym.create(finalspecializename,generrordef,true);
                 specializest.insert(srsym);
 
                 { specializations are declarations as such it is the wisest to
@@ -1033,7 +1033,7 @@ uses
         repeat
           if token=_ID then
             begin
-              generictype:=ctypesym.create(orgpattern,cundefinedtype);
+              generictype:=ctypesym.create(orgpattern,cundefinedtype,true);
               { type parameters need to be added as strict private }
               generictype.visibility:=vis_strictprivate;
               include(generictype.symoptions,sp_generic_para);
@@ -1230,7 +1230,7 @@ uses
             generictype:=ttypesym(genericlist[i]);
             if assigned(generictype.owner) then
               begin
-                sym:=ctypesym.create(genericlist.nameofindex(i),generictype.typedef);
+                sym:=ctypesym.create(genericlist.nameofindex(i),generictype.typedef,true);
                 { type parameters need to be added as strict private }
                 sym.visibility:=vis_strictprivate;
                 st.insert(sym);
@@ -1277,7 +1277,7 @@ uses
           begin
             { we need to pass nil as def here, because the constructor wants
               to set the typesym of the def which is not what we want }
-            gensym:=ctypesym.create(copy(name,1,pos('$',name)-1),nil);
+            gensym:=ctypesym.create(copy(name,1,pos('$',name)-1),nil,true);
             gensym.typedef:=current_structdef;
             include(gensym.symoptions,sp_internal);
             { the symbol should be only visible to the generic class

+ 1 - 1
compiler/pmodules.pas

@@ -723,7 +723,7 @@ implementation
           include(def.objectoptions,oo_is_external);
           include(def.objectoptions,oo_is_sealed);
           def.objextname:=stringdup(current_module.realmodulename^);
-          typesym:=ctypesym.create('__FPC_JVM_Module_Class_Alias$',def);
+          typesym:=ctypesym.create('__FPC_JVM_Module_Class_Alias$',def,true);
           symtablestack.top.insert(typesym);
         end;
 {$endif jvm}

+ 2 - 2
compiler/psystem.pas

@@ -172,7 +172,7 @@ implementation
 
         function addtype(const s:string;def:tdef):ttypesym;
         begin
-          result:=ctypesym.create(s,def);
+          result:=ctypesym.create(s,def,true);
           systemunit.insert(result);
         end;
 
@@ -480,7 +480,7 @@ implementation
             { can't use addtype for pvmt because the rtti of the pointed
               type is not available. The rtti for pvmt will be written implicitly
               by thev tblarray below }
-            systemunit.insert(ctypesym.create('$pvmt',pvmttype));
+            systemunit.insert(ctypesym.create('$pvmt',pvmttype,true));
             addfield(hrecst,cfieldvarsym.create('$length',vs_value,ptrsinttype,[]));
             addfield(hrecst,cfieldvarsym.create('$mlength',vs_value,ptrsinttype,[]));
             addfield(hrecst,cfieldvarsym.create('$parent',vs_value,pvmttype,[]));

+ 1 - 1
compiler/ptype.pas

@@ -1494,7 +1494,7 @@ implementation
               begin
                 if check_proc_directive(true) then
                   begin
-                    newtype:=ctypesym.create('unnamed',result);
+                    newtype:=ctypesym.create('unnamed',result,true);
                     parse_var_proc_directives(tsym(newtype));
                     newtype.typedef:=nil;
                     result.typesym:=nil;

+ 1 - 1
compiler/symcreat.pas

@@ -1270,7 +1270,7 @@ implementation
          (def.typ=recorddef) and
          not assigned(def.typesym) then
         begin
-          ts:=ctypesym.create(trecorddef(def).symtable.realname^,def);
+          ts:=ctypesym.create(trecorddef(def).symtable.realname^,def,true);
           st.insert(ts);
           ts.visibility:=vis_strictprivate;
           { this typesym can't be used by any Pascal code, so make sure we don't

+ 1 - 1
compiler/symdef.pas

@@ -4137,7 +4137,7 @@ implementation
         ts:=nil;
         if definedname then
           begin
-            ts:=ctypesym.create(n,self);
+            ts:=ctypesym.create(n,self,true);
             { avoid hints about unused types (these may only be used for
               typed constant data) }
             ts.increfcount;

+ 3 - 3
compiler/symsym.pas

@@ -157,7 +157,7 @@ interface
           typedef      : tdef;
           typedefderef : tderef;
           fprettyname : ansistring;
-          constructor create(const n : string;def:tdef);virtual;
+          constructor create(const n : string;def:tdef;doregister:boolean);virtual;
           destructor destroy;override;
           constructor ppuload(ppufile:tcompilerppufile);
           { do not override this routine in platform-specific subclasses,
@@ -2598,10 +2598,10 @@ implementation
 ****************************************************************************}
 
 
-    constructor ttypesym.create(const n : string;def:tdef);
+    constructor ttypesym.create(const n : string;def:tdef;doregister:boolean);
 
       begin
-        inherited create(typesym,n,true);
+        inherited create(typesym,n,doregister);
         typedef:=def;
         { register the typesym for the definition }
         if assigned(typedef) and