Version 6 (modified by cotto, 5 years ago) |
---|

The VM for the Smalltalk interpreter Squeak has a design similar to our eventual goal for Parrot, namely that it has a small core of operations implemented in C with the rest of the language being implemented in terms of these operations. In hope of jumpstarting the design and implementation of Lorito (aka L1), this page lists the 42 operations used by Squeak's VM. The hope is that a similar set of operations can be used as Lorito ops.

Because most Parrot developers are not familiar with Smalltalk, so the following table lists the operations used to implement Squeak (available here), example Smalltalk code, a description, their equivalent in C syntax and an appropriate name for the Lorito op. Many definitions were stolen from here.

Memory access goes through a set of 6 macros for reading and writing single bytes, 4-byte words and 8-byte floats.

Squeak operation | example Smalltalk code | description | equivalent C code |

& | logical and (no short-circuiting) | ||

| | logical or (no short-circuiting) | ||

and: | logical and (short-circuiting) | ||

or: | logical or (short-circuiting) | ||

not | logical not | ||

+ | 5+5 | addition | a = 5 + 5 |

- | 4-3 | subtraction | a = 4 - 3 |

* | 6*7 | multiplication | a = 6 * 7 |

// | 15//5 | division | a = 15 / 5 |

\\ | 7\\3 | mod | a = 7 % 3 |

max: | |a b| a := 1. b := 2. a max: b. | max | a = a>b?a:b; |

min: | |a b| a := 1. b := 2. a min: b. | min | a = a<b?a:b; |

bitAnd: | bitwise and | ||

bitOr: | bitwise or | ||

bitXor: | bitwise xor | ||

bitShift: | bitwise shift | ||

< | 5<3 | less than | a = 5 < 3 |

<= | 5<=3 | less than or equal | a = 5 <= 3 |

= | 5=3 | equality (deep) | a = 5 == 3 |

> | 5>3 | greater than | a = 5 > 3 |

>= | 5>=3 | greater than or equal | a = 5 <= 3 |

~= | 5=~3 | inequality (deep) | |

== | 5==5 | equality (shallow) | a = 5 == 5 |

isNil | null test | ||

notNil | non-null test | ||

whileTrue: | while loop | ||

whileFalse: | while loop | ||

to:do: | |||

to:by:do: | |||

ifTrue: | if | ||

ifFalse: | unless | ||

ifTrue:ifFalse: | if/else | ||

ifFalse:ifTrue: | |||

at: | hash/array read | ||

at:put: | hash/array write | ||

<< | |||

>> | |||

bitInvert32 | bitwise negation | ||

preIncrement | |||

integerValueOf: | |||

integerObjectOf: | |||

isIntegerObject: |