Initial Array Access Implementation

Signed-off-by: Will Hawkins <hawkinsw@obs.cr>
This commit is contained in:
Will Hawkins
2026-03-13 09:41:04 -04:00
parent 1982fda677
commit 0b4db34177
10 changed files with 266 additions and 11 deletions
+5 -5
View File
@@ -16,10 +16,10 @@
// along with this program. If not, see <https://www.gnu.org/licenses/>.
public struct Scope<T>: CustomStringConvertible, Sequence {
public typealias Element = T
public typealias Iterator = Dictionary<Identifier, T>.Values.Iterator
public typealias Element = (key: Identifier, value: T)
public typealias Iterator = Dictionary<Identifier, T>.Iterator
public func makeIterator() -> Iterator {
self.symbols.values.makeIterator()
self.symbols.makeIterator()
}
var symbols: [Identifier: T] = Dictionary()
@@ -123,8 +123,8 @@ public struct Scopes<T>: CustomStringConvertible, Sequence {
return .Error(Error(withMessage: "Cannot find \(identifier) in lexical scope."))
}
public typealias Element = T
public typealias Iterator = Dictionary<Identifier, T>.Values.Iterator
public typealias Element = (key: Identifier, value: T)
public typealias Iterator = Dictionary<Identifier, T>.Iterator
public func makeIterator() -> Iterator {
scopes.last?.makeIterator() ?? Scope<T>().makeIterator()
}