Parcourir la source

Add isSelf/isSuper to certain compiler objects.

Herbert Vojčík il y a 7 ans
Parent
commit
f4412cd654
5 fichiers modifiés avec 212 ajouts et 0 suppressions
  1. 16 0
      API-CHANGES.txt
  2. 82 0
      src/Compiler-IR.js
  3. 16 0
      src/Compiler-IR.st
  4. 82 0
      src/Compiler-Semantic.js
  5. 16 0
      src/Compiler-Semantic.st

+ 16 - 0
API-CHANGES.txt

@@ -1,3 +1,19 @@
+0.18.6:
+
++ IRInstructions >>
+  + isSelf
+  + isSuper
++ IRVariable >>
+  + isSelf
+  + isSuper
++ ScopeVar >>
+  + isSelf
+  + isSuper
++ PseudoVar >>
+  + isSelf
+  + isSuper
+
+
 0.18.3:
 
 * Move {add,remove}Element from Array.prototype to kernel API.

+ 82 - 0
src/Compiler-IR.js

@@ -1175,6 +1175,24 @@ messageSends: []
 }),
 $globals.IRInstruction);
 
+$core.addMethod(
+$core.method({
+selector: "isSelf",
+protocol: "testing",
+fn: function (){
+var self=this;
+return false;
+
+},
+//>>excludeStart("ide", pragmas.excludeIdeData);
+args: [],
+source: "isSelf\x0a\x09^ false",
+referencedClasses: [],
+//>>excludeEnd("ide");
+messageSends: []
+}),
+$globals.IRInstruction);
+
 $core.addMethod(
 $core.method({
 selector: "isSend",
@@ -1211,6 +1229,24 @@ messageSends: []
 }),
 $globals.IRInstruction);
 
+$core.addMethod(
+$core.method({
+selector: "isSuper",
+protocol: "testing",
+fn: function (){
+var self=this;
+return false;
+
+},
+//>>excludeStart("ide", pragmas.excludeIdeData);
+args: [],
+source: "isSuper\x0a\x09^ false",
+referencedClasses: [],
+//>>excludeEnd("ide");
+messageSends: []
+}),
+$globals.IRInstruction);
+
 $core.addMethod(
 $core.method({
 selector: "isTempDeclaration",
@@ -2829,6 +2865,52 @@ messageSends: ["visitIRVariable:"]
 }),
 $globals.IRVariable);
 
+$core.addMethod(
+$core.method({
+selector: "isSelf",
+protocol: "testing",
+fn: function (){
+var self=this;
+//>>excludeStart("ctx", pragmas.excludeDebugContexts);
+return $core.withContext(function($ctx1) {
+//>>excludeEnd("ctx");
+return $recv(self._variable())._isSelf();
+//>>excludeStart("ctx", pragmas.excludeDebugContexts);
+}, function($ctx1) {$ctx1.fill(self,"isSelf",{},$globals.IRVariable)});
+//>>excludeEnd("ctx");
+},
+//>>excludeStart("ide", pragmas.excludeIdeData);
+args: [],
+source: "isSelf\x0a\x09^ self variable isSelf",
+referencedClasses: [],
+//>>excludeEnd("ide");
+messageSends: ["isSelf", "variable"]
+}),
+$globals.IRVariable);
+
+$core.addMethod(
+$core.method({
+selector: "isSuper",
+protocol: "testing",
+fn: function (){
+var self=this;
+//>>excludeStart("ctx", pragmas.excludeDebugContexts);
+return $core.withContext(function($ctx1) {
+//>>excludeEnd("ctx");
+return $recv(self._variable())._isSuper();
+//>>excludeStart("ctx", pragmas.excludeDebugContexts);
+}, function($ctx1) {$ctx1.fill(self,"isSuper",{},$globals.IRVariable)});
+//>>excludeEnd("ctx");
+},
+//>>excludeStart("ide", pragmas.excludeIdeData);
+args: [],
+source: "isSuper\x0a\x09^ self variable isSuper",
+referencedClasses: [],
+//>>excludeEnd("ide");
+messageSends: ["isSuper", "variable"]
+}),
+$globals.IRVariable);
+
 $core.addMethod(
 $core.method({
 selector: "isVariable",

+ 16 - 0
src/Compiler-IR.st

@@ -317,6 +317,10 @@ isMethod
 	^ false
 !
 
+isSelf
+	^ false
+!
+
 isSend
 	^ false
 !
@@ -325,6 +329,10 @@ isSequence
 	^ false
 !
 
+isSuper
+	^ false
+!
+
 isTempDeclaration
 	^ false
 !
@@ -738,6 +746,14 @@ variable: aScopeVariable
 
 !IRVariable methodsFor: 'testing'!
 
+isSelf
+	^ self variable isSelf
+!
+
+isSuper
+	^ self variable isSuper
+!
+
 isVariable
 	^ true
 !

+ 82 - 0
src/Compiler-Semantic.js

@@ -1208,6 +1208,42 @@ messageSends: []
 }),
 $globals.ScopeVar);
 
