Ver código fonte

Merge branch 'upstream' into tamed-undefined

Conflicts:
	js/Compiler-Interpreter.js
Herbert Vojčík 11 anos atrás
pai
commit
a8fa8d3581
2 arquivos alterados com 36 adições e 22 exclusões
  1. 29 17
      js/Compiler-Interpreter.js
  2. 7 5
      st/Compiler-Interpreter.st

+ 29 - 17
js/Compiler-Interpreter.js

@@ -287,24 +287,31 @@ category: 'interpreting',
 fn: function (){
 var self=this;
 return smalltalk.withContext(function($ctx1) { 
-var $1,$2,$3,$4;
+var $1,$3,$2,$4,$5;
 $1=self._isBlockContext();
 if(smalltalk.assert($1)){
-$2=_st(self._outerContext())._ast();
+$3=self._outerContext();
+if(($receiver = $3) == nil || $receiver == null){
+$2=$3;
+} else {
+var context;
+context=$receiver;
+$2=_st(context)._ast();
+};
 return $2;
 };
-$3=self["@ast"];
-if(($receiver = $3) == nil || $receiver == null){
+$4=self["@ast"];
+if(($receiver = $4) == nil || $receiver == null){
 self._initializeAST();
 } else {
-$3;
+$4;
 };
-$4=self["@ast"];
-return $4;
+$5=self["@ast"];
+return $5;
 }, function($ctx1) {$ctx1.fill(self,"ast",{},smalltalk.AIContext)})},
 args: [],
-source: "ast\x0a\x09self isBlockContext ifTrue: [ ^ self outerContext ast ].\x0a\x0a\x09ast ifNil: [ self initializeAST ].\x0a\x09^ ast",
-messageSends: ["ifTrue:", "isBlockContext", "ast", "outerContext", "ifNil:", "initializeAST"],
+source: "ast\x0a\x09self isBlockContext ifTrue: [ \x0a\x09\x09^ self outerContext ifNotNil: [ :context | context ast ] ].\x0a\x0a\x09ast ifNil: [ self initializeAST ].\x0a\x09^ ast",
+messageSends: ["ifTrue:", "isBlockContext", "ifNotNil:", "outerContext", "ast", "ifNil:", "initializeAST"],
 referencedClasses: []
 }),
 smalltalk.AIContext);
@@ -813,17 +820,22 @@ fn: function (){
 var self=this;
 function $ASTPCNodeVisitor(){return smalltalk.ASTPCNodeVisitor||(typeof ASTPCNodeVisitor=="undefined"?nil:ASTPCNodeVisitor)}
 return smalltalk.withContext(function($ctx1) { 
-var $2,$3,$1;
-$2=_st($ASTPCNodeVisitor())._new();
-_st($2)._context_(self);
-_st($2)._visit_(self._ast());
-$3=_st($2)._currentNode();
-$1=$3;
+var $2,$3,$4,$1;
+$2=self._ast();
+if(($receiver = $2) == nil || $receiver == undefined){
+$1=$2;
+} else {
+$3=_st($ASTPCNodeVisitor())._new();
+_st($3)._context_(self);
+_st($3)._visit_(self._ast());
+$4=_st($3)._currentNode();
+$1=$4;
+};
 return $1;
 }, function($ctx1) {$ctx1.fill(self,"retrieveNode",{},smalltalk.AIContext)})},
 args: [],
-source: "retrieveNode\x0a\x09^ ASTPCNodeVisitor new\x0a\x09\x09context: self;\x0a\x09\x09visit: self ast;\x0a\x09\x09currentNode",
-messageSends: ["context:", "new", "visit:", "ast", "currentNode"],
+source: "retrieveNode\x0a\x09^ self ast ifNotNil: [\x0a\x09\x09ASTPCNodeVisitor new\x0a\x09\x09\x09context: self;\x0a\x09\x09\x09visit: self ast;\x0a\x09\x09\x09currentNode ]",
+messageSends: ["ifNotNil:", "ast", "context:", "new", "visit:", "currentNode"],
 referencedClasses: ["ASTPCNodeVisitor"]
 }),
 smalltalk.AIContext);

+ 7 - 5
st/Compiler-Interpreter.st

@@ -232,7 +232,8 @@ arguments
 !
 
 ast
-	self isBlockContext ifTrue: [ ^ self outerContext ast ].
+	self isBlockContext ifTrue: [ 
+		^ self outerContext ifNotNil: [ :context | context ast ] ].
 
 	ast ifNil: [ self initializeAST ].
 	^ ast
@@ -264,10 +265,11 @@ receiver: anObject
 !
 
 retrieveNode
-	^ ASTPCNodeVisitor new
-		context: self;
-		visit: self ast;
-		currentNode
+	^ self ast ifNotNil: [
+		ASTPCNodeVisitor new
+			context: self;
+			visit: self ast;
+			currentNode ]
 !
 
 setupInterpreter: anInterpreter