Ver código fonte

Various small fixes related to Helios debugger

Nicolas Petton 10 anos atrás
pai
commit
5021c7d63a

+ 44 - 16
src/Compiler-Interpreter.js

@@ -1067,16 +1067,23 @@ protocol: 'testing',
 fn: function (){
 var self=this;
 return smalltalk.withContext(function($ctx1) { 
-var $1;
-$1=_st(_st(self._interpreter())._atEnd())._and_((function(){
+var $1,$2,$receiver;
+$1=self._context();
+$ctx1.sendIdx["context"]=1;
+if(($receiver = $1) == nil || $receiver == null){
+return true;
+} else {
+$1;
+};
+$2=_st(_st(self._interpreter())._atEnd())._and_((function(){
 return smalltalk.withContext(function($ctx2) {
 return _st(_st(self._context())._outerContext())._isNil();
-}, function($ctx2) {$ctx2.fillBlock({},$ctx1,1)})}));
-return $1;
+}, function($ctx2) {$ctx2.fillBlock({},$ctx1,2)})}));
+return $2;
 }, function($ctx1) {$ctx1.fill(self,"atEnd",{},globals.ASTDebugger)})},
 args: [],
-source: "atEnd\x0a\x09^ self interpreter atEnd and: [ \x0a\x09\x09self context outerContext isNil ]",
-messageSends: ["and:", "atEnd", "interpreter", "isNil", "outerContext", "context"],
+source: "atEnd\x09\x0a\x09self context ifNil: [ ^ true ].\x0a\x09\x0a\x09^ self interpreter atEnd and: [ \x0a\x09\x09self context outerContext isNil ]",
+messageSends: ["ifNil:", "context", "and:", "atEnd", "interpreter", "isNil", "outerContext"],
 referencedClasses: []
 }),
 globals.ASTDebugger);
@@ -1120,11 +1127,19 @@ protocol: 'private',
 fn: function (){
 var self=this;
 return smalltalk.withContext(function($ctx1) { 
-_st(self._context())._innerContext_(nil);
+var $1,$receiver;
+$1=self._context();
+if(($receiver = $1) == nil || $receiver == null){
+$1;
+} else {
+var cxt;
+cxt=$receiver;
+_st(cxt)._innerContext_(nil);
+};
 return self}, function($ctx1) {$ctx1.fill(self,"flushInnerContexts",{},globals.ASTDebugger)})},
 args: [],
-source: "flushInnerContexts\x0a\x09\x22When stepping, the inner contexts are not relevent anymore,\x0a\x09and can be flushed\x22\x0a\x09\x0a\x09self context innerContext: nil",
-messageSends: ["innerContext:", "context"],
+source: "flushInnerContexts\x0a\x09\x22When stepping, the inner contexts are not relevent anymore,\x0a\x09and can be flushed\x22\x0a\x09\x0a\x09self context ifNotNil: [ :cxt | \x0a\x09\x09cxt innerContext: nil ]",
+messageSends: ["ifNotNil:", "context", "innerContext:"],
 referencedClasses: []
 }),
 globals.ASTDebugger);
@@ -1136,13 +1151,20 @@ protocol: 'accessing',
 fn: function (){
 var self=this;
 return smalltalk.withContext(function($ctx1) { 
-var $1;
-$1=_st(self._context())._interpreter();
+var $2,$1,$receiver;
+$2=self._context();
+if(($receiver = $2) == nil || $receiver == null){
+$1=$2;
+} else {
+var ctx;
+ctx=$receiver;
+$1=_st(ctx)._interpreter();
+};
 return $1;
 }, function($ctx1) {$ctx1.fill(self,"interpreter",{},globals.ASTDebugger)})},
 args: [],
-source: "interpreter\x0a\x09^ self context interpreter",
-messageSends: ["interpreter", "context"],
+source: "interpreter\x0a\x09^ self context ifNotNil: [ :ctx | \x0a\x09\x09ctx interpreter ]",
+messageSends: ["ifNotNil:", "context", "interpreter"],
 referencedClasses: []
 }),
 globals.ASTDebugger);
@@ -1190,13 +1212,19 @@ protocol: 'accessing',
 fn: function (){
 var self=this;
 return smalltalk.withContext(function($ctx1) { 
-var $1;
+var $2,$1,$receiver;
+$2=self._interpreter();
+$ctx1.sendIdx["interpreter"]=1;
+if(($receiver = $2) == nil || $receiver == null){
+$1=$2;
+} else {
 $1=_st(self._interpreter())._node();
+};
 return $1;
 }, function($ctx1) {$ctx1.fill(self,"node",{},globals.ASTDebugger)})},
 args: [],
-source: "node\x0a\x09^ self interpreter node",
-messageSends: ["node", "interpreter"],
+source: "node\x0a\x09^ self interpreter ifNotNil: [\x0a\x09\x09self interpreter node ]",
+messageSends: ["ifNotNil:", "interpreter", "node"],
 referencedClasses: []
 }),
 globals.ASTDebugger);

+ 9 - 4
src/Compiler-Interpreter.st

@@ -379,7 +379,8 @@ context: aContext
 !
 
 interpreter
-	^ self context interpreter
+	^ self context ifNotNil: [ :ctx | 
+		ctx interpreter ]
 !
 
 method
@@ -391,7 +392,8 @@ nextNode
 !
 
 node
-	^ self interpreter node
+	^ self interpreter ifNotNil: [
+		self interpreter node ]
 ! !
 
 !ASTDebugger methodsFor: 'private'!
@@ -400,7 +402,8 @@ flushInnerContexts
 	"When stepping, the inner contexts are not relevent anymore,
 	and can be flushed"
 	
