From ea417fbaaf750b7e1fdf1dd1150416785501e270 Mon Sep 17 00:00:00 2001 From: Sven/Sarah Barth Date: Thu, 26 Jan 2023 07:05:34 +0100 Subject: [PATCH] + add utility function to retrieve the char type def from a stringlike def --- compiler/defutil.pas | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/compiler/defutil.pas b/compiler/defutil.pas index 69273338f3..9b5da4875e 100644 --- a/compiler/defutil.pas +++ b/compiler/defutil.pas @@ -49,6 +49,9 @@ interface namely that can be joined and compared with another string-like type } function is_stringlike(def : tdef) : boolean; + {# Returns the typedef for the char type that matches the stringlike } + function chartype_for_stringlike(def : tdef) : tdef; + {# Returns True, if definition defines an enumeration type } function is_enum(def : tdef) : boolean; @@ -575,6 +578,22 @@ implementation (def=java_jlstring); end; + function chartype_for_stringlike(def : tdef) : tdef; + begin + if is_string(def) then + result:=tstringdef(def).get_default_char_type + else if is_anychar(def) then + result:=def + else if is_pchar(def) or is_chararray(def) or is_open_chararray(def) then + result:=cansichartype + else if is_pwidechar(def) or is_pwidechar(def) or is_open_widechararray(def) then + result:=cwidechartype + else if def=java_jlstring then + result:=cwidechartype + else + internalerror(2023012501); + end; + function is_enum(def : tdef) : boolean; begin result:=def.typ=enumdef;