From 085e04798eefe8590ad22ec34ef2bb43c24ef258 Mon Sep 17 00:00:00 2001 From: arookas <arookas@outlook.com> Date: Mon, 1 Feb 2016 19:18:19 -0500 Subject: [PATCH] Added symbol table cleaning functions --- ssc/compiler.cs | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/ssc/compiler.cs b/ssc/compiler.cs index c4e45cc..d1dc722 100644 --- a/ssc/compiler.cs +++ b/ssc/compiler.cs @@ -46,6 +46,9 @@ namespace arookas { using (mBinary = new sunBinary(output)) { CompileBody(name); CompileFunctions(); +#if SSC_CLEAN_SYMBOLS + CleanSymbols(); +#endif CompileRelocations(); CompileData(); CompileSymbols(); @@ -82,6 +85,25 @@ namespace arookas { } return count; } +#if SSC_CLEAN_SYMBOLS + void CleanSymbols() { + var i = 0; + while (i < mContext.SymbolTable.Count) { + if (mContext.SymbolTable[i] is sunCallableSymbol && !mContext.SymbolTable[i].HasRelocations) { + mContext.SymbolTable.RemoveAt(i); + continue; + } + ++i; + } + for (i = 0; i < mContext.SymbolTable.Count; ++i) { + var builtin = mContext.SymbolTable[i] as sunBuiltinSymbol; + if (builtin == null) { + continue; + } + builtin.Index = i; + } + } +#endif void CompileRelocations() { foreach (var symbol in mContext.SymbolTable) { symbol.CloseRelocations(this);