-	self context innerContext: nil
+	self context ifNotNil: [ :cxt | 
+		cxt innerContext: nil ]
 !
 
 onStep
@@ -445,7 +448,9 @@ stepOver
 
 !ASTDebugger methodsFor: 'testing'!
 
-atEnd
+atEnd	
+	self context ifNil: [ ^ true ].
+	
 	^ self interpreter atEnd and: [ 
 		self context outerContext isNil ]
 ! !

+ 37 - 5
src/Helios-Debugger.js

@@ -314,12 +314,18 @@ fn: function (anAnnouncement){
 var self=this;
 function $HLContextInspectorDecorator(){return globals.HLContextInspectorDecorator||(typeof HLContextInspectorDecorator=="undefined"?nil:HLContextInspectorDecorator)}
 return smalltalk.withContext(function($ctx1) { 
+var $1,$2;
+$1=_st(self._model())._atEnd();
+if(smalltalk.assert($1)){
+$2=_st(self._manager())._removeActiveTab();
+return $2;
+};
 _st(self._inspectorWidget())._inspect_(_st($HLContextInspectorDecorator())._on_(_st(anAnnouncement)._context()));
 _st(self._stackListWidget())._refresh();
 return self}, function($ctx1) {$ctx1.fill(self,"onDebuggerStepped:",{anAnnouncement:anAnnouncement},globals.HLDebugger)})},
 args: ["anAnnouncement"],
-source: "onDebuggerStepped: anAnnouncement\x0a\x09self inspectorWidget inspect: (HLContextInspectorDecorator on: anAnnouncement context).\x0a\x09self stackListWidget refresh",
-messageSends: ["inspect:", "inspectorWidget", "on:", "context", "refresh", "stackListWidget"],
+source: "onDebuggerStepped: anAnnouncement\x0a\x09self model atEnd ifTrue: [ ^ self manager removeActiveTab ].\x0a\x09\x0a\x09self inspectorWidget inspect: (HLContextInspectorDecorator on: anAnnouncement context).\x0a\x09self stackListWidget refresh",
+messageSends: ["ifTrue:", "atEnd", "model", "removeActiveTab", "manager", "inspect:", "inspectorWidget", "on:", "context", "refresh", "stackListWidget"],
 referencedClasses: ["HLContextInspectorDecorator"]
 }),
 globals.HLDebugger);
@@ -627,11 +633,19 @@ protocol: 'actions',
 fn: function (){
 var self=this;
 return smalltalk.withContext(function($ctx1) { 
-self._highlightNode_(_st(self._browserModel())._nextNode());
+var $1,$receiver;
+$1=_st(self._browserModel())._nextNode();
+if(($receiver = $1) == nil || $receiver == null){
+$1;
+} else {
+var node;
+node=$receiver;
+self._highlightNode_(node);
+};
 return self}, function($ctx1) {$ctx1.fill(self,"highlight",{},globals.HLDebuggerCodeWidget)})},
 args: [],
-source: "highlight\x0a\x09self highlightNode: self browserModel nextNode",
-messageSends: ["highlightNode:", "nextNode", "browserModel"],
+source: "highlight\x0a\x09self browserModel nextNode ifNotNil: [ :node |\x0a\x09\x09self highlightNode: node ]",
+messageSends: ["ifNotNil:", "nextNode", "browserModel", "highlightNode:"],
 referencedClasses: []
 }),
 globals.HLDebuggerCodeWidget);
@@ -737,6 +751,24 @@ globals.HLDebuggerCodeWidget);
 
 smalltalk.addClass('HLDebuggerModel', globals.HLToolModel, ['rootContext', 'debugger', 'error'], 'Helios-Debugger');
 globals.HLDebuggerModel.comment="I am a model for debugging Amber code in Helios.\x0a\x0aMy instances hold a reference to an `ASTDebugger` instance, itself referencing the current `context`. The context should be the root of the context stack.";
+smalltalk.addMethod(
+smalltalk.method({
+selector: "atEnd",
+protocol: 'testing',
+fn: function (){
+var self=this;
+return smalltalk.withContext(function($ctx1) { 
+var $1;
+$1=_st(self._debugger())._atEnd();
+return $1;
+}, function($ctx1) {$ctx1.fill(self,"atEnd",{},globals.HLDebuggerModel)})},
+args: [],
+source: "atEnd\x0a\x09^ self debugger atEnd",
+messageSends: ["atEnd", "debugger"],
+referencedClasses: []
+}),
+globals.HLDebuggerModel);
+
 smalltalk.addMethod(
 smalltalk.method({
 selector: "contexts",

+ 10 - 1
src/Helios-Debugger.st

@@ -110,6 +110,8 @@ onContextSelected: anAnnouncement
 !
 
 onDebuggerStepped: anAnnouncement
+	self model atEnd ifTrue: [ ^ self manager removeActiveTab ].
+	
 	self inspectorWidget inspect: (HLContextInspectorDecorator on: anAnnouncement context).
 	self stackListWidget refresh
 ! !
@@ -226,7 +228,8 @@ clearHighlight
 !
 
 highlight
-	self highlightNode: self browserModel nextNode
+	self browserModel nextNode ifNotNil: [ :node |
+		self highlightNode: node ]
 !
 
 highlightNode: aNode
@@ -385,6 +388,12 @@ onStep
 	rootContext := self currentContext
 ! !
 
+!HLDebuggerModel methodsFor: 'testing'!
+
+atEnd
+	^ self debugger atEnd
+! !
+
 !HLDebuggerModel class methodsFor: 'instance creation'!
 
 on: anError