public void Push(Value value) { if (this.length == this.storage.Length) { Array.Resize (ref this.storage, this.storage.Length * 2); } this.storage [this.length] = value; this.length++; }
public static Value GetStructInstanceValue(StructInstance str, string key, Value defaultValue) { for (int i = 0; i < str.Struct.Fields.Length; i++) { if (str.Struct.Fields[i] == key) { return str.Values[i]; } } return defaultValue; }
public static bool SetStructInstanceValue(StructInstance str, string key, Value newValue) { for (int i = 0; i < str.Struct.Fields.Length; i++) { if (str.Struct.Fields[i] == key) { str.Values[i] = newValue; return true; } } return false; }
public Value[] GetUsedStack() { var result = new Value[this.length]; Array.Copy (this.storage, result, this.length); return result; }
public void GetTopRange(int n, out Value[] array, out int start) { array = this.storage; start = this.length - n; }
public Stack(Value[] existingValues) { this.storage = new Value[existingValues.Length * 2]; this.length = existingValues.Length; Array.Copy (existingValues, this.storage, this.length); }