'From Squeak3.11alpha of 22 May 2011 [latest update: #11440] on 23 May 2011 at 11:32:52 pm'! "Change Set: InterpreterPlugins-primitiveFailFor-speedup-dtl Date: 23 May 2011 Author: David T. Lewis Recode #failed, #successful, and #success: for performance when translated to C. The main performance benefit comes from #failed. Simulator subclasses must reimplement these for execution in Smalltalk. Do not use #cCode:inSmalltalk: as this requires knowledge of the interpreter global structure, hence the use of overrides in interpreter subclasses."! !InterpreterPrimitives methodsFor: 'primitive support' stamp: 'dtl 5/23/2011 21:22'! failed "Answer true if primFailCode is not zero. This implementation is only for translation to C, and should not be modified without testing performance. Simulator subclasses must override this method as primFailCode ~= 0. Do not use #cCode:inSmalltalk: as this requires knowledge of the interpreter global structure." ^primFailCode "override in simulator as primFailCode ~= 0"! ! !InterpreterPrimitives methodsFor: 'primitive support' stamp: 'dtl 5/23/2011 22:09'! success: successBoolean "Set the state of the primitive failure code/success flag, iff successBoolean is false. If primFailCode is non-zero a primitive has failed. If primFailCode is greater than one then its value indicates the reason for failure." "Use returnTypeC: #sqInt because that's the way it is defined in sq.h. Use no explicit return so that Slang doesn't fail an inlin ingtype-check when a primitive with return type void uses ^self success: false to exit." successBoolean ifFalse: ["Don't overwrite an error code that has already been set." self successful ifTrue: [primFailCode := 1]]! ! !InterpreterPrimitives methodsFor: 'primitive support' stamp: 'dtl 5/23/2011 21:34'! successful "Answer the state of the primitive failure code/success flag. If primFailCode is non-zero a primitive has failed. If primFailCode is greater than one then its value indicates the reason for failure. This implementation is only for translation to C, and should not be modified without testing performance. Simulator subclasses must override this method as primFailCode == 0. Do not use #cCode:inSmalltalk: as this requires knowledge of the interpreter global structure." ^primFailCode not "override this in simulator as primFailCode == 0"! ! !InterpreterProxy methodsFor: 'other' stamp: 'dtl 5/23/2011 21:36'! failed ^primFailCode ~= 0! ! !InterpreterProxy methodsFor: 'other' stamp: 'dtl 5/23/2011 21:44'! success: aBoolean self failed ifTrue:[^self]. aBoolean ifFalse: [ primFailCode := 1. (self confirm:'A primitive is failing -- Stop simulation?') ifTrue:[self halt]] ! ! !InterpreterProxy methodsFor: 'other' stamp: 'dtl 5/23/2011 22:22'! successful ^primFailCode == 0! !