Browse Source

Smalltalk class >> current doing good old classinstvar singleton

Herbert Vojčík 10 years ago
parent
commit
76e224ce5f
2 changed files with 16 additions and 5 deletions
  1. 13 4
      js/Kernel-Infrastructure.js
  2. 3 1
      st/Kernel-Infrastructure.st

+ 13 - 4
js/Kernel-Infrastructure.js

@@ -2609,6 +2609,7 @@ referencedClasses: []
 smalltalk.Smalltalk);
 
 
+smalltalk.Smalltalk.klass.iVarNames = ['current'];
 smalltalk.addMethod(
 smalltalk.method({
 selector: "current",
@@ -2616,11 +2617,19 @@ protocol: 'accessing',
 fn: function (){
 var self=this;
 return smalltalk.withContext(function($ctx1) { 
-return smalltalk;
-return self}, function($ctx1) {$ctx1.fill(self,"current",{},smalltalk.Smalltalk.klass)})},
+var $2,$1;
+$2=self["@current"];
+if(($receiver = $2) == nil || $receiver == null){
+self["@current"]=self._new();
+$1=self["@current"];
+} else {
+$1=$2;
+};
+return $1;
+}, function($ctx1) {$ctx1.fill(self,"current",{},smalltalk.Smalltalk.klass)})},
 args: [],
-source: "current\x0a\x09<return smalltalk>",
-messageSends: [],
+source: "current\x0a\x09^ current ifNil: [ current := self new ]",
+messageSends: ["ifNil:", "new"],
 referencedClasses: []
 }),
 smalltalk.Smalltalk.klass);

+ 3 - 1
st/Kernel-Infrastructure.st

@@ -985,10 +985,12 @@ isSmalltalkObject: anObject
 	<return typeof anObject.klass !!== 'undefined'>
 ! !
 
+Smalltalk class instanceVariableNames: 'current'!
+
 !Smalltalk class methodsFor: 'accessing'!
 
 current
-	<return smalltalk>
+	^ current ifNil: [ current := self new ]
 ! !
 
 !SequenceableCollection methodsFor: '*Kernel-Infrastructure'!