1.1 --- a/docs/concepts.txt Mon Apr 27 02:20:22 2009 +0200
1.2 +++ b/docs/concepts.txt Fri May 01 01:02:20 2009 +0200
1.3 @@ -189,14 +189,14 @@
1.4 certain common features and operations are supported in the same way for all
1.5 of these things. To permit this, a common data structure format is used.
1.6
1.7 - Header............................................................................ Attributes.................
1.8 + Header............................................................................ Attributes.....
1.9
1.10 - Identifier Identifier Address Details Flag Identifier Size Object Object ...
1.11 + Identifier Identifier Address Details Identifier Size Object Object ...
1.12
1.13 - 0 1 2 3 4 5 6 7 8 9
1.14 - classcode attrcode invocation invocation instance funccode size __class__ attribute ...
1.15 - reference #args, status reference reference
1.16 - defaults
1.17 + 0 1 2 3 4 5 6 7 8
1.18 + classcode attrcode/ invocation invocation funccode size __class__ attribute ...
1.19 + instance reference #args, reference reference
1.20 + status defaults
1.21 reference
1.22
1.23 Classcode
1.24 @@ -216,43 +216,43 @@
1.25 Used to test instances for membership of classes (or descendants of classes).
1.26
1.27 Since, in traditional Python, classes are only ever instances of the "type"
1.28 -built-in class, support for testing such a relationship could be removed and
1.29 -the attrcode eliminated for classes, such that the presence of an attrcode
1.30 -would indicate that a given object is an instance.
1.31 +built-in class, support for testing such a relationship directly has been
1.32 +removed and the attrcode is not specified for classes: the presence of an
1.33 +attrcode indicates that a given object is an instance.
1.34
1.35 Structure Types
1.36 ---------------
1.37
1.38 Class C:
1.39
1.40 - 0 1 2 3 4 5 6 7 8 9
1.41 - classcode attrcode __new__ __new__ false size class type attribute ...
1.42 - for C for C reference #args, reference reference
1.43 + 0 1 2 3 4 5 6 7 8
1.44 + classcode (unused) __new__ __new__ size class type attribute ...
1.45 + for C reference #args, reference reference
1.46 defaults
1.47 reference
1.48
1.49 Instance of C:
1.50
1.51 - 0 1 2 3 4 5 6 7 8 9
1.52 - classcode attrcode C.__call__ C.__call__ true size class C attribute ...
1.53 - for C for C reference #args, reference reference
1.54 + 0 1 2 3 4 5 6 7 8
1.55 + classcode attrcode C.__call__ C.__call__ size class C attribute ...
1.56 + for C for C reference #args, reference reference
1.57 (if exists) defaults
1.58 reference
1.59
1.60 Function f:
1.61
1.62 - 0 1 2 3 4 5 6 7 8 9
1.63 - classcode attrcode code code true funccode size class attribute ...
1.64 - for for reference #args, function (default)
1.65 - function function defaults reference reference
1.66 + 0 1 2 3 4 5 6 7 8
1.67 + classcode attrcode code code funccode size class attribute ...
1.68 + for for reference #args, function (default)
1.69 + function function defaults reference reference
1.70 reference
1.71
1.72 Module m:
1.73
1.74 - 0 1 2 3 4 5 6 7 8 9
1.75 - classcode attrcode (unused) (unused) true module type attribute ...
1.76 - for m for m reference (global)
1.77 - reference
1.78 + 0 1 2 3 4 5 6 7 8
1.79 + classcode attrcode (unused) (unused) module type attribute ...
1.80 + for m for m reference (global)
1.81 + reference
1.82
1.83 The __class__ Attribute
1.84 -----------------------
2.1 --- a/micropython/data.py Mon Apr 27 02:20:22 2009 +0200
2.2 +++ b/micropython/data.py Fri May 01 01:02:20 2009 +0200
2.3 @@ -459,10 +459,9 @@
2.4 return [
2.5 DataObject(
2.6 objtable.as_list().get_code(self.value_type_name()),
2.7 - objtable.get_index(self.value_type_name()),
2.8 + objtable.get_index(self.value_type_name()), # is instance
2.9 None,
2.10 None,
2.11 - 1, # instance
2.12 self.value_type_name(),
2.13 1 # size
2.14 )
2.15 @@ -573,12 +572,13 @@
2.16 # Template instance...
2.17
2.18 DataObject(
2.19 - classcode, attrcode, call_method_code_location,
2.20 + classcode,
2.21 + attrcode, # is instance
2.22 + call_method_code_location,
2.23 (
2.24 call_method_value and len(call_method_value.positional_names),
2.25 call_method_value and len(call_method_value.defaults)
2.26 ),
2.27 - 1, # instance
2.28 self.full_name(),
2.29 len(self.instance_attributes()) + 1 # size
2.30 ),
2.31 @@ -586,12 +586,13 @@
2.32 # Class...
2.33
2.34 DataObject(
2.35 - classcode, attrcode, instantiator_code_location,
2.36 + classcode,
2.37 + None, # is not instance
2.38 + instantiator_code_location,
2.39 (
2.40 len(self.get_instantiator().positional_names),
2.41 len(self.get_instantiator().defaults)
2.42 ),
2.43 - 0, # not instance
2.44 self.full_name(),
2.45 len(self.class_attributes()) + 1 # size
2.46 )
2.47 @@ -968,13 +969,12 @@
2.48 return [
2.49 DataObject(
2.50 objtable.as_list().get_code("__builtins__.function"),
2.51 - objtable.get_index("__builtins__.function"),
2.52 + objtable.get_index("__builtins__.function"), # is instance
2.53 self.code_location,
2.54 (
2.55 len(self.positional_names),
2.56 len(self.defaults)
2.57 ),
2.58 - 1, # instance
2.59 "__builtins__.function",
2.60 len(self.defaults) + 1, # size
2.61 paramtable.as_list().get_code(self.full_name())
2.62 @@ -1173,10 +1173,9 @@
2.63 return [
2.64 DataObject(
2.65 objtable.as_list().get_code(self.full_name()),
2.66 - None, # module name not used as an attribute
2.67 + None, # NOTE: module name not used as an attribute, but should be instance
2.68 None,
2.69 None,
2.70 - 1, # instance
2.71 self.full_name(),
2.72 len(self.module_attributes()) + 1 # size
2.73 )
3.1 --- a/micropython/program.py Mon Apr 27 02:20:22 2009 +0200
3.2 +++ b/micropython/program.py Fri May 01 01:02:20 2009 +0200
3.3 @@ -25,22 +25,21 @@
3.4
3.5 "A representation of a raw program data object."
3.6
3.7 - def __init__(self, classcode, attrcode, codeaddr, codedetails, instance, name, size, funccode=None):
3.8 + def __init__(self, classcode, attrcode, codeaddr, codedetails, name, size, funccode=None):
3.9 self.classcode = classcode
3.10 self.attrcode = attrcode
3.11 self.codeaddr = codeaddr
3.12 self.codedetails = codedetails
3.13 - self.instance = instance
3.14 self.name = name
3.15 self.size = size
3.16 self.funccode = funccode
3.17
3.18 def with_size(self, size):
3.19 - return DataObject(self.classcode, self.attrcode, self.codeaddr, self.codedetails, self.instance, self.name, size, self.funccode)
3.20 + return DataObject(self.classcode, self.attrcode, self.codeaddr, self.codedetails, self.name, size, self.funccode)
3.21
3.22 def __repr__(self):
3.23 return "%r # %s" % (
3.24 - (self.classcode, self.attrcode, self.codeaddr, self.codedetails, self.instance, self.funccode, self.size), self.name
3.25 + (self.classcode, self.attrcode, self.codeaddr, self.codedetails, self.funccode, self.size), self.name
3.26 )
3.27
3.28 # vim: tabstop=4 expandtab shiftwidth=4
4.1 --- a/rsvp.py Mon Apr 27 02:20:22 2009 +0200
4.2 +++ b/rsvp.py Fri May 01 01:02:20 2009 +0200
4.3 @@ -481,7 +481,7 @@
4.4 context, ref = self.value
4.5 # NOTE: Should improve the representation and permit direct saving.
4.6 data = self.load(ref)
4.7 - self.save(ref, (data.classcode, data.attrcode) + self.callable + (data.instance,))
4.8 + self.save(ref, (data.classcode, data.attrcode) + self.callable)
4.9
4.10 def LoadContext(self):
4.11 context, ref = self.value
4.12 @@ -500,7 +500,7 @@
4.13 operand -= 1
4.14 else:
4.15 context_data = self.load(context)
4.16 - if not context_data.instance:
4.17 + if context_data.attrcode is None: # absent attrcode == class
4.18 self.invocation_sp_stack[-1] += 1
4.19 operand -= 1
4.20
4.21 @@ -611,7 +611,7 @@
4.22
4.23 # Insist on a class.
4.24
4.25 - if target_data.instance:
4.26 + if target_data.attrcode is not None: # present attrcode == instance
4.27 return 0
4.28
4.29 # Find the table entry for the descendant.