16 using System.Collections.Generic;
20 using ErrorManagement;
23 namespace CodeGeneration {
33 private List<Dictionary<string, Expression>> constants;
43 this.constants =
new List<Dictionary<string, Expression>>();
54 this.constants.Add(
new Dictionary<string, Expression>());
65 this.constants.RemoveAt(this.constants.Count - 1);
79 if (this.constants[this.constants.Count - 1].ContainsKey(
id))
81 this.constants[this.constants.Count - 1].Add(id, init);
97 scope = this.constants.Count - 1 ;
100 if (this.constants[scope].ContainsKey(
id))
101 return this.constants[scope][id];
115 return Search(
id, out scope);
Abstract class encapsulate a programming language expression.
bool Insert(string id, Expression init)
Insert a new constant in the current scope.
Expression Search(string id)
Searches the initialization of constant identifier. It performs a full search.
Expression Search(string id, out int scope)
Searches the initialization of constant identifier.
void Set()
Add a new scope
void Reset()
Removes the last scope
ConstantTable()
Constructor of ConstantTable.