1.1 --- a/rsvp.py Mon Feb 15 01:35:17 2010 +0100
1.2 +++ b/rsvp.py Sun Feb 21 22:26:08 2010 +0100
1.3 @@ -5,7 +5,7 @@
1.4 ignore low-level operations and merely concentrate on variable access, structure
1.5 access, structure allocation and function invocations.
1.6
1.7 -Copyright (C) 2007, 2008, 2009 Paul Boddie <paul@boddie.org.uk>
1.8 +Copyright (C) 2007, 2008, 2009, 2010 Paul Boddie <paul@boddie.org.uk>
1.9
1.10 This program is free software; you can redistribute it and/or modify it under
1.11 the terms of the GNU General Public License as published by the Free Software
1.12 @@ -662,6 +662,11 @@
1.13
1.14 self.status = self._CheckInstance(value.ref, target_value.ref)
1.15
1.16 + def CheckType(self):
1.17 + value = self.value
1.18 + target_value = self.operand
1.19 + self.status = self._CheckType(value.ref, target_value.ref)
1.20 +
1.21 def JumpInFrame(self):
1.22 codeaddr = self.callable
1.23 return self.jump(codeaddr, self.pc + 1) # return to the instruction after this one
1.24 @@ -770,6 +775,22 @@
1.25 else:
1.26 return 0
1.27
1.28 + def _CheckType(self, ref, cls):
1.29 + data = self.load(ref)
1.30 + target_data = self.load(cls)
1.31 +
1.32 + # Insist on instance vs. class.
1.33 +
1.34 + if data.attrcode is None: # absent attrcode == class/module
1.35 + return 0
1.36 +
1.37 + if target_data.attrcode is not None: # present attrcode == instance
1.38 + return 0
1.39 +
1.40 + # Return whether the types match.
1.41 +
1.42 + return data.classcode == target_data.classcode
1.43 +
1.44 def _MakeObject(self, size, ref):
1.45 # Load the template.
1.46 data = self.load(ref)