* Add is_systemunit_unicode function (cchartype suymbol)

This commit is contained in:
Michaël Van Canneyt 2023-01-05 10:06:21 +01:00 committed by Pierre Muller
parent 7ae949895a
commit 90eb89da9e
2 changed files with 23 additions and 0 deletions

View File

@ -313,6 +313,9 @@ interface
{ true, if def is a signed int type, equal in size to the processor's native int size }
function is_nativesint(def : tdef) : boolean;
{ true, if the char type is a widechar in the system unit }
function is_systemunit_unicode : boolean;
type
tperformrangecheck = (
rc_internal, { nothing, internal conversion }
@ -417,6 +420,7 @@ implementation
uses
verbose,cutils,
symtable, // search_system_type
symsym,
cpuinfo;
@ -1250,6 +1254,24 @@ implementation
result:=is_nativeint(def) and (def.typ=orddef) and (torddef(def).ordtype in [s64bit,s32bit,s16bit,s8bit]);
end;
function is_systemunit_unicode: boolean;
var
t : ttypesym;
begin
if cchartype=nil then
begin
t:=search_system_type('CHAR');
if t<>nil then
cchartype:=t.typedef;
end;
if cchartype=nil then
is_systemunit_unicode:=(sizeof(char)=2)
else
is_systemunit_unicode:=(cchartype.size=2);
end;
{ if l isn't in the range of todef a range check error (if not explicit) is generated and
the value is placed within the range }
procedure adaptrange(todef : tdef;var l : tconstexprint; rangecheck: tperformrangecheck);

View File

@ -1177,6 +1177,7 @@ interface
voidtype, { Void (procedure) }
cansichartype, { Char }
cwidechartype, { WideChar }
cchartype, { either cansichartype or cwidechartype. Do not free }
pasbool1type, { boolean type }
pasbool8type,
pasbool16type,