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);
 $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.addMethod(
 $core.method({
 $core.method({
 selector: "nodes",
 selector: "nodes",

+ 4 - 0
src/Compiler-AST.st

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

+ 8 - 9
src/Compiler-IR.js

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

+ 3 - 3
src/Compiler-IR.st

@@ -22,14 +22,14 @@ nextAlias
 !
 !
 
 
 node: aNode aliased: anAliasVar
 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
 nodeAliasFor: aNode
 	nodeAliases
 	nodeAliases
 		ifNil: [ ^ nil ]
 		ifNil: [ ^ nil ]
-		ifNotNil: [ ^ nodeAliases at: aNode ifAbsent: [] ]
+		ifNotNil: [ ^ nodeAliases at: aNode nodeId ifAbsent: [] ]
 !
 !
 
 
 sequence
 sequence