mirror of
https://github.com/byteworksinc/ORCA-C.git
synced 2025-02-01 01:30:47 +00:00
Fix handling of initializer counts in AutoInit.
This was broken by the previous changes to it.
This commit is contained in:
parent
335e8be75e
commit
5df94c953e
18
Parser.pas
18
Parser.pas
@ -4406,7 +4406,6 @@ procedure AutoInit {variable: identPtr; line: longint;
|
|||||||
{ isCompoundLiteral - initializing a compound literal? }
|
{ isCompoundLiteral - initializing a compound literal? }
|
||||||
|
|
||||||
var
|
var
|
||||||
count: integer; {initializer counter}
|
|
||||||
iPtr: initializerPtr; {pointer to the next initializer}
|
iPtr: initializerPtr; {pointer to the next initializer}
|
||||||
codeCount: longint; {number of initializer expressions}
|
codeCount: longint; {number of initializer expressions}
|
||||||
treeCount: integer; {current number of distinct trees}
|
treeCount: integer; {current number of distinct trees}
|
||||||
@ -4422,9 +4421,10 @@ var
|
|||||||
{ count - number of times to re-use the initializer }
|
{ count - number of times to re-use the initializer }
|
||||||
{ iPtr - pointer to the initializer record to use }
|
{ iPtr - pointer to the initializer record to use }
|
||||||
|
|
||||||
label 1,2;
|
label 1,2,3;
|
||||||
|
|
||||||
var
|
var
|
||||||
|
count: integer; {initializer counter}
|
||||||
disp: longint; {displacement to initialize at}
|
disp: longint; {displacement to initialize at}
|
||||||
elements: longint; {# array elements}
|
elements: longint; {# array elements}
|
||||||
itype: typePtr; {the type being initialized}
|
itype: typePtr; {the type being initialized}
|
||||||
@ -4498,9 +4498,10 @@ var
|
|||||||
begin {InitializeOneElement}
|
begin {InitializeOneElement}
|
||||||
itype := iPtr^.iType;
|
itype := iPtr^.iType;
|
||||||
disp := iPtr^.disp;
|
disp := iPtr^.disp;
|
||||||
|
count := iPtr^.count;
|
||||||
while itype^.kind = definedType do
|
while itype^.kind = definedType do
|
||||||
itype := itype^.dType;
|
itype := itype^.dType;
|
||||||
case itype^.kind of
|
3: case itype^.kind of
|
||||||
|
|
||||||
scalarType,pointerType,enumType,functionType: begin
|
scalarType,pointerType,enumType,functionType: begin
|
||||||
tree := iptr^.itree;
|
tree := iptr^.itree;
|
||||||
@ -4606,12 +4607,16 @@ var
|
|||||||
|
|
||||||
otherwise: Error(57);
|
otherwise: Error(57);
|
||||||
end; {case}
|
end; {case}
|
||||||
|
if count <> 1 then begin
|
||||||
|
count := count - 1;
|
||||||
|
disp := disp + itype^.size;
|
||||||
|
goto 3;
|
||||||
|
end; {if}
|
||||||
end; {InitializeOneElement}
|
end; {InitializeOneElement}
|
||||||
|
|
||||||
|
|
||||||
begin {AutoInit}
|
begin {AutoInit}
|
||||||
iPtr := variable^.iPtr;
|
iPtr := variable^.iPtr;
|
||||||
count := iPtr^.count;
|
|
||||||
if isCompoundLiteral then begin
|
if isCompoundLiteral then begin
|
||||||
treeCount := 0;
|
treeCount := 0;
|
||||||
codeCount := 0;
|
codeCount := 0;
|
||||||
@ -4627,12 +4632,7 @@ if variable^.class <> staticsy then begin
|
|||||||
RecordLineNumber(line);
|
RecordLineNumber(line);
|
||||||
while iPtr <> nil do begin
|
while iPtr <> nil do begin
|
||||||
InitializeOneElement;
|
InitializeOneElement;
|
||||||
if count = 1 then begin
|
|
||||||
iPtr := iPtr^.next;
|
iPtr := iPtr^.next;
|
||||||
count := iPtr^.count;
|
|
||||||
end {if}
|
|
||||||
else
|
|
||||||
count := count - 1;
|
|
||||||
end; {while}
|
end; {while}
|
||||||
end; {if}
|
end; {if}
|
||||||
if isCompoundLiteral then begin
|
if isCompoundLiteral then begin
|
||||||
|
Loading…
x
Reference in New Issue
Block a user