From a245d0a406aba04022d3f9d92708da899f250615 Mon Sep 17 00:00:00 2001 From: Joeri Exelmans Date: Wed, 29 Jan 2025 16:16:47 +0100 Subject: [PATCH 1/2] add a todo thingy --- TODO.txt | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/TODO.txt b/TODO.txt index 8df5fc8..bf1e3d4 100644 --- a/TODO.txt +++ b/TODO.txt @@ -29,7 +29,9 @@ Feature requests: - When matching edge, match 'any' src/tgt - - Support 'return'-statement in conditions? + - Support 'return'-statement in conditions? (just makes syntax nicer) + + - RAMification / matching: add `match_subtypes` attribute to each RAMified class. - Separate script for running LHS (+NAC) on any model, and visualizing the match. From ad6fcd7a244f56ffcce6ca42dce0bac253f32b89 Mon Sep 17 00:00:00 2001 From: Joeri Exelmans Date: Wed, 29 Jan 2025 16:16:59 +0100 Subject: [PATCH 2/2] add type check when overwriting slot value --- api/od.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/api/od.py b/api/od.py index c23160d..2740772 100644 --- a/api/od.py +++ b/api/od.py @@ -215,16 +215,25 @@ class ODAPI: def overwrite_primitive_value(self, name: str, value: any, is_code=False): referred_model = UUID(self.bottom.read_value(self.get(name))) + to_overwrite_type = self.get_type_name(self.get(name)) # watch out: in Python, 'bool' is subtype of 'int' # so we must check for 'bool' first if isinstance(value, bool): + if to_overwrite_type != "Boolean": + raise Exception(f"Cannot assign boolean value '{value}' to value of type {to_overwrite_type}.") Boolean(referred_model, self.state).create(value) elif isinstance(value, int): + if to_overwrite_type != "Integer": + raise Exception(f"Cannot assign integer value '{value}' to value of type {to_overwrite_type}.") Integer(referred_model, self.state).create(value) elif isinstance(value, str): if is_code: + if to_overwrite_type != "ActionCode": + raise Exception(f"Cannot assign code to value of type {to_overwrite_type}.") ActionCode(referred_model, self.state).create(value) else: + if to_overwrite_type != "String": + raise Exception(f"Cannot assign string value '{value}' to value of type {to_overwrite_type}.") String(referred_model, self.state).create(value) else: raise Exception("Unimplemented type "+value)