InstrumentingCompiler.st
changeset 3239 a603d73841d4
parent 3237 a6b2f875bcc3
child 3570 0ac6e8f11416
--- a/InstrumentingCompiler.st	Mon Jul 29 00:06:40 2013 +0200
+++ b/InstrumentingCompiler.st	Mon Jul 29 01:20:46 2013 +0200
@@ -8,7 +8,7 @@
 !
 
 InstrumentationInfo subclass:#StatementExecutionInfo
-	instanceVariableNames:'startPosition count'
+	instanceVariableNames:'startPosition endPosition count'
 	classVariableNames:''
 	poolDictionaries:''
 	privateIn:InstrumentingCompiler
@@ -71,7 +71,7 @@
 !
 
 InstrumentingCompiler::StatementExecutionInfo subclass:#BlockExecutionInfo
-	instanceVariableNames:'endPosition'
+	instanceVariableNames:''
 	classVariableNames:''
 	poolDictionaries:''
 	privateIn:InstrumentingCompiler
@@ -397,17 +397,21 @@
     "Modified (comment): / 30-09-2011 / 12:16:05 / cg"
 !
 
-statementListRewriteHookFor:firstStatement
+statementListRewriteHookFor:firstStatementArg
     "invoked whenever a statement list node has been generated"
 
     "/ care for blocks which return...
-    |thisStatement prevStatement countStatement mustInsertExecutionInfo|
+    |thisStatement prevStatement countStatement mustInsertExecutionInfo statementInfo firstStatement |
 
     mustInsertExecutionInfo := false.
     prevStatement := nil.
 
-    thisStatement := firstStatement.
-    thisStatement isNil ifTrue:[^ firstStatement].
+    thisStatement := firstStatementArg.
+    thisStatement isNil ifTrue:[^ firstStatementArg].
+    firstStatement := self statementCounterBefore:thisStatement.
+    statementInfo := firstStatement expression receiver value. 
+    statementInfo endPosition: thisStatement endPosition.
+
 
     [true] whileTrue:[
         mustInsertExecutionInfo ifTrue:[
@@ -415,12 +419,14 @@
             "/ insert a statement-entry here.
             thisStatement notNil ifTrue:[
                 countStatement := self statementCounterBefore:thisStatement.
+                statementInfo := countStatement expression receiver value.
+                statementInfo endPosition: thisStatement endPosition.
                 prevStatement nextStatement:countStatement.
                 mustInsertExecutionInfo := false.
                 prevStatement := countStatement.
             ]
         ].
-        thisStatement isNil ifTrue:[^ firstStatement].
+        thisStatement isNil ifTrue:[ ^ firstStatement ].
 
         thisStatement isReturnNode ifFalse:[
             thisStatement containsReturn ifTrue:[
@@ -428,10 +434,14 @@
             ]
         ].
         prevStatement := thisStatement.
+        statementInfo notNil ifTrue:[
+            statementInfo endPosition: prevStatement endPosition.
+        ].
         thisStatement := thisStatement nextStatement.
     ].
 
     "Modified (comment): / 30-09-2011 / 12:15:52 / cg"
+    "Modified: / 29-07-2013 / 00:11:03 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 !
 
 variableReadRewriteHookFor:aVariableNode
@@ -509,14 +519,31 @@
     "Created: / 23-06-2006 / 13:31:28 / cg"
 !
 
+endPosition
+    ^ endPosition
+
+    "Created: / 28-04-2010 / 15:57:14 / cg"
+!
+
+endPosition:anInteger
+    endPosition := anInteger.
+!
+
 startPosition
     ^ startPosition
 
     "Created: / 28-04-2010 / 15:54:26 / cg"
 !
 
-startPosition:something
-    startPosition := something.
+startPosition:anInteger
+    startPosition := anInteger.
+!
+
+startPosition:startArg endPosition:endArg
+    startPosition := startArg.
+    endPosition := endArg.
+
+    "Created: / 28-04-2010 / 15:54:47 / cg"
 ! !
 
 !InstrumentingCompiler::StatementExecutionInfo methodsFor:'cleanup'!
@@ -531,6 +558,39 @@
     "Created: / 20-07-2011 / 18:59:01 / cg"
 ! !
 
+!InstrumentingCompiler::StatementExecutionInfo methodsFor:'debugging'!
+
+inspector2TabSource
+
+    | source |
+
+    source := owningMethod source asText.
+    startPosition isNil ifTrue:[
+        source colorizeAllWith: Color red.
+    ] ifFalse:[
+        endPosition isNil ifTrue:[
+            source emphasizeFrom:startPosition to:source string size with: #bold.
+            source emphasizeFrom:startPosition to:source string size with: #color -> Color red.
+        ] ifFalse:[
+            source emphasizeFrom:startPosition to: endPosition with: #bold.
+            source emphasizeFrom:startPosition to: endPosition with: #color -> Color blue.
+        ].
+    ].
+
+    ^self newInspector2Tab
+        label: 'Source';
+        priority: 50;
+        view: ((ScrollableView for:EditTextView) contents: source; yourself)
+
+    "Created: / 28-07-2013 / 23:16:28 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+inspector2Tabs
+    ^ #( inspector2TabForBasicInspect inspector2TabSource )
+
+    "Created: / 28-07-2013 / 23:18:21 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+! !
+
 !InstrumentingCompiler::StatementExecutionInfo methodsFor:'instrumentation calls'!
 
 entry:callingContext
@@ -996,21 +1056,6 @@
 "
 ! !
 
-!InstrumentingCompiler::BlockExecutionInfo methodsFor:'accessing'!
-
-endPosition
-    ^ endPosition
-
-    "Created: / 28-04-2010 / 15:57:14 / cg"
-!
-
-startPosition:startArg endPosition:endArg
-    startPosition := startArg.
-    endPosition := endArg.
-
-    "Created: / 28-04-2010 / 15:54:47 / cg"
-! !
-
 !InstrumentingCompiler::BlockExecutionInfo methodsFor:'entry'!
 
 changeClassToAlreadyEntered
@@ -1106,10 +1151,10 @@
 !InstrumentingCompiler class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libcomp/InstrumentingCompiler.st,v 1.32 2013-07-28 16:05:48 vrany Exp $'
+    ^ '$Header: /cvs/stx/stx/libcomp/InstrumentingCompiler.st,v 1.33 2013-07-28 23:20:46 vrany Exp $'
 !
 
 version_CVS
-    ^ '$Header: /cvs/stx/stx/libcomp/InstrumentingCompiler.st,v 1.32 2013-07-28 16:05:48 vrany Exp $'
+    ^ '$Header: /cvs/stx/stx/libcomp/InstrumentingCompiler.st,v 1.33 2013-07-28 23:20:46 vrany Exp $'
 ! !