1
0
Kaynağa Gözat

Explicit iterative withTail: instead of valueForReceiver:.

Herbert Vojčík 8 yıl önce
ebeveyn
işleme
4aec62dc58
5 değiştirilmiş dosya ile 204 ekleme ve 318 silme
  1. 9 0
      API-CHANGES.txt
  2. 38 39
      src/Compiler-AST.js
  3. 13 14
      src/Compiler-AST.st
  4. 139 227
      support/parser.js
  5. 5 38
      support/parser.pegjs

+ 9 - 0
API-CHANGES.txt

@@ -1,3 +1,12 @@
+0.19.0:
+
++ ASTNode >>
+  + withTail:
+
+- SendNode >>
+  - valueWithReceiver:
+
+
 0.18.0:
 
 * Remove class RethrowErrorHandler (hack for cli before 0.12.3).

+ 38 - 39
src/Compiler-AST.js

@@ -718,6 +718,44 @@ messageSends: []
 }),
 $globals.ASTNode);
 
+$core.addMethod(
+$core.method({
+selector: "withTail:",
+protocol: 'building',
+fn: function (aCollection){
+var self=this;
+//>>excludeStart("ctx", pragmas.excludeDebugContexts);
+return $core.withContext(function($ctx1) {
+//>>excludeEnd("ctx");
+var $1;
+return $recv(aCollection)._inject_into_(self,(function(receiver,send){
+//>>excludeStart("ctx", pragmas.excludeDebugContexts);
+return $core.withContext(function($ctx2) {
+//>>excludeEnd("ctx");
+$1=$recv($globals.SendNode)._new();
+$recv($1)._position_($recv(send)._position());
+$recv($1)._source_($recv(send)._source());
+$recv($1)._receiver_(receiver);
+$recv($1)._selector_($recv(send)._selector());
+$recv($1)._arguments_($recv(send)._arguments());
+return $recv($1)._yourself();
+//>>excludeStart("ctx", pragmas.excludeDebugContexts);
+}, function($ctx2) {$ctx2.fillBlock({receiver:receiver,send:send},$ctx1,1)});
+//>>excludeEnd("ctx");
+}));
+//>>excludeStart("ctx", pragmas.excludeDebugContexts);
+}, function($ctx1) {$ctx1.fill(self,"withTail:",{aCollection:aCollection},$globals.ASTNode)});
+//>>excludeEnd("ctx");
+},
+//>>excludeStart("ide", pragmas.excludeIdeData);
+args: ["aCollection"],
+source: "withTail: aCollection\x0a\x09^ aCollection inject: self into: [\x0a\x09\x09:receiver :send | SendNode new\x0a\x09\x09\x09position: send position;\x0a\x09\x09\x09source: send source;\x0a\x09\x09\x09receiver: receiver;\x0a\x09\x09\x09selector: send selector;\x0a\x09\x09\x09arguments: send arguments;\x0a\x09\x09\x09yourself ]",
+referencedClasses: ["SendNode"],
+//>>excludeEnd("ide");
+messageSends: ["inject:into:", "position:", "new", "position", "source:", "source", "receiver:", "selector:", "selector", "arguments:", "arguments", "yourself"]
+}),
+$globals.ASTNode);
+
 
 
 $core.addClass('AssignmentNode', $globals.ASTNode, ['left', 'right'], 'Compiler-AST');
@@ -2042,45 +2080,6 @@ messageSends: ["and:", "notNil", "receiver", "isSuperKeyword"]
 }),
 $globals.SendNode);
 
-$core.addMethod(
-$core.method({
-selector: "valueForReceiver:",
-protocol: 'building',
-fn: function (anObject){
-var self=this;
-//>>excludeStart("ctx", pragmas.excludeDebugContexts);
-return $core.withContext(function($ctx1) {
-//>>excludeEnd("ctx");
-var $1,$3,$2,$receiver;
-$1=$recv($globals.SendNode)._new();
-$recv($1)._position_(self._position());
-$recv($1)._source_(self._source());
-$3=self._receiver();
-//>>excludeStart("ctx", pragmas.excludeDebugContexts);
-$ctx1.sendIdx["receiver"]=1;
-//>>excludeEnd("ctx");
-if(($receiver = $3) == null || $receiver.isNil){
-$2=anObject;
-} else {
-$2=$recv(self._receiver())._valueForReceiver_(anObject);
-};
-$recv($1)._receiver_($2);
-$recv($1)._selector_(self._selector());
-$recv($1)._arguments_(self._arguments());
-return $recv($1)._yourself();
-//>>excludeStart("ctx", pragmas.excludeDebugContexts);
-}, function($ctx1) {$ctx1.fill(self,"valueForReceiver:",{anObject:anObject},$globals.SendNode)});
-//>>excludeEnd("ctx");
-},
-//>>excludeStart("ide", pragmas.excludeIdeData);
-args: ["anObject"],
-source: "valueForReceiver: anObject\x0a\x09^ SendNode new\x0a\x09\x09position: self position;\x0a\x09\x09source: self source;\x0a\x09\x09receiver: (self receiver\x0a\x09\x09ifNil: [ anObject ] \x0a\x09\x09ifNotNil: [ self receiver valueForReceiver: anObject ]);\x0a\x09\x09selector: self selector;\x0a\x09\x09arguments: self arguments;\x0a\x09\x09yourself",
-referencedClasses: ["SendNode"],
-//>>excludeEnd("ide");
-messageSends: ["position:", "new", "position", "source:", "source", "receiver:", "ifNil:ifNotNil:", "receiver", "valueForReceiver:", "selector:", "selector", "arguments:", "arguments", "yourself"]
-}),
-$globals.SendNode);
-
 
 
 $core.addClass('SequenceNode', $globals.ASTNode, ['temps', 'scope'], 'Compiler-AST');

