浏览代码

Added 'NativeFunction exists:' method

Apostolis Xekoukoulotakis 11 年之前
父节点
当前提交
d10b797e3c
共有 3 个文件被更改,包括 31 次插入0 次删除
  1. 11 0
      js/Kernel-Methods.deploy.js
  2. 16 0
      js/Kernel-Methods.js
  3. 4 0
      st/Kernel-Methods.st

+ 11 - 0
js/Kernel-Methods.deploy.js

@@ -923,4 +923,15 @@ return self}, function($ctx1) {$ctx1.fill(self,"class:value:value:value:",{aStri
 }),
 smalltalk.NativeFunction.klass);
 
+smalltalk.addMethod(
+"_exists_",
+smalltalk.method({
+selector: "exists:",
+fn: function (aString){
+var self=this;
+return smalltalk.withContext(function($ctx1) { 
if(aString in window){return true}else{return false};
+return self}, function($ctx1) {$ctx1.fill(self,"exists:",{aString:aString}, smalltalk.NativeFunction.klass)})}
+}),
+smalltalk.NativeFunction.klass);
+
 

+ 16 - 0
js/Kernel-Methods.js

@@ -1268,4 +1268,20 @@ referencedClasses: []
 }),
 smalltalk.NativeFunction.klass);
 
+smalltalk.addMethod(
+"_exists_",
+smalltalk.method({
+selector: "exists:",
+category: 'not yet classified',
+fn: function (aString){
+var self=this;
+return smalltalk.withContext(function($ctx1) { 
if(aString in window){return true}else{return false};
+return self}, function($ctx1) {$ctx1.fill(self,"exists:",{aString:aString}, smalltalk.NativeFunction.klass)})},
+args: ["aString"],
+source: "exists: aString\x0a<if(aString in window){return true}else{return false}>\x0a",
+messageSends: [],
+referencedClasses: []
+}),
+smalltalk.NativeFunction.klass);
+
 

+ 4 - 0
st/Kernel-Methods.st

@@ -442,5 +442,9 @@ class: aString value:anObject value: anObject2
 class: aString value:anObject value: anObject2 value:anObject3
 
 <var a=eval(aString); return new a(anObject,anObject2, anObject3);>
+!
+
+exists: aString
+<if(aString in window){return true}else{return false}>
 ! !