Skip to content

Commit 24574b6

Browse files
committed
global and nonlocal are removed.
1 parent bc621d2 commit 24574b6

File tree

3 files changed

+18
-83
lines changed

3 files changed

+18
-83
lines changed

docker/Dockerfile

Lines changed: 0 additions & 12 deletions
This file was deleted.

veriloggen/thread/compiler.py

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ def visit_ClassDef(self, node):
128128

129129
# -------------------------------------------------------------------------
130130
def visit_FunctionDef(self, node):
131-
self.scope.addFunction(node)
131+
raise NotImplementedError('closure is not supported.')
132132

133133
def visit_Assign(self, node):
134134
if self.skip():
@@ -753,12 +753,10 @@ def _is_intrinsic_method(self, value, method):
753753

754754
# ------------------------------------------------------------------
755755
def visit_Nonlocal(self, node):
756-
for name in node.names:
757-
self.addNonlocal(name)
756+
raise NotImplementedError('nonlocal is not supported.')
758757

759758
def visit_Global(self, node):
760-
for name in node.names:
761-
self.addGlobal(name)
759+
raise NotImplementedError('global is not supported.')
762760

763761
def visit_Pass(self, node):
764762
pass
@@ -1133,12 +1131,6 @@ def getGlobalObject(self, name):
11331131
return global_objects[name]
11341132
return None
11351133

1136-
def addNonlocal(self, name):
1137-
self.scope.addNonlocal(name)
1138-
1139-
def addGlobal(self, name):
1140-
self.scope.addGlobal(name)
1141-
11421134
def getFunction(self, name):
11431135
func = self.scope.searchFunction(name)
11441136
if func is not None:

veriloggen/thread/scope.py

Lines changed: 15 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ def __init__(self):
2222
self.scopeframes = []
2323
self.scopeframes.append(ScopeFrame(ScopeName(('_',))))
2424
self.current = self.scopeframes[0]
25-
self.globalframe = self.scopeframes[0]
2625
self.previousframes = OrderedDict()
2726
self.previousframes[self.current] = None
2827
self.nextframes = OrderedDict()
@@ -64,65 +63,45 @@ def addVariable(self, name, var):
6463
targ = self.previousframes[targ]
6564
return None
6665

67-
def addNonlocal(self, name):
68-
if self.current is None:
69-
return None
70-
targ = self.current
71-
while targ is not None:
72-
if targ.ftype == 'call':
73-
targ.addNonlocal(name)
74-
break
75-
targ = self.previousframes[targ]
76-
return None
77-
78-
def addGlobal(self, name):
79-
if self.current is None:
80-
return None
81-
targ = self.current
82-
while targ is not None:
83-
if targ.ftype == 'call':
84-
targ.addGlobal(name)
85-
break
86-
targ = self.previousframes[targ]
87-
return None
88-
8966
def addFunction(self, func):
9067
self.current.addFunction(func)
9168

9269
def searchVariable(self, name, store=False):
9370
if self.current is None:
9471
return None
72+
9573
targ = self.current
96-
is_global = False
74+
9775
while targ is not None:
9876
ret = targ.searchVariable(name)
9977
if ret is not None:
10078
return ret
79+
80+
ret = targ.searchFunction(name)
81+
if ret is not None:
82+
return ret
83+
10184
if targ.ftype == 'call':
102-
ret = targ.searchNonlocal(name)
103-
if ret:
104-
continue
105-
ret = targ.searchGlobal(name)
106-
if ret:
107-
is_global = True
10885
break
86+
10987
targ = self.previousframes[targ]
110-
if not store or is_global:
111-
ret = self.globalframe.searchVariable(name)
112-
return ret
88+
11389
return None
11490

11591
def searchFunction(self, name):
11692
if self.current is None:
11793
return None
94+
11895
targ = self.current
96+
11997
while targ is not None:
12098
ret = targ.searchFunction(name)
121-
if ret:
99+
if ret is not None:
122100
return ret
101+
123102
targ = self.previousframes[targ]
124-
ret = self.globalframe.searchFunction(name)
125-
return ret
103+
104+
return None
126105

127106
def addBind(self, state, dst, var, cond=None):
128107
if dst not in self.binds:
@@ -239,8 +218,6 @@ def __init__(self, name, ftype=None):
239218
self.name = name
240219
self.ftype = ftype
241220
self.variables = OrderedDict()
242-
self.nonlocals = []
243-
self.globals = []
244221
self.functions = OrderedDict()
245222
self.unresolved_break = []
246223
self.unresolved_continue = []
@@ -253,12 +230,6 @@ def getNamePrefix(self):
253230
def addVariable(self, name, var):
254231
self.variables[name] = var
255232

256-
def addNonlocal(self, name):
257-
self.nonlocals.append(name)
258-
259-
def addGlobal(self, name):
260-
self.globals.append(name)
261-
262233
def addFunction(self, func):
263234
name = func.name
264235
self.functions[name] = func
@@ -268,16 +239,6 @@ def searchVariable(self, name):
268239
return None
269240
return self.variables[name]
270241

271-
def searchNonlocal(self, name):
272-
if name not in self.nonlocals:
273-
return None
274-
return name
275-
276-
def searchGlobal(self, name):
277-
if name not in self.globals:
278-
return None
279-
return name
280-
281242
def searchFunction(self, name):
282243
if name not in self.functions:
283244
return None
@@ -287,12 +248,6 @@ def searchFunction(self, name):
287248
def getVariables(self):
288249
return tuple(self.variables)
289250

290-
def getNonlocals(self):
291-
return tuple(self.nonlocals)
292-
293-
def getGlobals(self):
294-
return tuple(self.globals)
295-
296251
def getFunctions(self):
297252
return self.functions
298253

0 commit comments

Comments
 (0)