+ 13 - 14
src/Compiler-AST.st

@@ -84,6 +84,19 @@ source: aString
 	source := aString
 ! !
 
+!ASTNode methodsFor: 'building'!
+
+withTail: aCollection
+	^ aCollection inject: self into: [
+		:receiver :send | SendNode new
+			position: send position;
+			source: send source;
+			receiver: receiver;
+			selector: send selector;
+			arguments: send arguments;
+			yourself ]
+! !
+
 !ASTNode methodsFor: 'testing'!
 
 inPosition: aPoint
@@ -482,20 +495,6 @@ superSend
 	^ self receiver notNil and: [ self receiver isSuperKeyword ]
 ! !
 
-!SendNode methodsFor: 'building'!
-
-valueForReceiver: anObject
-	^ SendNode new
-		position: self position;
-		source: self source;
-		receiver: (self receiver
-		ifNil: [ anObject ] 
-		ifNotNil: [ self receiver valueForReceiver: anObject ]);
-		selector: self selector;
-		arguments: self arguments;
-		yourself
-! !
-
 !SendNode methodsFor: 'testing'!
 
 isNavigationNode

Dosya farkı çok büyük olduğundan ihmal edildi
+ 139 - 227
support/parser.js


+ 5 - 38
support/parser.pegjs

@@ -173,22 +173,8 @@ wsUnaryMessage   = ws selector:unarySelector !":" {
                             ._selector_(selector);
                  }
 
-wsUnaryTail      = message:wsUnaryMessage tail:wsUnaryTail? {
-                     if(tail) {
-                         return tail._valueForReceiver_(message);
-                     }
-                     else {
-                         return message;
-                     }
-                 }
-
-unarySend      = receiver:operand tail:wsUnaryTail? {
-                     if(tail) {
-                         return tail._valueForReceiver_(receiver);
-                     }
-                     else {
-                         return receiver;
-                     }
+unarySend      = receiver:operand tail:wsUnaryMessage* {
+					 return receiver._withTail_(tail);
                  }
 
 wsBinaryMessage  = ws selector:binarySelector ws arg:unarySend {
@@ -199,22 +185,8 @@ wsBinaryMessage  = ws selector:binarySelector ws arg:unarySend {
                             ._arguments_([arg]);
                  }
 
-wsBinaryTail     = message:wsBinaryMessage tail:wsBinaryTail? {
-                     if(tail) {
-                         return tail._valueForReceiver_(message);
-                      }
-                     else {
-                         return message;
-                     }
-                 }
-
-binarySend     = receiver:unarySend tail:wsBinaryTail? {
-                     if(tail) {
-                         return tail._valueForReceiver_(receiver);
-                     }
-                     else {
-                         return receiver;
-                     }
+binarySend     = receiver:unarySend tail:wsBinaryMessage* {
+					 return receiver._withTail_(tail);
                  }
 
 
@@ -233,12 +205,7 @@ wsKeywordMessage = pairs:(ws key:keyword ws arg:binarySend {return {key:key, arg
                  }
 
 keywordSend    = receiver:binarySend tail:wsKeywordMessage? {
-                     if(tail) {
-                         return tail._valueForReceiver_(receiver);
-                     }
-                     else {
-                         return receiver;
-                     }
+					 return tail ? receiver._withTail_([tail]) : receiver;
                  }
 
 wsMessage        = wsBinaryMessage / wsUnaryMessage / wsKeywordMessage

Bu fark içinde çok fazla dosya değişikliği olduğu için bazı dosyalar gösterilmiyor