From a4b6bb63c093b0947995ae67fa34910cf8151166 Mon Sep 17 00:00:00 2001 From: Laubzega Date: Fri, 21 Sep 2018 21:10:58 -0700 Subject: [PATCH] Minor changes after review. --- src/cc65/function.c | 3 ++- src/cc65/function.h | 2 -- src/cc65/locals.c | 3 +-- src/cc65/stmt.c | 3 ++- src/cc65/symentry.h | 5 ++--- 5 files changed, 7 insertions(+), 9 deletions(-) diff --git a/src/cc65/function.c b/src/cc65/function.c index eb2ad4bcd..96b3d6c75 100644 --- a/src/cc65/function.c +++ b/src/cc65/function.c @@ -60,6 +60,7 @@ /*****************************************************************************/ + /* Pointer to current function */ Function* CurrentFunc = 0; @@ -523,7 +524,7 @@ void NewFunc (SymEntry* Func) /* Need a starting curly brace */ ConsumeLCurly (); - CollAppend (&CurrentFunc->LocalsBlockStack, (void *)CurrentFunc->LocalsBlockCount); + CollAppend (&CurrentFunc->LocalsBlockStack, 0); /* Parse local variable declarations if any */ DeclareLocals (); diff --git a/src/cc65/function.h b/src/cc65/function.h index 1b04009d6..5c5822045 100644 --- a/src/cc65/function.h +++ b/src/cc65/function.h @@ -65,8 +65,6 @@ struct Function { Collection LocalsBlockStack; /* Stack of blocks with local vars */ }; - - /* Structure that holds all data needed for function activation */ typedef struct Function Function; diff --git a/src/cc65/locals.c b/src/cc65/locals.c index a231a6003..20d370c46 100644 --- a/src/cc65/locals.c +++ b/src/cc65/locals.c @@ -538,8 +538,7 @@ void DeclareLocals (void) /* Be sure to allocate any reserved space for locals */ F_AllocLocalSpace (CurrentFunc); - if (InitialStack != StackPtr) - { + if (InitialStack != StackPtr) { ++CurrentFunc->LocalsBlockCount; /* Is it ok to abuse Collection in this way? */ CollAppend (&CurrentFunc->LocalsBlockStack, (void *)CurrentFunc->LocalsBlockCount); diff --git a/src/cc65/stmt.c b/src/cc65/stmt.c index be58e4a7e..b766ec044 100644 --- a/src/cc65/stmt.c +++ b/src/cc65/stmt.c @@ -535,8 +535,9 @@ static int CompoundStatement (void) g_space (StackPtr - OldStack); } - if (OldStack != StackPtr) + if (OldStack != StackPtr) { CollPop (&CurrentFunc->LocalsBlockStack); + } StackPtr = OldStack; diff --git a/src/cc65/symentry.h b/src/cc65/symentry.h index 2c22f99a0..24b647234 100644 --- a/src/cc65/symentry.h +++ b/src/cc65/symentry.h @@ -100,18 +100,17 @@ struct LiteralPool; -/* Symbol table entry */ +/* Label definition or reference */ typedef struct DefOrRef DefOrRef; - struct DefOrRef { unsigned Line; long LocalsBlockNum; unsigned Flags; }; +/* Symbol table entry */ typedef struct SymEntry SymEntry; - struct SymEntry { SymEntry* NextHash; /* Next entry in hash list */ SymEntry* PrevSym; /* Previous symbol in dl list */