From 4d947f5b6f95272f43b6642514b7da52f13f32fb Mon Sep 17 00:00:00 2001 From: arookas Date: Sun, 27 Dec 2015 22:51:42 -0500 Subject: [PATCH] Cleanup. --- ssc/scope stack.cs | 33 ++++++++++++++++++--------------- 1 file changed, 18 insertions(+), 15 deletions(-) diff --git a/ssc/scope stack.cs b/ssc/scope stack.cs index 00ccf06..725db8d 100644 --- a/ssc/scope stack.cs +++ b/ssc/scope stack.cs @@ -73,19 +73,22 @@ namespace arookas class sunScope { - List storables = new List(10); + List Storables { get; set; } + IEnumerable Variables { get { return Storables.OfType(); } } + IEnumerable Constants { get { return Storables.OfType(); } } public sunScopeType Type { get; private set; } public sunScope(sunScopeType type) { + Storables = new List(10); Type = type; } - public int StorableCount { get { return storables.Count; } } - public int VariableCount { get { return storables.OfType().Count(); } } - public int ConstantCount { get { return storables.OfType().Count(); } } + public int StorableCount { get { return Storables.Count; } } + public int VariableCount { get { return Variables.Count(); } } + public int ConstantCount { get { return Constants.Count(); } } - public bool GetIsDeclared(string name) { return storables.Any(v => v.Name == name); } + public bool GetIsDeclared(string name) { return Storables.Any(v => v.Name == name); } public sunVariableSymbol DeclareVariable(string name, int display, int index) { @@ -93,9 +96,9 @@ namespace arookas { return null; } - var variableInfo = new sunVariableSymbol(name, display, index); - storables.Add(variableInfo); - return variableInfo; + var symbol = new sunVariableSymbol(name, display, index); + Storables.Add(symbol); + return symbol; } public sunConstantSymbol DeclareConstant(string name, sunExpression expression) { @@ -103,14 +106,14 @@ namespace arookas { return null; } - var constantSymbol = new sunConstantSymbol(name, expression); - storables.Add(constantSymbol); - return constantSymbol; + var symbol = new sunConstantSymbol(name, expression); + Storables.Add(symbol); + return symbol; } - - public sunStorableSymbol ResolveStorable(string name) { return storables.FirstOrDefault(i => i.Name == name); } - public sunVariableSymbol ResolveVariable(string name) { return storables.OfType().FirstOrDefault(i => i.Name == name); } - public sunConstantSymbol ResolveConstant(string name) { return storables.OfType().FirstOrDefault(i => i.Name == name); } + + public sunStorableSymbol ResolveStorable(string name) { return Storables.FirstOrDefault(i => i.Name == name); } + public sunVariableSymbol ResolveVariable(string name) { return Variables.FirstOrDefault(i => i.Name == name); } + public sunConstantSymbol ResolveConstant(string name) { return Constants.FirstOrDefault(i => i.Name == name); } } enum sunScopeType