mirror of
https://github.com/byteworksinc/ORCA-C.git
synced 2025-01-18 03:29:49 +00:00
Apply return optimization to enum and pointer return types.
This commit is contained in:
parent
d68e0b268f
commit
030f3ff9e1
36
Parser.pas
36
Parser.pas
@ -831,6 +831,26 @@ var
|
|||||||
size: longint; {size of the struct/union}
|
size: longint; {size of the struct/union}
|
||||||
tk: tokenType; {structure name token}
|
tk: tokenType; {structure name token}
|
||||||
|
|
||||||
|
|
||||||
|
procedure ReturnValue (tp: baseTypeEnum);
|
||||||
|
|
||||||
|
{ generate code to return a value of specified type }
|
||||||
|
|
||||||
|
begin {ReturnValue}
|
||||||
|
if (returnCount = 0)
|
||||||
|
and (token.kind = rbracech)
|
||||||
|
and (statementList^.next = nil)
|
||||||
|
and (vaInfoLLN = 0)
|
||||||
|
and (tp in [cgByte,cgUByte,cgWord,cgUWord,cgLong,cgULong])
|
||||||
|
then begin
|
||||||
|
Gen0t(pc_rev, tp);
|
||||||
|
skipReturn := true;
|
||||||
|
end {if}
|
||||||
|
else
|
||||||
|
Gen2t(pc_str, 0, 0, tp);
|
||||||
|
end; {ReturnValue}
|
||||||
|
|
||||||
|
|
||||||
begin {ReturnStatement}
|
begin {ReturnStatement}
|
||||||
if fIsNoreturn then
|
if fIsNoreturn then
|
||||||
if (lint & lintReturn) <> 0 then
|
if (lint & lintReturn) <> 0 then
|
||||||
@ -857,20 +877,10 @@ var
|
|||||||
case fType^.kind of
|
case fType^.kind of
|
||||||
scalarType: if fType^.baseType in [cgQuad,cgUQuad] then
|
scalarType: if fType^.baseType in [cgQuad,cgUQuad] then
|
||||||
Gen0t(pc_sto, fType^.baseType)
|
Gen0t(pc_sto, fType^.baseType)
|
||||||
else if (returnCount = 0)
|
|
||||||
and (token.kind = rbracech)
|
|
||||||
and (statementList^.next = nil)
|
|
||||||
and (vaInfoLLN = 0)
|
|
||||||
and (fType^.baseType in
|
|
||||||
[cgByte,cgUByte,cgWord,cgUWord,cgLong,cgULong])
|
|
||||||
then begin
|
|
||||||
Gen0t(pc_rev, fType^.baseType);
|
|
||||||
skipReturn := true;
|
|
||||||
end {else if}
|
|
||||||
else
|
else
|
||||||
Gen2t(pc_str, 0, 0, fType^.baseType);
|
ReturnValue(fType^.baseType);
|
||||||
enumType: Gen2t(pc_str, 0, 0, cgWord);
|
enumType: ReturnValue(cgWord);
|
||||||
pointerType: Gen2t(pc_str, 0, 0, cgULong);
|
pointerType: ReturnValue(cgULong);
|
||||||
structType,
|
structType,
|
||||||
unionType: begin
|
unionType: begin
|
||||||
Gen2(pc_mov, long(size).msw, long(size).lsw);
|
Gen2(pc_mov, long(size).msw, long(size).lsw);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user