From 9fcde120aa1fca60c19f09210adf2557f8888502 Mon Sep 17 00:00:00 2001 From: acqn Date: Tue, 18 Aug 2020 20:43:19 +0800 Subject: [PATCH] Made function signatures in asm output use the parameter lists from original definitions instead of the composites. --- src/cc65/datatype.c | 18 ++++++++++++++++-- src/cc65/datatype.h | 3 +++ src/cc65/funcdesc.c | 1 + src/cc65/funcdesc.h | 1 + src/cc65/function.c | 3 +++ 5 files changed, 24 insertions(+), 2 deletions(-) diff --git a/src/cc65/datatype.c b/src/cc65/datatype.c index b95e37f87..ad008cfd3 100644 --- a/src/cc65/datatype.c +++ b/src/cc65/datatype.c @@ -596,8 +596,8 @@ void PrintFuncSig (FILE* F, const char* Name, Type* T) StrBuf East = AUTO_STRBUF_INITIALIZER; StrBuf West = AUTO_STRBUF_INITIALIZER; - /* Get the function descriptor */ - const FuncDesc* D = GetFuncDesc (T); + /* Get the function descriptor used in definition */ + const FuncDesc* D = GetFuncDefinitionDesc (T); /* Get the parameter list string. Start from the first parameter */ SymEntry* Param = D->SymTab->SymHead; @@ -1137,6 +1137,20 @@ Type* GetFuncReturn (Type* T) +FuncDesc* GetFuncDefinitionDesc (Type* T) +/* Get the function descriptor of the function definition */ +{ + FuncDesc* D; + + /* Be sure it's a function type */ + CHECK (IsClassFunc (T)); + + D = GetFuncDesc (T); + return D->FuncDef != 0 ? D->FuncDef : D; +} + + + long GetElementCount (const Type* T) /* Get the element count of the array specified in T (which must be of ** array type). diff --git a/src/cc65/datatype.h b/src/cc65/datatype.h index 472098788..8e9ee4c33 100644 --- a/src/cc65/datatype.h +++ b/src/cc65/datatype.h @@ -836,6 +836,9 @@ void SetFuncDesc (Type* T, FuncDesc* F); Type* GetFuncReturn (Type* T) attribute ((const)); /* Return a pointer to the return type of a function or pointer-to-function type */ +FuncDesc* GetFuncDefinitionDesc (struct Type* T); +/* Get the function descriptor of the function definition */ + long GetElementCount (const Type* T); /* Get the element count of the array specified in T (which must be of ** array type). diff --git a/src/cc65/funcdesc.c b/src/cc65/funcdesc.c index 273263dec..4c959fb6c 100644 --- a/src/cc65/funcdesc.c +++ b/src/cc65/funcdesc.c @@ -60,6 +60,7 @@ FuncDesc* NewFuncDesc (void) F->ParamCount = 0; F->ParamSize = 0; F->LastParam = 0; + F->FuncDef = 0; F->WrappedCall = 0; F->WrappedCallData = 0; diff --git a/src/cc65/funcdesc.h b/src/cc65/funcdesc.h index a04ffb14a..1cfb2bd09 100644 --- a/src/cc65/funcdesc.h +++ b/src/cc65/funcdesc.h @@ -68,6 +68,7 @@ struct FuncDesc { unsigned ParamCount; /* Number of parameters */ unsigned ParamSize; /* Size of the parameters */ struct SymEntry* LastParam; /* Pointer to last parameter */ + struct FuncDesc* FuncDef; /* Descriptor used in definition */ struct SymEntry* WrappedCall; /* Pointer to the WrappedCall */ unsigned char WrappedCallData;/* The WrappedCall's user data */ }; diff --git a/src/cc65/function.c b/src/cc65/function.c index fc113b29a..290916cd2 100644 --- a/src/cc65/function.c +++ b/src/cc65/function.c @@ -382,6 +382,9 @@ void NewFunc (SymEntry* Func, FuncDesc* D) SymEntry* Param; const Type* RType; /* Real type used for struct parameters */ + /* Remember this function descriptor used for definition */ + GetFuncDesc (Func->Type)->FuncDef = D; + /* Allocate the function activation record for the function */ CurrentFunc = NewFunction (Func, D);