Skip to content

Commit 45a974b

Browse files
committed
Fix types in Memory
1 parent 7aa502a commit 45a974b

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

utils/memory.py

+6-5
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,31 @@
11
from .values import Value
2+
from .types import Type
23

34

45
class Memory:
56
def __init__(self):
6-
self.variables: dict[str, Value] = {}
7+
self.variables: dict[str, Value | Type] = {}
78

89
def has_variable(self, name: str) -> bool:
910
return name in self.variables
1011

11-
def get(self, name: str) -> Value:
12+
def get(self, name: str) -> Value | Type:
1213
return self.variables[name]
1314

14-
def put(self, name: str, value: Value):
15+
def put(self, name: str, value: Value | Type):
1516
self.variables[name] = value
1617

1718

1819
class MemoryStack:
1920
def __init__(self):
2021
self.stack: list[Memory] = []
2122

22-
def get(self, name: str) -> Value:
23+
def get(self, name: str) -> Value | Type:
2324
for memory in self.stack:
2425
if memory.has_variable(name):
2526
return memory.get(name)
2627

27-
def put(self, name: str, value: Value):
28+
def put(self, name: str, value: Value | Type):
2829
for memory in self.stack:
2930
if memory.has_variable(name):
3031
memory.put(name, value)

0 commit comments

Comments
 (0)