Object subclass: Primitive [ primitive: aPrimitive on: anObject ifFailed: aBlock [ ^ aPrimitive isSmallInteger ifFalse: [ SystemExceptions.WrongClass signalOn: aPrimitive mustBe: SmallInteger ] ifTrue: [ aBlock value: aPrimitive value: anObject ] ] primitive: aPrimitive on: anObject with: aParameter1 ifFailed: aBlock [ ^ aPrimitive isSmallInteger ifFalse: [ SystemExceptions.WrongClass signalOn: aPrimitive mustBe: SmallInteger ] ifTrue: [ aBlock value: aPrimitive value: anObject value: aParameter1 ] ] primitive: aPrimitive on: anObject with: aParameter1 with: aParameter2 ifFailed: aBlock [ ^ aPrimitive isSmallInteger ifFalse: [ SystemExceptions.WrongClass signalOn: aPrimitive mustBe: SmallInteger ] ifTrue: [ aBlock valueWithArguments: {aPrimitive. anObject. aParameter1. aParameter2} ] ] primitive: aPrimitive on: anObject with: aParameter1 with: aParameter2 with: aParameter3 ifFailed: aBlock [ ^ aPrimitive isSmallInteger ifFalse: [ SystemExceptions.WrongClass signalOn: aPrimitive mustBe: SmallInteger ] ifTrue: [ aBlock valueWithArguments: {aPrimitive. anObject. aParameter1. aParameter2. aParameter3} ] ] primitive: aPrimitive on: anObject with: aParameter1 with: aParameter2 with: aParameter3 with: aParameter4 ifFailed: aBlock [ ^ aPrimitive isSmallInteger ifFalse: [ SystemExceptions.WrongClass signalOn: aPrimitive mustBe: SmallInteger ] ifTrue: [ aBlock valueWithArguments: {aPrimitive. anObject. aParameter1. aParameter2. aParameter3. aParameter4} ] ] primitive: aPrimitive on: anObject withArguments: anArray ifFailed: aBlock [ aPrimitive isSmallInteger ifFalse: [ ^ SystemExceptions.WrongClass signalOn: aPrimitive mustBe: SmallInteger ]. anArray isArray ifFalse: [ ^ SystemExceptions.WrongClass signalOn: anArray mustBe: Array ]. ^ aBlock value: aPrimitive value: anObject value: anArray ] ] Eval [ | array | [ (Primitive new primitive: $a on: 1 ifFailed: [ :aPrimitive :anObject | ]). 'KO' printNl. ] on: Error do: [ :err | 'OK' printNl ]. (Primitive new primitive: VMpr_Object_basicAt on: #(14 24 34) ifFailed: [ :aPrimitive :anObject | (aPrimitive == VMpr_Object_basicAt and: [ anObject = #(14 24 34) ]) ifTrue: [ 'OK' printNl] ifFalse: [ 'KO' printNl ] ]). (Primitive new primitive: VMpr_Object_class on: 1 ifFailed: [ :aPrimitive :anObject |'KO' printNl. ]) == SmallInteger ifTrue: [ 'OK' printNl ] ifFalse: [ 'KO' printNl ]. (Primitive new primitive: VMpr_Object_basicAt on: #(14 24 34) with: 1 ifFailed: [ :aPrimitive :anObject :arg1 | 'KO' printNl ]) == 14 ifTrue: [ 'OK' printNl ] ifFalse: [ 'KO' printNl ]. (Primitive new primitive: VMpr_Object_basicAtPut on: #(14 24 34) with: 1 with: 'abc' ifFailed: [ :aPrimitive :anObject :arg1 :arg2 | (aPrimitive == VMpr_Object_basicAtPut and: [ anObject = #(14 24 34) and: [ arg1 == 1 and: [ arg2 = 'abc' ] ] ]) ifTrue: [ 'OK' printNl ] ifFalse: [ 'KO' printNl ] ] ). array := Array with: 14 with: 24 with: 34. (Primitive new primitive: VMpr_Object_basicAtPut on: array with: 1 with: 'abc' ifFailed: [ :aPrimitive :anObject :arg1 :arg2 | ] ) = 'abc' ifTrue: [ 'OK' printNl] ifFalse: [ 'KO' printNl ]. (array at: 1) = 'abc' ifFalse: [ 'KO' printNl ]. "b VMpr_Object_primitiveOn" array := Array with: 14 with: 24 with: 34. (Primitive new primitive: VMpr_Object_basicAt on: array withArguments: #(1) ifFailed: [ :aPrimitive :anObject :anArray | ]) == 14 ifFalse: [ 'KO' printNl ] ifTrue: [ 'OK' printNl ]. array := Array with: 14 with: 24 with: 34. (Primitive new primitive: VMpr_Object_basicAtPut on: array withArguments: #(1 2) ifFailed: [ :aPrimitive :anObject :anArray | ]). (array at: 1) == 2 ifTrue: [ 'OK' printNl ] ifFalse: [ 'KO' printNl ]. array := Array with: 14 with: 24 with: 34. (Primitive new primitive: VMpr_Object_basicAtPut on: #(14 24 34) withArguments: #(1 2) ifFailed: [ :aPrimitive :anObject :anArray | 'OK' printNl ]). "b VMpr_Object_primitiveOnWithArguments" ]