From VisualWorks®, Release 5i.4 of November 12, 2001 on January 17, 2002 at 11:58:45 pm ChangeSet current addPatch: 'UPrims-VW7' <class> <name>UserPrimitives</name> <environment>Examples</environment> <super>Core.Object</super> <private>false</private> none <imports></imports> <category>User Primitives</category> </class> <name>UPErrorSignal</name> <environment>Examples.UserPrimitives</environment> <private>false</private> <constant>false</constant> <category>As yet unclassified</category> <name>FailCodes</name> <environment>Examples.UserPrimitives</environment> <private>false</private> <constant>false</constant> <category>As yet unclassified</category> <methods> Examples.UserPrimitives class <category>class initialization</category>
initFailCodes FailCodes := IdentityDictionary new: 20. FailCodes at: 0 put: 'failure code lost'. FailCodes at: -1 put: 'C argument out of range'. FailCodes at: -2 put: 'Smalltalk argument out of range'. FailCodes at: -3 put: 'argument not an object'. FailCodes at: -4 put: 'object incorrect type'. FailCodes at: -5 put: 'declared arg wrong type'. FailCodes at: -6 put: 'C int was not a SmallInteger'. FailCodes at: -7 put: 'C data structure too small'. FailCodes at: -8 put: 'Smalltalk datum too small to be represented in C'. FailCodes at: -9 put: 'Smalltalk datum too big to be represented in C'. FailCodes at: -10 put: 'Smalltalk object memory allocation failed'. FailCodes at: -11 put: 'arg count mismatch'. FailCodes at: -12 put: 'user primitive is not installed'. FailCodes at: -13 put: 'too many arguments'. FailCodes at: -14 put: 'no value returned'. FailCodes at: -15 put: 'assertion failure'
initialize "UserPrimitives initialize" UPErrorSignal := (Object errorSignal newSignalMayProceed: true) notifierString: 'User-defined primitive Error'; nameClass: self message: #errorSignal. self initFailCodes
</methods> <methods> Examples.UserPrimitives class <category>error reporting</category>
errorStringFor: code "Answer a string describing the error code." ^FailCodes at: code ifAbsent: ['error code ', code printString]
raiseError: anErrorCode "Raise a signal, with the failure code as an argument." ^self errorSignal raiseRequestWith: anErrorCode errorString: (self errorStringFor: anErrorCode)
</methods> <methods> Examples.UserPrimitives class <category>class accessing</category>
errorSignal "Return the standard error signal for user-defined primitive errors." ^UPErrorSignal
</methods> <comment> Examples.UserPrimitives
I am a place to hang behavior for user-defined primitives. My metaclass has protocol for interpreting error codes. Class Variables: FailCodes <IdentityDictionary> Maps standard failure codes to strings. UPErrorSignal <Signal> Standard exception signal for user-defined primitive errors. @(#)UPrims.st 63.13
</comment> <initialize> Examples.UserPrimitives </initialize>