1
0
mirror of https://github.com/cc65/cc65.git synced 2024-06-26 05:29:30 +00:00

Fix minor function handling stuff

git-svn-id: svn://svn.cc65.org/cc65/trunk@53 b7a2c559-68d2-44c3-8de9-860c34a00d81
This commit is contained in:
cuz 2000-06-10 16:33:25 +00:00
parent e932798ead
commit 4219ffcb6a

View File

@ -60,8 +60,8 @@ struct Function {
type* ReturnType; /* Function return type */ type* ReturnType; /* Function return type */
struct FuncDesc* Desc; /* Function descriptor */ struct FuncDesc* Desc; /* Function descriptor */
CodeMark EntryCode; /* Backpatch addr for entry code */ CodeMark EntryCode; /* Backpatch addr for entry code */
unsigned LocalMax; /* Total space for locals */ int LocalMax; /* Total space for locals */
unsigned LocalSize; /* Current space for locals */ int LocalSize; /* Current space for locals */
unsigned RetLab; /* Return code label */ unsigned RetLab; /* Return code label */
}; };
@ -156,17 +156,14 @@ unsigned GetRetLab (const Function* F)
int AllocLocalSpace (Function* F, unsigned Size) int AllocLocalSpace (Function* F, unsigned Size)
/* Allocate space for the function locals, return stack offset */ /* Allocate space for the function locals, return stack offset */
{ {
/* Remember the current offset */
unsigned Offs = F->LocalSize;
/* Add the size */ /* Add the size */
F->LocalSize += Size; F->LocalSize += Size;
if (F->LocalSize > F->LocalMax) { if (F->LocalSize > F->LocalMax) {
F->LocalMax = F->LocalSize; F->LocalMax = F->LocalSize;
} }
/* Return the offset, it is below the initial stack pointer */ /* Return the offset, it is below the initial stack pointer */
return -(int)Offs; return -F->LocalSize;;
} }
@ -230,10 +227,12 @@ void NewFunc (SymEntry* Func)
/* Generate function entry code if needed */ /* Generate function entry code if needed */
g_enter (TypeOf (Func->Type), GetParamSize (CurrentFunc)); g_enter (TypeOf (Func->Type), GetParamSize (CurrentFunc));
/* Remember the current code position to create local variable space once /* Remember the current code position. This may be used later to create
* we have created the function body itself. * local variable space once we have created the function body itself.
* Currently this is not possible because the stack offsets of all locals
* have to be known in advance.
*/ */
RememberEntry (Func); RememberEntry (CurrentFunc);
/* Parse the function body */ /* Parse the function body */
oursp = 0; oursp = 0;
@ -267,3 +266,4 @@ void NewFunc (SymEntry* Func)