The Trunk: Compiler-eem.419.mcz

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

The Trunk: Compiler-eem.419.mcz

commits-2
Eliot Miranda uploaded a new version of Compiler to project The Trunk:
http://source.squeak.org/trunk/Compiler-eem.419.mcz

==================== Summary ====================

Name: Compiler-eem.419
Author: eem
Time: 12 March 2020, 10:28:24.737942 am
UUID: f0f3fd57-9e0f-414f-9a9f-7638120dd7aa
Ancestors: Compiler-eem.418

Fix a slip in enabling read-only literals.  The property of being read-only should apply recursively to all literals embedded in array literals.

Update the package postscript to apply this to existing array literals.

=============== Diff against Compiler-eem.418 ===============

Item was changed:
  ----- Method: Encoder>>litIndex: (in category 'encoding') -----
  litIndex: literal
  | p |
  p := literalStream position.
  p = self maxNumLiterals ifTrue:
  [self notify: 'More than ', self maxNumLiterals printString, ' literals referenced.\You must split or otherwise simplify this method.\The ' withCRs, (self maxNumLiterals + 1) printString, 'th literal is: ', literal printString. ^nil].
  literal isLiteral ifTrue: "filters out BlockClosures, ExternalLibraryFunctions"
+ [self setReadOnlyIfAppropriate: literal].
+ "Would like to show where it is in the source code, but that info is hard to get."
- [(literal isReadOnlyObject
- or: [literal isVariableBinding]) ifFalse:
- [literal setIsReadOnlyObject: true]].
- "Would like to show where it is in the source code,
- but that info is hard to get."
  literalStream nextPut: literal.
  ^p!

Item was added:
+ ----- Method: Encoder>>setReadOnlyIfAppropriate: (in category 'encoding') -----
+ setReadOnlyIfAppropriate: literal
+ "If literal is not read-only and should be, set it to be read-only, along with any other such literals it may contain."
+ (literal isReadOnlyObject
+ or: [literal isVariableBinding]) ifFalse:
+ [literal setIsReadOnlyObject: true.
+ literal isArray ifTrue:
+ [literal do: [:subLiteral| self setReadOnlyIfAppropriate: subLiteral]]]!

Item was changed:
  (PackageInfo named: 'Compiler') postscript: '"below, add code to be run after the loading of this package"
 
  "Make all relevant literals read-only, avoiding the recompile step, so as to avoid unbound methods"
  self systemNavigation allSelect:
+ [:m| | b |
+ b := #notNil.
+ b := [:lit| lit isCollection ifTrue: [lit beReadOnlyObject. lit isArray ifTrue: [lit do: b "do: b do:"]]].
- [:m|
  m allLiteralsDo:
  [:l|
  (l isLiteral
  and: [(l isCollection or: [l isNumber and: [l isReadOnlyObject not]])
  and: [(l isArray and: [m primitive == 117 and: [l == (m literalAt: 1)]]) not]]) ifTrue:
+ [b value: l]].
- [l beReadOnlyObject]].
  false]'!