+$core.addMethod(
+$core.method({
+selector: "isSelf",
+protocol: "testing",
+fn: function (){
+var self=this;
+return false;
+
+},
+//>>excludeStart("ide", pragmas.excludeIdeData);
+args: [],
+source: "isSelf\x0a\x09^ false",
+referencedClasses: [],
+//>>excludeEnd("ide");
+messageSends: []
+}),
+$globals.ScopeVar);
+
+$core.addMethod(
+$core.method({
+selector: "isSuper",
+protocol: "testing",
+fn: function (){
+var self=this;
+return false;
+
+},
+//>>excludeStart("ide", pragmas.excludeIdeData);
+args: [],
+source: "isSuper\x0a\x09^ false",
+referencedClasses: [],
+//>>excludeEnd("ide");
+messageSends: []
+}),
+$globals.ScopeVar);
+
 $core.addMethod(
 $core.method({
 selector: "isTempVar",
@@ -1667,6 +1703,52 @@ messageSends: []
 }),
 $globals.PseudoVar);
 
+$core.addMethod(
+$core.method({
+selector: "isSelf",
+protocol: "testing",
+fn: function (){
+var self=this;
+//>>excludeStart("ctx", pragmas.excludeDebugContexts);
+return $core.withContext(function($ctx1) {
+//>>excludeEnd("ctx");
+return $recv(self["@name"]).__eq("self");
+//>>excludeStart("ctx", pragmas.excludeDebugContexts);
+}, function($ctx1) {$ctx1.fill(self,"isSelf",{},$globals.PseudoVar)});
+//>>excludeEnd("ctx");
+},
+//>>excludeStart("ide", pragmas.excludeIdeData);
+args: [],
+source: "isSelf\x0a\x09^ name = 'self'",
+referencedClasses: [],
+//>>excludeEnd("ide");
+messageSends: ["="]
+}),
+$globals.PseudoVar);
+
+$core.addMethod(
+$core.method({
+selector: "isSuper",
+protocol: "testing",
+fn: function (){
+var 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",{},$globals.PseudoVar)});
+//>>excludeEnd("ctx");
+},
+//>>excludeStart("ide", pragmas.excludeIdeData);
+args: [],
+source: "isSuper\x0a\x09^ name = 'super'",
+referencedClasses: [],
+//>>excludeEnd("ide");
+messageSends: ["="]
+}),
+$globals.PseudoVar);
+
 
 
 $core.addClass("TempVar", $globals.ScopeVar, [], "Compiler-Semantic");

+ 16 - 0
src/Compiler-Semantic.st

@@ -258,6 +258,14 @@ isPseudoVar
 	^ false
 !
 
+isSelf
+	^ false
+!
+
+isSuper
+	^ false
+!
+
 isTempVar
 	^ false
 !
@@ -383,6 +391,14 @@ isImmutable
 
 isPseudoVar
 	^ true
+!
+
+isSelf
+	^ name = 'self'
+!
+
+isSuper
+	^ name = 'super'
 ! !
 
 ScopeVar subclass: #TempVar