# HG changeset patch # User Paul Boddie # Date 1241132540 -7200 # Node ID 79f8d72c8c78a6711dddae1be817f8e2980d3ef9 # Parent 0a00400508cd5af6987c9de899514da177b67122 Removed the instance attribute from DataObject (the common data structure), employing the presence of a value on the attrcode attribute to indicate the instance status of objects. diff -r 0a00400508cd -r 79f8d72c8c78 docs/concepts.txt --- a/docs/concepts.txt Mon Apr 27 02:20:22 2009 +0200 +++ b/docs/concepts.txt Fri May 01 01:02:20 2009 +0200 @@ -189,14 +189,14 @@ certain common features and operations are supported in the same way for all of these things. To permit this, a common data structure format is used. - Header............................................................................ Attributes................. + Header............................................................................ Attributes..... - Identifier Identifier Address Details Flag Identifier Size Object Object ... + Identifier Identifier Address Details Identifier Size Object Object ... - 0 1 2 3 4 5 6 7 8 9 - classcode attrcode invocation invocation instance funccode size __class__ attribute ... - reference #args, status reference reference - defaults + 0 1 2 3 4 5 6 7 8 + classcode attrcode/ invocation invocation funccode size __class__ attribute ... + instance reference #args, reference reference + status defaults reference Classcode @@ -216,43 +216,43 @@ Used to test instances for membership of classes (or descendants of classes). Since, in traditional Python, classes are only ever instances of the "type" -built-in class, support for testing such a relationship could be removed and -the attrcode eliminated for classes, such that the presence of an attrcode -would indicate that a given object is an instance. +built-in class, support for testing such a relationship directly has been +removed and the attrcode is not specified for classes: the presence of an +attrcode indicates that a given object is an instance. Structure Types --------------- Class C: - 0 1 2 3 4 5 6 7 8 9 - classcode attrcode __new__ __new__ false size class type attribute ... - for C for C reference #args, reference reference + 0 1 2 3 4 5 6 7 8 + classcode (unused) __new__ __new__ size class type attribute ... + for C reference #args, reference reference defaults reference Instance of C: - 0 1 2 3 4 5 6 7 8 9 - classcode attrcode C.__call__ C.__call__ true size class C attribute ... - for C for C reference #args, reference reference + 0 1 2 3 4 5 6 7 8 + classcode attrcode C.__call__ C.__call__ size class C attribute ... + for C for C reference #args, reference reference (if exists) defaults reference Function f: - 0 1 2 3 4 5 6 7 8 9 - classcode attrcode code code true funccode size class attribute ... - for for reference #args, function (default) - function function defaults reference reference + 0 1 2 3 4 5 6 7 8 + classcode attrcode code code funccode size class attribute ... + for for reference #args, function (default) + function function defaults reference reference reference Module m: - 0 1 2 3 4 5 6 7 8 9 - classcode attrcode (unused) (unused) true module type attribute ... - for m for m reference (global) - reference + 0 1 2 3 4 5 6 7 8 + classcode attrcode (unused) (unused) module type attribute ... + for m for m reference (global) + reference The __class__ Attribute ----------------------- diff -r 0a00400508cd -r 79f8d72c8c78 micropython/data.py --- a/micropython/data.py Mon Apr 27 02:20:22 2009 +0200 +++ b/micropython/data.py Fri May 01 01:02:20 2009 +0200 @@ -459,10 +459,9 @@ return [ DataObject( objtable.as_list().get_code(self.value_type_name()), - objtable.get_index(self.value_type_name()), + objtable.get_index(self.value_type_name()), # is instance None, None, - 1, # instance self.value_type_name(), 1 # size ) @@ -573,12 +572,13 @@ # Template instance... DataObject( - classcode, attrcode, call_method_code_location, + classcode, + attrcode, # is instance + call_method_code_location, ( call_method_value and len(call_method_value.positional_names), call_method_value and len(call_method_value.defaults) ), - 1, # instance self.full_name(), len(self.instance_attributes()) + 1 # size ), @@ -586,12 +586,13 @@ # Class... DataObject( - classcode, attrcode, instantiator_code_location, + classcode, + None, # is not instance + instantiator_code_location, ( len(self.get_instantiator().positional_names), len(self.get_instantiator().defaults) ), - 0, # not instance self.full_name(), len(self.class_attributes()) + 1 # size ) @@ -968,13 +969,12 @@ return [ DataObject( objtable.as_list().get_code("__builtins__.function"), - objtable.get_index("__builtins__.function"), + objtable.get_index("__builtins__.function"), # is instance self.code_location, ( len(self.positional_names), len(self.defaults) ), - 1, # instance "__builtins__.function", len(self.defaults) + 1, # size paramtable.as_list().get_code(self.full_name()) @@ -1173,10 +1173,9 @@ return [ DataObject( objtable.as_list().get_code(self.full_name()), - None, # module name not used as an attribute + None, # NOTE: module name not used as an attribute, but should be instance None, None, - 1, # instance self.full_name(), len(self.module_attributes()) + 1 # size ) diff -r 0a00400508cd -r 79f8d72c8c78 micropython/program.py --- a/micropython/program.py Mon Apr 27 02:20:22 2009 +0200 +++ b/micropython/program.py Fri May 01 01:02:20 2009 +0200 @@ -25,22 +25,21 @@ "A representation of a raw program data object." - def __init__(self, classcode, attrcode, codeaddr, codedetails, instance, name, size, funccode=None): + def __init__(self, classcode, attrcode, codeaddr, codedetails, name, size, funccode=None): self.classcode = classcode self.attrcode = attrcode self.codeaddr = codeaddr self.codedetails = codedetails - self.instance = instance self.name = name self.size = size self.funccode = funccode def with_size(self, size): - return DataObject(self.classcode, self.attrcode, self.codeaddr, self.codedetails, self.instance, self.name, size, self.funccode) + return DataObject(self.classcode, self.attrcode, self.codeaddr, self.codedetails, self.name, size, self.funccode) def __repr__(self): return "%r # %s" % ( - (self.classcode, self.attrcode, self.codeaddr, self.codedetails, self.instance, self.funccode, self.size), self.name + (self.classcode, self.attrcode, self.codeaddr, self.codedetails, self.funccode, self.size), self.name ) # vim: tabstop=4 expandtab shiftwidth=4 diff -r 0a00400508cd -r 79f8d72c8c78 rsvp.py --- a/rsvp.py Mon Apr 27 02:20:22 2009 +0200 +++ b/rsvp.py Fri May 01 01:02:20 2009 +0200 @@ -481,7 +481,7 @@ context, ref = self.value # NOTE: Should improve the representation and permit direct saving. data = self.load(ref) - self.save(ref, (data.classcode, data.attrcode) + self.callable + (data.instance,)) + self.save(ref, (data.classcode, data.attrcode) + self.callable) def LoadContext(self): context, ref = self.value @@ -500,7 +500,7 @@ operand -= 1 else: context_data = self.load(context) - if not context_data.instance: + if context_data.attrcode is None: # absent attrcode == class self.invocation_sp_stack[-1] += 1 operand -= 1 @@ -611,7 +611,7 @@ # Insist on a class. - if target_data.instance: + if target_data.attrcode is not None: # present attrcode == instance return 0 # Find the table entry for the descendant.