help-smalltalk
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Help-smalltalk] reverse class order for instvar indexing


From: Paolo Bonzini
Subject: Re: [Help-smalltalk] reverse class order for instvar indexing
Date: Sun, 31 Dec 2006 17:03:41 +0100
User-agent: Thunderbird 1.5.0.9 (Macintosh/20061207)

Stephen Compall wrote:
I was getting instvar indexing conflicts (different classes would choose
instvar 0 for different instvars) in Compiler until the attached tiny
patch to STSymbolTable>>#declareEnvironment:.  Iterating from the other
end of the inheritance tree seems to be what is intended by the readOnly
calculation semantics, anyway.

Applied the patch, and reworked the readOnly stuff to be correct. See the equivalent snippet of libgst/sym.c, where if the method is trusted all variables are read-write (in is_instance_variable_read_only).

@@ -157,18 +157,19 @@ addPool: poolDictionary

 declareEnvironment: aBehavior

-    | i readOnly |
+    | i canAlwaysStore inSandbox |
     environment := aBehavior.
+    inSandbox := thisContext isUntrusted.

     i := -1.
-    readOnly := aBehavior isUntrusted not and: [ thisContext isUntrusted ].
-    aBehavior withAllSuperclassesDo: [ :class |
-       readOnly := readOnly and: [ class isUntrusted not ].
+    canAlwaysStore := aBehavior isUntrusted.
+    aBehavior withAllSuperclasses reverseDo: [ :class |
+       canAlwaysStore := canAlwaysStore and: [ class isUntrusted ].
        class instVarNames do: [ :iv |
            instVars at: iv asSymbol put: (STVariable
                id: (i := i + 1)
                scope: 0
-               canStore: readOnly not).
+               canStore: (canAlwaysStore or: [ inSandbox not ])).
        ].
     ].
     self declareGlobals

Paolo





reply via email to

[Prev in Thread] Current Thread [Next in Thread]