summaryrefslogtreecommitdiff
path: root/Variables.py
diff options
context:
space:
mode:
authorPeter Wu <lekensteyn@gmail.com>2011-12-03 11:35:52 +0000
committerPeter Wu <lekensteyn@gmail.com>2011-12-03 11:35:52 +0000
commit6045870ad6e5b59a0c4f54eaa5a29018c985f343 (patch)
tree3763a6829564fbd67f6a513c4d1bad8653ee2d75 /Variables.py
parent1ef20f9e52551d6cdca02ecd9bc829bdb859c7f7 (diff)
downloadpp2cc-6045870ad6e5b59a0c4f54eaa5a29018c985f343.tar.gz
Fix issue with globals being local to files
Diffstat (limited to 'Variables.py')
-rw-r--r--Variables.py19
1 files changed, 13 insertions, 6 deletions
diff --git a/Variables.py b/Variables.py
index b84d0ad..424f6bd 100644
--- a/Variables.py
+++ b/Variables.py
@@ -115,10 +115,17 @@ class GlobalVariables(Variables):
if is_param:
raise RuntimeError("Parameter '{}' declared in global context".format(name))
else:
- # global variables are prefixed "var_"
- var_name = self._uniqName("var_" + name)
+ # global variables are prefixed "var_". Don't use _uniqName because
+ # globals are by definition global and may be declared multiple
+ # times
+ var_name = "var_" + name
self.global_vars[name] = var_name
- if var_name not in self.defined_names:
- self.defined_names[var_name] = []
- # insert size items, initialized with 0
- self.defined_names[var_name] += ["0"] * size
+ if var_name in self.defined_names:
+ old_size = len(self.defined_names[var_name])
+ if size != old_size:
+ raise RuntimeError("Size {} of global '{}' does not equal"
+ " an earlier definition {}"
+ .format(size, name, old_size))
+ else:
+ # insert size items, initialized with 0
+ self.defined_names[var_name] = ["0"] * size