05.08.2014 Views

here - Stefan-Marr.de

here - Stefan-Marr.de

here - Stefan-Marr.de

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

7.2. Virtual Machine Support<br />

1 void primitiveClone () {<br />

2 Oop x = stackTop ();<br />

3<br />

4 if ( requires_<strong>de</strong>legation (x, Domain :: PrimShallowCopy__Mask )) {<br />

5 request_primitive_clone ();<br />

6 return ;<br />

7 }<br />

8<br />

9 if (x. is_int ()) // is immediate value , no copying necessary<br />

10 return ;<br />

11<br />

12 Oop nc = x. as_object ()-> clone ();<br />

13 popThenPush (1 , nc );<br />

14 }<br />

15<br />

16 void request_primitive_clone () {<br />

17 Oop value = stackTop ();<br />

18 Oop domain = value . as_object ()-> domain_oop ();<br />

19<br />

20 popThenPush (1 , domain );<br />

21 push ( value );<br />

22<br />

23 set_argumentCount (1);<br />

24<br />

25 roots . messageSelector = The_Domain . prim_shallow_copy ();<br />

26 roots . lkupClass = domain . fetchClass ();<br />

27<br />

28 commonSend ( roots . lkupClass );<br />

29 }<br />

Listing 7.4: Adapted primitive for shallow object copies.<br />

195

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!