comp.lang.ada
 help / color / mirror / Atom feed
From: "andrew.carroll@okstate.edu" <andrew.carroll@okstate.edu>
Subject: Re: STORAGE_ERROR : EXCEPTION_STACK_OVERFLOW
Date: 12 Apr 2007 06:48:01 -0700
Date: 2007-04-12T06:48:01-07:00	[thread overview]
Message-ID: <1176385681.104884.119930@l77g2000hsb.googlegroups.com> (raw)
In-Reply-To: <1175494388.509572.267790@l77g2000hsb.googlegroups.com>

S.I.T.R.E.P

I changed the GPS compiler to Ada95 and fixed any compiler errors.
Once I did that (and without using dispatching or abstract types) I
was able to get the program _working_, again.  I made some other
changes to the overall design.  The schema type now has it's own file
for 'input and 'output so I don't have to read past it in the file
that contains the tuples.  I implemented accessor methods (set and
get) for the attributes of the attribute types and extentions.  So I
have getValue, setValue...

After all that was working I changed the attribute type to be abstract
and all it's methods to be abstract and implemented the to_disc
procedure again (dispatching for writing to disk).  That part worked.

After that I tried to implement the from_disc function (dispatching
from the disk).  Problem with this one is that when I used it, the
context of the call is for an attribute type and of course attribute
is abstract and therefore cannot be instantiated.  Here is a small
example:

attrib : attribute_ptr;
...
attrib.all := from_disc(fin, obj_of_desired_attribute_class.all)

but in order to do this, attrib has to be "not null" like the
following

attrib: attribute_ptr;
...
attrib := new attribute;
attrib.all := from_disc(fin, obj_of_desired_attribute_class.all)

and of course the type attribute is abstract so it cannot be
instantiated.


So I removed the abstract and implemented the methods for the
attribute type.  Now I can do:

attrib: attribute_ptr;
...
attrib := new attribute;
attrib.all := from_disc(fin, obj_of_desired_attribute_class.all);

but, it only ever dispatches to the from_disc of attribute even though
I've supplied an object of booleanattribute or stringattribute or
dateattribute or integerattribute as the actual parameter.  So now I
have some questions:

1.  If I have the following function defined for attribute type, and
also defined for types extending from attribute type, do they all need
to have attribute'class as the return value so that it dispatches
based on the actual parameter ONLY?

function from_disc(fin :ada.streams.stream_io.file_type; item:
attribute) return attribute;
function from_disc(fin :ada.streams.stream_io.file_type; item:
booleanattribute) return booleanattribute;
function from_disc(fin :ada.streams.stream_io.file_type; item:
integerattribute) return integerattribute;
function from_disc(fin :ada.streams.stream_io.file_type; item:
stringattribute) return stringattribute;
function from_disc(fin :ada.streams.stream_io.file_type; item:
dateattribute) return dateattribute;



The reason the program crashes NOW is because when from_disc is called
it only ever 'inputs an attribute type.  An attribute type is smaller
in size than the other attribute extentions.  So if the file actually
contains a booleanattribute then 'input will not read the full
booleanattribute; just the attribute.  This means that the fin file
pointer is not on end_of_file.  So a loop with the following sentinel;
not end_of_file(fin), will not break (exit) when it should because fin
is not at end_of_file and it will try to read another attribute.  Of
course for my test cases there is only one attribute in the file but
because we are not at end_of_file the program loops and tries to read
another attribute.

If from_disc were dispatching, then the correct extention of attribute
type would be 'input-ed and the fin file pointer would be at end of
file, the loop would exit properly and things would be okay.

Am I making any sense?

Andrew






  parent reply	other threads:[~2007-04-12 13:48 UTC|newest]

Thread overview: 46+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-04-02  6:13 STORAGE_ERROR : EXCEPTION_STACK_OVERFLOW andrew.carroll
2007-04-02 10:10 ` Stephen Leake
2007-04-02 14:11   ` andrew.carroll
2007-04-02 18:43     ` andrew.carroll
2007-04-02 21:48       ` Georg Bauhaus
2007-04-02 21:40         ` andrew.carroll
2007-04-03 10:25           ` Georg Bauhaus
2007-04-03 17:07             ` andrew.carroll
2007-04-03 19:43             ` Simon Wright
2007-04-03 21:32               ` andrew.carroll
2007-04-04  0:49               ` Georg Bauhaus
2007-04-04  0:32                 ` andrew.carroll
2007-04-05 18:28                   ` Georg Bauhaus
2007-04-09 13:12                     ` andrew.carroll
2007-04-09 18:19                       ` Georg Bauhaus
2007-04-10 13:22                         ` andrew.carroll
2007-04-10 15:07                           ` Ludovic Brenta
2007-04-10 20:55                             ` andrew.carroll
2007-04-10 22:17                               ` Georg Bauhaus
2007-04-10 21:43                                 ` andrew.carroll
2007-04-12  8:32                                   ` Ludovic Brenta
2007-04-11  1:55                               ` Jeffrey R. Carter
2007-04-11  2:34                                 ` andrew.carroll
2007-04-05  0:56                 ` andrew.carroll
2007-04-02 20:45     ` Simon Wright
2007-04-02 21:47       ` andrew.carroll
2007-04-02 22:05 ` andrew.carroll
2007-04-03  0:09   ` Randy Brukardt
2007-04-11  2:49 ` andrew.carroll
2007-04-11  8:07   ` Georg Bauhaus
2007-04-11 21:31   ` Simon Wright
2007-04-12 16:00     ` andrew.carroll
2007-04-12 19:08       ` Simon Wright
2007-04-12 13:48 ` andrew.carroll [this message]
2007-04-12 15:49   ` Georg Bauhaus
  -- strict thread matches above, loose matches on Subject: below --
2005-08-05  0:55 Adaddict
2005-08-05  1:21 ` Adaddict
     [not found] <200507082148.j68LmXhG002695@mail733.megamailservers.com>
2005-07-09  9:27 ` Marius Amado Alves
2005-07-09 19:14 ` Duncan Sands
     [not found] <20050709100024.322314C41FD@lovelace.ada-france.org>
2005-07-09 12:29 ` Robert C. Leif
2005-07-08 21:48 Robert C. Leif
2005-07-09  3:52 ` John B. Matthews
2005-07-12  0:29   ` jim hopper
2005-07-09 22:55 ` Björn Persson
2005-07-11 10:15 ` Alex R. Mosteo
2005-07-11 20:07 ` Keith Thompson
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox