* fixed object field parsing

This commit is contained in:
peter 1999-10-01 07:59:20 +00:00
parent 03ffad8965
commit e838769af8
2 changed files with 96 additions and 60 deletions

View File

@ -1344,8 +1344,32 @@ Begin
{ probably a variable or normal expression } { probably a variable or normal expression }
{ or a procedure (such as in CALL ID) } { or a procedure (such as in CALL ID) }
Begin Begin
{ is it a constant ? }
if SearchIConstant(actasmpattern,l) then
Begin
if not (opr.typ in [OPR_NONE,OPR_CONSTANT]) then
Message(asmr_e_invalid_operand_type);
BuildConstant;
end
else
begin
InitRef; InitRef;
if not SetupVar(actasmpattern) then if SetupVar(actasmpattern) then
begin
expr:=actasmpattern;
Consume(AS_ID);
MaybeRecordOffset;
{ add a constant expression? }
if (actasmtoken=AS_PLUS) then
begin
l:=BuildConstExpression(true,false);
if opr.typ=OPR_CONSTANT then
inc(opr.val,l)
else
inc(opr.ref.offset,l);
end
end
else
Begin Begin
{ look for special symbols ... } { look for special symbols ... }
if actasmpattern = '__RESULT' then if actasmpattern = '__RESULT' then
@ -1370,33 +1394,23 @@ Begin
end end
else else
Message1(sym_e_unknown_id,actasmpattern); Message1(sym_e_unknown_id,actasmpattern);
end;
{ constant expression? }
if (opr.typ=OPR_CONSTANT) then
begin
l:=BuildConstExpression(true,false);
{ indexing? }
if actasmtoken=AS_LPAREN then
begin
opr.typ:=OPR_REFERENCE;
reset_reference(opr.Ref);
opr.Ref.Offset:=l;
BuildReference;
end
else
opr.Val:=l;
end
else
begin
expr:=actasmpattern;
Consume(AS_ID); Consume(AS_ID);
MaybeRecordOffset; end;
end; end;
end; end;
{ Do we have a indexing reference, then parse it also } { Do we have a indexing reference, then parse it also }
if actasmtoken=AS_LPAREN then if actasmtoken=AS_LPAREN then
begin
if (opr.typ=OPR_CONSTANT) then
begin
l:=opr.val;
opr.typ:=OPR_REFERENCE;
reset_reference(opr.Ref);
opr.Ref.Offset:=l;
end;
BuildReference; BuildReference;
end; end;
end;
AS_REGISTER: { Register, a variable reference or a constant reference } AS_REGISTER: { Register, a variable reference or a constant reference }
Begin Begin
@ -1973,7 +1987,10 @@ begin
end. end.
{ {
$Log$ $Log$
Revision 1.59 1999-09-27 23:44:57 peter Revision 1.60 1999-10-01 07:59:20 peter
* fixed object field parsing
Revision 1.59 1999/09/27 23:44:57 peter
* procinfo is now a pointer * procinfo is now a pointer
* support for result setting in sub procedure * support for result setting in sub procedure

View File

@ -1331,30 +1331,46 @@ Begin
{ is it a normal variable ? } { is it a normal variable ? }
Begin Begin
InitRef; InitRef;
if not SetupVar(actasmpattern) then if SetupVar(actasmpattern) then
begin
expr:=actasmpattern;
Consume(AS_ID);
MaybeRecordOffset;
{ add a constant expression? }
if (actasmtoken=AS_PLUS) then
begin
l:=BuildConstExpression;
if opr.typ=OPR_CONSTANT then
inc(opr.val,l)
else
inc(opr.ref.offset,l);
end
end
else
Begin Begin
{ not a variable, check special variables.. } { not a variable, check special variables.. }
if actasmpattern = 'SELF' then if actasmpattern = 'SELF' then
SetupSelf SetupSelf
else else
Message1(sym_e_unknown_id,actasmpattern); Message1(sym_e_unknown_id,actasmpattern);
end;
expr:=actasmpattern;
Consume(AS_ID); Consume(AS_ID);
MaybeRecordOffset; end;
end;
{ handle references }
if actasmtoken=AS_LBRACKET then if actasmtoken=AS_LBRACKET then
begin begin
if opr.typ<>OPR_REFERENCE then if opr.typ=OPR_CONSTANT then
begin begin
l:=opr.val;
opr.typ:=OPR_REFERENCE; opr.typ:=OPR_REFERENCE;
reset_reference(opr.Ref); reset_reference(opr.Ref);
opr.Ref.Offset:=l;
end; end;
BuildReference; BuildReference;
MaybeRecordOffset; MaybeRecordOffset;
end; end;
end; end;
end; end;
end;
AS_REGISTER : { Register, a variable reference or a constant reference } AS_REGISTER : { Register, a variable reference or a constant reference }
Begin Begin
@ -1751,7 +1767,10 @@ begin
end. end.
{ {
$Log$ $Log$
Revision 1.49 1999-09-27 23:44:58 peter Revision 1.50 1999-10-01 07:59:21 peter
* fixed object field parsing
Revision 1.49 1999/09/27 23:44:58 peter
* procinfo is now a pointer * procinfo is now a pointer
* support for result setting in sub procedure * support for result setting in sub procedure