# HG changeset patch # User Paul Boddie # Date 1336947596 -7200 # Node ID 6e530bfa326eb6cdd002f843100771774e0db41f # Parent 8bf8faf18dbe169fa81b7bbe4c9849fe7d00f956 Improved support for specific type annotations in program regions. diff -r 8bf8faf18dbe -r 6e530bfa326e TO_DO.txt --- a/TO_DO.txt Fri May 11 00:20:56 2012 +0200 +++ b/TO_DO.txt Mon May 14 00:19:56 2012 +0200 @@ -126,7 +126,11 @@ ----------------------- Consider handling CallFunc in micropython.inspect in order to produce instances of specific classes. -Then, consider adding support for guard removal/verification where known instances are involved. +Then, consider adding support for guard removal/verification where known instances are involved. For +example: + + l = [] + l.append(123) # type deductions are filtered using instantiation knowledge Frame Optimisations =================== diff -r 8bf8faf18dbe -r 6e530bfa326e micropython/common.py --- a/micropython/common.py Fri May 11 00:20:56 2012 +0200 +++ b/micropython/common.py Mon May 14 00:19:56 2012 +0200 @@ -88,6 +88,9 @@ if not self.has_key(obj): self[obj] = set() + def issubset(self, other): + return set(self).issubset(other) + # Dictionary and related methods. def __getitem__(self, key): @@ -170,6 +173,9 @@ for old_dict in dicts: for key, value in old_dict.items(): + + # Add existing mappings within an object set. + if not new_dict.has_key(key): if value is not None: new_dict[key] = ObjectSet(value) diff -r 8bf8faf18dbe -r 6e530bfa326e micropython/data.py --- a/micropython/data.py Fri May 11 00:20:56 2012 +0200 +++ b/micropython/data.py Mon May 14 00:19:56 2012 +0200 @@ -441,9 +441,26 @@ if not hasattr(node, "_attrspecifictypes"): merged = {} - for user in node._attrdefs: - merged.update(user._attrnames) - node._attrmerged = combine_mapping_dicts(deepen_mapping_dict(node._attrnames), deepen_mapping_dict(merged)) + + # Get the combined usage information from the user definitions. + + for user in node._attrdefs or [node]: + + # Filter the usage for each name using the local usage + # information. + + for name, usage in user._attrcombined.items(): + localusage = node._attrnames.get(name) + + if usage and localusage: + if not merged.has_key(name): + merged[name] = ObjectSet() + + for attrnames, value in usage.items(): + if attrnames and localusage.issubset(attrnames): + merged[name][attrnames] = value + + node._attrmerged = merged node._attrspecifictypes = self._deduce_types(node._attrmerged, objtable) self._finalise_contributors(node, objtable)