1
0
Herbert Vojčík 9 лет назад
Родитель
Сommit
c398987d94
4 измененных файлов с 63 добавлено и 10 удалено
  1. 45 0
      src/Compiler-AST.js
  2. 12 0
      src/Compiler-AST.st
  3. 5 9
      src/Compiler-Semantic.js
  4. 1 1
      src/Compiler-Semantic.st

+ 45 - 0
src/Compiler-AST.js

@@ -95,6 +95,33 @@ messageSends: ["asSet", "nodes", "do:", "addAll:", "allNodes"]
 }),
 $globals.Node);
 
+$core.addMethod(
+$core.method({
+selector: "asRefNode",
+protocol: 'converting',
+fn: function (){
+var self=this;
+function $RefNode(){return $globals.RefNode||(typeof RefNode=="undefined"?nil:RefNode)}
+//>>excludeStart("ctx", pragmas.excludeDebugContexts);
+return $core.withContext(function($ctx1) {
+//>>excludeEnd("ctx");
+var $1;
+$1=$recv($RefNode())._new();
+$recv($1)._node_(self);
+return $recv($1)._yourself();
+//>>excludeStart("ctx", pragmas.excludeDebugContexts);
+}, function($ctx1) {$ctx1.fill(self,"asRefNode",{},$globals.Node)});
+//>>excludeEnd("ctx");
+},
+//>>excludeStart("ide", pragmas.excludeIdeData);
+args: [],
+source: "asRefNode\x0a\x09^ RefNode new node: self; yourself",
+referencedClasses: ["RefNode"],
+//>>excludeEnd("ide");
+messageSends: ["node:", "new", "yourself"]
+}),
+$globals.Node);
+
 $core.addMethod(
 $core.method({
 selector: "inPosition:",
@@ -2055,6 +2082,24 @@ messageSends: ["visitRefNode:"]
 }),
 $globals.RefNode);
 
+$core.addMethod(
+$core.method({
+selector: "asRefNode",
+protocol: 'converting',
+fn: function (){
+var self=this;
+return self;
+
+},
+//>>excludeStart("ide", pragmas.excludeIdeData);
+args: [],
+source: "asRefNode\x0a\x09^ self",
+referencedClasses: [],
+//>>excludeEnd("ide");
+messageSends: []
+}),
+$globals.RefNode);
+
 $core.addMethod(
 $core.method({
 selector: "isImmutable",

+ 12 - 0
src/Compiler-AST.st

@@ -122,6 +122,12 @@ nodes: aCollection
 	aCollection do: [ :each | each parent: self ]
 ! !
 
+!Node methodsFor: 'converting'!
+
+asRefNode
+	^ RefNode new node: self; yourself
+! !
+
 !Node methodsFor: 'copying'!
 
 postCopy
@@ -490,6 +496,12 @@ node: anObject
 	node := anObject
 ! !
 
+!RefNode methodsFor: 'converting'!
+
+asRefNode
+	^ self
+! !
+
 !RefNode methodsFor: 'testing'!
 
 isImmutable

+ 5 - 9
src/Compiler-Semantic.js

@@ -2302,11 +2302,10 @@ protocol: 'visiting',
 fn: function (aNode){
 var self=this;
 var recv;
-function $RefNode(){return $globals.RefNode||(typeof RefNode=="undefined"?nil:RefNode)}
 //>>excludeStart("ctx", pragmas.excludeDebugContexts);
 return $core.withContext(function($ctx1) {
 //>>excludeEnd("ctx");
-var $2,$1,$4,$3;
+var $2,$1;
 $2=$recv(aNode)._nodes();
 //>>excludeStart("ctx", pragmas.excludeDebugContexts);
 $ctx1.sendIdx["nodes"]=1;
@@ -2317,10 +2316,7 @@ $recv($recv(aNode)._nodes())._do_((function(each){
 //>>excludeStart("ctx", pragmas.excludeDebugContexts);
 return $core.withContext(function($ctx2) {
 //>>excludeEnd("ctx");
-$4=$recv($RefNode())._new();
-$recv($4)._node_(recv);
-$3=$recv($4)._yourself();
-return $recv(each)._receiver_($3);
+return $recv(each)._receiver_($recv(recv)._asRefNode());
 //>>excludeStart("ctx", pragmas.excludeDebugContexts);
 $ctx2.sendIdx["receiver:"]=1;
 //>>excludeEnd("ctx");
@@ -2344,10 +2340,10 @@ return self;
 },
 //>>excludeStart("ide", pragmas.excludeIdeData);
 args: ["aNode"],
-source: "visitCascadeNode: aNode\x0a\x09| recv |\x0a\x09recv := aNode nodes first receiver.\x0a\x09aNode nodes do: [ :each | each receiver: (RefNode new node: recv; yourself) ].\x0a\x09aNode receiver: recv.\x0a\x09super visitCascadeNode: aNode",
-referencedClasses: ["RefNode"],
+source: "visitCascadeNode: aNode\x0a\x09| recv |\x0a\x09recv := aNode nodes first receiver.\x0a\x09aNode nodes do: [ :each | each receiver: recv asRefNode ].\x0a\x09aNode receiver: recv.\x0a\x09super visitCascadeNode: aNode",
+referencedClasses: [],
 //>>excludeEnd("ide");
-messageSends: ["receiver", "first", "nodes", "do:", "receiver:", "node:", "new", "yourself", "visitCascadeNode:"]
+messageSends: ["receiver", "first", "nodes", "do:", "receiver:", "asRefNode", "visitCascadeNode:"]
 }),
 $globals.SemanticAnalyzer);
 

+ 1 - 1
src/Compiler-Semantic.st

@@ -560,7 +560,7 @@ visitBlockNode: aNode
 visitCascadeNode: aNode
 	| recv |
 	recv := aNode nodes first receiver.
-	aNode nodes do: [ :each | each receiver: (RefNode new node: recv; yourself) ].
+	aNode nodes do: [ :each | each receiver: recv asRefNode ].
 	aNode receiver: recv.
 	super visitCascadeNode: aNode
 !