Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve isAssociation() in vm.primitives.js #125

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

ccrraaiigg
Copy link
Contributor

We have a Global in the special objects array, so we can be rather more specific in isAssociation(). This bit me when marshaling a complex object for use with the JS bridge.

We have a Global in the special objects array, so we can be rather more specific in isAssociation(). This bit me when marshaling a complex object for use with the JS bridge.
Copy link
Owner

@codefrau codefrau left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, good idea to be more specific, but in older images

(Smalltalk specialObjectsArray at: 4) class === Association

so maybe we need to check that the superclass chain includes LookupKey ?

@codefrau
Copy link
Owner

Alternatively, we could iterate through the array and make sure every entry is a 2-pointer object and the first of these 2 is a bytes object (ByteSymbol / ByteString).

@ccrraaiigg
Copy link
Contributor Author

Hm, I still would have been bitten. Perhaps we could check both the old and new special objects array cases, and answer true if either of them is a match?

@codefrau
Copy link
Owner

codefrau commented Mar 31, 2021

Okay. We could try to find (and maybe cache) LookupKey class by following the superclass chain from the Processor global to the class that has only 1 instance variable:

(Smalltalk specialObjectsArray at: 4) class withAllSuperclasses collect: [:c | c -> c instSize] 

Global->2 Binding->1 LookupKey->1 Magnitude->0 Object->0 ProtoObject->0

Association->2 LookupKey->1 Magnitude->0 Object->0 

So maybe something like

  1. LookupKey = starting at schedAssoc.sqClass, go up superclass chain until we find a class satisfying cls.pointers[0].classInstSize() === 0
  2. Object in question is an Association if its superclass is LookupKey and it has 2 inst vars.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants