Peter N Lewis wrote:
At 9:24 +0800 27/6/05, Peter N Lewis wrote:
dispose( self ) complains:
/Source/MyAssocStrings.p: In method `AssocStringsObject.Destroy': /Source/MyAssocStrings.p:254: error: argument 1 to `Dispose' must be a pointer
Here is a test program for this case:
{$mac-pascal} program peterN;
type obj = object procedure Destroy; end;
procedure obj.Destroy; begin dispose( self ); end;
var o: obj; begin new(o); o.Destroy; WriteLn( 'OK' ); end.
The problem was that `self' was not a pointer but a reference (like for BP objects). The following should fix it:
diff -u p.nn/declarations.c p/declarations.c --- p.nn/declarations.c 2005-06-23 02:05:16.000000000 +0200 +++ p/declarations.c 2005-06-30 03:40:04.350829024 +0200 @@ -2849,6 +2849,18 @@ { /* Implicitly do `with Self do' */ tree self = lookup_name (self_id), t; + if (self && TREE_CODE (TREE_TYPE (self)) == REFERENCE_TYPE) + { + tree stp = TYPE_POINTER_TO (TREE_TYPE (TREE_TYPE (self))); + if (stp && PASCAL_TYPE_CLASS (stp)) + { + tree d = build_decl (CONST_DECL, self_id, stp); + DECL_INITIAL (d) = convert (stp, self); + IDENTIFIER_VALUE (self_id) = d; + pushdecl_nocheck (d); + DECL_CONTEXT (d) = current_function_decl; + } + } if (self) shadowed = pascal_shadow_record_fields (build_indirect_ref (self, "`Self' reference"), NULL_TREE); /* Mark the fields as declared in the current scope (fjf280b.pas) */