Browse Source

SuperVar; isSuperKeyword => isSuper

Herby Vojčík 5 years ago
parent
commit
496a94f2da
4 changed files with 89 additions and 32 deletions
  1. 10 10
      lang/src/Compiler-AST.js
  2. 4 4
      lang/src/Compiler-AST.st
  3. 57 15
      lang/src/Compiler-Semantic.js
  4. 18 3
      lang/src/Compiler-Semantic.st

+ 10 - 10
lang/src/Compiler-AST.js

@@ -232,7 +232,7 @@ $globals.ASTNode);
 
 $core.addMethod(
 $core.method({
-selector: "isSuperKeyword",
+selector: "isSuper",
 protocol: "testing",
 fn: function (){
 var self=this,$self=this;
@@ -241,7 +241,7 @@ return false;
 },
 //>>excludeStart("ide", pragmas.excludeIdeData);
 args: [],
-source: "isSuperKeyword\x0a\x09^ false",
+source: "isSuper\x0a\x09^ false",
 referencedClasses: [],
 //>>excludeEnd("ide");
 pragmas: [],
@@ -2199,7 +2199,7 @@ return $recv($1)._and_((function(){
 //>>excludeStart("ctx", pragmas.excludeDebugContexts);
 return $core.withContext(function($ctx2) {
 //>>excludeEnd("ctx");
-return $recv($self._receiver())._isSuperKeyword();
+return $recv($self._receiver())._isSuper();
 //>>excludeStart("ctx", pragmas.excludeDebugContexts);
 }, function($ctx2) {$ctx2.fillBlock({},$ctx1,1)});
 //>>excludeEnd("ctx");
@@ -2210,11 +2210,11 @@ return $recv($self._receiver())._isSuperKeyword();
 },
 //>>excludeStart("ide", pragmas.excludeIdeData);
 args: [],
-source: "superSend\x0a\x09^ self receiver notNil and: [ self receiver isSuperKeyword ]",
+source: "superSend\x0a\x09^ self receiver notNil and: [ self receiver isSuper ]",
 referencedClasses: [],
 //>>excludeEnd("ide");
 pragmas: [],
-messageSends: ["and:", "notNil", "receiver", "isSuperKeyword"]
+messageSends: ["and:", "notNil", "receiver", "isSuper"]
 }),
 $globals.SendNode);
 
@@ -2755,25 +2755,25 @@ $globals.VariableNode);
 
 $core.addMethod(
 $core.method({
-selector: "isSuperKeyword",
+selector: "isSuper",
 protocol: "testing",
 fn: function (){
 var self=this,$self=this;
 //>>excludeStart("ctx", pragmas.excludeDebugContexts);
 return $core.withContext(function($ctx1) {
 //>>excludeEnd("ctx");
-return $recv($self._value()).__eq("super");
+return $recv($self._binding())._isSuper();
 //>>excludeStart("ctx", pragmas.excludeDebugContexts);
-}, function($ctx1) {$ctx1.fill(self,"isSuperKeyword",{})});
+}, function($ctx1) {$ctx1.fill(self,"isSuper",{})});
 //>>excludeEnd("ctx");
 },
 //>>excludeStart("ide", pragmas.excludeIdeData);
 args: [],
-source: "isSuperKeyword\x0a\x09^ self value = 'super'",
+source: "isSuper\x0a\x09^ self binding isSuper",
 referencedClasses: [],
 //>>excludeEnd("ide");
 pragmas: [],
-messageSends: ["=", "value"]
+messageSends: ["isSuper", "binding"]
 }),
 $globals.VariableNode);
 

+ 4 - 4
lang/src/Compiler-AST.st

@@ -146,7 +146,7 @@ isSequenceNode
 	^ false
 !
 
-isSuperKeyword
+isSuper
 	^ false
 !
 
@@ -500,7 +500,7 @@ shouldBeInlined: aBoolean
 !
 
 superSend
-	^ self receiver notNil and: [ self receiver isSuperKeyword ]
+	^ self receiver notNil and: [ self receiver isSuper ]
 ! !
 
 !SendNode methodsFor: 'testing'!
@@ -660,8 +660,8 @@ isNavigationNode
 	^ true
 !
 
-isSuperKeyword
-	^ self value = 'super'
+isSuper
+	^ self binding isSuper
 !
 
 isVariableNode

+ 57 - 15
lang/src/Compiler-Semantic.js

@@ -1032,7 +1032,7 @@ var self=this,$self=this;
 //>>excludeStart("ctx", pragmas.excludeDebugContexts);
 return $core.withContext(function($ctx1) {
 //>>excludeEnd("ctx");
-var $1,$2,$4,$3,$receiver;
+var $1,$2,$4,$5,$6,$3,$7,$9,$8,$receiver;
 $1=$self.pseudoVars;
 if(($receiver = $1) == null || $receiver.a$nil){
 $self.pseudoVars=$recv($globals.Dictionary)._new();
@@ -1042,13 +1042,35 @@ return $core.withContext(function($ctx2) {
 //>>excludeEnd("ctx");
 $2=$self.pseudoVars;
 $4=$recv($globals.PseudoVar)._on_(each);
-$recv($4)._scope_($self._methodScope());
-$3=$recv($4)._yourself();
+//>>excludeStart("ctx", pragmas.excludeDebugContexts);
+$ctx2.sendIdx["on:"]=1;
+//>>excludeEnd("ctx");
+$5=$self._methodScope();
+//>>excludeStart("ctx", pragmas.excludeDebugContexts);
+$ctx2.sendIdx["methodScope"]=1;
+//>>excludeEnd("ctx");
+$recv($4)._scope_($5);
+//>>excludeStart("ctx", pragmas.excludeDebugContexts);
+$ctx2.sendIdx["scope:"]=1;
+//>>excludeEnd("ctx");
+$6=$recv($4)._yourself();
+//>>excludeStart("ctx", pragmas.excludeDebugContexts);
+$ctx2.sendIdx["yourself"]=1;
+//>>excludeEnd("ctx");
+$3=$6;
 return $recv($2)._at_put_(each,$3);
 //>>excludeStart("ctx", pragmas.excludeDebugContexts);
+$ctx2.sendIdx["at:put:"]=1;
+//>>excludeEnd("ctx");
+//>>excludeStart("ctx", pragmas.excludeDebugContexts);
 }, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1,2)});
 //>>excludeEnd("ctx");
 }));
