mirror of
https://github.com/byteworksinc/ORCA-C.git
synced 2025-01-01 13:29:32 +00:00
Simplify code generation for function parameters.
The old approach would call GenerateCode twice for each parameter expression. Now, it is only called once. This is faster, and also avoids some oddities with error handling. With the previous approach, expressionType would not be set if there was an error in the expression, which could lead to additional spurious errors. Also, a lint message treated as a warning could appear twice.
This commit is contained in:
parent
ea623d38fc
commit
a985a9ca7a
@ -3346,9 +3346,7 @@ var
|
||||
{ fType - function type }
|
||||
|
||||
var
|
||||
kind: typeKind; {for expression kinds}
|
||||
ldoDispose: boolean; {local copy of doDispose}
|
||||
lnumErrors: integer; {number of errors before type check}
|
||||
numParms: integer; {# of parameters generated}
|
||||
parameters: parameterPtr; {next prototyped parameter}
|
||||
pCount: integer; {# of parameters prototyped}
|
||||
@ -3430,25 +3428,20 @@ var
|
||||
doDispose := false;
|
||||
while tp <> nil do begin
|
||||
if tp^.middle <> nil then begin
|
||||
lnumErrors := numErrors;
|
||||
kind := ExpressionKind(tp^.middle);
|
||||
if numErrors = lnumErrors then
|
||||
if kind in [structType,unionType] then begin
|
||||
GenerateCode(tp^.middle);
|
||||
if expressionType^.size & $FFFF8000 <> 0 then
|
||||
Error(61);
|
||||
Gen1t(pc_ldc, long(expressionType^.size).lsw, cgWord);
|
||||
Gen0(pc_psh);
|
||||
end {else if}
|
||||
else
|
||||
GenerateCode(tp^.middle);
|
||||
GenerateCode(tp^.middle);
|
||||
if expressionType^.kind in [structType,unionType] then begin
|
||||
if expressionType^.size & $FFFF8000 <> 0 then
|
||||
Error(61);
|
||||
Gen1t(pc_ldc, long(expressionType^.size).lsw, cgWord);
|
||||
Gen0(pc_psh);
|
||||
end; {if}
|
||||
if fmt <> fmt_none then begin
|
||||
new(tfp);
|
||||
tfp^.next := fp;
|
||||
tfp^.tk := tp^.middle;
|
||||
tfp^.ty := expressionType;
|
||||
fp := tfp;
|
||||
end;
|
||||
new(tfp);
|
||||
tfp^.next := fp;
|
||||
tfp^.tk := tp^.middle;
|
||||
tfp^.ty := expressionType;
|
||||
fp := tfp;
|
||||
end; {if}
|
||||
if prototype then begin
|
||||
if pCount = 0 then begin
|
||||
if parameters <> nil then begin
|
||||
|
Loading…
Reference in New Issue
Block a user