Hi,
On Wed, 16 May 2001 [EMAIL PROTECTED] wrote:
> > This leaves us with two other possibilities:
> > a) Use 32 bit pointers as "generic" references
> > b) Use the 32 bits to store type information
> >
> > (b) would allow us to do additional checks; for example, we could
> > signal a
> > warning if arithmetics were performed on object pointers (this would
> > allow
> > us to detect problems in our code or evil hacks introduced by Sierra).
> >
> Could you explain me (b) way in more detail?
Basically, the idea is to store type information along with references.
Sierra SCI (pre-SCI32) expects all arithmetics to be performed on 16 bit
integer values. If, for example, we force the upper 16 bits to be zeroed
out for all results of arithmetical operations and make sure that all
object references have their MSB set, we could detect arithmetical
operations on object references by just testing whether the upper 16 bit
are /not/ zero.
Example:
pushi 0x42
; => stack = [0x00000042]
ldi 0x0c
; => acc = 0x0000000c
shl
; => stack = []
; => acc = 0x00002000 - upper 16 bits are zeroed out
(Nothing new so far.)
Second example:
class 0x17
; => ac = 0x80000017 - MSB signals "this is a class"
pushi 0x42
; => stack = [0x00000042]
add
; Error: Attempt to perform arithmetics on class address
Of course the naming scheme would have to be slighly more sophisticated
than that, since we need to cover lists, list nodes, the stack, dynamic
objects (clones) and references to static data (CWD etc.) as well, but
that's the basic idea.
llap,
Christoph