05.08.2014 Views

here - Stefan-Marr.de

here - Stefan-Marr.de

here - Stefan-Marr.de

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

5.4. Semantics of the MOP<br />

1 SOMObject = ( | " ... " domain | " ... "<br />

2 postAllocate = (<br />

3 domain := interpreter frame domain<br />

4 initialDomainForNewObjects ) )<br />

5<br />

6 SOMFrame = SOMArray ( | " ... " enforced | " ... "<br />

7 enforced = ( ^ enforced )<br />

8 enforced : aBool = ( enforced := aBool ) )<br />

9<br />

10 SOMInvokable = SOMObject ( | " ... " attribute | " ... "<br />

11 unenforced = ( ^ attribute == # unenforced ) )<br />

12<br />

13 SOMUniverse = ( | globals symbolTable interpreter | " ... "<br />

14 bootstrapFrameWithArguments : args = (<br />

15 ( interpreter pushNewFrameWithMethod : self bootstrapMethod )<br />

16 push : ( self globalAt : # system );<br />

17 push : args ;<br />

18 enforced : false ) )<br />

Listing 5.4: Structural Changes to support the OMOP in SOM<br />

The execution of a program starts from a bootstrap frame created by the<br />

#bootstrapFrameWithArguments: method in SOMUniverse. The initialization<br />

of the bootstrap frame sets the execution mo<strong>de</strong> to unenforced. This gives an<br />

application the freedom to set up the runtime environment properly before<br />

it continues with its normal execution in enforced mo<strong>de</strong>. However, this also<br />

implies that a language implementation on top of the OMOP needs to opt-in<br />

to the enforced execution mo<strong>de</strong>, which can make it prone to incorrect use by<br />

a language implementer.<br />

Lst. 5.5 shows the adapted implementation of the POP_FIELD byteco<strong>de</strong>. During<br />

unenforced execution, the value that was on the top of the stack is stored<br />

directly into the receiver. When the OMOP’s semantics are enforced however,<br />

it triggers the intercession handler by sending #write:toField:of: to the<br />

receiver’s domain to reify the store operation. Note that the operations of<br />

the OMOP are executed with enforcement disabled. As shown in previous<br />

domain <strong>de</strong>finitions such as Lst. 5.1 and Lst. 5.3, the OMOP operations are annotated<br />

with unenforced. The implementation of #pushNewFrameWithMethod<br />

will make sure that in these cases the unenforced flag overri<strong>de</strong>s normal propagation<br />

of the enforcement flag of the frame.<br />

Lst. 5.6 shows the corresponding read operation. It pushes the value of an<br />

object field onto the operand stack. The main difference between POP_FIELD<br />

125

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

Saved successfully!

Ooh no, something went wrong!