From 75be2d41c1a7bfb37941d8f0f2ba18d14c86dfe2 Mon Sep 17 00:00:00 2001
From: arookas <arookas@outlook.com>
Date: Mon, 28 Dec 2015 20:16:12 -0500
Subject: [PATCH] Added a name-label stack.

Not like it really needs to be a stack, but just in case.
---
 ssc/context.cs | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)

diff --git a/ssc/context.cs b/ssc/context.cs
index 2a9ca76..5f5a288 100644
--- a/ssc/context.cs
+++ b/ssc/context.cs
@@ -1,5 +1,6 @@
 using arookas.IO.Binary;
 using System;
+using System.Collections.Generic;
 using System.IO;
 using System.Linq;
 using System.Text;
@@ -9,6 +10,7 @@ namespace arookas {
 		bool mOpen;
 		aBinaryWriter mWriter;
 		uint mTextOffset, mDataOffset, mSymbolOffset;
+		Stack<sunNameLabel> mNameStack;
 
 		public sunWriter Text { get; private set; }
 		public sunDataTable DataTable { get; private set; }
@@ -22,6 +24,7 @@ namespace arookas {
 			SymbolTable = new sunSymbolTable();
 			Scopes = new sunScopeStack();
 			Loops = new sunLoopStack();
+			mNameStack = new Stack<sunNameLabel>(5);
 		}
 
 		// open/close
@@ -41,6 +44,7 @@ namespace arookas {
 			SymbolTable.Clear();
 			Scopes.Clear();
 			Loops.Clear();
+			mNameStack.Clear();
 			ImportResolver = importResolver;
 			mWriter = new aBinaryWriter(output, Endianness.Big, Encoding.GetEncoding(932));
 			Text = new sunWriter(mWriter);
@@ -215,6 +219,19 @@ namespace arookas {
 			return symbol;
 		}
 
+		public void PushNameLabel(sunNameLabel label) {
+			if (label == null) {
+				throw new ArgumentNullException("label");
+			}
+			mNameStack.Push(label);
+		}
+		public sunNameLabel PopNameLabel() {
+			if (mNameStack.Count > 0) {
+				return mNameStack.Pop();
+			}
+			return null;
+		}
+
 		void WriteHeader() {
 			mWriter.WriteString("SPCB");
 			mWriter.Write32(mTextOffset);