From 2aeb072b28cf7f444ea90e0c2f22ccb24d53442b Mon Sep 17 00:00:00 2001 From: Jose Rodriguez Date: Thu, 28 May 2020 00:24:20 +0200 Subject: [PATCH] SymbolVAR always return its final value If it's a constant we don't need to resolve it outside. It comes resolved (for constants of constants) --- symbols/bound.py | 4 ++-- symbols/var.py | 3 +++ 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/symbols/bound.py b/symbols/bound.py index f3da51303..7f6d32806 100644 --- a/symbols/bound.py +++ b/symbols/bound.py @@ -48,13 +48,13 @@ def make_node(lower, upper, lineno): syntax_error(lineno, 'Array bounds must be constants') return None - while isinstance(lower, SymbolVAR): + if isinstance(lower, SymbolVAR): lower = lower.value if lower is None: # semantic error syntax_error(lineno, "Unknown lower bound for array dimension") return - while isinstance(upper, SymbolVAR): + if isinstance(upper, SymbolVAR): upper = upper.value if upper is None: # semantic error syntax_error(lineno, "Unknown upper bound for array dimension") diff --git a/symbols/var.py b/symbols/var.py index 0bf5f6bfe..4c57f90cc 100644 --- a/symbols/var.py +++ b/symbols/var.py @@ -170,6 +170,9 @@ def value(self): """ An alias of default value, only available is class_ is CONST """ assert self.class_ == CLASS.const + if isinstance(self.default_value, SymbolVAR): + return self.default_value.value + return self.default_value @value.setter