* consolidated code

This commit is contained in:
florian 2024-10-21 23:04:25 +02:00
parent d01efd153c
commit a9f522c29d

View File

@ -2294,48 +2294,49 @@ type
begin begin
try_consume_nestedsym(srsym,srsymtable); try_consume_nestedsym(srsym,srsymtable);
if assigned(srsym) then if assigned(srsym) then
case srsym.typ of begin
constsym: MarkSymbolAsUsed(srsym);
begin case srsym.typ of
{ const def must conform to the set type } constsym:
if (conform_to<>nil) and begin
(conform_to.typ=setdef) and { const def must conform to the set type }
(tconstsym(srsym).constdef.typ=setdef) and if (conform_to<>nil) and
(compare_defs(tsetdef(tconstsym(srsym).constdef).elementdef,tsetdef(conform_to).elementdef,nothingn)<>te_exact) then (conform_to.typ=setdef) and
(tconstsym(srsym).constdef.typ=setdef) and
(compare_defs(tsetdef(tconstsym(srsym).constdef).elementdef,tsetdef(conform_to).elementdef,nothingn)<>te_exact) then
begin
result.free;
result:=nil;
// TODO(ryan): better error?
Message(scan_e_error_in_preproc_expr);
end;
if result<>nil then
begin begin
result.free; result.free;
result:=nil; result:=texprvalue.create_const(tconstsym(srsym));
// TODO(ryan): better error?
Message(scan_e_error_in_preproc_expr);
end; end;
if result<>nil then end;
begin enumsym:
result.free; begin
result:=texprvalue.create_const(tconstsym(srsym)); { enum definition must conform to the set type }
MarkSymbolAsUsed(tconstsym(srsym)); if (conform_to<>nil) and
end; (conform_to.typ=setdef) and
end; (compare_defs(tenumsym(srsym).definition,tsetdef(conform_to).elementdef,nothingn)<>te_exact) then
enumsym: begin
begin result.free;
{ enum definition must conform to the set type } result:=nil;
if (conform_to<>nil) and // TODO(ryan): better error?
(conform_to.typ=setdef) and Message(scan_e_error_in_preproc_expr);
(compare_defs(tenumsym(srsym).definition,tsetdef(conform_to).elementdef,nothingn)<>te_exact) then end;
if result<>nil then
begin begin
result.free; result.free;
result:=nil; result:=texprvalue.create_int(tenumsym(srsym).value);
// TODO(ryan): better error?
Message(scan_e_error_in_preproc_expr);
end; end;
if result<>nil then end;
begin else
result.free; ;
result:=texprvalue.create_int(tenumsym(srsym).value); end;
MarkSymbolAsUsed(tenumsym(srsym));
end;
end;
else
MarkSymbolAsUsed(tconstsym(srsym));
end; end;
end end
{ the id must be belong to the set type } { the id must be belong to the set type }