mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-08-16 17:19:19 +02:00
* fixed const s : ^string
* first things for const pchar : @string[1]
This commit is contained in:
parent
4fbc61f5ea
commit
c7230805a2
@ -190,11 +190,10 @@ unit pdecl;
|
|||||||
end;
|
end;
|
||||||
COLON:
|
COLON:
|
||||||
begin
|
begin
|
||||||
consume(COLON);
|
{ set the blocktype first so a consume also supports a
|
||||||
{ this was missed, so const s : ^string = nil gives an
|
caret, to support const s : ^string = nil }
|
||||||
error (FK)
|
|
||||||
}
|
|
||||||
block_type:=bt_type;
|
block_type:=bt_type;
|
||||||
|
consume(COLON);
|
||||||
ignore_equal:=true;
|
ignore_equal:=true;
|
||||||
def:=read_type('');
|
def:=read_type('');
|
||||||
ignore_equal:=false;
|
ignore_equal:=false;
|
||||||
@ -2124,7 +2123,11 @@ unit pdecl;
|
|||||||
end.
|
end.
|
||||||
{
|
{
|
||||||
$Log$
|
$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
|
+ globtype,tokens,version unit splitted from globals
|
||||||
|
|
||||||
Revision 1.88 1998/11/30 09:43:20 pierre
|
Revision 1.88 1998/11/30 09:43:20 pierre
|
||||||
|
@ -214,22 +214,24 @@ unit ptconst;
|
|||||||
if p^.treetype=addrn then
|
if p^.treetype=addrn then
|
||||||
begin
|
begin
|
||||||
hp:=p^.left;
|
hp:=p^.left;
|
||||||
while assigned(hp) and (hp^.treetype=subscriptn) do
|
while assigned(hp) and (hp^.treetype in [subscriptn,vecn]) do
|
||||||
hp:=hp^.left;
|
hp:=hp^.left;
|
||||||
if (is_equal(ppointerdef(p^.resulttype)^.definition,ppointerdef(def)^.definition) or
|
if (is_equal(ppointerdef(p^.resulttype)^.definition,ppointerdef(def)^.definition) or
|
||||||
(is_equal(ppointerdef(p^.resulttype)^.definition,voiddef)) or
|
(is_equal(ppointerdef(p^.resulttype)^.definition,voiddef)) or
|
||||||
(is_equal(ppointerdef(def)^.definition,voiddef))) and
|
(is_equal(ppointerdef(def)^.definition,voiddef))) and
|
||||||
(hp^.treetype = loadn) then
|
(hp^.treetype=loadn) then
|
||||||
begin
|
begin
|
||||||
firstpass(p^.left);
|
firstpass(p^.left);
|
||||||
hp:=p^.left;
|
hp:=p^.left;
|
||||||
offset:=0;
|
offset:=0;
|
||||||
while assigned(hp) and (hp^.treetype<>loadn) do
|
while assigned(hp) and (hp^.treetype<>loadn) do
|
||||||
begin
|
begin
|
||||||
if hp^.treetype=subscriptn then
|
case hp^.treetype of
|
||||||
inc(offset,hp^.vs^.address)
|
vecn : internalerror(9779);
|
||||||
|
subscriptn : inc(offset,hp^.vs^.address)
|
||||||
else
|
else
|
||||||
Message(cg_e_illegal_expression);
|
Message(cg_e_illegal_expression);
|
||||||
|
end;
|
||||||
hp:=hp^.left;
|
hp:=hp^.left;
|
||||||
end;
|
end;
|
||||||
datasegment^.concat(new(pai_const_symbol_offset,init(
|
datasegment^.concat(new(pai_const_symbol_offset,init(
|
||||||
@ -659,7 +661,11 @@ unit ptconst;
|
|||||||
end.
|
end.
|
||||||
{
|
{
|
||||||
$Log$
|
$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
|
+ typed const int64 and qword
|
||||||
+ unary minus-operator q1:=-q2;
|
+ unary minus-operator q1:=-q2;
|
||||||
+ not-operator
|
+ not-operator
|
||||||
|
@ -349,6 +349,9 @@ implementation
|
|||||||
var
|
var
|
||||||
harr : pdef;
|
harr : pdef;
|
||||||
ct : tconverttype;
|
ct : tconverttype;
|
||||||
|
{$ifdef consteval}
|
||||||
|
tcsym : ptypedconstsym;
|
||||||
|
{$endif}
|
||||||
begin
|
begin
|
||||||
firstpass(p^.left);
|
firstpass(p^.left);
|
||||||
firstpass(p^.right);
|
firstpass(p^.right);
|
||||||
@ -368,17 +371,14 @@ implementation
|
|||||||
{ Never convert a boolean or a char !}
|
{ Never convert a boolean or a char !}
|
||||||
{ maybe type conversion }
|
{ maybe type conversion }
|
||||||
if (p^.right^.resulttype^.deftype<>enumdef) and
|
if (p^.right^.resulttype^.deftype<>enumdef) and
|
||||||
not ((p^.right^.resulttype^.deftype=orddef) and
|
not(is_char(p^.right^.resulttype)) and
|
||||||
(Porddef(p^.right^.resulttype)^.typ in [bool8bit,bool16bit,bool32bit,uchar])) then
|
not(is_boolean(p^.right^.resulttype)) then
|
||||||
begin
|
begin
|
||||||
p^.right:=gentypeconvnode(p^.right,s32bitdef);
|
p^.right:=gentypeconvnode(p^.right,s32bitdef);
|
||||||
{ once more firstpass }
|
firstpass(p^.right);
|
||||||
{?? It's better to only firstpass when the tree has
|
if codegenerror then
|
||||||
changed, isn't it ?}
|
exit;
|
||||||
firstpass(p^.right);
|
end;
|
||||||
end;
|
|
||||||
if codegenerror then
|
|
||||||
exit;
|
|
||||||
|
|
||||||
{ determine return type }
|
{ determine return type }
|
||||||
if not assigned(p^.resulttype) then
|
if not assigned(p^.resulttype) then
|
||||||
@ -413,6 +413,18 @@ implementation
|
|||||||
{ the register calculation is easy if a const index is used }
|
{ the register calculation is easy if a const index is used }
|
||||||
if p^.right^.treetype=ordconstn then
|
if p^.right^.treetype=ordconstn then
|
||||||
begin
|
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;
|
p^.registers32:=p^.left^.registers32;
|
||||||
|
|
||||||
{ for ansi/wide strings, we need at least one register }
|
{ for ansi/wide strings, we need at least one register }
|
||||||
@ -508,7 +520,11 @@ implementation
|
|||||||
end.
|
end.
|
||||||
{
|
{
|
||||||
$Log$
|
$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
|
+ globtype,tokens,version unit splitted from globals
|
||||||
|
|
||||||
Revision 1.4 1998/11/25 19:12:53 pierre
|
Revision 1.4 1998/11/25 19:12:53 pierre
|
||||||
|
Loading…
Reference in New Issue
Block a user