From 07646b11b3480bd48a7e924093b1cfb6b1d0835d Mon Sep 17 00:00:00 2001 From: arookas Date: Mon, 1 Feb 2016 11:45:52 -0500 Subject: [PATCH] Minor cleanup --- ssc/data.cs | 28 ++++++++++++++++++++-------- ssc/symbol.cs | 38 ++++++++++++++++++++++++-------------- 2 files changed, 44 insertions(+), 22 deletions(-) diff --git a/ssc/data.cs b/ssc/data.cs index d2d91b0..105c1cf 100644 --- a/ssc/data.cs +++ b/ssc/data.cs @@ -3,21 +3,33 @@ using System.Collections.Generic; namespace arookas { class sunDataTable : IEnumerable { - List data = new List(10); + List mData; - public int Count { get { return data.Count; } } + public int Count { + get { return mData.Count; } + } + + public sunDataTable() { + mData = new List(10); + } public int Add(string value) { - int index = data.IndexOf(value); + var index = mData.IndexOf(value); if (index < 0) { - index = data.Count; - data.Add(value); + index = mData.Count; + mData.Add(value); } return index; } - public void Clear() { data.Clear(); } + public void Clear() { + mData.Clear(); + } - public IEnumerator GetEnumerator() { return data.GetEnumerator(); } - IEnumerator IEnumerable.GetEnumerator() { return GetEnumerator(); } + public IEnumerator GetEnumerator() { + return mData.GetEnumerator(); + } + IEnumerator IEnumerable.GetEnumerator() { + return GetEnumerator(); + } } } diff --git a/ssc/symbol.cs b/ssc/symbol.cs index d603072..199e60c 100644 --- a/ssc/symbol.cs +++ b/ssc/symbol.cs @@ -1,5 +1,4 @@ using arookas.Collections; -using arookas.IO.Binary; using System; using System.Collections; using System.Collections.Generic; @@ -7,9 +6,9 @@ using System.Linq; namespace arookas { class sunSymbolTable : IEnumerable { - List Symbols { get; set; } + List mSymbols; - public int Count { get { return Symbols.Count; } } + public int Count { get { return mSymbols.Count; } } public int CallableCount { get { return Callables.Count(); } } public int BuiltinCount { get { return Builtins.Count(); } } public int FunctionCount { get { return Functions.Count(); } } @@ -17,22 +16,33 @@ namespace arookas { public int VariableCount { get { return Variables.Count(); } } public int ConstantCount { get { return Constants.Count(); } } - public IEnumerable Callables { get { return Symbols.OfType(); } } - public IEnumerable Builtins { get { return Symbols.OfType(); } } - public IEnumerable Functions { get { return Symbols.OfType(); } } - public IEnumerable Storables { get { return Symbols.OfType(); } } - public IEnumerable Variables { get { return Symbols.OfType(); } } - public IEnumerable Constants { get { return Symbols.OfType(); } } + public IEnumerable Callables { get { return mSymbols.OfType(); } } + public IEnumerable Builtins { get { return mSymbols.OfType(); } } + public IEnumerable Functions { get { return mSymbols.OfType(); } } + public IEnumerable Storables { get { return mSymbols.OfType(); } } + public IEnumerable Variables { get { return mSymbols.OfType(); } } + public IEnumerable Constants { get { return mSymbols.OfType(); } } public sunSymbolTable() { - Symbols = new List(10); + mSymbols = new List(10); } - public void Add(sunSymbol symbol) { Symbols.Add(symbol); } - public void Clear() { Symbols.Clear(); } + public void Add(sunSymbol symbol) { + if (symbol == null) { + throw new ArgumentNullException("symbol"); + } + mSymbols.Add(symbol); + } + public void Clear() { + mSymbols.Clear(); + } - public IEnumerator GetEnumerator() { return Symbols.GetEnumerator(); } - IEnumerator IEnumerable.GetEnumerator() { return GetEnumerator(); } + public IEnumerator GetEnumerator() { + return mSymbols.GetEnumerator(); + } + IEnumerator IEnumerable.GetEnumerator() { + return GetEnumerator(); + } } abstract class sunSymbol {