def declare_param(self, id_: str, lineno: int, type_=None, is_array=False): """ Declares a parameter Check if entry.declared is False. Otherwise raises an error. """ if not self.check_is_undeclared(id_, lineno, classname='parameter', scope=self.current_scope, show_error=True): return None if is_array: entry = self.declare( id_, lineno, symbols.VARARRAY(id_, symbols.BOUNDLIST(), lineno, None, type_)) entry.callable = True entry.scope = SCOPE.parameter else: entry = self.declare(id_, lineno, symbols.PARAMDECL(id_, lineno, type_)) if entry is None: return entry.declared = True if entry.type_.implicit: warning_implicit_type(lineno, id_, type_) return entry
def test__len__(self): l1 = 1 l2 = 2 l3 = 3 l4 = 4 b = symbols.BOUND(l1, l2) c = symbols.BOUND(l3, l4) a = symbols.BOUNDLIST(b, c) self.assertEqual(len(a), 2)
def test_declare_local_array(self): """ the logic for declaring a local array differs from local scalar variables """ self.s.enter_scope('testfunction') self.s.declare_array('a', 12, self.btyperef(TYPE.float_), symbols.BOUNDLIST(symbols.BOUND(0, 2))) self.assertTrue(self.s.check_is_declared('a', 11, scope=self.s.current_scope)) self.assertEqual(self.s.get_entry('a').scope, SCOPE.local)