ParseNode question
Dan Ingalls
DanI at wdi.disney.com
Wed Feb 3 17:26:29 UTC 1999
"Leandro Caniglia" <caniglia at dm.uba.ar> wrote...
>Is it possible for a VariableNode to decide if it is an instance variable
>reference?
[I answered this privately but, in case others are interested...]
Not easily. I have been bothered by this before, and the situation is even worse with the recent extention to 256 ivars. I should have cleaned it up then, but didn't. However, look at the code in Encoder...
init: aClass context: aContext notifying: req
| node n homeNode indexNode |
requestor _ req.
class _ aClass.
nTemps _ 0.
supered _ false.
self initScopeAndLiteralTables.
n _ -1.
class allInstVarNames do:
[:variable |
node _ VariableNode new
name: variable
index: (n _ n + 1)
type: LdInstType.
scopeTable at: variable put: node].
etc...
My suggestion is to add a new ivar to VariableNode, called 'type' or 'loadType', and simply store into it the value passed in as 'type:' in the creation messages. Then, testing for instvars should be as simple as
^ type = LdInstType
I would include this for clarity, even if it's not needed in the system right now.
Otherwise the only way I can see is to duplicate the hideous tests in code generation 8-(.
Good luck.
- Dan
More information about the Squeak-dev
mailing list
|