From 116aa7996fced20dbb7abe455d57b38fdea86553 Mon Sep 17 00:00:00 2001 From: arookas Date: Mon, 1 Feb 2016 19:15:21 -0500 Subject: [PATCH] Removed local stack from context Now the mangle function requires the local identifier being passed directly. --- ssc/compiler.cs | 2 -- ssc/context.cs | 17 ++--------------- 2 files changed, 2 insertions(+), 17 deletions(-) diff --git a/ssc/compiler.cs b/ssc/compiler.cs index 3712623..c4e45cc 100644 --- a/ssc/compiler.cs +++ b/ssc/compiler.cs @@ -107,9 +107,7 @@ namespace arookas { if (result == sunImportResult.Loaded) { try { mResolver.EnterFile(file); - mContext.PushLocal(); mParser.Parse(file).Compile(this); - mContext.PopLocal(); mResolver.ExitFile(file); } finally { diff --git a/ssc/context.cs b/ssc/context.cs index 1d42095..01eb29b 100644 --- a/ssc/context.cs +++ b/ssc/context.cs @@ -8,8 +8,6 @@ using System.Text; namespace arookas { class sunContext { Stack mNameStack; - Stack mLocalStack; - long mLocal; public sunDataTable DataTable { get; private set; } public sunSymbolTable SymbolTable { get; private set; } @@ -31,7 +29,6 @@ namespace arookas { Scopes = new sunScopeStack(); Loops = new sunLoopStack(); mNameStack = new Stack(10); - mLocalStack = new Stack(10); AddSystemSymbols(); } @@ -41,8 +38,6 @@ namespace arookas { Scopes.Clear(); Loops.Clear(); mNameStack.Clear(); - mLocalStack.Clear(); - mLocal = 0; // reinstall system symbols AddSystemSymbols(); @@ -184,14 +179,6 @@ namespace arookas { return null; } - // locals - public void PushLocal() { - mLocalStack.Push(mLocal++); - } - public void PopLocal() { - mLocalStack.Pop(); - } - // system symbols void AddSystemSymbols() { // add system builtins @@ -215,7 +202,7 @@ namespace arookas { } // static util - string MangleSymbolName(string basename, bool system, bool local) { + static string MangleSymbolName(string basename, ulong id, bool system, bool local) { if (!system && !local) { return basename; } @@ -225,7 +212,7 @@ namespace arookas { } sb.Append(basename); if (local) { - sb.AppendFormat("@{0}", mLocalStack.Peek()); + sb.AppendFormat("@{0}", id); } return sb.ToString(); }