|
@@ -173,7 +173,6 @@ implementation
|
|
|
end;
|
|
|
end;
|
|
|
|
|
|
-
|
|
|
{ both are int constants }
|
|
|
if (
|
|
|
(
|
|
@@ -382,7 +381,92 @@ implementation
|
|
|
end;
|
|
|
result:=t;
|
|
|
exit;
|
|
|
- end;
|
|
|
+ end
|
|
|
+ {Match against the ranges, i.e.:
|
|
|
+ var a:1..10;
|
|
|
+ begin
|
|
|
+ if a>0 then
|
|
|
+ ... always evaluates to true. (DM)}
|
|
|
+ else if is_constintnode(left) and (right.resultdef.typ=orddef)
|
|
|
+ {workaround for u64bit bugs} and (Torddef(right.resultdef).ordtype<>u64bit) then
|
|
|
+ begin
|
|
|
+ t:=nil;
|
|
|
+ lv:=Tordconstnode(left).value;
|
|
|
+ with Torddef(right.resultdef) do
|
|
|
+ case nodetype of
|
|
|
+ ltn:
|
|
|
+ if lv<low then
|
|
|
+ t:=Cordconstnode.create(1,booltype,true)
|
|
|
+ else if lv>=high then
|
|
|
+ t:=Cordconstnode.create(0,booltype,true);
|
|
|
+ lten:
|
|
|
+ if lv<=low then
|
|
|
+ t:=Cordconstnode.create(1,booltype,true)
|
|
|
+ else if lv>high then
|
|
|
+ t:=Cordconstnode.create(0,booltype,true);
|
|
|
+ gtn:
|
|
|
+ if lv<=low then
|
|
|
+ t:=Cordconstnode.create(0,booltype,true)
|
|
|
+ else if lv>high then
|
|
|
+ t:=Cordconstnode.create(1,booltype,true);
|
|
|
+ gten :
|
|
|
+ if lv<low then
|
|
|
+ t:=Cordconstnode.create(0,booltype,true)
|
|
|
+ else if lv>=high then
|
|
|
+ t:=Cordconstnode.create(1,booltype,true);
|
|
|
+ equaln:
|
|
|
+ if (lv<low) or (lv>high) then
|
|
|
+ t:=Cordconstnode.create(0,booltype,true);
|
|
|
+ unequaln:
|
|
|
+ if (lv<low) or (lv>high) then
|
|
|
+ t:=Cordconstnode.create(1,booltype,true);
|
|
|
+ end;
|
|
|
+ if t<>nil then
|
|
|
+ begin
|
|
|
+ result:=t;
|
|
|
+ exit;
|
|
|
+ end
|
|
|
+ end
|
|
|
+ else if (left.resultdef.typ=orddef) and is_constintnode(right)
|
|
|
+ {workaround for u64bit bugs} and (Torddef(left.resultdef).ordtype<>u64bit) then
|
|
|
+ begin
|
|
|
+ t:=nil;
|
|
|
+ rv:=Tordconstnode(right).value;
|
|
|
+ with Torddef(left.resultdef) do
|
|
|
+ case nodetype of
|
|
|
+ ltn:
|
|
|
+ if high<rv then
|
|
|
+ t:=Cordconstnode.create(1,booltype,true)
|
|
|
+ else if low>=rv then
|
|
|
+ t:=Cordconstnode.create(0,booltype,true);
|
|
|
+ lten:
|
|
|
+ if high<=rv then
|
|
|
+ t:=Cordconstnode.create(1,booltype,true)
|
|
|
+ else if low>rv then
|
|
|
+ t:=Cordconstnode.create(0,booltype,true);
|
|
|
+ gtn:
|
|
|
+ if high<=rv then
|
|
|
+ t:=Cordconstnode.create(0,booltype,true)
|
|
|
+ else if low>rv then
|
|
|
+ t:=Cordconstnode.create(1,booltype,true);
|
|
|
+ gten:
|
|
|
+ if high<rv then
|
|
|
+ t:=Cordconstnode.create(0,booltype,true)
|
|
|
+ else if low>=rv then
|
|
|
+ t:=Cordconstnode.create(1,booltype,true);
|
|
|
+ equaln:
|
|
|
+ if (rv<low) or (rv>high) then
|
|
|
+ t:=Cordconstnode.create(0,booltype,true);
|
|
|
+ unequaln:
|
|
|
+ if (rv<low) or (rv>high) then
|
|
|
+ t:=Cordconstnode.create(1,booltype,true);
|
|
|
+ end;
|
|
|
+ if t<>nil then
|
|
|
+ begin
|
|
|
+ result:=t;
|
|
|
+ exit;
|
|
|
+ end
|
|
|
+ end;
|
|
|
|
|
|
{ Add,Sub,Mul with constant 0 or 1? }
|
|
|
if is_constintnode(right) and is_integer(left.resultdef) then
|