The Trunk: System-eem.709.mcz

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

The Trunk: System-eem.709.mcz

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

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

Name: System-eem.709
Author: eem
Time: 20 March 2015, 12:33:44.474 pm
UUID: c5ffe3f2-3a6a-4110-9d9b-ebb72d5334c3
Ancestors: System-eem.708

Fix breakpoint source when pragmas follow temporaries.

=============== Diff against System-eem.708 ===============

Item was changed:
  ----- Method: BreakpointManager class>>compilePrototype:in: (in category 'private') -----
  compilePrototype: aSymbol in: aClass
  "Compile and answer a new method containing a break statement"
 
+ | oldSource parser methodNode breakOnlyMethodNode sendBreakMessageNode hasTemps newSource mark positionParser markBeforePragmas pragmasFollowTemps |
- | oldSource parser methodNode breakOnlyMethodNode sendBreakMessageNode hasTemps newSource mark |
  oldSource := aClass sourceCodeAt: aSymbol.
  parser := aClass newParser.
  methodNode := parser
  parse: oldSource
  class: aClass
  noPattern: false
  notifying: nil
  ifFail: [self error: '[breakpoint] unable to install breakpoint'].
  breakOnlyMethodNode := aClass newCompiler
  compile: 'temporaryMethodSelectorForBreakpoint self break. ^self'
  in: aClass
  notifying: nil
  ifFail: [self error: '[breakpoint] unable to install breakpoint'].
  sendBreakMessageNode := breakOnlyMethodNode block statements first.
  methodNode block statements addFirst: sendBreakMessageNode.
+ "Use anothe rparser to discover positions because if pragmas follow temporaries
+ then we want to insert the break after the last pragma, not after the temporaries."
+ (positionParser := aClass newParser)
+ initPattern: oldSource
+ return:
+ [:pattern|
+ positionParser pragmaSequence; temporaries.
+ markBeforePragmas := positionParser startOfNextToken.
+ positionParser pragmaSequence].
+ mark := (pragmasFollowTemps := positionParser startOfNextToken > markBeforePragmas)
+ ifTrue:
+ [positionParser startOfNextToken - 1]
- hasTemps := parser tempsMark <= oldSource size and: [(oldSource at: parser tempsMark) = $|].
- "If no temps, tempsMark points at start of first token in body"
- mark := hasTemps
- ifTrue: [parser tempsMark + 2]
  ifFalse:
+ [(hasTemps := positionParser tempsMark <= oldSource size and: [(oldSource at: positionParser tempsMark) = $|])
+ ifTrue: [positionParser tempsMark + 2]
+ ifFalse: "If no temps, tempsMark points at start of first token in body iff there is a body"
+ [positionParser tempsMark >= oldSource size
+ ifTrue: "empty body"
+ [positionParser startOfNextToken]
+ ifFalse:
+ [positionParser tempsMark - 1]]].
- [parser tempsMark >= oldSource size
- ifTrue: "empty body"
- [(parser tempsMark min: oldSource size) + 1]
- ifFalse:
- [parser tempsMark - 1]].
  newSource := oldSource copyReplaceFrom: mark to: mark - 1 with: ' self break.\' withCRs.
  ^methodNode generate copyWithSourceCode: newSource!