From b540d5ef1ba3d128d454bb5d059464334ff2844c Mon Sep 17 00:00:00 2001 From: Curle Date: Wed, 25 Nov 2020 02:11:09 +0000 Subject: [PATCH] Cleanup data, prepare for local vars --- include/Data.h | 6 ++++-- include/Defs.h | 11 +++++++++++ src/Main.c | 1 - 3 files changed, 15 insertions(+), 3 deletions(-) diff --git a/include/Data.h b/include/Data.h index 9ccbef3..654c869 100644 --- a/include/Data.h +++ b/include/Data.h @@ -19,7 +19,6 @@ extern_ struct SymbolTable Symbols[SYMBOLS]; extern_ int TypeSizes[9]; extern_ char* TypeNames[9]; -extern_ char* TokenStrings[]; extern_ char* TokenNames[]; extern_ int CurrentFunction; @@ -30,4 +29,7 @@ extern_ FILE* SourceFile; extern_ FILE* OutputFile; extern_ struct Token CurrentToken; -extern_ char CurrentIdentifier[TEXTLEN + 1]; \ No newline at end of file +extern_ char CurrentIdentifier[TEXTLEN + 1]; + +extern_ int CurrentGlobal; +extern_ int CurrentLocal; \ No newline at end of file diff --git a/include/Defs.h b/include/Defs.h index 122a387..e2c2ee4 100644 --- a/include/Defs.h +++ b/include/Defs.h @@ -196,6 +196,17 @@ struct SymbolTable { int Structure; // An entry in StructureType - metadata on how to process the data int EndLabel; // The number of the label to jump to, in order to exit this function (if applicable) int Length; // The length of the symbol in units of 1 element -- the size of an array, for example. + int Storage; // The scope of this symbol - decides when it is discarded. + int SinkOffset; // How many times must we sink the rbp to get to this symbol in the stack? +}; + +enum StorageScope { + SC_GLOBAL = 1, // Global Scope + //SC_CLASS, // Class-local definitions + //SC_STATIC, // Static storage definitions + //SC_PARAM, // Function parameters + SC_LOCAL // Function-local scope. + // There is no deeper scope than function. }; diff --git a/src/Main.c b/src/Main.c index 87c14fb..11701a2 100644 --- a/src/Main.c +++ b/src/Main.c @@ -12,7 +12,6 @@ int TypeSizes[9] = { 0, 1, 4, 8, 0, 8, 8, 8, 8}; // in BYTES -char* TokenStrings[] = { "+", "-", "*", "/", "int" }; char* TokenNames[] = { "End of file", "Equivalency",