1.1 --- a/micropython/data.py Mon Feb 15 01:35:17 2010 +0100
1.2 +++ b/micropython/data.py Sun Feb 21 22:26:08 2010 +0100
1.3 @@ -387,13 +387,20 @@
1.4 all_users = self.all_attribute_users[-1]
1.5 speculative = self.speculative_attributes[-1]
1.6
1.7 - # This node overrides previous definitions.
1.8 + # Record the current name usage as speculative since it will not be
1.9 + # propagated any further.
1.10
1.11 if not speculative.has_key(name):
1.12 speculative[name] = defs.get(name, set())
1.13 +
1.14 + # Where speculative usage has already been recorded, just note the usage
1.15 + # for coverage purposes.
1.16 +
1.17 else:
1.18 self.all_usage_shelves[-1].append({name : defs[name]})
1.19
1.20 + # This node overrides previous definitions.
1.21 +
1.22 all_users[name] = set([node])
1.23 users[name] = set([node])
1.24 defs[name] = set()
2.1 --- a/micropython/rsvp.py Mon Feb 15 01:35:17 2010 +0100
2.2 +++ b/micropython/rsvp.py Sun Feb 21 22:26:08 2010 +0100
2.3 @@ -3,7 +3,7 @@
2.4 """
2.5 RSVP instruction and serialisation classes.
2.6
2.7 -Copyright (C) 2007, 2008, 2009 Paul Boddie <paul@boddie.org.uk>
2.8 +Copyright (C) 2007, 2008, 2009, 2010 Paul Boddie <paul@boddie.org.uk>
2.9
2.10 This program is free software; you can redistribute it and/or modify it under
2.11 the terms of the GNU General Public License as published by the Free Software
2.12 @@ -433,7 +433,9 @@
2.13
2.14 class CheckContext(Instruction): "Check to see if the context is valid."
2.15 class CheckClass(Instruction): "Check the current value to determine whether it is a class."
2.16 -class CheckInstance(Instruction): "Check the current value as an instance of a specific class (used with 'self' in an invocation)."
2.17 +class CheckInstance(Instruction): """Check the current value as an instance of a class or its subclasses (used with 'self' in an
2.18 + invocation)."""
2.19 +class CheckType(Instruction): "Check the current value as an instance of a specific class only."
2.20
2.21 # Access to frames upon invocation.
2.22
2.23 @@ -499,7 +501,7 @@
2.24 TestIdentity, TestIdentityAddress, CheckInstance, # as one of the operands
2.25 CheckException, CheckFrame, FillDefaults,
2.26 MakeInstance,
2.27 - CheckContext, CheckClass,
2.28 + CheckContext, CheckClass, CheckType,
2.29 LoadContext # as the object providing the result
2.30 )
2.31
3.1 --- a/rsvp.py Mon Feb 15 01:35:17 2010 +0100
3.2 +++ b/rsvp.py Sun Feb 21 22:26:08 2010 +0100
3.3 @@ -5,7 +5,7 @@
3.4 ignore low-level operations and merely concentrate on variable access, structure
3.5 access, structure allocation and function invocations.
3.6
3.7 -Copyright (C) 2007, 2008, 2009 Paul Boddie <paul@boddie.org.uk>
3.8 +Copyright (C) 2007, 2008, 2009, 2010 Paul Boddie <paul@boddie.org.uk>
3.9
3.10 This program is free software; you can redistribute it and/or modify it under
3.11 the terms of the GNU General Public License as published by the Free Software
3.12 @@ -662,6 +662,11 @@
3.13
3.14 self.status = self._CheckInstance(value.ref, target_value.ref)
3.15
3.16 + def CheckType(self):
3.17 + value = self.value
3.18 + target_value = self.operand
3.19 + self.status = self._CheckType(value.ref, target_value.ref)
3.20 +
3.21 def JumpInFrame(self):
3.22 codeaddr = self.callable
3.23 return self.jump(codeaddr, self.pc + 1) # return to the instruction after this one
3.24 @@ -770,6 +775,22 @@
3.25 else:
3.26 return 0
3.27
3.28 + def _CheckType(self, ref, cls):
3.29 + data = self.load(ref)
3.30 + target_data = self.load(cls)
3.31 +
3.32 + # Insist on instance vs. class.
3.33 +
3.34 + if data.attrcode is None: # absent attrcode == class/module
3.35 + return 0
3.36 +
3.37 + if target_data.attrcode is not None: # present attrcode == instance
3.38 + return 0
3.39 +
3.40 + # Return whether the types match.
3.41 +
3.42 + return data.classcode == target_data.classcode
3.43 +
3.44 def _MakeObject(self, size, ref):
3.45 # Load the template.
3.46 data = self.load(ref)