? Can I modify ANY like this ?

22 views
Skip to first unread message

Jimmy Johnson

unread,
Jun 10, 2015, 1:47:13 PM6/10/15
to eiffelst...@googlegroups.com
Can I change class ANY as shown below without breaking something?

How much overhead does this change add to objects?  Are the boolean values one bit, one byte, 32 bits...?

Also, if `pid' is declared of type PID (where that class was available by adding it to the kernel cluster), I get error "
    Error code: Library_error

    Error: Particular class content does not match what compiler is expecting.
    What to do: Make sure you haven't modified one of the kernel classes on which
      compiler relies.
    Class ARRAY[G]
    Class ARRAY must have exactly one attribute of reference type.
Is there a simple explanation to the reasoning for this?

thanks,
jjj


class ANY

feature -- Customization

modified_objects: LINKED_SET [ANY]
-- Usable by the auto-persist system to maintain a list of
-- objects that were modified through an assignment or creation
-- applied to one of its attributes since the last store operation.
-- This feature need not be called for a normal (i.e. non-
-- persistent system; code using this feature is added by the
-- persistence pre-processor tool.
once
create Result.make
end

on_modified (a_object: ANY)
-- Adds `a_object' to `modified_objects' if `a_object' `is_persistable'.
-- This feature need not be called for a normal (i.e. non-
-- persistent system; code using this feature is added by the
-- persistence pre-processor tool.
do
is_clean := false
if is_persistable then
modified_objects.extend (a_object)
end
end

is_clean: BOOLEAN
-- Is Current in the same state as it was after the last store operation?
-- (I.e. is Current unchanged?)
-- Set by `on_modified' and cleared by the peristent system when
-- the object is written to the external store.

is_persistable: BOOLEAN
-- Is Current automatically persistable?  Objects of type {PERSISTABLE}
-- are `is_persistable' by default; other object become `is_persistable'
-- through reachability from some other object that `is_persistable' or
-- if the programmer "manually" persists the object using features of the
-- persistence cluster.
do
-- Result := not pid.is_void
Result := pid /= 0
end

-- pid: PID
pid: NATURAL_32
-- The persistent identifier for Current.  Initially set to `is_void (i.e.
-- the representation of a Void reference, but changed by the persistent
-- system when the object becomes (i.e. to make the object) `is_persistable'.
-- attribute
-- create Result
-- end

feature -- Access

Jimmy Johnson

unread,
Jun 11, 2015, 12:21:01 AM6/11/15
to eiffelst...@googlegroups.com
Okay, I just tried using a modified ANY in a system.  Where I expected to get various natural numbers as output I get all zero's.  Also, running my auto test routines gives this error:  "Cannot read buffer size from header.:  Serialization failed."

The program runs fine when the two once features are included in ANY, but if I add a single attribute, such as `is_clean: BOOLEAN' to ANY I get the above errors.

I have assumed that the "customization" section of ANY is there for what I am trying to do.  Is there some other steps I should take to make a custom version of ANY work?

Thanks,
Jimmy J. Johnson



Emmanuel Stapf

unread,
Jun 12, 2015, 4:35:56 AM6/12/15
to eiffelst...@googlegroups.com

Hi,

 

Adding attributes to ANY is going to break anything based on storables which is the case of AutoTest so this is not surprising. To make AutoTest, you will need to bootstrap EiffelStudio with your modified version of ANY.

 

As for your previous questions:

- BOOLEAN takes up to 1 byte, however with memory alignment, it might actually add up to 8 bytes on 64-bit machines.

- Due to some optimizations/assumptions on the runtime part, we can only have one reference attribute in the class STRING_xx and ARRAY. This enables some optimizations in accessing the SPECIAL object for fast access to items of a string or an array.

 

Regards,

Manu

 

--
For more messaging options, visit this group at http://forum.eiffel.com.
Information on the Eiffelstudio project: http://dev.eiffel.com.

Jimmy Johnson

unread,
Jun 12, 2015, 9:29:20 AM6/12/15
to eiffelst...@googlegroups.com, ma...@eiffel.com
I suspected that for autotest.  So, "bootstrap EiffelStudio" means compile EiffelStudio as per https://dev.eiffel.com/Compiling_EiffelStudio ?

Okay, I think I can live with the one attribute restriction.

Even so, it seems programs are not working when I add a single [NATURAL_32] attribute to ANY.  In one of my programs it appears the INTEGER_32.max is returning zero instead of one of the two numbers, but I'm not sure.  The debugger will not pause at a stop point set in INTEGER_32.max or jump into that routine; it just goes to the next call.  Another [Vision2] application also does not work.  In this one I step into a routine to line "Result := word.to_hex_string" where word is a NATURAL_32 with a non-zero value.  When stepping into `to_hex_string', Current (i.e. word) is shown as zero.

I will try to reproduce this on as small a system as possible.

As always, thanks for your help,
jjj

Jimmy Johnson

unread,
Jun 12, 2015, 9:40:15 AM6/12/15
to eiffelst...@googlegroups.com, ma...@eiffel.com
Manu,

This produces the error I mentioned in other post:

make
-- Run application.
local
n: NATURAL_32
do
n := 999
print (n.out)
end

In NATURAL_32.out, Current is zero, not 999.


Emmanuel Stapf

unread,
Jun 17, 2015, 2:03:42 AM6/17/15
to Jimmy Johnson, eiffelst...@googlegroups.com

Does this output `999’?

 

Manu

Jimmy Johnson

unread,
Jun 17, 2015, 8:27:48 PM6/17/15
to eiffelst...@googlegroups.com, ma...@eiffel.com, jjj...@g.uky.edu
It outputs zero.

Jimmy Johnson

unread,
Jun 17, 2015, 9:10:19 PM6/17/15
to eiffelst...@googlegroups.com, jjj...@g.uky.edu, ma...@eiffel.com
I just tried (again) to reproduce this and now I get 999 as I would expect.  I don't understand.  I'll get back to you



On Wednesday, June 17, 2015 at 2:03:42 AM UTC-4, Emmanuel Stapf wrote:

Jimmy Johnson

unread,
Jun 17, 2015, 9:26:49 PM6/17/15
to eiffelst...@googlegroups.com, ma...@eiffel.com, jjj...@g.uky.edu
This is odd.  The original code was:
  make
    local: n: NATURAL_32
  do
    n := 999
    print (n.out)
  end   

Making any changes seems to break it (e.g. changing "999" to "998".)  Freezing seems to fix it.



On Wednesday, June 17, 2015 at 2:03:42 AM UTC-4, Emmanuel Stapf wrote:

Emmanuel Stapf

unread,
Jun 18, 2015, 9:37:34 AM6/18/15
to Jimmy Johnson, eiffelst...@googlegroups.com

Are you running this code using the EiffelStudio delivery from Eiffel Software, or your own modified copy?

Jimmy Johnson

unread,
Jun 18, 2015, 2:44:36 PM6/18/15
to eiffelst...@googlegroups.com, jjj...@g.uky.edu, ma...@eiffel.com
The only modification is to class ANY; I added an attribute.

But, you make me think...  I am running the GPL version of the compiler, but the ISE_SOURCE and ISE_LIBRARY are from the 15.01_dev directory downloaded from the development site.  That is, in .profile:

#additions for Eiffel
export ISE_PLATFORM=macosx-x86-64
export ISE_EIFFEL=/Applications/MacPorts/Eiffel_15.01
export GOBO=$ISE_EIFFEL/library/gobo/svn
export PATH=$PATH:$ISE_EIFFEL/studio/spec/$ISE_PLATFORM/bin:$GOBO/../spec/$ISE_PLATFORM/bin
#end additions for Eiffel

#additions for Compiling Eiffel
export EIFFEL_SRC=/Users/jjj/15.01_dev
export ISE_LIBRARY=/Users/jjj/15.01_dev
#end additions for Compiling Eiffel

Why do you ask?  Do you expect this (i.e. adding an attribute to ANY) to work?  If so, should it work for SPECIAL objects?  expanded?

Emmanuel Stapf

unread,
Jun 18, 2015, 4:08:06 PM6/18/15
to Jimmy Johnson, eiffelst...@googlegroups.com

Then this is normal you are getting 0.

 

What is happening is that the implementation of `out’ applied to to a reference version of a basic type is simply looking at the first field of the object. If you added a field that happens to be at the place where we expect `item’ to be, then you get 0. When you freeze, we optimize the call to not use the object representation of `n’.

Jimmy Johnson

unread,
Jun 18, 2015, 4:42:43 PM6/18/15
to eiffelst...@googlegroups.com, ma...@eiffel.com, jjj...@g.uky.edu
So, can I force the field to be added some place other than where you look for `item'? 

Emmanuel Stapf

unread,
Jun 18, 2015, 5:01:15 PM6/18/15
to Jimmy Johnson, eiffelst...@googlegroups.com

If this is a reference field, you cannot as references always appear before any other fields. Changing the order of fields is actually not recommended as it effects the runtime (garbage collection) and some compiler optimizations.

Reply all
Reply to author
Forward
0 new messages