Test if an object is of a given class (from the VM)

Javier Lanatta javier at lanatta.com.ar
Mon Dec 8 14:41:32 UTC 2003


Hello,
	I'm trying to access an array of classes from the VM to test if an
object is of a class present on this array. The array is defined in the
specialObjectsArray and it was created using:

Smalltalk specialObjectsArray at: 58 put: (Array with: TestClass with:
Testclass2)

I'm using the following code (from the VM) to test if the "rcvr" is of a
given class present on the array:


arrayOfClasses _ self splObj: ArrayOfClasses.
arrayOfClassesSize _ self stSizeOf:arrayOfClasses.
i _ 0.
[i<arrayOfClassesSize] whileTrue:
[
	aClass _ self fetchPointer: i ofObject: arrayOfClasses.
	self assertClassOf: rcvr is: aClass.
	successFlag ifTrue: [self print:'Class found!';cr.found _ true].
	i _ i + 1.
].

The problem is that this code only works for the first item of the array...
That is if the object is a TestClass it works fine, but if the object is a
TestClass2 it does not work. Any ideas?

Regards,
	Javier




More information about the Squeak-dev mailing list