Hi. There is something I don't understand about #cannotInterpret and maybe you can help me. Since I am not sure if this is more image side or vm, I did a cross post, sorry for that.<br>Context: I am implementing proxies for classes. Since I want that a proxy loads back the original object when receiving the message #class, I have removed from the compiler the shortcut bytecode for class, with this:<br>
<br>(ParseNode classVarNamed: 'StdSelectors') removeKey: #class ifAbsent: [].<br><br>Now, my testcase is something like this:<br><br> | inst proxy |<br> "This is the simplest test that does the less assert as possible."<br>
inst := ClassWith1Var new.<br> self assert: inst foo = 'foo'.<br> proxy := ClassProxyInstVar new.<br> proxy become: ClassWith1Var.<br> "here I can send any message, it is just to load back the original class"<br>
inst basicIdentityHash.<br> self assert: (inst class == ClassWith1Var).<br> self assert: inst foo = 'foo'.<br><br><br>ProtoObject subclass: #ClassProxyInstVar<br> instanceVariableNames: 'superclass methodDict format actualClass'<br>
classVariableNames: ''<br> poolDictionaries: ''<br> category: 'Proxies'<br><br><br>ClassProxyInstVar >> initialize<br> super initialize.<br> superclass := ProxySuperclass.<br>
methodDict := nil.<br> actualClass := self<br><br><br>So...with this i can use an instance of ClassProxyInstVar like a class. When an instance of the class receives a message, the methodDict will be in nil, and then the VM will send the #cannotInterpret. and there I want to put back the original class. Then I do:<br>
<br>ProxySuperclass >> cannotInterpret: aMessage<br> Transcript cr; <br> show: 'cannotInterpret:';<br> space;<br> show: aMessage selector..<br> self class restore.<br> ^aMessage sendTo: self<br>
<br>Now, this is working, but there is something I DO NOT UNSERSTAND. When I try to do the "inst basicIdentityHash" the VM will send the #cannotInterpret to ProxySuperclass because the methodDict was nil in ClassProxyInstVar. Ok, perfect. What I don't understand is how the method #cannotInterptet can be run perfeclty in this case, since I am doing a "self class restore" there. Remember I removed the shortcut bytecode, so #class is sent like any normal message. So, my question is, when sending "self class", why the VM doesn't call #cannotInterpter again like it did it when I did " inst basicIdentityHash." ? in other words...why the VM isn't entering in a loop ? There is something I am not seeing.<br>
<br>Thanks for any help in advance,<br><br>Mariano<br>