diff --git a/compiler/i386/cpuasm.pas b/compiler/i386/cpuasm.pas index 3a259f682b..fd39b482cd 100644 --- a/compiler/i386/cpuasm.pas +++ b/compiler/i386/cpuasm.pas @@ -857,7 +857,7 @@ begin { as default an untyped size can get all the sizes, this is different from nasm, but else we need to do a lot checking which opcodes want size or not with the automatic size generation } - asize:=$ffffffff; + asize:=longint($ffffffff); if (p^.flags and IF_SB)<>0 then asize:=OT_BITS8 else if (p^.flags and IF_SW)<>0 then @@ -1670,7 +1670,19 @@ end; end. { $Log$ - Revision 1.3 2000-11-12 22:20:37 peter + Revision 1.4 2000-12-07 17:19:45 jonas + * new constant handling: from now on, hex constants >$7fffffff are + parsed as unsigned constants (otherwise, $80000000 got sign extended + and became $ffffffff80000000), all constants in the longint range + become longints, all constants >$7fffffff and <=cardinal($ffffffff) + are cardinals and the rest are int64's. + * added lots of longint typecast to prevent range check errors in the + compiler and rtl + * type casts of symbolic ordinal constants are now preserved + * fixed bug where the original resulttype wasn't restored correctly + after doing a 64bit rangecheck + + Revision 1.3 2000/11/12 22:20:37 peter * create generic toutputsection for binary writers Revision 1.2 2000/10/15 10:50:46 florian diff --git a/compiler/i386/cpubase.pas b/compiler/i386/cpubase.pas index 950de67546..d99e913bc4 100644 --- a/compiler/i386/cpubase.pas +++ b/compiler/i386/cpubase.pas @@ -89,7 +89,7 @@ const OT_SHORT = $00000080; OT_SIZE_MASK = $000000FF; { all the size attributes } - OT_NON_SIZE = not OT_SIZE_MASK; + OT_NON_SIZE = longint(not OT_SIZE_MASK); OT_SIGNED = $00000100; { the operand need to be signed -128-127 } @@ -167,8 +167,10 @@ const IF_MMX = $00004000; { it's an MMX instruction } IF_3DNOW = $00008000; { it's a 3DNow! instruction } IF_SSE = $00010000; { it's a SSE (KNI, MMX2) instruction } - IF_PMASK = $FF000000; { the mask for processor types } - IF_PFMASK = $F001FF00; { the mask for disassembly "prefer" } + IF_PMASK = + longint($FF000000); { the mask for processor types } + IF_PFMASK = + longint($F001FF00); { the mask for disassembly "prefer" } IF_8086 = $00000000; { 8086 instruction } IF_186 = $01000000; { 186+ instruction } IF_286 = $02000000; { 286+ instruction } @@ -181,7 +183,8 @@ const IF_AMD = $20000000; { AMD-specific instruction } { added flags } IF_PRE = $40000000; { it's a prefix instruction } - IF_PASS2 = $80000000; { if the instruction can change in a second pass } + IF_PASS2 = + longint($80000000); { if the instruction can change in a second pass } type TAttSuffix = (AttSufNONE,AttSufINT,AttSufFPU,AttSufFPUint); @@ -916,7 +919,19 @@ end; end. { $Log$ - Revision 1.1 2000-10-15 09:39:37 peter + Revision 1.2 2000-12-07 17:19:45 jonas + * new constant handling: from now on, hex constants >$7fffffff are + parsed as unsigned constants (otherwise, $80000000 got sign extended + and became $ffffffff80000000), all constants in the longint range + become longints, all constants >$7fffffff and <=cardinal($ffffffff) + are cardinals and the rest are int64's. + * added lots of longint typecast to prevent range check errors in the + compiler and rtl + * type casts of symbolic ordinal constants are now preserved + * fixed bug where the original resulttype wasn't restored correctly + after doing a 64bit rangecheck + + Revision 1.1 2000/10/15 09:39:37 peter * moved cpu*.pas to i386/ * renamed n386 to common cpunode diff --git a/compiler/i386/n386cal.pas b/compiler/i386/n386cal.pas index d9af5cf007..9dacdbb2f0 100644 --- a/compiler/i386/n386cal.pas +++ b/compiler/i386/n386cal.pas @@ -404,11 +404,11 @@ implementation inc(push_size,12); emit_reg_reg(A_MOV,S_L,R_ESP,R_EDI); if (push_size mod 8)=0 then - emit_const_reg(A_AND,S_L,$fffffff8,R_ESP) + emit_const_reg(A_AND,S_L,longint($fffffff8),R_ESP) else begin emit_const_reg(A_SUB,S_L,push_size,R_ESP); - emit_const_reg(A_AND,S_L,$fffffff8,R_ESP); + emit_const_reg(A_AND,S_L,longint($fffffff8),R_ESP); emit_const_reg(A_SUB,S_L,push_size,R_ESP); end; emit_reg(A_PUSH,S_L,R_EDI); @@ -1588,7 +1588,19 @@ begin end. { $Log$ - Revision 1.13 2000-12-05 11:44:33 jonas + Revision 1.14 2000-12-07 17:19:46 jonas + * new constant handling: from now on, hex constants >$7fffffff are + parsed as unsigned constants (otherwise, $80000000 got sign extended + and became $ffffffff80000000), all constants in the longint range + become longints, all constants >$7fffffff and <=cardinal($ffffffff) + are cardinals and the rest are int64's. + * added lots of longint typecast to prevent range check errors in the + compiler and rtl + * type casts of symbolic ordinal constants are now preserved + * fixed bug where the original resulttype wasn't restored correctly + after doing a 64bit rangecheck + + Revision 1.13 2000/12/05 11:44:33 jonas + new integer regvar handling, should be much more efficient Revision 1.12 2000/12/03 22:26:54 florian diff --git a/compiler/i386/n386cnv.pas b/compiler/i386/n386cnv.pas index 6ea0291850..2cd0064dfc 100644 --- a/compiler/i386/n386cnv.pas +++ b/compiler/i386/n386cnv.pas @@ -182,7 +182,7 @@ implementation emit_reg_reg(A_XOR,S_L, hregister2,hregister2) else - emit_const_reg(A_MOV,S_L,$ffffffff,hregister2); + emit_const_reg(A_MOV,S_L,longint($ffffffff),hregister2); end else begin @@ -192,7 +192,7 @@ implementation is_signed(left.resulttype) then begin getlabel(l); - emit_const_reg(A_TEST,S_L,$80000000,makereg32(hregister)); + emit_const_reg(A_TEST,S_L,longint($80000000),makereg32(hregister)); emitjmp(C_Z,l); emit_reg(A_NOT,S_L, hregister2); @@ -681,7 +681,7 @@ implementation emit_ref_reg(A_MOV,S_L,r,R_EDI); r:=new_reference(R_ESP,4); emit_const_ref(A_AND,S_L,$7fffffff,r); - emit_const_reg(A_TEST,S_L,$80000000,R_EDI); + emit_const_reg(A_TEST,S_L,longint($80000000),R_EDI); {$ifndef noAllocEdi} ungetregister32(R_EDI); {$endif noAllocEdi} @@ -1493,7 +1493,19 @@ begin end. { $Log$ - Revision 1.9 2000-12-05 11:44:33 jonas + Revision 1.10 2000-12-07 17:19:46 jonas + * new constant handling: from now on, hex constants >$7fffffff are + parsed as unsigned constants (otherwise, $80000000 got sign extended + and became $ffffffff80000000), all constants in the longint range + become longints, all constants >$7fffffff and <=cardinal($ffffffff) + are cardinals and the rest are int64's. + * added lots of longint typecast to prevent range check errors in the + compiler and rtl + * type casts of symbolic ordinal constants are now preserved + * fixed bug where the original resulttype wasn't restored correctly + after doing a 64bit rangecheck + + Revision 1.9 2000/12/05 11:44:33 jonas + new integer regvar handling, should be much more efficient Revision 1.8 2000/11/29 00:30:46 florian diff --git a/compiler/i386/n386inl.pas b/compiler/i386/n386inl.pas index f87c6d1198..5ce205c6bc 100644 --- a/compiler/i386/n386inl.pas +++ b/compiler/i386/n386inl.pas @@ -143,12 +143,12 @@ implementation Case PordDef(dest.resulttype)^.typ of u8bit,u16bit,u32bit: begin - new(hdef,init(u32bit,0,$ffffffff)); + new(hdef,init(u32bit,0,longint($ffffffff))); hreg:=hregister; end; s8bit,s16bit,s32bit: begin - new(hdef,init(s32bit,$80000000,$7fffffff)); + new(hdef,init(s32bit,longint($80000000),$7fffffff)); hreg:=hregister; end; end; @@ -890,8 +890,8 @@ implementation OldRegisterDef := RegisterDef; RegisterDef := False; Case PordDef(dest_para.left.resulttype)^.typ of - u8bit,u16bit,u32bit: new(hdef,init(u32bit,0,$ffffffff)); - s8bit,s16bit,s32bit: new(hdef,init(s32bit,$80000000,$7fffffff)); + u8bit,u16bit,u32bit: new(hdef,init(u32bit,0,longint($ffffffff))); + s8bit,s16bit,s32bit: new(hdef,init(s32bit,longint($80000000),$7fffffff)); end; hp.resulttype := hdef; emitrangecheck(hp,dest_para.left.resulttype); @@ -1682,7 +1682,19 @@ begin end. { $Log$ - Revision 1.8 2000-12-05 11:44:33 jonas + Revision 1.9 2000-12-07 17:19:46 jonas + * new constant handling: from now on, hex constants >$7fffffff are + parsed as unsigned constants (otherwise, $80000000 got sign extended + and became $ffffffff80000000), all constants in the longint range + become longints, all constants >$7fffffff and <=cardinal($ffffffff) + are cardinals and the rest are int64's. + * added lots of longint typecast to prevent range check errors in the + compiler and rtl + * type casts of symbolic ordinal constants are now preserved + * fixed bug where the original resulttype wasn't restored correctly + after doing a 64bit rangecheck + + Revision 1.8 2000/12/05 11:44:33 jonas + new integer regvar handling, should be much more efficient Revision 1.7 2000/11/29 00:30:47 florian diff --git a/compiler/i386/n386mat.pas b/compiler/i386/n386mat.pas index 72d94adcd6..8e6c760861 100644 --- a/compiler/i386/n386mat.pas +++ b/compiler/i386/n386mat.pas @@ -894,7 +894,7 @@ implementation location.loc:=LOC_MMXREGISTER; { prepare EDI } getexplicitregister32(R_EDI); - emit_const_reg(A_MOV,S_L,$ffffffff,R_EDI); + emit_const_reg(A_MOV,S_L,longint($ffffffff),R_EDI); { load operand } case left.location.loc of LOC_MMXREGISTER: @@ -996,7 +996,19 @@ begin end. { $Log$ - Revision 1.8 2000-12-05 11:44:33 jonas + Revision 1.9 2000-12-07 17:19:46 jonas + * new constant handling: from now on, hex constants >$7fffffff are + parsed as unsigned constants (otherwise, $80000000 got sign extended + and became $ffffffff80000000), all constants in the longint range + become longints, all constants >$7fffffff and <=cardinal($ffffffff) + are cardinals and the rest are int64's. + * added lots of longint typecast to prevent range check errors in the + compiler and rtl + * type casts of symbolic ordinal constants are now preserved + * fixed bug where the original resulttype wasn't restored correctly + after doing a 64bit rangecheck + + Revision 1.8 2000/12/05 11:44:33 jonas + new integer regvar handling, should be much more efficient Revision 1.7 2000/11/29 00:30:48 florian diff --git a/compiler/i386/n386util.pas b/compiler/i386/n386util.pas index 0812793da0..fa83d8f6c5 100644 --- a/compiler/i386/n386util.pas +++ b/compiler/i386/n386util.pas @@ -970,7 +970,7 @@ implementation if from_signed and to_signed then begin getlabel(neglabel); - emit_const_reg(A_CMP,S_L,$ffffffff,hreg); + emit_const_reg(A_CMP,S_L,longint($ffffffff),hreg); emitjmp(C_E,neglabel); end; if hreg = R_EDI then @@ -981,7 +981,7 @@ implementation { if the high dword = 0, the low dword can be considered a } { simple cardinal } emitlab(poslabel); - new(hdef,init(u32bit,0,$ffffffff)); + new(hdef,init(u32bit,0,longint($ffffffff))); { the real p.resulttype is already saved in fromdef } p.resulttype := hdef; emitrangecheck(p,todef); @@ -1016,16 +1016,16 @@ implementation { if we get here, the 64bit value lies between } { longint($80000000) and -1 (JM) } emitlab(neglabel); - new(hdef,init(s32bit,$80000000,-1)); + new(hdef,init(s32bit,longint($80000000),-1)); p.resulttype := hdef; emitrangecheck(p,todef); dispose(hdef,done); emitlab(endlabel); { restore p's resulttype } - p.resulttype := fromdef; end; registerdef := oldregisterdef; end; + p.resulttype := fromdef; end; { produces if necessary rangecheckcode } @@ -1485,7 +1485,19 @@ implementation end. { $Log$ - Revision 1.6 2000-12-05 11:44:34 jonas + Revision 1.7 2000-12-07 17:19:46 jonas + * new constant handling: from now on, hex constants >$7fffffff are + parsed as unsigned constants (otherwise, $80000000 got sign extended + and became $ffffffff80000000), all constants in the longint range + become longints, all constants >$7fffffff and <=cardinal($ffffffff) + are cardinals and the rest are int64's. + * added lots of longint typecast to prevent range check errors in the + compiler and rtl + * type casts of symbolic ordinal constants are now preserved + * fixed bug where the original resulttype wasn't restored correctly + after doing a 64bit rangecheck + + Revision 1.6 2000/12/05 11:44:34 jonas + new integer regvar handling, should be much more efficient Revision 1.5 2000/11/29 00:30:49 florian diff --git a/compiler/i386/ra386att.pas b/compiler/i386/ra386att.pas index 54874fdb78..8c14745faf 100644 --- a/compiler/i386/ra386att.pas +++ b/compiler/i386/ra386att.pas @@ -1938,7 +1938,7 @@ Begin AS_DD: Begin Consume(AS_DD); - BuildConstant($ffffffff); + BuildConstant(longint($ffffffff)); end; AS_DQ: @@ -2120,7 +2120,19 @@ begin end. { $Log$ - Revision 1.4 2000-11-30 20:27:51 peter + Revision 1.5 2000-12-07 17:19:46 jonas + * new constant handling: from now on, hex constants >$7fffffff are + parsed as unsigned constants (otherwise, $80000000 got sign extended + and became $ffffffff80000000), all constants in the longint range + become longints, all constants >$7fffffff and <=cardinal($ffffffff) + are cardinals and the rest are int64's. + * added lots of longint typecast to prevent range check errors in the + compiler and rtl + * type casts of symbolic ordinal constants are now preserved + * fixed bug where the original resulttype wasn't restored correctly + after doing a 64bit rangecheck + + Revision 1.4 2000/11/30 20:27:51 peter * merged fix for bug 1229 Revision 1.3 2000/11/29 00:30:50 florian diff --git a/compiler/i386/ra386int.pas b/compiler/i386/ra386int.pas index 79d81344a5..e5ef69063b 100644 --- a/compiler/i386/ra386int.pas +++ b/compiler/i386/ra386int.pas @@ -1854,7 +1854,7 @@ Begin Begin inexpression:=true; Consume(AS_DD); - BuildConstant($ffffffff); + BuildConstant(longint($ffffffff)); inexpression:=false; end; @@ -1920,7 +1920,19 @@ begin end. { $Log$ - Revision 1.4 2000-11-30 20:27:51 peter + Revision 1.5 2000-12-07 17:19:46 jonas + * new constant handling: from now on, hex constants >$7fffffff are + parsed as unsigned constants (otherwise, $80000000 got sign extended + and became $ffffffff80000000), all constants in the longint range + become longints, all constants >$7fffffff and <=cardinal($ffffffff) + are cardinals and the rest are int64's. + * added lots of longint typecast to prevent range check errors in the + compiler and rtl + * type casts of symbolic ordinal constants are now preserved + * fixed bug where the original resulttype wasn't restored correctly + after doing a 64bit rangecheck + + Revision 1.4 2000/11/30 20:27:51 peter * merged fix for bug 1229 Revision 1.3 2000/11/29 00:30:51 florian diff --git a/compiler/ncnv.pas b/compiler/ncnv.pas index 0945b8760a..1860806a61 100644 --- a/compiler/ncnv.pas +++ b/compiler/ncnv.pas @@ -1084,6 +1084,16 @@ implementation else enable_range_check := false; hp:=genordinalconstnode(tordconstnode(left).value,resulttype); + + { do sign extension if necessary (JM) } + if not (cs_check_range in aktlocalswitches) and + is_signed(resulttype) then + with tordconstnode(hp) do + case left.resulttype^.size of + 1: value := shortint(value); + 2: value := smallint(value); + 4: value := longint(value); + end; if enable_range_check then include(aktlocalswitches,cs_check_range); firstpass(hp); @@ -1186,7 +1196,19 @@ begin end. { $Log$ - Revision 1.13 2000-11-29 00:30:32 florian + Revision 1.14 2000-12-07 17:19:42 jonas + * new constant handling: from now on, hex constants >$7fffffff are + parsed as unsigned constants (otherwise, $80000000 got sign extended + and became $ffffffff80000000), all constants in the longint range + become longints, all constants >$7fffffff and <=cardinal($ffffffff) + are cardinals and the rest are int64's. + * added lots of longint typecast to prevent range check errors in the + compiler and rtl + * type casts of symbolic ordinal constants are now preserved + * fixed bug where the original resulttype wasn't restored correctly + after doing a 64bit rangecheck + + Revision 1.13 2000/11/29 00:30:32 florian * unused units removed from uses clause * some changes for widestrings diff --git a/compiler/ncon.pas b/compiler/ncon.pas index d371f460c2..3cd6cd5a80 100644 --- a/compiler/ncon.pas +++ b/compiler/ncon.pas @@ -116,7 +116,7 @@ interface { some helper routines } - function get_ordinal_value(p : tnode) : longint; + function get_ordinal_value(p : tnode) : TConstExprInt; function is_constnode(p : tnode) : boolean; function is_constintnode(p : tnode) : boolean; function is_constcharnode(p : tnode) : boolean; @@ -201,7 +201,7 @@ implementation genpcharconstnode:=cstringconstnode.createpchar(s,length); end; - function get_ordinal_value(p : tnode) : longint; + function get_ordinal_value(p : tnode) : TConstExprInt; begin if p.nodetype=ordconstn then get_ordinal_value:=tordconstnode(p).value @@ -650,7 +650,19 @@ begin end. { $Log$ - Revision 1.11 2000-11-29 00:30:32 florian + Revision 1.12 2000-12-07 17:19:42 jonas + * new constant handling: from now on, hex constants >$7fffffff are + parsed as unsigned constants (otherwise, $80000000 got sign extended + and became $ffffffff80000000), all constants in the longint range + become longints, all constants >$7fffffff and <=cardinal($ffffffff) + are cardinals and the rest are int64's. + * added lots of longint typecast to prevent range check errors in the + compiler and rtl + * type casts of symbolic ordinal constants are now preserved + * fixed bug where the original resulttype wasn't restored correctly + after doing a 64bit rangecheck + + Revision 1.11 2000/11/29 00:30:32 florian * unused units removed from uses clause * some changes for widestrings diff --git a/compiler/ogcoff.pas b/compiler/ogcoff.pas index d026e1eec9..02895c134e 100644 --- a/compiler/ogcoff.pas +++ b/compiler/ogcoff.pas @@ -235,7 +235,7 @@ implementation sec_data : begin if win32 then - Flags:=$c0300040 + Flags:=longint($c0300040) else Flags:=$40; Aalign:=4; @@ -243,7 +243,7 @@ implementation sec_bss : begin if win32 then - Flags:=$c0300080 + Flags:=longint($c0300080) else Flags:=$80; Aalign:=4; @@ -260,7 +260,7 @@ implementation sec_edata : begin if win32 then - Flags:=$c0300040; + Flags:=longint($c0300040); end; end; sects[sec]:=new(PcoffSection,InitSec(Sec,AAlign,Flags)); @@ -747,7 +747,19 @@ implementation end. { $Log$ - Revision 1.1 2000-11-12 22:20:37 peter + Revision 1.2 2000-12-07 17:19:42 jonas + * new constant handling: from now on, hex constants >$7fffffff are + parsed as unsigned constants (otherwise, $80000000 got sign extended + and became $ffffffff80000000), all constants in the longint range + become longints, all constants >$7fffffff and <=cardinal($ffffffff) + are cardinals and the rest are int64's. + * added lots of longint typecast to prevent range check errors in the + compiler and rtl + * type casts of symbolic ordinal constants are now preserved + * fixed bug where the original resulttype wasn't restored correctly + after doing a 64bit rangecheck + + Revision 1.1 2000/11/12 22:20:37 peter * create generic toutputsection for binary writers } diff --git a/compiler/pdecl.pas b/compiler/pdecl.pas index e7237eac1a..33558ae576 100644 --- a/compiler/pdecl.pas +++ b/compiler/pdecl.pas @@ -78,7 +78,8 @@ implementation ordconstn: begin if is_constintnode(p) then - hp:=new(pconstsym,init_def(name,constint,tordconstnode(p).value,nil)) + hp:=new(pconstsym,init_def(name,constint,tordconstnode(p).value, + tordconstnode(p).resulttype)) else if is_constcharnode(p) then hp:=new(pconstsym,init_def(name,constchar,tordconstnode(p).value,nil)) else if is_constboolnode(p) then @@ -535,7 +536,19 @@ implementation end. { $Log$ - Revision 1.22 2000-11-29 00:30:35 florian + Revision 1.23 2000-12-07 17:19:42 jonas + * new constant handling: from now on, hex constants >$7fffffff are + parsed as unsigned constants (otherwise, $80000000 got sign extended + and became $ffffffff80000000), all constants in the longint range + become longints, all constants >$7fffffff and <=cardinal($ffffffff) + are cardinals and the rest are int64's. + * added lots of longint typecast to prevent range check errors in the + compiler and rtl + * type casts of symbolic ordinal constants are now preserved + * fixed bug where the original resulttype wasn't restored correctly + after doing a 64bit rangecheck + + Revision 1.22 2000/11/29 00:30:35 florian * unused units removed from uses clause * some changes for widestrings diff --git a/compiler/pexpr.pas b/compiler/pexpr.pas index 1fc5990748..54d4b5ca0c 100644 --- a/compiler/pexpr.pas +++ b/compiler/pexpr.pas @@ -28,7 +28,8 @@ interface uses symtype, - node; + node, + cpuinfo; { reads a whole expression } function expr : tnode; @@ -45,7 +46,7 @@ interface procedure do_member_read(getaddr : boolean;const sym : psym;var p1 : tnode; var pd : pdef;var again : boolean); - function get_intconst:longint; + function get_intconst:TConstExprInt; function get_stringconst:string; @@ -56,7 +57,7 @@ implementation cutils,cobjects, { global } globtype,globals,tokens,verbose, - systems,cpuinfo,widestr, + systems,widestr, { symtable } symconst,symbase,symdef,symsym,symtable,types, { pass 1 } @@ -1006,6 +1007,7 @@ implementation function factor(getaddr : boolean) : tnode; var l : longint; + card : cardinal; ic : TConstExprInt; oldp1, p1,p2,p3 : tnode; @@ -1979,39 +1981,55 @@ implementation postfixoperators; end; _INTCONST : begin - valint(pattern,l,code); + { try cardinal first } + val(pattern,card,code); if code<>0 then - begin - { try int64 if available } - { if no int64 available longint is tried a second } - { time which doesn't hurt } - val(pattern,ic,code); - if code<>0 then + begin + { then longint } + valint(pattern,l,code); + if code <> 0 then begin - val(pattern,d,code); - if code<>0 then + { then int64 } + val(pattern,ic,code); + if code<>0 then begin - Message(cg_e_invalid_integer); - consume(_INTCONST); - l:=1; - p1:=genordinalconstnode(l,s32bitdef); + {finally float } + val(pattern,d,code); + if code<>0 then + begin + Message(cg_e_invalid_integer); + consume(_INTCONST); + l:=1; + p1:=genordinalconstnode(l,s32bitdef); + end + else + begin + consume(_INTCONST); + p1:=genrealconstnode(d,bestrealdef^); + end; end else begin consume(_INTCONST); - p1:=genrealconstnode(d,bestrealdef^); - end; + p1:=genordinalconstnode(ic,cs64bitdef); + end end else begin - consume(_INTCONST); - p1:=genordinalconstnode(ic,cs64bitdef); - end; - end + consume(_INTCONST); + p1:=genordinalconstnode(l,s32bitdef) + end + end else begin consume(_INTCONST); - p1:=genordinalconstnode(l,s32bitdef) + { check whether the value isn't in the longint range as well } + { (longint is easier to perform calculations with) (JM) } + if card <= $7fffffff then + { no sign extension necessary, so not longint typecast (JM) } + p1:=genordinalconstnode(card,s32bitdef) + else + p1:=genordinalconstnode(card,u32bitdef) end; end; _REALNUMBER : begin @@ -2350,7 +2368,7 @@ _LECKKLAMMER : begin end; - function get_intconst:longint; + function get_intconst:TConstExprInt; {Reads an expression, tries to evalute it and check if it is an integer constant. Then the constant is returned.} var @@ -2395,7 +2413,19 @@ _LECKKLAMMER : begin end. { $Log$ - Revision 1.18 2000-11-29 00:30:36 florian + Revision 1.19 2000-12-07 17:19:42 jonas + * new constant handling: from now on, hex constants >$7fffffff are + parsed as unsigned constants (otherwise, $80000000 got sign extended + and became $ffffffff80000000), all constants in the longint range + become longints, all constants >$7fffffff and <=cardinal($ffffffff) + are cardinals and the rest are int64's. + * added lots of longint typecast to prevent range check errors in the + compiler and rtl + * type casts of symbolic ordinal constants are now preserved + * fixed bug where the original resulttype wasn't restored correctly + after doing a 64bit rangecheck + + Revision 1.18 2000/11/29 00:30:36 florian * unused units removed from uses clause * some changes for widestrings diff --git a/compiler/ppu.pas b/compiler/ppu.pas index 373a0edd79..3c0ae7cc1b 100644 --- a/compiler/ppu.pas +++ b/compiler/ppu.pas @@ -624,8 +624,8 @@ begin bufstart:=sizeof(tppuheader); bufidx:=0; {reset} - crc:=$ffffffff; - interface_crc:=$ffffffff; + crc:=longint($ffffffff); + interface_crc:=longint($ffffffff); do_interface_crc:=true; Error:=false; do_crc:=true; @@ -889,7 +889,19 @@ end; end. { $Log$ - Revision 1.5 2000-10-31 22:02:50 peter + Revision 1.6 2000-12-07 17:19:43 jonas + * new constant handling: from now on, hex constants >$7fffffff are + parsed as unsigned constants (otherwise, $80000000 got sign extended + and became $ffffffff80000000), all constants in the longint range + become longints, all constants >$7fffffff and <=cardinal($ffffffff) + are cardinals and the rest are int64's. + * added lots of longint typecast to prevent range check errors in the + compiler and rtl + * type casts of symbolic ordinal constants are now preserved + * fixed bug where the original resulttype wasn't restored correctly + after doing a 64bit rangecheck + + Revision 1.5 2000/10/31 22:02:50 peter * symtable splitted, no real code changes Revision 1.4 2000/09/24 15:06:24 peter diff --git a/compiler/psystem.pas b/compiler/psystem.pas index 35d157b863..687c17fce0 100644 --- a/compiler/psystem.pas +++ b/compiler/psystem.pas @@ -215,8 +215,8 @@ begin voiddef:=new(porddef,init(uvoid,0,0)); u8bitdef:=new(porddef,init(u8bit,0,255)); u16bitdef:=new(porddef,init(u16bit,0,65535)); - u32bitdef:=new(porddef,init(u32bit,0,$ffffffff)); - s32bitdef:=new(porddef,init(s32bit,$80000000,$7fffffff)); + u32bitdef:=new(porddef,init(u32bit,0,longint($ffffffff))); + s32bitdef:=new(porddef,init(s32bit,longint($80000000),$7fffffff)); cu64bitdef:=new(porddef,init(u64bit,0,0)); cs64bitdef:=new(porddef,init(s64bit,0,0)); booldef:=new(porddef,init(bool8bit,0,1)); @@ -259,7 +259,19 @@ end; end. { $Log$ - Revision 1.10 2000-11-29 00:30:38 florian + Revision 1.11 2000-12-07 17:19:43 jonas + * new constant handling: from now on, hex constants >$7fffffff are + parsed as unsigned constants (otherwise, $80000000 got sign extended + and became $ffffffff80000000), all constants in the longint range + become longints, all constants >$7fffffff and <=cardinal($ffffffff) + are cardinals and the rest are int64's. + * added lots of longint typecast to prevent range check errors in the + compiler and rtl + * type casts of symbolic ordinal constants are now preserved + * fixed bug where the original resulttype wasn't restored correctly + after doing a 64bit rangecheck + + Revision 1.10 2000/11/29 00:30:38 florian * unused units removed from uses clause * some changes for widestrings diff --git a/compiler/ptype.pas b/compiler/ptype.pas index 4cdb2d0a23..ec9eb309ef 100644 --- a/compiler/ptype.pas +++ b/compiler/ptype.pas @@ -55,7 +55,7 @@ implementation uses { common } - cutils,cobjects, + cutils,cobjects,cpuinfo, { global } globals,tokens,verbose, systems, @@ -224,7 +224,7 @@ implementation aktenumdef : penumdef; ap : parraydef; s : stringid; - l,v : longint; + l,v : TConstExprInt; oldaktpackrecords : tpackrecords; hs : string; defpos,storepos : tfileposinfo; @@ -350,7 +350,7 @@ implementation consume(_LECKKLAMMER); { defaults } arraytype:=generrordef; - lowval:=$80000000; + lowval:=longint($80000000); highval:=$7fffffff; tt.reset; repeat @@ -577,7 +577,19 @@ implementation end. { $Log$ - Revision 1.16 2000-11-29 00:30:38 florian + Revision 1.17 2000-12-07 17:19:43 jonas + * new constant handling: from now on, hex constants >$7fffffff are + parsed as unsigned constants (otherwise, $80000000 got sign extended + and became $ffffffff80000000), all constants in the longint range + become longints, all constants >$7fffffff and <=cardinal($ffffffff) + are cardinals and the rest are int64's. + * added lots of longint typecast to prevent range check errors in the + compiler and rtl + * type casts of symbolic ordinal constants are now preserved + * fixed bug where the original resulttype wasn't restored correctly + after doing a 64bit rangecheck + + Revision 1.16 2000/11/29 00:30:38 florian * unused units removed from uses clause * some changes for widestrings diff --git a/compiler/rautils.pas b/compiler/rautils.pas index 90fd1811c0..07f07f487f 100644 --- a/compiler/rautils.pas +++ b/compiler/rautils.pas @@ -334,12 +334,6 @@ begin else begin { Convert String to number and add to stack } - if token='-2147483648' then - begin - temp:=$80000000; - localerror:=0; - end - else Val(Token, Temp, LocalError); if LocalError = 0 then RPNPush(Temp) @@ -1554,7 +1548,19 @@ end; end. { $Log$ - Revision 1.12 2000-11-29 00:30:38 florian + Revision 1.13 2000-12-07 17:19:43 jonas + * new constant handling: from now on, hex constants >$7fffffff are + parsed as unsigned constants (otherwise, $80000000 got sign extended + and became $ffffffff80000000), all constants in the longint range + become longints, all constants >$7fffffff and <=cardinal($ffffffff) + are cardinals and the rest are int64's. + * added lots of longint typecast to prevent range check errors in the + compiler and rtl + * type casts of symbolic ordinal constants are now preserved + * fixed bug where the original resulttype wasn't restored correctly + after doing a 64bit rangecheck + + Revision 1.12 2000/11/29 00:30:38 florian * unused units removed from uses clause * some changes for widestrings diff --git a/compiler/symdef.pas b/compiler/symdef.pas index 08c327cd41..deeb02666a 100644 --- a/compiler/symdef.pas +++ b/compiler/symdef.pas @@ -1735,7 +1735,7 @@ implementation begin datasegment^.concat(new(pai_const,init_32bit(low))); datasegment^.concat(new(pai_const,init_32bit($7fffffff))); - datasegment^.concat(new(pai_const,init_32bit($80000000))); + datasegment^.concat(new(pai_const,init_32bit(longint($80000000)))); datasegment^.concat(new(pai_const,init_32bit(high))); end; end; @@ -2581,7 +2581,7 @@ implementation begin datasegment^.concat(new(pai_const,init_32bit(lowrange))); datasegment^.concat(new(pai_const,init_32bit($7fffffff))); - datasegment^.concat(new(pai_const,init_32bit($80000000))); + datasegment^.concat(new(pai_const,init_32bit(longint($80000000)))); datasegment^.concat(new(pai_const,init_32bit(highrange))); end; end; @@ -5549,7 +5549,19 @@ Const local_symtable_index : longint = $8001; end. { $Log$ - Revision 1.16 2000-11-30 23:12:57 florian + Revision 1.17 2000-12-07 17:19:43 jonas + * new constant handling: from now on, hex constants >$7fffffff are + parsed as unsigned constants (otherwise, $80000000 got sign extended + and became $ffffffff80000000), all constants in the longint range + become longints, all constants >$7fffffff and <=cardinal($ffffffff) + are cardinals and the rest are int64's. + * added lots of longint typecast to prevent range check errors in the + compiler and rtl + * type casts of symbolic ordinal constants are now preserved + * fixed bug where the original resulttype wasn't restored correctly + after doing a 64bit rangecheck + + Revision 1.16 2000/11/30 23:12:57 florian * if raw interfaces inherit from IUnknown they are ref. counted too Revision 1.15 2000/11/29 00:30:40 florian diff --git a/compiler/verbose.pas b/compiler/verbose.pas index 99e7f2748e..f4eaaafdd5 100644 --- a/compiler/verbose.pas +++ b/compiler/verbose.pas @@ -61,7 +61,7 @@ Const V_Debug = $100000; V_Executable = $200000; V_ShowFile = $ffff; - V_All = $ffffffff; + V_All = longint($ffffffff); V_Default = V_Fatal + V_Error + V_Normal; var @@ -626,7 +626,19 @@ end; end. { $Log$ - Revision 1.8 2000-11-29 00:30:43 florian + Revision 1.9 2000-12-07 17:19:45 jonas + * new constant handling: from now on, hex constants >$7fffffff are + parsed as unsigned constants (otherwise, $80000000 got sign extended + and became $ffffffff80000000), all constants in the longint range + become longints, all constants >$7fffffff and <=cardinal($ffffffff) + are cardinals and the rest are int64's. + * added lots of longint typecast to prevent range check errors in the + compiler and rtl + * type casts of symbolic ordinal constants are now preserved + * fixed bug where the original resulttype wasn't restored correctly + after doing a 64bit rangecheck + + Revision 1.8 2000/11/29 00:30:43 florian * unused units removed from uses clause * some changes for widestrings diff --git a/rtl/inc/graph/graph.inc b/rtl/inc/graph/graph.inc index 3dee5f28c2..ac337108e6 100644 --- a/rtl/inc/graph/graph.inc +++ b/rtl/inc/graph/graph.inc @@ -1299,8 +1299,9 @@ Begin {$endif logging} inc(x,startXViewPort); inc(y,startYViewPort); - x1 := ptw(Bitmap)[0]+x; { get width and adjust end coordinate accordingly } - y1 := ptw(Bitmap)[1]+y; { get height and adjust end coordinate accordingly } + { width/height are 1-based, coordinates are zero based } + x1 := ptw(Bitmap)[0]+x-1; { get width and adjust end coordinate accordingly } + y1 := ptw(Bitmap)[1]+y-1; { get height and adjust end coordinate accordingly } deltaX := 0; deltaX1 := 0; @@ -1363,8 +1364,8 @@ Begin GetScanLine(x1,x2,j,pt(Bitmap)[k]); inc(k,i); end; - ptw(Bitmap)[0] := X2-X1; { First longint is width } - ptw(Bitmap)[1] := Y2-Y1; { Second longint is height } + ptw(Bitmap)[0] := X2-X1+1; { First longint is width } + ptw(Bitmap)[1] := Y2-Y1+1; { Second longint is height } ptw(bitmap)[2] := 0; { Third longint is reserved} end; @@ -2440,7 +2441,19 @@ begin end; { $Log$ - Revision 1.4 2000-08-12 12:27:13 jonas + Revision 1.5 2000-12-07 17:19:47 jonas + * new constant handling: from now on, hex constants >$7fffffff are + parsed as unsigned constants (otherwise, $80000000 got sign extended + and became $ffffffff80000000), all constants in the longint range + become longints, all constants >$7fffffff and <=cardinal($ffffffff) + are cardinals and the rest are int64's. + * added lots of longint typecast to prevent range check errors in the + compiler and rtl + * type casts of symbolic ordinal constants are now preserved + * fixed bug where the original resulttype wasn't restored correctly + after doing a 64bit rangecheck + + Revision 1.4 2000/08/12 12:27:13 jonas + setallpalette hook + setallpalette implemented for standard vga and VESA 2.0+ diff --git a/rtl/inc/heaptrc.pp b/rtl/inc/heaptrc.pp index 602db5aaea..07379f8cd2 100644 --- a/rtl/inc/heaptrc.pp +++ b/rtl/inc/heaptrc.pp @@ -179,7 +179,7 @@ var crc : longint; pl : plongint; begin - crc:=$ffffffff; + crc:=longint($ffffffff); crc:=UpdateCrc32(crc,p^.size,sizeof(longint)); crc:=UpdateCrc32(crc,p^.calls,tracesize*sizeof(longint)); if extra_info_size>0 then @@ -199,7 +199,7 @@ var crc : longint; pl : plongint; begin - crc:=$ffffffff; + crc:=longint($ffffffff); crc:=UpdateCrc32(crc,p^.size,sizeof(longint)); crc:=UpdateCrc32(crc,p^.calls,tracesize*sizeof(longint)); if extra_info_size>0 then @@ -313,9 +313,9 @@ begin i:=0; while pp<>nil do begin - if ((pp^.sig<>$DEADBEEF) or usecrc) and + if ((pp^.sig<>longint($DEADBEEF)) or usecrc) and ((pp^.sig<>calculate_sig(pp)) or not usecrc) and - (pp^.sig <> $AAAAAAAA) then + (pp^.sig <> longint($AAAAAAAA)) then begin writeln(ptext^,'error in linked list of heap_mem_info'); RunError(204); @@ -348,12 +348,12 @@ begin inc(bp,sizeof(longint)); p:=SysGetMem(bp); { Create the info block } - pheap_mem_info(p)^.sig:=$DEADBEEF; + pheap_mem_info(p)^.sig:=longint($DEADBEEF); pheap_mem_info(p)^.size:=size; if add_tail then begin pl:=pointer(p)+bp-sizeof(longint); - pl^:=$DEADBEEF; + pl^:=longint($DEADBEEF); end; bp:=get_caller_frame(get_frame); for i:=1 to tracesize do @@ -412,13 +412,13 @@ begin pp:=pheap_mem_info(p); if not quicktrace and not(is_in_getmem_list(pp)) then RunError(204); - if (pp^.sig=$AAAAAAAA) and not usecrc then + if (pp^.sig=longint($AAAAAAAA)) and not usecrc then begin error_in_heap:=true; dump_already_free(pp,ptext^); if haltonerror then halt(1); end - else if ((pp^.sig<>$DEADBEEF) or usecrc) and + else if ((pp^.sig<>longint($DEADBEEF)) or usecrc) and ((pp^.sig<>calculate_sig(pp)) or not usecrc) then begin error_in_heap:=true; @@ -442,7 +442,7 @@ begin exit; end; { now it is released !! } - pp^.sig:=$AAAAAAAA; + pp^.sig:=longint($AAAAAAAA); if not keepreleased then begin if pp^.next<>nil then @@ -567,7 +567,7 @@ begin dec(p,sizeof(theap_mem_info)+extra_info_size); pp:=pheap_mem_info(p); { test block } - if ((pp^.sig<>$DEADBEEF) or usecrc) and + if ((pp^.sig<>longint($DEADBEEF)) or usecrc) and ((pp^.sig<>calculate_sig(pp)) or not usecrc) then begin error_in_heap:=true; @@ -608,12 +608,12 @@ begin inc(getmem_size,size); inc(getmem8_size,((size+7) div 8)*8); { Create the info block } - pp^.sig:=$DEADBEEF; + pp^.sig:=longint($DEADBEEF); pp^.size:=size; if add_tail then begin pl:=pointer(p)+bp-sizeof(longint); - pl^:=$DEADBEEF; + pl^:=longint($DEADBEEF); end; bp:=get_caller_frame(get_frame); for i:=1 to tracesize do @@ -723,10 +723,10 @@ begin (cardinal(p)<=cardinal(pp)+sizeof(theap_mem_info)+extra_info_size+pp^.size) then begin { check allocated block } - if ((pp^.sig=$DEADBEEF) and not usecrc) or + if ((pp^.sig=longint($DEADBEEF)) and not usecrc) or ((pp^.sig=calculate_sig(pp)) and usecrc) or { special case of the fill_extra_info call } - ((pp=heap_valid_last) and usecrc and (pp^.sig=$DEADBEEF) + ((pp=heap_valid_last) and usecrc and (pp^.sig=longint($DEADBEEF)) and inside_trace_getmem) then goto _exit else @@ -754,7 +754,7 @@ begin if (cardinal(p)>=cardinal(pp)+sizeof(theap_mem_info)+extra_info_size) and (cardinal(p)<=cardinal(pp)+sizeof(theap_mem_info)+extra_info_size+pp^.size) then { allocated block } - if ((pp^.sig=$DEADBEEF) and not usecrc) or + if ((pp^.sig=longint($DEADBEEF)) and not usecrc) or ((pp^.sig=calculate_sig(pp)) and usecrc) then goto _exit else @@ -813,7 +813,7 @@ begin Writeln(ptext^,'More memory blocks than expected'); exit; end; - if ((pp^.sig=$DEADBEEF) and not usecrc) or + if ((pp^.sig=longint($DEADBEEF)) and not usecrc) or ((pp^.sig=calculate_sig(pp)) and usecrc) then begin { this one was not released !! } @@ -821,7 +821,7 @@ begin call_stack(pp,ptext^); dec(i); end - else if pp^.sig<>$AAAAAAAA then + else if pp^.sig<>longint($AAAAAAAA) then begin dump_error(pp,ptext^); {$ifdef EXTRA} @@ -850,7 +850,7 @@ begin pp:=heap_mem_root; while pp<>nil do begin - pp^.sig:=$AAAAAAAA; + pp^.sig:=longint($AAAAAAAA); pp:=pp^.previous; end; end; @@ -992,7 +992,19 @@ finalization end. { $Log$ - Revision 1.4 2000-11-13 13:40:03 marco + Revision 1.5 2000-12-07 17:19:47 jonas + * new constant handling: from now on, hex constants >$7fffffff are + parsed as unsigned constants (otherwise, $80000000 got sign extended + and became $ffffffff80000000), all constants in the longint range + become longints, all constants >$7fffffff and <=cardinal($ffffffff) + are cardinals and the rest are int64's. + * added lots of longint typecast to prevent range check errors in the + compiler and rtl + * type casts of symbolic ordinal constants are now preserved + * fixed bug where the original resulttype wasn't restored correctly + after doing a 64bit rangecheck + + Revision 1.4 2000/11/13 13:40:03 marco * Renamefest Revision 1.3 2000/08/24 09:01:07 jonas diff --git a/rtl/inc/int64.inc b/rtl/inc/int64.inc index c82572c48c..1b909791e2 100644 --- a/rtl/inc/int64.inc +++ b/rtl/inc/int64.inc @@ -31,7 +31,7 @@ r:=0; for i:=0 to 31 do begin - if (tqwordrec(q).high and ($80000000 shr i))<>0 then + if (tqwordrec(q).high and (longint($80000000) shr i))<>0 then begin count_leading_zeros:=r; exit; @@ -40,7 +40,7 @@ end; for i:=0 to 31 do begin - if (tqwordrec(q).low and ($80000000 shr i))<>0 then + if (tqwordrec(q).low and (longint($80000000) shr i))<>0 then begin count_leading_zeros:=r; exit; @@ -296,7 +296,7 @@ ((q1>q3) or (q2>q3) or { the bit 63 can be only set if we have $80000000 00000000 } { and sign is true } - ((tqwordrec(q3).high and $80000000)<>0) and + ((tqwordrec(q3).high and longint($80000000))<>0) and ((q3<>(qword(1) shl 63)) or not(sign)) ) then HandleErrorFrame(215,get_frame); @@ -395,13 +395,13 @@ { high(int64) produces 0 in version 1.0 (JM) } with qwordrec(maxint64) do begin - l1 := $ffffffff; + l1 := longint($ffffffff); l2 := $7fffffff; end; with qwordrec(maxqword) do begin - l1 := $ffffffff; - l2 := $ffffffff; + l1 := longint($ffffffff); + l2 := longint($ffffffff); end; while Code<=Length(s) do @@ -479,7 +479,19 @@ { $Log$ - Revision 1.4 2000-11-17 17:01:23 jonas + Revision 1.5 2000-12-07 17:19:47 jonas + * new constant handling: from now on, hex constants >$7fffffff are + parsed as unsigned constants (otherwise, $80000000 got sign extended + and became $ffffffff80000000), all constants in the longint range + become longints, all constants >$7fffffff and <=cardinal($ffffffff) + are cardinals and the rest are int64's. + * added lots of longint typecast to prevent range check errors in the + compiler and rtl + * type casts of symbolic ordinal constants are now preserved + * fixed bug where the original resulttype wasn't restored correctly + after doing a 64bit rangecheck + + Revision 1.4 2000/11/17 17:01:23 jonas * fixed bug for val when processing -2147483648 and low(int64) (merged) Revision 1.3 2000/07/28 12:29:49 jonas diff --git a/rtl/inc/systemh.inc b/rtl/inc/systemh.inc index adc2d24e11..f61b65dd52 100644 --- a/rtl/inc/systemh.inc +++ b/rtl/inc/systemh.inc @@ -47,7 +47,8 @@ Type shortint = -128..127; SmallInt = -32768..32767; - Longint = $80000000..$7fffffff; { $8000000 creates a longint overfow !! } + { can't use -2147483648 because of a bug in 1.0.2's val() procedure (JM) } + Longint = +(-2147483647-1)..$7fffffff; byte = 0..255; Word = 0..65535; dword = cardinal; @@ -484,7 +485,19 @@ const { $Log$ - Revision 1.12 2000-11-13 13:40:04 marco + Revision 1.13 2000-12-07 17:19:47 jonas + * new constant handling: from now on, hex constants >$7fffffff are + parsed as unsigned constants (otherwise, $80000000 got sign extended + and became $ffffffff80000000), all constants in the longint range + become longints, all constants >$7fffffff and <=cardinal($ffffffff) + are cardinals and the rest are int64's. + * added lots of longint typecast to prevent range check errors in the + compiler and rtl + * type casts of symbolic ordinal constants are now preserved + * fixed bug where the original resulttype wasn't restored correctly + after doing a 64bit rangecheck + + Revision 1.12 2000/11/13 13:40:04 marco * Renamefest Revision 1.11 2000/11/11 16:12:01 peter