+$7=$self.pseudoVars;
+$9=$recv($globals.SuperVar)._on_("super");
+$recv($9)._scope_($self._methodScope());
+$8=$recv($9)._yourself();
+$recv($7)._at_put_("super",$8);
 } else {
 $1;
 }
@@ -1059,8 +1081,8 @@ return $self.pseudoVars;
 },
 //>>excludeStart("ide", pragmas.excludeIdeData);
 args: [],
-source: "pseudoVars\x0a\x09pseudoVars ifNil: [\x0a\x09\x09pseudoVars := Dictionary new.\x0a\x09\x09Smalltalk pseudoVariableNames do: [ :each |\x0a\x09\x09\x09pseudoVars at: each put: ((PseudoVar on: each)\x0a\x09\x09\x09\x09scope: self methodScope;\x0a\x09\x09\x09\x09yourself) ]].\x0a\x09^ pseudoVars",
-referencedClasses: ["Dictionary", "Smalltalk", "PseudoVar"],
+source: "pseudoVars\x0a\x09pseudoVars ifNil: [\x0a\x09\x09pseudoVars := Dictionary new.\x0a\x09\x09Smalltalk pseudoVariableNames do: [ :each |\x0a\x09\x09\x09pseudoVars at: each put: ((PseudoVar on: each)\x0a\x09\x09\x09\x09scope: self methodScope;\x0a\x09\x09\x09\x09yourself) ].\x0a\x09\x09pseudoVars at: #super put: ((SuperVar on: #super) scope: self methodScope; yourself) ].\x0a\x09^ pseudoVars",
+referencedClasses: ["Dictionary", "Smalltalk", "PseudoVar", "SuperVar"],
 //>>excludeEnd("ide");
 pragmas: [],
 messageSends: ["ifNil:", "new", "do:", "pseudoVariableNames", "at:put:", "scope:", "on:", "methodScope", "yourself"]
@@ -1787,29 +1809,49 @@ messageSends: ["="]
 }),
 $globals.PseudoVar);
 
+
+
+$core.addClass("SuperVar", $globals.PseudoVar, [], "Compiler-Semantic");
+//>>excludeStart("ide", pragmas.excludeIdeData);
+$globals.SuperVar.comment="I am a 'super' pseudo variable.";
+//>>excludeEnd("ide");
+$core.addMethod(
+$core.method({
+selector: "alias",
+protocol: "accessing",
+fn: function (){
+var self=this,$self=this;
+return "self";
+
+},
+//>>excludeStart("ide", pragmas.excludeIdeData);
+args: [],
+source: "alias\x0a\x09^ 'self'",
+referencedClasses: [],
+//>>excludeEnd("ide");
+pragmas: [],
+messageSends: []
+}),
+$globals.SuperVar);
+
 $core.addMethod(
 $core.method({
 selector: "isSuper",
 protocol: "testing",
 fn: function (){
 var self=this,$self=this;
-//>>excludeStart("ctx", pragmas.excludeDebugContexts);
-return $core.withContext(function($ctx1) {
-//>>excludeEnd("ctx");
-return $recv($self.name).__eq("super");
-//>>excludeStart("ctx", pragmas.excludeDebugContexts);
-}, function($ctx1) {$ctx1.fill(self,"isSuper",{})});
-//>>excludeEnd("ctx");
+return true;
+
 },
 //>>excludeStart("ide", pragmas.excludeIdeData);
 args: [],
-source: "isSuper\x0a\x09^ name = 'super'",
+source: "isSuper\x0a\x09^ true",
 referencedClasses: [],
 //>>excludeEnd("ide");
 pragmas: [],
-messageSends: ["="]
+messageSends: []
 }),
-$globals.PseudoVar);
+$globals.SuperVar);
 
 
 

+ 18 - 3
lang/src/Compiler-Semantic.st

@@ -166,7 +166,8 @@ pseudoVars
 		Smalltalk pseudoVariableNames do: [ :each |
 			pseudoVars at: each put: ((PseudoVar on: each)
 				scope: self methodScope;
-				yourself) ]].
+				yourself) ].
+		pseudoVars at: #super put: ((SuperVar on: #super) scope: self methodScope; yourself) ].
 	^ pseudoVars
 !
 
@@ -395,10 +396,24 @@ isPseudoVar
 
 isSelf
 	^ name = 'self'
-!
+! !
+
+PseudoVar subclass: #SuperVar
+	slots: {}
+	package: 'Compiler-Semantic'!
+!SuperVar commentStamp!
+I am a 'super' pseudo variable.!
+
+!SuperVar methodsFor: 'accessing'!
+
+alias
+	^ 'self'
+! !
+
+!SuperVar methodsFor: 'testing'!
 
 isSuper
-	^ name = 'super'
+	^ true
 ! !
 
 ScopeVar subclass: #TempVar