* fixed small tp7 things

* boolean:=longbool and longbool fixed
This commit is contained in:
peter 1998-10-14 12:53:38 +00:00
parent ef7da87e66
commit 7c2bb05a9a
2 changed files with 332 additions and 299 deletions

View File

@ -146,307 +146,332 @@ implementation
{ we walk the wanted (def_to) types and check then the def_from { we walk the wanted (def_to) types and check then the def_from
types if there is a conversion possible } types if there is a conversion possible }
case def_to^.deftype of case def_to^.deftype of
orddef : begin orddef :
if (def_from^.deftype=orddef) then begin
begin if (def_from^.deftype=orddef) then
doconv:=basedefconverts[porddef(def_from)^.typ,porddef(def_to)^.typ]; begin
if (doconv<>tc_not_possible) and doconv:=basedefconverts[porddef(def_from)^.typ,porddef(def_to)^.typ];
(explicit or not(doconv in [tc_int_2_bool])) then b:=true;
b:=true; if (doconv=tc_not_possible) or
((doconv=tc_int_2_bool) and
(not explicit) and
(not is_boolean(def_from))) then
b:=true;
end;
end;
stringdef :
begin
case def_from^.deftype of
stringdef : begin
doconv:=tc_string_to_string;
b:=true;
end;
orddef : begin
{ char to string}
if is_equal(def_from,cchardef) then
begin
doconv:=tc_char_to_string;
b:=true;
end;
end;
arraydef : begin
{ string to array of char, the length check is done by the firstpass of this node }
if is_equal(parraydef(def_from)^.definition,cchardef) then
begin
doconv:=tc_chararray_2_string;
b:=true;
end;
end;
pointerdef : begin
{ pchar can be assigned to short/ansistrings }
if is_pchar(def_from) then
begin
doconv:=tc_pchar_2_string;
b:=true;
end;
end;
end;
end;
floatdef :
begin
case def_from^.deftype of
orddef : begin { ordinal to real }
if pfloatdef(def_to)^.typ=f32bit then
doconv:=tc_int_2_fix
else
doconv:=tc_int_2_real;
b:=true;
end; end;
end; floatdef : begin { 2 float types ? }
stringdef : begin if pfloatdef(def_from)^.typ=pfloatdef(def_to)^.typ then
case def_from^.deftype of doconv:=tc_equal
stringdef : begin else
doconv:=tc_string_to_string; begin
b:=true; if pfloatdef(def_from)^.typ=f32bit then
end; doconv:=tc_fix_2_real
orddef : begin else
{ char to string} if pfloatdef(def_to)^.typ=f32bit then
if is_equal(def_from,cchardef) then doconv:=tc_real_2_fix
begin else
doconv:=tc_char_to_string; doconv:=tc_real_2_real;
b:=true; { comp isn't a floating type }
end;
end;
arraydef : begin
{ string to array of char, the length check is done by the firstpass of this node }
if is_equal(parraydef(def_from)^.definition,cchardef) then
begin
doconv:=tc_chararray_2_string;
b:=true;
end;
end;
pointerdef : begin
{ pchar can be assigned to short/ansistrings }
if is_pchar(def_from) then
begin
doconv:=tc_pchar_2_string;
b:=true;
end;
end;
end;
end;
floatdef : begin
case def_from^.deftype of
orddef : begin { ordinal to real }
if pfloatdef(def_to)^.typ=f32bit then
doconv:=tc_int_2_fix
else
doconv:=tc_int_2_real;
b:=true;
end;
floatdef : begin { 2 float types ? }
if pfloatdef(def_from)^.typ=pfloatdef(def_to)^.typ then
doconv:=tc_equal
else
begin
if pfloatdef(def_from)^.typ=f32bit then
doconv:=tc_fix_2_real
else
if pfloatdef(def_to)^.typ=f32bit then
doconv:=tc_real_2_fix
else
doconv:=tc_real_2_real;
{ comp isn't a floating type }
{$ifdef i386} {$ifdef i386}
if (pfloatdef(def_to)^.typ=s64bit) and if (pfloatdef(def_to)^.typ=s64bit) and
(pfloatdef(def_from)^.typ<>s64bit) and (pfloatdef(def_from)^.typ<>s64bit) and
not (explicit) then not (explicit) then
CGMessage(type_w_convert_real_2_comp); CGMessage(type_w_convert_real_2_comp);
{$endif} {$endif}
end; end;
b:=true;
end;
end;
end;
enumdef : begin
if (def_from^.deftype=enumdef) then
begin
if assigned(penumdef(def_from)^.basedef) then
hd1:=penumdef(def_from)^.basedef
else
hd1:=def_from;
if assigned(penumdef(def_to)^.basedef) then
hd2:=penumdef(def_to)^.basedef
else
hd2:=def_to;
b:=(hd1=hd2);
end;
end;
arraydef : begin
{ open array is also compatible with a single element of its base type }
if is_open_array(def_to) and
is_equal(parraydef(def_to)^.definition,def_from) then
begin
doconv:=tc_equal;
b:=true; b:=true;
end end;
else end;
begin end;
case def_from^.deftype of
pointerdef : begin enumdef :
if (parraydef(def_to)^.lowrange=0) and begin
is_equal(ppointerdef(def_from)^.definition,parraydef(def_to)^.definition) then if (def_from^.deftype=enumdef) then
begin begin
doconv:=tc_pointer_to_array; if assigned(penumdef(def_from)^.basedef) then
b:=true; hd1:=penumdef(def_from)^.basedef
end; else
end; hd1:=def_from;
stringdef : begin if assigned(penumdef(def_to)^.basedef) then
{ array of char to string } hd2:=penumdef(def_to)^.basedef
if is_equal(parraydef(def_to)^.definition,cchardef) then else
begin hd2:=def_to;
doconv:=tc_string_chararray; b:=(hd1=hd2);
b:=true; end;
end; end;
end;
arraydef :
begin
{ open array is also compatible with a single element of its base type }
if is_open_array(def_to) and
is_equal(parraydef(def_to)^.definition,def_from) then
begin
doconv:=tc_equal;
b:=true;
end
else
begin
case def_from^.deftype of
pointerdef : begin
if (parraydef(def_to)^.lowrange=0) and
is_equal(ppointerdef(def_from)^.definition,parraydef(def_to)^.definition) then
begin
doconv:=tc_pointer_to_array;
b:=true;
end;
end;
stringdef : begin
{ array of char to string }
if is_equal(parraydef(def_to)^.definition,cchardef) then
begin
doconv:=tc_string_chararray;
b:=true;
end;
end;
end;
end;
end;
pointerdef :
begin
case def_from^.deftype of
stringdef : begin
{ string constant to zero terminated string constant }
if (fromtreetype=stringconstn) and
is_pchar(def_to) then
begin
doconv:=tc_cstring_charpointer;
b:=true;
end;
end; end;
end; orddef : begin
end; { char constant to zero terminated string constant }
pointerdef : begin if (fromtreetype=ordconstn) and is_equal(def_from,cchardef) and
case def_from^.deftype of is_pchar(def_to) then
stringdef : begin begin
{ string constant to zero terminated string constant } doconv:=tc_cchar_charpointer;
if (fromtreetype=stringconstn) and b:=true;
is_pchar(def_to) then end;
begin end;
doconv:=tc_cstring_charpointer; arraydef : begin
b:=true; { chararray to pointer }
end; if (parraydef(def_from)^.lowrange=0) and
end; is_equal(parraydef(def_from)^.definition,ppointerdef(def_to)^.definition) then
orddef : begin begin
{ char constant to zero terminated string constant } doconv:=tc_array_to_pointer;
if (fromtreetype=ordconstn) and is_equal(def_from,cchardef) and b:=true;
is_pchar(def_to) then end;
begin end;
doconv:=tc_cchar_charpointer; pointerdef : begin
b:=true; { child class pointer can be assigned to anchestor pointers }
end; if (
end; (ppointerdef(def_from)^.definition^.deftype=objectdef) and
arraydef : begin (ppointerdef(def_to)^.definition^.deftype=objectdef) and
{ chararray to pointer } pobjectdef(ppointerdef(def_from)^.definition)^.isrelated(
if (parraydef(def_from)^.lowrange=0) and pobjectdef(ppointerdef(def_to)^.definition))
is_equal(parraydef(def_from)^.definition,ppointerdef(def_to)^.definition) then ) or
begin { all pointers can be assigned to void-pointer }
doconv:=tc_array_to_pointer; is_equal(ppointerdef(def_to)^.definition,voiddef) or
b:=true; { in my opnion, is this not clean pascal }
end; { well, but it's handy to use, it isn't ? (FK) }
end; is_equal(ppointerdef(def_from)^.definition,voiddef) then
pointerdef : begin begin
{ child class pointer can be assigned to anchestor pointers } doconv:=tc_equal;
if ( b:=true;
(ppointerdef(def_from)^.definition^.deftype=objectdef) and end;
(ppointerdef(def_to)^.definition^.deftype=objectdef) and end;
pobjectdef(ppointerdef(def_from)^.definition)^.isrelated( procvardef : begin
pobjectdef(ppointerdef(def_to)^.definition)) { procedure variable can be assigned to an void pointer }
) or { Not anymore. Use the @ operator now.}
{ all pointers can be assigned to void-pointer } if not(m_tp_procvar in aktmodeswitches) and
is_equal(ppointerdef(def_to)^.definition,voiddef) or (ppointerdef(def_to)^.definition^.deftype=orddef) and
{ in my opnion, is this not clean pascal } (porddef(ppointerdef(def_to)^.definition)^.typ=uvoid) then
{ well, but it's handy to use, it isn't ? (FK) } begin
is_equal(ppointerdef(def_from)^.definition,voiddef) then doconv:=tc_equal;
begin b:=true;
doconv:=tc_equal; end;
b:=true; end;
end; classrefdef,
end; objectdef : begin
procvardef : begin { class types and class reference type
{ procedure variable can be assigned to an void pointer } can be assigned to void pointers }
{ Not anymore. Use the @ operator now.} if (
if not(m_tp_procvar in aktmodeswitches) and ((def_from^.deftype=objectdef) and pobjectdef(def_from)^.isclass) or
(ppointerdef(def_to)^.definition^.deftype=orddef) and (def_from^.deftype=classrefdef)
(porddef(ppointerdef(def_to)^.definition)^.typ=uvoid) then ) and
begin (ppointerdef(def_to)^.definition^.deftype=orddef) and
doconv:=tc_equal; (porddef(ppointerdef(def_to)^.definition)^.typ=uvoid) then
b:=true; begin
end; doconv:=tc_equal;
end; b:=true;
classrefdef, end;
objectdef : begin end;
{ class types and class reference type end;
can be assigned to void pointers } end;
if (
((def_from^.deftype=objectdef) and pobjectdef(def_from)^.isclass) or setdef :
(def_from^.deftype=classrefdef) begin
) and { automatic arrayconstructor -> set conversion }
(ppointerdef(def_to)^.definition^.deftype=orddef) and if (def_from^.deftype=arraydef) and (parraydef(def_from)^.IsConstructor) then
(porddef(ppointerdef(def_to)^.definition)^.typ=uvoid) then begin
begin doconv:=tc_arrayconstructor_2_set;
doconv:=tc_equal; b:=true;
b:=true; end;
end; end;
end;
end; procvardef :
end; begin
setdef : begin { proc -> procvar }
{ automatic arrayconstructor -> set conversion } if (def_from^.deftype=procdef) then
if (def_from^.deftype=arraydef) and (parraydef(def_from)^.IsConstructor) then begin
begin def_from^.deftype:=procvardef;
doconv:=tc_arrayconstructor_2_set; doconv:=tc_proc2procvar;
b:=true; b:=is_equal(def_from,def_to);
end; def_from^.deftype:=procdef;
end; end
procvardef : begin else
{ proc -> procvar } { for example delphi allows the assignement from pointers }
if (def_from^.deftype=procdef) then { to procedure variables }
begin if (m_pointer_2_procedure in aktmodeswitches) and
def_from^.deftype:=procvardef; (def_from^.deftype=pointerdef) and
doconv:=tc_proc2procvar; (ppointerdef(def_from)^.definition^.deftype=orddef) and
b:=is_equal(def_from,def_to); (porddef(ppointerdef(def_from)^.definition)^.typ=uvoid) then
def_from^.deftype:=procdef; begin
end doconv:=tc_equal;
else b:=true;
{ for example delphi allows the assignement from pointers } end
{ to procedure variables } else
if (m_pointer_2_procedure in aktmodeswitches) and { nil is compatible with procvars }
(def_from^.deftype=pointerdef) and if (fromtreetype=niln) then
(ppointerdef(def_from)^.definition^.deftype=orddef) and begin
(porddef(ppointerdef(def_from)^.definition)^.typ=uvoid) then doconv:=tc_equal;
begin b:=true;
doconv:=tc_equal; end;
b:=true; end;
end
else objectdef :
{ nil is compatible with procvars } begin
if (fromtreetype=niln) then { object pascal objects }
begin if (def_from^.deftype=objectdef) {and
doconv:=tc_equal; pobjectdef(def_from)^.isclass and pobjectdef(def_to)^.isclass }then
b:=true; begin
end; doconv:=tc_equal;
end; b:=pobjectdef(def_from)^.isrelated(pobjectdef(def_to));
objectdef : begin end
{ object pascal objects } else
if (def_from^.deftype=objectdef) {and { nil is compatible with class instances }
pobjectdef(def_from)^.isclass and pobjectdef(def_to)^.isclass }then if (fromtreetype=niln) and (pobjectdef(def_to)^.isclass) then
begin begin
doconv:=tc_equal; doconv:=tc_equal;
b:=pobjectdef(def_from)^.isrelated(pobjectdef(def_to)); b:=true;
end end;
else end;
{ nil is compatible with class instances }
if (fromtreetype=niln) and (pobjectdef(def_to)^.isclass) then classrefdef :
begin begin
doconv:=tc_equal; { class reference types }
b:=true; if (def_from^.deftype=classrefdef) then
end; begin
end; doconv:=tc_equal;
classrefdef : begin b:=pobjectdef(pclassrefdef(def_from)^.definition)^.isrelated(
{ class reference types } pobjectdef(pclassrefdef(def_to)^.definition));
if (def_from^.deftype=classrefdef) then end
begin else
doconv:=tc_equal; { nil is compatible with class references }
b:=pobjectdef(pclassrefdef(def_from)^.definition)^.isrelated( if (fromtreetype=niln) then
pobjectdef(pclassrefdef(def_to)^.definition)); begin
end doconv:=tc_equal;
else b:=true;
{ nil is compatible with class references } end;
if (fromtreetype=niln) then end;
begin
doconv:=tc_equal; filedef :
b:=true; begin
end; { typed files are all equal to the abstract file type
end; name TYPEDFILE in system.pp in is_equal in types.pas
filedef : begin the problem is that it sholud be also compatible to FILE
{ typed files are all equal to the abstract file type but this would leed to a problem for ASSIGN RESET and REWRITE
name TYPEDFILE in system.pp in is_equal in types.pas when trying to find the good overloaded function !!
the problem is that it sholud be also compatible to FILE so all file function are doubled in system.pp
but this would leed to a problem for ASSIGN RESET and REWRITE this is not very beautiful !!}
when trying to find the good overloaded function !! if (def_from^.deftype=filedef) and
so all file function are doubled in system.pp (
this is not very beautiful !!} (
if (def_from^.deftype=filedef) and (pfiledef(def_from)^.filetype = ft_typed) and
( (pfiledef(def_to)^.filetype = ft_typed) and
( (
(pfiledef(def_from)^.filetype = ft_typed) and (pfiledef(def_from)^.typed_as = pdef(voiddef)) or
(pfiledef(def_to)^.filetype = ft_typed) and (pfiledef(def_to)^.typed_as = pdef(voiddef))
( )
(pfiledef(def_from)^.typed_as = pdef(voiddef)) or ) or
(pfiledef(def_to)^.typed_as = pdef(voiddef)) (
) (
) or (pfiledef(def_from)^.filetype = ft_untyped) and
( (pfiledef(def_to)^.filetype = ft_typed)
( ) or
(pfiledef(def_from)^.filetype = ft_untyped) and (
(pfiledef(def_to)^.filetype = ft_typed) (pfiledef(def_from)^.filetype = ft_typed) and
) or (pfiledef(def_to)^.filetype = ft_untyped)
( )
(pfiledef(def_from)^.filetype = ft_typed) and )
(pfiledef(def_to)^.filetype = ft_untyped) ) then
) begin
) doconv:=tc_equal;
) then b:=true;
begin end
doconv:=tc_equal; end;
b:=true;
end else
end; begin
else { assignment overwritten ?? }
begin if is_assignment_overloaded(def_from,def_to) then
{ assignment overwritten ?? } b:=true;
if is_assignment_overloaded(def_from,def_to) then end;
b:=true;
end;
end; end;
{ nil is compatible with ansi- and wide strings } { nil is compatible with ansi- and wide strings }
@ -650,7 +675,11 @@ implementation
end. end.
{ {
$Log$ $Log$
Revision 1.5 1998-10-12 09:49:58 florian Revision 1.6 1998-10-14 12:53:38 peter
* fixed small tp7 things
* boolean:=longbool and longbool fixed
Revision 1.5 1998/10/12 09:49:58 florian
+ support of <procedure var type>:=<pointer> in delphi mode added + support of <procedure var type>:=<pointer> in delphi mode added
Revision 1.4 1998/09/30 16:42:52 peter Revision 1.4 1998/09/30 16:42:52 peter

View File

@ -379,6 +379,7 @@ implementation
case p^.treetype of case p^.treetype of
andn,orn : begin andn,orn : begin
calcregisters(p,0,0,0); calcregisters(p,0,0,0);
make_bool_equal_size(p);
p^.location.loc:=LOC_JUMP; p^.location.loc:=LOC_JUMP;
end; end;
unequaln, unequaln,
@ -406,7 +407,6 @@ implementation
p^.treetype:=equaln; p^.treetype:=equaln;
end; end;
end; end;
make_bool_equal_size(p); make_bool_equal_size(p);
calcregisters(p,1,0,0); calcregisters(p,1,0,0);
end end
@ -905,7 +905,11 @@ implementation
end. end.
{ {
$Log$ $Log$
Revision 1.3 1998-10-11 14:31:19 peter Revision 1.4 1998-10-14 12:53:39 peter
* fixed small tp7 things
* boolean:=longbool and longbool fixed
Revision 1.3 1998/10/11 14:31:19 peter
+ checks for division by zero + checks for division by zero
Revision 1.2 1998/10/05 21:33:31 peter Revision 1.2 1998/10/05 21:33:31 peter