List Info

Thread: reverse class order for instvar indexing




reverse class order for instvar indexing
user name
2006-12-30 06:06:12
Array
reverse class order for instvar indexing
user name
2006-12-31 16:03:41
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



_______________________________________________
help-smalltalk mailing list
help-smalltalkgnu.org

http://lists.gnu.org/mailman/listinfo/help-smalltalk
[1-2]

about | contact  Other archives ( Real Estate discussion Medical topics )