[fpc-devel] Implicit function specialization precedence

Ryan Joseph genericptr at gmail.com
Thu Apr 8 19:28:45 CEST 2021



> On Apr 7, 2021, at 1:56 PM, Ryan Joseph <genericptr at gmail.com> wrote:
> 
> Ok, so with $H+ constant strings will be specialized as AnsiStrings. And there is another unicode string mode I should do a similar thing with? Also if you happen to know where I can get the state of $H+ that would be helpful otherwise I need to track it down in the debugger. :)

I think I got this part figured out (see function below). I'm going to upload another patch and a bunch of unit tests on the bug tracker but I'm leaving my latest ambiguous function call as-is until further notice. it's sneaky like it is but it follows rules which you can manipulate using casting.


==============================

function create_unamed_typesym(def:tdef): tsym;
        var
          newtype: tsym;
        begin
          newtype:=nil;
          if is_stringlike(def) then
            begin
              if (def.typ=arraydef) and (ado_isconststring in tarraydef(def).arrayoptions) then
                newtype:=nil
              else
                case tstringdef(def).stringtype of
                  st_shortstring:
                    newtype:=nil;
                  st_longstring,
                  st_ansistring:
                    newtype:=search_system_type('ANSISTRING');
                  st_widestring:
                    newtype:=search_system_type('WIDESTRING');
                  st_unicodestring:
                    newtype:=search_system_type('UNICODESTRING');
                end;
              { not better string type was found so chose the default string type }
              if newtype=nil then
                begin
                  if (cs_refcountedstrings in current_settings.localswitches) then
                    begin
                      if m_default_unicodestring in current_settings.modeswitches then
                        newtype:=search_system_type('UNICODESTRING')
                      else
                        newtype:=search_system_type('ANSISTRING');
                    end
                  else
                    newtype:=search_system_type('SHORTSTRING');
                end;
            end
          else
            begin
              newtype:=ctypesym.create(def.typename,def);
              newtype.owner:=def.owner;
            end;
          if newtype=nil then
            internalerror(2021020904);
          result:=newtype;
        end;

Regards,
	Ryan Joseph



More information about the fpc-devel mailing list