@Peter: I'm not sure if spin nows to only include one copy of the object program when one of the copies is a sub-object of another sub-object. I think what your code is doing is including two copies of obj1 including code and variables. All you are doing is resetting the variable base for the copy in obj2 to point back to the variables in main. If you want to run the actual code in main then you will need to do the same thing with the object pointers as well as the variable pointers.
@Peter: just had a look at the code I posted before and
PUB getObjectAddress(index)
' if index==1 'using the absolute addresses
' return word[noparse][[/noparse] @endOfObjects-4 ]
' elseif index==0
' return word[noparse][[/noparse] @endOfObjects-8 ]
'or if you want the absolute address and not the offset (makes finding the new offset easier)
if index==1
return word[noparse][[/noparse] @endOfObjects-4]+$10 'the $10 is where the first object starts
elseif index==0
return word[noparse][[/noparse] @endOfObjects-8]+$10
should have been
PUB getObjectAddress(index)
' if index==1 'using the absolute addresses
' return word[noparse][[/noparse] @endOfObjects-4+2 ]
' elseif index==0
' return word[noparse][[/noparse] @endOfObjects-8+2 ]
'or if you want the absolute address and not the offset (makes finding the new offset easier)
if index==1
return word[noparse][[/noparse] @endOfObjects-4+2]+$10 'the $10 is where the first object starts
elseif index==0
return word[noparse][[/noparse] @endOfObjects-8+2]+$10
As far as I know, the methods and DAT area of an object are included only once in the compilation
no matter how many instances you use of·that object. Only the VAR section is different
for every instance of the object.
@ Steven : Yes, only one copy of any object's executable code and DAT in hub memory no matter how many times or where the object is used.
This is the trick which allows a "debugging object" to be included whereever it's needed without worrying about massively inflating the size of the code. The proof is had by adding more objects of the same type and using F8 to note memory use doesn't increase by much.
hippy said...
@ Steven : Yes, only one copy of any object's executable code and DAT in hub memory no matter how many times or where the object is used.
This is the trick which allows a "debugging object" to be included whereever it's needed without worrying about massively inflating the size of the code. The proof is had by adding more objects of the same type and using F8 to note memory use doesn't increase by much.
@Hippy, in the JVM development, we hit at least one exception to the rule.
The problem is related to using a large array (everything's relative) about 16KB.
Reorganizing how the file was included avoided the issue.
See JVM for Prop page 4, Peter Posted 2/6/2008 10:16 PM (GMT -8)
Comments
Steven
Yes, as d in file obj2 is of type obj1 and I want to call obj1 that is declared in main.
So the object base is identical.
regards peter
Steven
should have been
but I think you figured that out.
Steven
no matter how many instances you use of·that object. Only the VAR section is different
for every instance of the object.
regards peter
This is the trick which allows a "debugging object" to be included whereever it's needed without worrying about massively inflating the size of the code. The proof is had by adding more objects of the same type and using F8 to note memory use doesn't increase by much.
The problem is related to using a large array (everything's relative) about 16KB.
Reorganizing how the file was included avoided the issue.
See JVM for Prop page 4, Peter Posted 2/6/2008 10:16 PM (GMT -8)
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
jazzed·... about·living in·http://en.wikipedia.org/wiki/Silicon_Valley
Traffic is slow at times, but Parallax orders·always get here fast 8)