diff --git a/compiler/pdecl.pas b/compiler/pdecl.pas index a536931654..b3d46f19d1 100644 --- a/compiler/pdecl.pas +++ b/compiler/pdecl.pas @@ -190,11 +190,10 @@ unit pdecl; end; COLON: begin - consume(COLON); - { this was missed, so const s : ^string = nil gives an - error (FK) - } + { set the blocktype first so a consume also supports a + caret, to support const s : ^string = nil } block_type:=bt_type; + consume(COLON); ignore_equal:=true; def:=read_type(''); ignore_equal:=false; @@ -2124,7 +2123,11 @@ unit pdecl; end. { $Log$ - Revision 1.89 1998-12-11 00:03:30 peter + Revision 1.90 1998-12-15 17:16:00 peter + * fixed const s : ^string + * first things for const pchar : @string[1] + + Revision 1.89 1998/12/11 00:03:30 peter + globtype,tokens,version unit splitted from globals Revision 1.88 1998/11/30 09:43:20 pierre diff --git a/compiler/ptconst.pas b/compiler/ptconst.pas index a6b42378ff..9b03c1bbe8 100644 --- a/compiler/ptconst.pas +++ b/compiler/ptconst.pas @@ -214,22 +214,24 @@ unit ptconst; if p^.treetype=addrn then begin hp:=p^.left; - while assigned(hp) and (hp^.treetype=subscriptn) do + while assigned(hp) and (hp^.treetype in [subscriptn,vecn]) do hp:=hp^.left; if (is_equal(ppointerdef(p^.resulttype)^.definition,ppointerdef(def)^.definition) or (is_equal(ppointerdef(p^.resulttype)^.definition,voiddef)) or (is_equal(ppointerdef(def)^.definition,voiddef))) and - (hp^.treetype = loadn) then + (hp^.treetype=loadn) then begin firstpass(p^.left); hp:=p^.left; offset:=0; while assigned(hp) and (hp^.treetype<>loadn) do begin - if hp^.treetype=subscriptn then - inc(offset,hp^.vs^.address) + case hp^.treetype of + vecn : internalerror(9779); + subscriptn : inc(offset,hp^.vs^.address) else Message(cg_e_illegal_expression); + end; hp:=hp^.left; end; datasegment^.concat(new(pai_const_symbol_offset,init( @@ -659,7 +661,11 @@ unit ptconst; end. { $Log$ - Revision 1.32 1998-12-11 16:50:23 florian + Revision 1.33 1998-12-15 17:16:01 peter + * fixed const s : ^string + * first things for const pchar : @string[1] + + Revision 1.32 1998/12/11 16:50:23 florian + typed const int64 and qword + unary minus-operator q1:=-q2; + not-operator diff --git a/compiler/tcmem.pas b/compiler/tcmem.pas index 13d368e016..30d5dcf757 100644 --- a/compiler/tcmem.pas +++ b/compiler/tcmem.pas @@ -349,6 +349,9 @@ implementation var harr : pdef; ct : tconverttype; +{$ifdef consteval} + tcsym : ptypedconstsym; +{$endif} begin firstpass(p^.left); firstpass(p^.right); @@ -368,17 +371,14 @@ implementation { Never convert a boolean or a char !} { maybe type conversion } if (p^.right^.resulttype^.deftype<>enumdef) and - not ((p^.right^.resulttype^.deftype=orddef) and - (Porddef(p^.right^.resulttype)^.typ in [bool8bit,bool16bit,bool32bit,uchar])) then - begin - p^.right:=gentypeconvnode(p^.right,s32bitdef); - { once more firstpass } - {?? It's better to only firstpass when the tree has - changed, isn't it ?} - firstpass(p^.right); - end; - if codegenerror then - exit; + not(is_char(p^.right^.resulttype)) and + not(is_boolean(p^.right^.resulttype)) then + begin + p^.right:=gentypeconvnode(p^.right,s32bitdef); + firstpass(p^.right); + if codegenerror then + exit; + end; { determine return type } if not assigned(p^.resulttype) then @@ -413,6 +413,18 @@ implementation { the register calculation is easy if a const index is used } if p^.right^.treetype=ordconstn then begin +{$ifdef consteval} + { constant evaluation } + if (p^.left^.treetype=loadn) and + (p^.left^.symtableentry^.typ=typedconstsym) then + begin + tcsym:=ptypedconstsym(p^.left^.symtableentry); + if tcsym^.defintion^.typ=stringdef then + begin + + end; + end; +{$endif} p^.registers32:=p^.left^.registers32; { for ansi/wide strings, we need at least one register } @@ -508,7 +520,11 @@ implementation end. { $Log$ - Revision 1.5 1998-12-11 00:03:57 peter + Revision 1.6 1998-12-15 17:16:02 peter + * fixed const s : ^string + * first things for const pchar : @string[1] + + Revision 1.5 1998/12/11 00:03:57 peter + globtype,tokens,version unit splitted from globals Revision 1.4 1998/11/25 19:12:53 pierre