The Trunk: ShoutCore-ct.73.mcz

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

The Trunk: ShoutCore-ct.73.mcz

commits-2
Levente Uzonyi uploaded a new version of ShoutCore to project The Trunk:
http://source.squeak.org/trunk/ShoutCore-ct.73.mcz

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

Name: ShoutCore-ct.73
Author: ct
Time: 28 September 2019, 11:31:09.24777 pm
UUID: 27e05259-bafa-0749-827d-b54de84bb8d2
Ancestors: ShoutCore-ct.72

Fixes a bug in context-dependent styling, as described in [1].

Until proved otherwise, we cannot distinguish between args and tempvars via DebuggerMap, so shout-reparse the original context source up to the place where the provided context starts and access the active variables from the nested shout parser.

(Minimal example to reproduce the old bug: Do it:
[:x| [:z | (x*z) halt] value: 7] value: 6
And style [z] in the context of #halt - it was wrongly styled as a tempvar before.)

[1] http://forum.world.st/Distinguishing-temp-vars-and-arguments-via-DebuggerMap-td5104614.html

=============== Diff against ShoutCore-ct.72 ===============

Item was added:
+ ----- Method: SHParserST80>>activeArguments (in category 'accessing') -----
+ activeArguments
+ "Parsed arguments that are in the active scope"
+ ^ arguments!

Item was added:
+ ----- Method: SHParserST80>>activeTemporaries (in category 'accessing') -----
+ activeTemporaries
+ "Parsed temporaries that are in the active scope"
+ ^ temporaries!

Item was changed:
  ----- Method: SHParserST80>>initializeInstanceVariables (in category 'parse support') -----
  initializeInstanceVariables
 
  instanceVariables := classOrMetaClass
  ifNil: [ #() ]
  ifNotNil: [ classOrMetaClass allInstVarNames asArray ].
  allowUnderscoreAssignments := Scanner allowUnderscoreAsAssignment.
  allowUnderscoreSelectors := Scanner prefAllowUnderscoreSelectors.
  allowBlockArgumentAssignment := Scanner allowBlockArgumentAssignment.
  sourcePosition := 1.
  arguments
  ifNil: [ arguments := OrderedCollection with: nil ]
  ifNotNil: [ arguments reset; addLast: nil ].
  temporaries
  ifNil: [ temporaries := OrderedCollection with: nil ]
  ifNotNil: [ temporaries reset; addLast: nil ].
+ context ifNotNil: [ self initializeVariablesFromContext ].
- context ifNotNil: [
- | contextArgumentCount contextVariableNames |
- contextArgumentCount := context numArgs.
- contextVariableNames := context tempNames asOrderedCollection.
- contextArgumentCount > 0 ifTrue: [
- arguments at: 1 put: (contextVariableNames first: contextArgumentCount) ].
- contextArgumentCount < contextVariableNames size ifTrue: [
- temporaries at: 1 put: (contextVariableNames allButFirst: contextArgumentCount) ] ].
  bracketDepth := 0.
  ranges
  ifNil: [ ranges := OrderedCollection new: 40 "Covers over 80% of all methods." ]
  ifNotNil: [ ranges reset ]!

Item was added:
+ ----- Method: SHParserST80>>initializeVariablesFromContext (in category 'parse support') -----
+ initializeVariablesFromContext
+
+ | contextSourcePcIndex contextSourceParser |
+ contextSourcePcIndex := (context debuggerMap
+ rangeForPC: context pc
+ in: context method
+ contextIsActiveContext: true "little white lie to work in every situation")
+ start.
+ contextSourceParser := self class new
+ classOrMetaClass: context method methodClass;
+ environment: self environment;
+ source: (context method getSource first: contextSourcePcIndex);
+ yourself.
+ contextSourceParser parse.
+ arguments at: 1 put: ((contextSourceParser activeArguments
+ reject: #isNil) gather: #yourself) asOrderedCollection.
+ temporaries at: 1 put: ((contextSourceParser activeTemporaries
+ reject: #isNil) gather: #yourself) asOrderedCollection.!