-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMemoria2.py
More file actions
44 lines (38 loc) · 1.31 KB
/
Memoria2.py
File metadata and controls
44 lines (38 loc) · 1.31 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
import sys
from Contador import Contador
class Memoria:
def __init__(self):
self.diccionario ={'dirMem':{}}
self.contador = {'contador':{}}
def create_memoria(self, name):
new_table = {
'int' : {},
'float' : {},
'string' : {},
'bool' : {},
}
self.diccionario['dirMem'][name] = new_table
if(name == 'global'):
inicio = 10000
elif(name == 'constantes'):
inicio = 20000
else:
inicio = 30000
new_contador = {
'name' : name,
'inicio': inicio,
'limite' : 999,
'int' : inicio,
'float' : inicio + 1000,
'string' : inicio + 2000,
'bool' : inicio + 3000,
}
self.contador['contador'][name] = new_contador
def insert_id(self, dato, scope):
direccion = self.contador['contador'][scope][dato.type]
self.diccionario['dirMem'][scope][dato.type].update({dato.id:direccion})
self.contador['contador'][scope][dato.type] += 1
def insert_constant(self, name, type, scope):
direccion = self.contador['contador'][scope][type]
self.diccionario['dirMem'][scope][type].update({name:direccion})
self.contador['contador'][scope][type] += 1