1
0
فهرست منبع

use nodeId to remember node extensions

so the compilation is as fast as before
Herbert Vojčík 10 سال پیش
والد
کامیت
c8892d9ceb
4فایلهای تغییر یافته به همراه38 افزوده شده و 12 حذف شده
  1. 23 0
      src/Compiler-AST.js
  2. 4 0
      src/Compiler-AST.st
  3. 8 9
      src/Compiler-IR.js
  4. 3 3
      src/Compiler-IR.st

+ 23 - 0
src/Compiler-AST.js

@@ -554,6 +554,29 @@ messageSends: ["select:", "allNodes", "and:", "isNavigationNode", "inPosition:",
 }),
 $globals.Node);
 
+$core.addMethod(
+$core.method({
+selector: "nodeId",
+protocol: 'accessing',
+fn: function (){
+var self=this;
+//>>excludeStart("ctx", pragmas.excludeDebugContexts);
+return $core.withContext(function($ctx1) {
+//>>excludeEnd("ctx");
+return self._identityHash();
+//>>excludeStart("ctx", pragmas.excludeDebugContexts);
+}, function($ctx1) {$ctx1.fill(self,"nodeId",{},$globals.Node)});
+//>>excludeEnd("ctx");
+},
+//>>excludeStart("ide", pragmas.excludeIdeData);
+args: [],
+source: "nodeId\x0a\x09^ self identityHash",
+referencedClasses: [],
+//>>excludeEnd("ide");
+messageSends: ["identityHash"]
+}),
+$globals.Node);
+
 $core.addMethod(
 $core.method({
 selector: "nodes",

+ 4 - 0
src/Compiler-AST.st

@@ -52,6 +52,10 @@ navigationNodeAt: aPoint ifAbsent: aBlock
 		(b positionStart dist: aPoint) ]) first
 !
 
+nodeId
+	^ self identityHash
+!
+
 nodes
 	^ nodes ifNil: [ nodes := Array new ]
 !

+ 8 - 9
src/Compiler-IR.js

@@ -219,19 +219,18 @@ selector: "node:aliased:",
 protocol: 'accessing',
 fn: function (aNode,anAliasVar){
 var self=this;
-function $Dictionary(){return $globals.Dictionary||(typeof Dictionary=="undefined"?nil:Dictionary)}
 //>>excludeStart("ctx", pragmas.excludeDebugContexts);
 return $core.withContext(function($ctx1) {
 //>>excludeEnd("ctx");
 var $1,$receiver;
 $1=self["@nodeAliases"];
 if(($receiver = $1) == null || $receiver.isNil){
-self["@nodeAliases"]=$recv($Dictionary())._new();
+self["@nodeAliases"]=$globals.HashedCollection._newFromPairs_([]);
 self["@nodeAliases"];
 } else {
 $1;
 };
-$recv(self["@nodeAliases"])._at_put_(aNode,anAliasVar);
+$recv(self["@nodeAliases"])._at_put_($recv(aNode)._nodeId(),anAliasVar);
 return self;
 //>>excludeStart("ctx", pragmas.excludeDebugContexts);
 }, function($ctx1) {$ctx1.fill(self,"node:aliased:",{aNode:aNode,anAliasVar:anAliasVar},$globals.IRASTTranslator)});
@@ -239,10 +238,10 @@ return self;
 },
 //>>excludeStart("ide", pragmas.excludeIdeData);
 args: ["aNode", "anAliasVar"],
-source: "node: aNode aliased: anAliasVar\x0a\x09nodeAliases ifNil: [ nodeAliases := Dictionary new ].\x0a\x09nodeAliases at: aNode put: anAliasVar",
-referencedClasses: ["Dictionary"],
+source: "node: aNode aliased: anAliasVar\x0a\x09nodeAliases ifNil: [ nodeAliases := #{} ].\x0a\x09nodeAliases at: aNode nodeId put: anAliasVar",
+referencedClasses: [],
 //>>excludeEnd("ide");
-messageSends: ["ifNil:", "new", "at:put:"]
+messageSends: ["ifNil:", "at:put:", "nodeId"]
 }),
 $globals.IRASTTranslator);
 
@@ -260,7 +259,7 @@ $1=self["@nodeAliases"];
 if(($receiver = $1) == null || $receiver.isNil){
 return nil;
 } else {
-return $recv(self["@nodeAliases"])._at_ifAbsent_(aNode,(function(){
+return $recv(self["@nodeAliases"])._at_ifAbsent_($recv(aNode)._nodeId(),(function(){
 
 }));
 };
@@ -271,10 +270,10 @@ return self;
 },
 //>>excludeStart("ide", pragmas.excludeIdeData);
 args: ["aNode"],
-source: "nodeAliasFor: aNode\x0a\x09nodeAliases\x0a\x09\x09ifNil: [ ^ nil ]\x0a\x09\x09ifNotNil: [ ^ nodeAliases at: aNode ifAbsent: [] ]",
+source: "nodeAliasFor: aNode\x0a\x09nodeAliases\x0a\x09\x09ifNil: [ ^ nil ]\x0a\x09\x09ifNotNil: [ ^ nodeAliases at: aNode nodeId ifAbsent: [] ]",
 referencedClasses: [],
 //>>excludeEnd("ide");
-messageSends: ["ifNil:ifNotNil:", "at:ifAbsent:"]
+messageSends: ["ifNil:ifNotNil:", "at:ifAbsent:", "nodeId"]
 }),
 $globals.IRASTTranslator);
 

+ 3 - 3
src/Compiler-IR.st

@@ -22,14 +22,14 @@ nextAlias
 !
 
 node: aNode aliased: anAliasVar
-	nodeAliases ifNil: [ nodeAliases := Dictionary new ].
-	nodeAliases at: aNode put: anAliasVar
+	nodeAliases ifNil: [ nodeAliases := #{} ].
+	nodeAliases at: aNode nodeId put: anAliasVar
 !
 
 nodeAliasFor: aNode
 	nodeAliases
 		ifNil: [ ^ nil ]
-		ifNotNil: [ ^ nodeAliases at: aNode ifAbsent: [] ]
+		ifNotNil: [ ^ nodeAliases at: aNode nodeId ifAbsent: [] ]
 !
 
 sequence