From 58849607a1fd34dd4db2f73053c3334a5b60449e Mon Sep 17 00:00:00 2001 From: Stephen Heumann Date: Sat, 18 Jun 2022 19:30:20 -0500 Subject: [PATCH] Use cgPointerSize for size of pointers in various places. This makes no practical difference when targeting the GS, but it better documents what the relevant size is. --- Expression.pas | 19 +++++++++++-------- Parser.pas | 2 +- Symbol.pas | 6 +++--- 3 files changed, 15 insertions(+), 12 deletions(-) diff --git a/Expression.pas b/Expression.pas index 10f9a0e..c735638 100644 --- a/Expression.pas +++ b/Expression.pas @@ -1917,7 +1917,7 @@ var codeGeneration := lCodeGeneration and (numErrors = 0); {get controlling type after conversions} if expressionType^.kind = functionType then begin - controllingType.size := cgLongSize; + controllingType.size := cgPointerSize; controllingType.saveDisp := 0; controllingType.qualifiers := []; controllingType.kind := pointerType; @@ -1932,8 +1932,11 @@ var end {else if} else controllingType := expressionType^; - if controllingType.kind = arrayType then + if controllingType.kind = arrayType then begin controllingType.kind := pointerType; + controllingType.size := cgPointerSize; + controllingType.saveDisp := 0; + end; {if} controllingType.qualifiers := []; typesSeen := nil; @@ -2868,7 +2871,7 @@ var otherwise: ; end; {case} eType := pointer(Malloc(sizeof(typeRecord))); - eType^.size := cgLongSize; + eType^.size := cgPointerSize; eType^.saveDisp := 0; eType^.qualifiers := []; eType^.kind := pointerType; @@ -2912,7 +2915,7 @@ var Gen0(pc_adl); end; {else} eType := pointer(Malloc(sizeof(typeRecord))); - eType^.size := cgLongSize; + eType^.size := cgPointerSize; eType^.saveDisp := 0; eType^.qualifiers := []; eType^.kind := pointerType; @@ -2929,7 +2932,7 @@ var expressionType := tree^.castType; if expressionType^.kind <> arrayType then begin eType := pointer(Malloc(sizeof(typeRecord))); - eType^.size := cgLongSize; + eType^.size := cgPointerSize; eType^.saveDisp := 0; eType^.qualifiers := []; eType^.kind := pointerType; @@ -4232,7 +4235,7 @@ case tree^.token.kind of ChangePointer(pc_adl, lType^.size, et); if expressionType^.kind = arrayType then begin tType := pointer(Malloc(sizeof(typeRecord))); - tType^.size := cgLongSize; + tType^.size := cgPointerSize; tType^.saveDisp := 0; tType^.qualifiers := []; tType^.kind := pointerType; @@ -4288,7 +4291,7 @@ case tree^.token.kind of expressionType := lType; if expressionType^.kind = arrayType then begin tType := pointer(Malloc(sizeof(typeRecord))); - tType^.size := cgLongSize; + tType^.size := cgPointerSize; tType^.saveDisp := 0; tType^.qualifiers := []; tType^.kind := pointerType; @@ -4515,7 +4518,7 @@ case tree^.token.kind of {build pointer-to-array type for address of string constant} tType := pointer(Malloc(sizeof(typeRecord))); with tType^ do begin - size := cgLongSize; + size := cgPointerSize; saveDisp := 0; qualifiers := []; kind := pointerType; diff --git a/Parser.pas b/Parser.pas index 9c84b1a..901b75b 100644 --- a/Parser.pas +++ b/Parser.pas @@ -4136,7 +4136,7 @@ var {create a pointer type} NextToken; tp := pointer(Malloc(sizeof(typeRecord))); - tp^.size := cgLongSize; + tp^.size := cgPointerSize; tp^.saveDisp := 0; tp^.qualifiers := []; tp^.kind := pointerType; diff --git a/Symbol.pas b/Symbol.pas index 273e36c..e2a90b9 100644 --- a/Symbol.pas +++ b/Symbol.pas @@ -581,7 +581,7 @@ case kind1 of if tp1.kind = arrayType then tp1.kind := pointerType else if tp1.kind = functionType then begin - tp1.size := cgLongSize; + tp1.size := cgPointerSize; tp1.qualifiers := []; tp1.saveDisp := 0; tp1.kind := pointerType; @@ -590,7 +590,7 @@ case kind1 of if tp2.kind = arrayType then tp2.kind := pointerType else if tp2.kind = functionType then begin - tp2.size := cgLongSize; + tp2.size := cgPointerSize; tp2.qualifiers := []; tp2.saveDisp := 0; tp2.kind := pointerType; @@ -1644,7 +1644,7 @@ with voidPtr^ do begin end; {with} new(voidPtrPtr); {typeless pointer} with voidPtrPtr^ do begin - size := 4; + size := cgPointerSize; saveDisp := 0; qualifiers := []; kind := pointerType;