mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-11-02 06:29:25 +01:00
* more stuff fixed
This commit is contained in:
parent
c284d15e57
commit
5a855db55d
@ -48,7 +48,7 @@ implementation
|
||||
|
||||
uses
|
||||
globtype,systems,tokens,
|
||||
cobjects,verbose,globals,
|
||||
cobjects,cutils,verbose,globals,
|
||||
symconst,symtable,aasm,types,
|
||||
cpuinfo,
|
||||
{$ifdef newcg}
|
||||
@ -58,9 +58,93 @@ implementation
|
||||
{$endif newcg}
|
||||
htypechk,pass_1,
|
||||
cpubase,ncnv,ncal,nld,
|
||||
ncon
|
||||
ncon,nmat
|
||||
;
|
||||
|
||||
function isbinaryoverloaded(var p : ptree) : boolean;
|
||||
|
||||
var
|
||||
rd,ld : pdef;
|
||||
t : tnode;
|
||||
optoken : ttoken;
|
||||
|
||||
begin
|
||||
isbinaryoverloaded:=false;
|
||||
{ overloaded operator ? }
|
||||
{ load easier access variables }
|
||||
rd:=p.right.resulttype;
|
||||
ld:=p.left.resulttype;
|
||||
if isbinaryoperatoroverloadable(ld,rd,voiddef,p.nodetype) then
|
||||
begin
|
||||
isbinaryoverloaded:=true;
|
||||
{!!!!!!!!! handle paras }
|
||||
case p.nodetype of
|
||||
{ the nil as symtable signs firstcalln that this is
|
||||
an overloaded operator }
|
||||
addn:
|
||||
optoken:=_PLUS;
|
||||
subn:
|
||||
optoken:=_MINUS;
|
||||
muln:
|
||||
optoken:=_STAR;
|
||||
starstarn:
|
||||
optoken:=_STARSTAR;
|
||||
slashn:
|
||||
optoken:=_SLASH;
|
||||
ltn:
|
||||
optoken:=tokens._lt;
|
||||
gtn:
|
||||
optoken:=tokens._gt;
|
||||
lten:
|
||||
optoken:=_lte;
|
||||
gten:
|
||||
optoken:=_gte;
|
||||
equaln,unequaln :
|
||||
optoken:=_EQUAL;
|
||||
symdifn :
|
||||
optoken:=_SYMDIF;
|
||||
modn :
|
||||
optoken:=_OP_MOD;
|
||||
orn :
|
||||
optoken:=_OP_OR;
|
||||
xorn :
|
||||
optoken:=_OP_XOR;
|
||||
andn :
|
||||
optoken:=_OP_AND;
|
||||
divn :
|
||||
optoken:=_OP_DIV;
|
||||
shln :
|
||||
optoken:=_OP_SHL;
|
||||
shrn :
|
||||
optoken:=_OP_SHR;
|
||||
else
|
||||
exit;
|
||||
end;
|
||||
t:=gencallnode(overloaded_operators[optoken],nil);
|
||||
{ we have to convert p.left and p.right into
|
||||
callparanodes }
|
||||
if tcallnode(t).symtableprocentry=nil then
|
||||
begin
|
||||
CGMessage(parser_e_operator_not_overloaded);
|
||||
putnode(t);
|
||||
end
|
||||
else
|
||||
begin
|
||||
inc(t.symtableprocentry^.refs);
|
||||
t.left:=gencallparanode(p.left,nil);
|
||||
t.left:=gencallparanode(p.right,t.left);
|
||||
if p.nodetype=unequaln then
|
||||
t:=cnotnode.create(t);
|
||||
p.left:=nil;
|
||||
p.right:=nil;
|
||||
p.free;
|
||||
firstpass(t);
|
||||
putnode(p);
|
||||
p:=t;
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
|
||||
{*****************************************************************************
|
||||
TADDNODE
|
||||
*****************************************************************************}
|
||||
@ -136,7 +220,7 @@ implementation
|
||||
ld:=left.resulttype;
|
||||
convdone:=false;
|
||||
|
||||
if isbinaryoverloaded(hp) then
|
||||
if isbinaryoverloaded() then
|
||||
begin
|
||||
pass_1:=hp;
|
||||
exit;
|
||||
@ -269,8 +353,8 @@ implementation
|
||||
else
|
||||
if (lt=stringconstn) and (rt=ordconstn) and is_char(rd) then
|
||||
begin
|
||||
s1:=getpcharcopy(left);
|
||||
l1:=left.length;
|
||||
s1:=tstringconstnode(left).getpcharcopy;
|
||||
l1:=tstringconstnode(left).len;
|
||||
s2:=strpnew(char(byte(tordconstnode(right).value)));
|
||||
l2:=1;
|
||||
concatstrings:=true;
|
||||
@ -280,16 +364,16 @@ implementation
|
||||
begin
|
||||
s1:=strpnew(char(byte(tordconstnode(left).value)));
|
||||
l1:=1;
|
||||
s2:=getpcharcopy(right);
|
||||
l2:=right.length;
|
||||
s2:=tstringconstnode(right).getpcharcopy;
|
||||
l2:=tstringconstnode(right).len;
|
||||
concatstrings:=true;
|
||||
end
|
||||
else if (lt=stringconstn) and (rt=stringconstn) then
|
||||
begin
|
||||
s1:=getpcharcopy(left);
|
||||
l1:=tstringconstnode(left).length;
|
||||
s1:=tstringconstnode(left).getpcharcopy;
|
||||
l1:=tstringconstnode(left).len;
|
||||
s2:=getpcharcopy(right);
|
||||
l2:=tstringconstnode(right).length;
|
||||
l2:=tstringconstnode(right).len;
|
||||
concatstrings:=true;
|
||||
end;
|
||||
|
||||
@ -327,41 +411,42 @@ implementation
|
||||
if (cs_full_boolean_eval in aktlocalswitches) or
|
||||
(nodetype in [xorn,ltn,lten,gtn,gten]) then
|
||||
begin
|
||||
make_bool_equal_size(p);
|
||||
make_bool_equal_size;
|
||||
if (left.location.loc in [LOC_JUMP,LOC_FLAGS]) and
|
||||
(left.location.loc in [LOC_JUMP,LOC_FLAGS]) then
|
||||
calcregisters(p,2,0,0)
|
||||
calcregisters(self,2,0,0)
|
||||
else
|
||||
calcregisters(p,1,0,0);
|
||||
calcregisters(self,1,0,0);
|
||||
end
|
||||
else
|
||||
case nodetype of
|
||||
andn,
|
||||
orn:
|
||||
begin
|
||||
make_bool_equal_size(p);
|
||||
calcregisters(p,0,0,0);
|
||||
make_bool_equal_size;
|
||||
calcregisters(self,0,0,0);
|
||||
location.loc:=LOC_JUMP;
|
||||
end;
|
||||
unequaln,
|
||||
equaln:
|
||||
begin
|
||||
make_bool_equal_size(p);
|
||||
make_bool_equal_size;
|
||||
{ Remove any compares with constants }
|
||||
if (left.nodetype=ordconstn) then
|
||||
begin
|
||||
hp:=right;
|
||||
b:=(left.value<>0);
|
||||
b:=(tordconstnode(left).value<>0);
|
||||
ot:=nodetype;
|
||||
disposetree(left);
|
||||
putnode(p);
|
||||
p:=hp;
|
||||
left.free;
|
||||
left:=nil;
|
||||
right:=nil;
|
||||
if (not(b) and (ot=equaln)) or
|
||||
(b and (ot=unequaln)) then
|
||||
begin
|
||||
p:=gensinglenode(notn,hp);
|
||||
hp:=cnotnode.create(hp);
|
||||
firstpass(hp);
|
||||
end;
|
||||
pass_1:=hp;
|
||||
exit;
|
||||
end;
|
||||
if (right.nodetype=ordconstn) then
|
||||
@ -1230,7 +1315,10 @@ begin
|
||||
end.
|
||||
{
|
||||
$Log$
|
||||
Revision 1.7 2000-09-27 18:14:31 florian
|
||||
Revision 1.8 2000-09-27 20:25:44 florian
|
||||
* more stuff fixed
|
||||
|
||||
Revision 1.7 2000/09/27 18:14:31 florian
|
||||
* fixed a lot of syntax errors in the n*.pas stuff
|
||||
|
||||
Revision 1.6 2000/09/24 15:06:19 peter
|
||||
|
||||
@ -108,11 +108,23 @@ interface
|
||||
|
||||
function gensetconstnode(s : pconstset;settype : psetdef) : tsetconstnode;
|
||||
|
||||
{ some helper routines }
|
||||
|
||||
function get_ordinal_value(p : tnode) : longint;
|
||||
function is_constnode(p : tnode) : boolean;
|
||||
function is_constintnode(p : tnode) : boolean;
|
||||
function is_constcharnode(p : tnode) : boolean;
|
||||
function is_constrealnode(p : tnode) : boolean;
|
||||
function is_constboolnode(p : tnode) : boolean;
|
||||
function is_constresourcestringnode(p : tnode) : boolean;
|
||||
function str_length(p : tnode) : longint;
|
||||
function is_emptyset(p : tnode):boolean;
|
||||
|
||||
implementation
|
||||
|
||||
uses
|
||||
cobjects,verbose,globals,systems,
|
||||
types,hcodegen,pass_1,cpubase;
|
||||
types,hcodegen,pass_1,cpubase,nld;
|
||||
|
||||
function genordinalconstnode(v : tconstexprint;def : pdef) : tordconstnode;
|
||||
begin
|
||||
@ -168,6 +180,78 @@ implementation
|
||||
genpcharconstnode:=cstringconstnode.createpchar(s,length);
|
||||
end;
|
||||
|
||||
function get_ordinal_value(p : tnode) : longint;
|
||||
begin
|
||||
if p.nodetype=ordconstn then
|
||||
get_ordinal_value:=tordconstnode(p).value
|
||||
else
|
||||
begin
|
||||
Message(type_e_ordinal_expr_expected);
|
||||
get_ordinal_value:=0;
|
||||
end;
|
||||
end;
|
||||
|
||||
|
||||
function is_constnode(p : tnode) : boolean;
|
||||
begin
|
||||
is_constnode:=(p.nodetype in [ordconstn,realconstn,stringconstn,fixconstn,setconstn]);
|
||||
end;
|
||||
|
||||
|
||||
function is_constintnode(p : tnode) : boolean;
|
||||
begin
|
||||
is_constintnode:=(p.nodetype=ordconstn) and is_integer(p.resulttype);
|
||||
end;
|
||||
|
||||
|
||||
function is_constcharnode(p : tnode) : boolean;
|
||||
|
||||
begin
|
||||
is_constcharnode:=(p.nodetype=ordconstn) and is_char(p.resulttype);
|
||||
end;
|
||||
|
||||
function is_constrealnode(p : tnode) : boolean;
|
||||
|
||||
begin
|
||||
is_constrealnode:=(p.nodetype=realconstn);
|
||||
end;
|
||||
|
||||
function is_constboolnode(p : tnode) : boolean;
|
||||
|
||||
begin
|
||||
is_constboolnode:=(p.nodetype=ordconstn) and is_boolean(p.resulttype);
|
||||
end;
|
||||
|
||||
|
||||
function is_constresourcestringnode(p : tnode) : boolean;
|
||||
begin
|
||||
is_constresourcestringnode:=(p.nodetype=loadn) and
|
||||
(tloadnode(p).symtableentry^.typ=constsym) and
|
||||
(pconstsym(tloadnode(p).symtableentry)^.consttyp=constresourcestring);
|
||||
end;
|
||||
|
||||
|
||||
function str_length(p : tnode) : longint;
|
||||
|
||||
begin
|
||||
str_length:=tstrconstnode(p).length;
|
||||
end;
|
||||
|
||||
function is_emptyset(p : tnode):boolean;
|
||||
|
||||
var
|
||||
i : longint;
|
||||
begin
|
||||
i:=0;
|
||||
if p.nodetype=setconstn then
|
||||
begin
|
||||
while (i<32) and (tsetconstnode(p).value_set^[i]=0) do
|
||||
inc(i);
|
||||
end;
|
||||
is_emptyset:=(i=32);
|
||||
end;
|
||||
|
||||
|
||||
{*****************************************************************************
|
||||
TREALCONSTNODE
|
||||
*****************************************************************************}
|
||||
@ -477,7 +561,10 @@ begin
|
||||
end.
|
||||
{
|
||||
$Log$
|
||||
Revision 1.5 2000-09-27 18:14:31 florian
|
||||
Revision 1.6 2000-09-27 20:25:44 florian
|
||||
* more stuff fixed
|
||||
|
||||
Revision 1.5 2000/09/27 18:14:31 florian
|
||||
* fixed a lot of syntax errors in the n*.pas stuff
|
||||
|
||||
Revision 1.4 2000/09/26 14:59:34 florian
|
||||
|
||||
@ -29,14 +29,15 @@ interface
|
||||
uses
|
||||
node;
|
||||
|
||||
{$i innr.inc}
|
||||
|
||||
type
|
||||
type
|
||||
tinlinenode = class(tunarynode)
|
||||
inlinenumber : byte;
|
||||
constructor create(number : byte;is_const:boolean;l : tnode);virtual;
|
||||
function getcopy : tnode;override;
|
||||
function pass_1 : tnode;override;
|
||||
end;
|
||||
tinlinenode = class(tunarynode)
|
||||
inlinenumber : byte;
|
||||
constructor create(number : byte;is_const:boolean;l : tnode);virtual;
|
||||
function getcopy : tnode;override;
|
||||
function pass_1 : tnode;override;
|
||||
end;
|
||||
|
||||
var
|
||||
cinlinenode : class of tinlinenode;
|
||||
@ -50,7 +51,8 @@ implementation
|
||||
globtype,
|
||||
symconst,symtable,aasm,types,
|
||||
htypechk,pass_1,
|
||||
ncal,cpubase
|
||||
ncal,ncon,ncnv,nadd,
|
||||
cpubase
|
||||
{$ifdef newcg}
|
||||
,cgbase
|
||||
,tgobj
|
||||
@ -67,7 +69,7 @@ implementation
|
||||
|
||||
begin
|
||||
geninlinenode:=cinlinenode.create(number,is_const,l);
|
||||
end:
|
||||
end;
|
||||
|
||||
{*****************************************************************************
|
||||
TINLINENODE
|
||||
@ -78,7 +80,7 @@ implementation
|
||||
begin
|
||||
inherited create(inlinen,l);
|
||||
if is_const then
|
||||
include(flags,nf_is_const);
|
||||
include(flags,nf_inlineconst);
|
||||
inlinenumber:=number;
|
||||
end;
|
||||
|
||||
@ -95,7 +97,7 @@ implementation
|
||||
{$ifdef fpc}
|
||||
{$maxfpuregisters 0}
|
||||
{$endif fpc}
|
||||
function tinlinenode.pass_1 : tnode;override;
|
||||
function tinlinenode.pass_1 : tnode;
|
||||
var
|
||||
vl,vl2 : longint;
|
||||
vr : bestreal;
|
||||
@ -124,8 +126,7 @@ implementation
|
||||
v:=porddef(adef)^.high;
|
||||
hp:=genordinalconstnode(v,adef);
|
||||
firstpass(hp);
|
||||
disposetree(p);
|
||||
p:=hp;
|
||||
pass_1:=hp;
|
||||
end;
|
||||
enumdef:
|
||||
begin
|
||||
@ -134,8 +135,7 @@ implementation
|
||||
while enum^.nextenum<>nil do
|
||||
enum:=enum^.nextenum;
|
||||
hp:=genenumnode(enum);
|
||||
disposetree(p);
|
||||
p:=hp;
|
||||
pass_1:=hp;
|
||||
end;
|
||||
else
|
||||
internalerror(87);
|
||||
@ -145,11 +145,11 @@ implementation
|
||||
function getconstrealvalue : bestreal;
|
||||
|
||||
begin
|
||||
case left.treetype of
|
||||
case left.nodetype of
|
||||
ordconstn:
|
||||
getconstrealvalue:=left.value;
|
||||
getconstrealvalue:=tordconstnode(left).value;
|
||||
realconstn:
|
||||
getconstrealvalue:=left.value_real;
|
||||
getconstrealvalue:=trealconstnode(left).value_real;
|
||||
else
|
||||
internalerror(309992);
|
||||
end;
|
||||
@ -162,9 +162,7 @@ implementation
|
||||
|
||||
begin
|
||||
hp:=genrealconstnode(r,bestrealdef^);
|
||||
disposetree(p);
|
||||
p:=hp;
|
||||
firstpass(p);
|
||||
firstpass(hp);
|
||||
end;
|
||||
|
||||
procedure handleextendedfunction;
|
||||
@ -173,7 +171,7 @@ implementation
|
||||
location.loc:=LOC_FPU;
|
||||
resulttype:=s80floatdef;
|
||||
{ redo firstpass for varstate status PM }
|
||||
set_varstate(left,true);
|
||||
left.set_varstate(true);
|
||||
if (left.resulttype^.deftype<>floatdef) or
|
||||
(pfloatdef(left.resulttype)^.typ<>s80real) then
|
||||
begin
|
||||
@ -191,11 +189,11 @@ implementation
|
||||
{ if we handle writeln; left contains no valid address }
|
||||
if assigned(left) then
|
||||
begin
|
||||
if left.treetype=callparan then
|
||||
if left.nodetype=callparan then
|
||||
firstcallparan(left,nil,false)
|
||||
else
|
||||
firstpass(left);
|
||||
left_right_max(p);
|
||||
left_right_max;
|
||||
set_location(location,left.location);
|
||||
end;
|
||||
inc(parsing_para_level);
|
||||
@ -220,19 +218,19 @@ implementation
|
||||
vl2:=0; { second parameter Ex: ptr(vl,vl2) }
|
||||
vr:=0;
|
||||
isreal:=false;
|
||||
case left.treetype of
|
||||
case left.nodetype of
|
||||
realconstn :
|
||||
begin
|
||||
isreal:=true;
|
||||
vr:=left.value_real;
|
||||
vr:=trealconstnode(left).value_real;
|
||||
end;
|
||||
ordconstn :
|
||||
vl:=left.value;
|
||||
vl:=tordconstnode(left).value;
|
||||
callparan :
|
||||
begin
|
||||
{ both exists, else it was not generated }
|
||||
vl:=left.left.value;
|
||||
vl2:=left.right.left.value;
|
||||
vl:=tordconstnode(tcallparanode(left).left).value;
|
||||
vl2:=tordconstnode(tcallparanode(tcallparanode(left).right).left).value;
|
||||
end;
|
||||
else
|
||||
CGMessage(cg_e_illegal_expression);
|
||||
@ -431,47 +429,45 @@ implementation
|
||||
CGMessage(type_e_mismatch)
|
||||
else
|
||||
begin
|
||||
if left.treetype=ordconstn then
|
||||
if left.nodetype=ordconstn then
|
||||
begin
|
||||
case inlinenumber of
|
||||
in_lo_word : hp:=genordinalconstnode(left.value and $ff,left.resulttype);
|
||||
in_hi_word : hp:=genordinalconstnode(left.value shr 8,left.resulttype);
|
||||
in_lo_long : hp:=genordinalconstnode(left.value and $ffff,left.resulttype);
|
||||
in_hi_long : hp:=genordinalconstnode(left.value shr 16,left.resulttype);
|
||||
in_lo_qword : hp:=genordinalconstnode(left.value and $ffffffff,left.resulttype);
|
||||
in_hi_qword : hp:=genordinalconstnode(left.value shr 32,left.resulttype);
|
||||
in_lo_word : hp:=genordinalconstnode(tordconstnode(left).value and $ff,left.resulttype);
|
||||
in_hi_word : hp:=genordinalconstnode(tordconstnode(left).value shr 8,left.resulttype);
|
||||
in_lo_long : hp:=genordinalconstnode(tordconstnode(left).value and $ffff,left.resulttype);
|
||||
in_hi_long : hp:=genordinalconstnode(tordconstnode(left).value shr 16,left.resulttype);
|
||||
in_lo_qword : hp:=genordinalconstnode(tordconstnode(left).value and $ffffffff,left.resulttype);
|
||||
in_hi_qword : hp:=genordinalconstnode(tordconstnode(left).value shr 32,left.resulttype);
|
||||
end;
|
||||
disposetree(p);
|
||||
firstpass(hp);
|
||||
p:=hp;
|
||||
pass_1:=hp;
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
|
||||
in_sizeof_x:
|
||||
begin
|
||||
set_varstate(left,false);
|
||||
left.set_varstate(false);
|
||||
if push_high_param(left.resulttype) then
|
||||
begin
|
||||
getsymonlyin(left.symtable,'high'+pvarsym(left.symtableentry)^.name);
|
||||
hp:=gennode(addn,genloadnode(pvarsym(srsym),left.symtable),
|
||||
getsymonlyin(tloadnode(left).symtable,'high'+pvarsym(tloadnode(left).symtableentry)^.name);
|
||||
hp:=caddnode.create(addn,genloadnode(pvarsym(srsym),tloadnode(left).symtable),
|
||||
genordinalconstnode(1,s32bitdef));
|
||||
if (left.resulttype^.deftype=arraydef) and
|
||||
(parraydef(left.resulttype)^.elesize<>1) then
|
||||
hp:=gennode(muln,hp,genordinalconstnode(parraydef(left.resulttype)^.elesize,s32bitdef));
|
||||
disposetree(p);
|
||||
p:=hp;
|
||||
firstpass(p);
|
||||
firstpass(hp);
|
||||
end;
|
||||
if registers32<1 then
|
||||
registers32:=1;
|
||||
resulttype:=s32bitdef;
|
||||
location.loc:=LOC_REGISTER;
|
||||
if hp.registers32<1 then
|
||||
hp.registers32:=1;
|
||||
hp.resulttype:=s32bitdef;
|
||||
hp.location.loc:=LOC_REGISTER;
|
||||
pass_1:=hp;
|
||||
end;
|
||||
|
||||
in_typeof_x:
|
||||
begin
|
||||
set_varstate(left,false);
|
||||
left.set_varstate(false);
|
||||
if registers32<1 then
|
||||
registers32:=1;
|
||||
location.loc:=LOC_REGISTER;
|
||||
@ -480,13 +476,12 @@ implementation
|
||||
|
||||
in_ord_x:
|
||||
begin
|
||||
set_varstate(left,true);
|
||||
if (left.treetype=ordconstn) then
|
||||
left.set_varstate(true);
|
||||
if (left.nodetype=ordconstn) then
|
||||
begin
|
||||
hp:=genordinalconstnode(left.value,s32bitdef);
|
||||
disposetree(p);
|
||||
p:=hp;
|
||||
firstpass(p);
|
||||
hp:=genordinalconstnode(tordconstnode(left).value,s32bitdef);
|
||||
firstpass(hp);
|
||||
pass_1:=hp;
|
||||
end
|
||||
else
|
||||
begin
|
||||
@ -567,7 +562,7 @@ implementation
|
||||
else
|
||||
resulttype:=u8bitdef;
|
||||
{ we don't need string conversations here }
|
||||
if (left.treetype=typeconvn) and
|
||||
if (left.nodetype=typeconvn) and
|
||||
(left.left.resulttype^.deftype=stringdef) then
|
||||
begin
|
||||
hp:=left.left;
|
||||
@ -581,7 +576,7 @@ implementation
|
||||
CGMessage(type_e_mismatch);
|
||||
|
||||
{ evaluates length of constant strings direct }
|
||||
if (left.treetype=stringconstn) then
|
||||
if (left.nodetype=stringconstn) then
|
||||
begin
|
||||
hp:=genordinalconstnode(left.length,s32bitdef);
|
||||
disposetree(p);
|
||||
@ -639,7 +634,7 @@ implementation
|
||||
(penumdef(resulttype)^.has_jumps) then
|
||||
CGMessage(type_e_succ_and_pred_enums_with_assign_not_possible)
|
||||
else
|
||||
if left.treetype=ordconstn then
|
||||
if left.nodetype=ordconstn then
|
||||
begin
|
||||
if inlinenumber=in_succ_x then
|
||||
hp:=genordinalconstnode(left.value+1,left.resulttype)
|
||||
@ -741,7 +736,7 @@ implementation
|
||||
hpp:=left;
|
||||
while (hpp<>hp) do
|
||||
begin
|
||||
if (hpp.left.treetype=typen) then
|
||||
if (hpp.left.nodetype=typen) then
|
||||
CGMessage(type_e_cant_read_write_type);
|
||||
if not is_equal(hpp.resulttype,pfiledef(hp.resulttype)^.typedfiletype.def) then
|
||||
CGMessage(type_e_mismatch);
|
||||
@ -764,7 +759,7 @@ implementation
|
||||
while assigned(hp) do
|
||||
begin
|
||||
incrementregisterpushed($ff);
|
||||
if (hp.left.treetype=typen) then
|
||||
if (hp.left.nodetype=typen) then
|
||||
CGMessage(type_e_cant_read_write_type);
|
||||
if assigned(hp.left.resulttype) then
|
||||
begin
|
||||
@ -1153,7 +1148,7 @@ implementation
|
||||
begin
|
||||
set_varstate(left,false);
|
||||
{ this fixes tests\webtbs\tbug879.pp (FK)
|
||||
if left.treetype in [typen,loadn,subscriptn] then
|
||||
if left.nodetype in [typen,loadn,subscriptn] then
|
||||
begin
|
||||
}
|
||||
case left.resulttype^.deftype of
|
||||
@ -1238,7 +1233,7 @@ implementation
|
||||
|
||||
in_cos_extended:
|
||||
begin
|
||||
if left.treetype in [ordconstn,realconstn] then
|
||||
if left.nodetype in [ordconstn,realconstn] then
|
||||
setconstrealvalue(cos(getconstrealvalue))
|
||||
else
|
||||
handleextendedfunction;
|
||||
@ -1246,7 +1241,7 @@ implementation
|
||||
|
||||
in_sin_extended:
|
||||
begin
|
||||
if left.treetype in [ordconstn,realconstn] then
|
||||
if left.nodetype in [ordconstn,realconstn] then
|
||||
setconstrealvalue(sin(getconstrealvalue))
|
||||
else
|
||||
handleextendedfunction;
|
||||
@ -1254,7 +1249,7 @@ implementation
|
||||
|
||||
in_arctan_extended:
|
||||
begin
|
||||
if left.treetype in [ordconstn,realconstn] then
|
||||
if left.nodetype in [ordconstn,realconstn] then
|
||||
setconstrealvalue(arctan(getconstrealvalue))
|
||||
else
|
||||
handleextendedfunction;
|
||||
@ -1271,7 +1266,7 @@ implementation
|
||||
|
||||
in_abs_extended:
|
||||
begin
|
||||
if left.treetype in [ordconstn,realconstn] then
|
||||
if left.nodetype in [ordconstn,realconstn] then
|
||||
setconstrealvalue(abs(getconstrealvalue))
|
||||
else
|
||||
handleextendedfunction;
|
||||
@ -1279,7 +1274,7 @@ implementation
|
||||
|
||||
in_sqr_extended:
|
||||
begin
|
||||
if left.treetype in [ordconstn,realconstn] then
|
||||
if left.nodetype in [ordconstn,realconstn] then
|
||||
setconstrealvalue(sqr(getconstrealvalue))
|
||||
else
|
||||
handleextendedfunction;
|
||||
@ -1287,7 +1282,7 @@ implementation
|
||||
|
||||
in_sqrt_extended:
|
||||
begin
|
||||
if left.treetype in [ordconstn,realconstn] then
|
||||
if left.nodetype in [ordconstn,realconstn] then
|
||||
begin
|
||||
vr:=getconstrealvalue;
|
||||
if vr<0.0 then
|
||||
@ -1304,7 +1299,7 @@ implementation
|
||||
|
||||
in_ln_extended:
|
||||
begin
|
||||
if left.treetype in [ordconstn,realconstn] then
|
||||
if left.nodetype in [ordconstn,realconstn] then
|
||||
begin
|
||||
vr:=getconstrealvalue;
|
||||
if vr<=0.0 then
|
||||
@ -1377,7 +1372,10 @@ begin
|
||||
end.
|
||||
{
|
||||
$Log$
|
||||
Revision 1.1 2000-09-26 14:59:34 florian
|
||||
Revision 1.2 2000-09-27 20:25:44 florian
|
||||
* more stuff fixed
|
||||
|
||||
Revision 1.1 2000/09/26 14:59:34 florian
|
||||
* more conversion work done
|
||||
|
||||
}
|
||||
@ -22,7 +22,7 @@
|
||||
}
|
||||
unit nmat;
|
||||
|
||||
{$i defines}
|
||||
{$i defines.inc}
|
||||
|
||||
interface
|
||||
|
||||
@ -67,14 +67,15 @@ interface
|
||||
hcodegen,
|
||||
{$endif newcg}
|
||||
{ for isbinaryoverloaded function }
|
||||
nadd;
|
||||
nadd,
|
||||
ncon,ncnv,ncal;
|
||||
|
||||
{****************************************************************************
|
||||
TMODDIVNODE
|
||||
****************************************************************************}
|
||||
function tmoddivnode.pass_1 : tnode;
|
||||
var
|
||||
t : tnode
|
||||
t : tnode;
|
||||
rv,lv : tconstexprint;
|
||||
rd,ld : pdef;
|
||||
|
||||
@ -91,8 +92,8 @@ interface
|
||||
exit;
|
||||
|
||||
{ check for division by zero }
|
||||
rv:=right.value;
|
||||
lv:=left.value;
|
||||
rv:=tordconstnode(right).value;
|
||||
lv:=tordconstnode(left).value;
|
||||
if is_constintnode(right) and (rv=0) then
|
||||
begin
|
||||
Message(parser_e_division_by_zero);
|
||||
@ -102,7 +103,7 @@ interface
|
||||
|
||||
if is_constintnode(left) and is_constintnode(right) then
|
||||
begin
|
||||
case treetype of
|
||||
case nodetype of
|
||||
modn:
|
||||
t:=genintconstnode(lv mod rv);
|
||||
divn:
|
||||
@ -129,7 +130,7 @@ interface
|
||||
right:=gentypeconvnode(right,cs64bitdef);
|
||||
firstpass(right);
|
||||
end;
|
||||
calcregisters(p,2,0,0);
|
||||
calcregisters(self,2,0,0);
|
||||
end
|
||||
else if (porddef(rd)^.typ=u64bit) or (porddef(ld)^.typ=u64bit) then
|
||||
begin
|
||||
@ -143,7 +144,7 @@ interface
|
||||
right:=gentypeconvnode(right,cu64bitdef);
|
||||
firstpass(right);
|
||||
end;
|
||||
calcregisters(p,2,0,0);
|
||||
calcregisters(self,2,0,0);
|
||||
end;
|
||||
resulttype:=left.resulttype;
|
||||
end
|
||||
@ -192,7 +193,7 @@ interface
|
||||
if codegenerror then
|
||||
exit;
|
||||
|
||||
left_right_max(p);
|
||||
left_right_max;
|
||||
if left.registers32<=right.registers32 then
|
||||
inc(registers32);
|
||||
end;
|
||||
@ -212,22 +213,22 @@ interface
|
||||
begin
|
||||
pass_1:=nil;
|
||||
firstpass(left);
|
||||
set_varstate(left,true);
|
||||
left.set_varstate(true);
|
||||
firstpass(right);
|
||||
set_varstate(right,true);
|
||||
right.set_varstate(true);
|
||||
if codegenerror then
|
||||
exit;
|
||||
|
||||
if isbinaryoverloaded(p) then
|
||||
if isbinaryoverloaded(self) then
|
||||
exit;
|
||||
|
||||
if is_constintnode(left) and is_constintnode(right) then
|
||||
begin
|
||||
case treetype of
|
||||
case nodetype of
|
||||
shrn:
|
||||
t:=genintconstnode(left.value shr right.value);
|
||||
t:=genintconstnode(tordconstnode(left).value shr tordconstnode(right).value);
|
||||
shln:
|
||||
t:=genintconstnode(left.value shl right.value);
|
||||
t:=genintconstnode(tordconstnode(left).value shl tordconstnode(right).value);
|
||||
end;
|
||||
firstpass(t);
|
||||
pass_1:=t;
|
||||
@ -253,9 +254,9 @@ interface
|
||||
if codegenerror then
|
||||
exit;
|
||||
|
||||
if (right.treetype<>ordconstn) then
|
||||
if (right.nodetype<>ordconstn) then
|
||||
inc(regs);
|
||||
calcregisters(p,regs,0,0);
|
||||
calcregisters(self,regs,0,0);
|
||||
|
||||
location.loc:=LOC_REGISTER;
|
||||
end;
|
||||
@ -277,7 +278,7 @@ interface
|
||||
begin
|
||||
pass_1:=nil;
|
||||
firstpass(left);
|
||||
set_varstate(left,true);
|
||||
left.set_varstate(true);
|
||||
registers32:=left.registers32;
|
||||
registersfpu:=left.registersfpu;
|
||||
{$ifdef SUPPORT_MMX}
|
||||
@ -288,7 +289,7 @@ interface
|
||||
exit;
|
||||
if is_constintnode(left) then
|
||||
begin
|
||||
t:=genintconstnode(-left.value);
|
||||
t:=genintconstnode(-tordconstnode(left).value);
|
||||
firstpass(t);
|
||||
pass_1:=t;
|
||||
exit;
|
||||
@ -300,7 +301,7 @@ interface
|
||||
{$endif i386}
|
||||
then
|
||||
begin
|
||||
t:=genrealconstnode(-left.value_real,bestrealdef^);
|
||||
t:=genrealconstnode(-trealconstnode(left).value_real,bestrealdef^);
|
||||
firstpass(t);
|
||||
pass_1:=t;
|
||||
exit;
|
||||
@ -378,7 +379,7 @@ interface
|
||||
(pparaitem(minusdef^.para^.first)^.next=nil) then
|
||||
begin
|
||||
t:=gencallnode(overloaded_operators[_minus],nil);
|
||||
t.left:=gencallparanode(left,nil);
|
||||
tcallnode(t).left:=gencallparanode(left,nil);
|
||||
left:=nil;
|
||||
firstpass(t);
|
||||
pass_1:=t;
|
||||
@ -408,18 +409,18 @@ interface
|
||||
begin
|
||||
pass_1:=nil;
|
||||
firstpass(left);
|
||||
set_varstate(left,true);
|
||||
left.set_varstate(true);
|
||||
if codegenerror then
|
||||
exit;
|
||||
|
||||
if (left.treetype=ordconstn) then
|
||||
if (left.nodetype=ordconstn) then
|
||||
begin
|
||||
if is_boolean(left.resulttype) then
|
||||
{ here we do a boolena(byte(..)) type cast because }
|
||||
{ boolean(<int64>) is buggy in 1.00 }
|
||||
t:=genordinalconstnode(byte(not(boolean(byte(left.value)))),left.resulttype)
|
||||
t:=genordinalconstnode(byte(not(boolean(byte(tordconstnode(left).value)))),left.resulttype)
|
||||
else
|
||||
t:=genordinalconstnode(not(left.value),left.resulttype);
|
||||
t:=genordinalconstnode(not(tordconstnode(left).value),left.resulttype);
|
||||
firstpass(t);
|
||||
pass_1:=t;
|
||||
exit;
|
||||
@ -496,7 +497,7 @@ interface
|
||||
(pparaitem(notdef^.para^.first)^.next=nil) then
|
||||
begin
|
||||
t:=gencallnode(overloaded_operators[_op_not],nil);
|
||||
t.left:=gencallparanode(left,nil);
|
||||
tcallnode(t).left:=gencallparanode(left,nil);
|
||||
left:=nil;
|
||||
firstpass(t);
|
||||
pass_1:=t;
|
||||
@ -519,7 +520,10 @@ begin
|
||||
end.
|
||||
{
|
||||
$Log$
|
||||
Revision 1.4 2000-09-24 15:06:19 peter
|
||||
Revision 1.5 2000-09-27 20:25:44 florian
|
||||
* more stuff fixed
|
||||
|
||||
Revision 1.4 2000/09/24 15:06:19 peter
|
||||
* use defines.inc
|
||||
|
||||
Revision 1.3 2000/09/22 22:48:54 florian
|
||||
@ -530,4 +534,4 @@ end.
|
||||
|
||||
Revision 1.1 2000/09/20 21:35:12 florian
|
||||
* initial revision
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user