1
0
Bläddra i källkod

Cleaning Smalltalk class

Herbert Vojčík 11 år sedan
förälder
incheckning
f2cd6b7cd6
3 ändrade filer med 89 tillägg och 54 borttagningar
  1. 24 10
      js/Kernel-Infrastructure.deploy.js
  2. 37 18
      js/Kernel-Infrastructure.js
  3. 28 26
      st/Kernel-Infrastructure.st

+ 24 - 10
js/Kernel-Infrastructure.deploy.js

@@ -1396,10 +1396,10 @@ fn: function (){
 var self=this;
 return smalltalk.withContext(function($ctx1) { 
 var $1;
-$1=self._basicAt_("amdRequire");
+$1=self._at_("amdRequire");
 return $1;
 }, function($ctx1) {$ctx1.fill(self,"amdRequire",{},smalltalk.Smalltalk)})},
-messageSends: ["basicAt:"]}),
+messageSends: ["at:"]}),
 smalltalk.Smalltalk);
 
 smalltalk.addMethod(
@@ -1431,9 +1431,24 @@ selector: "at:",
 fn: function (aString){
 var self=this;
 return smalltalk.withContext(function($ctx1) { 
-return self[aString];
-return self}, function($ctx1) {$ctx1.fill(self,"at:",{aString:aString},smalltalk.Smalltalk)})},
-messageSends: []}),
+var $1;
+$1=self._basicAt_(aString);
+return $1;
+}, function($ctx1) {$ctx1.fill(self,"at:",{aString:aString},smalltalk.Smalltalk)})},
+messageSends: ["basicAt:"]}),
+smalltalk.Smalltalk);
+
+smalltalk.addMethod(
+smalltalk.method({
+selector: "at:put:",
+fn: function (aString,anObject){
+var self=this;
+return smalltalk.withContext(function($ctx1) { 
+var $1;
+$1=self._basicAt_put_(aString,anObject);
+return $1;
+}, function($ctx1) {$ctx1.fill(self,"at:put:",{aString:aString,anObject:anObject},smalltalk.Smalltalk)})},
+messageSends: ["basicAt:put:"]}),
 smalltalk.Smalltalk);
 
 smalltalk.addMethod(
@@ -1507,10 +1522,10 @@ fn: function (){
 var self=this;
 return smalltalk.withContext(function($ctx1) { 
 var $1;
-$1=self._basicAt_("defaultAMDNamespace");
+$1=self._at_("defaultAMDNamespace");
 return $1;
 }, function($ctx1) {$ctx1.fill(self,"defaultAMDNamespace",{},smalltalk.Smalltalk)})},
-messageSends: ["basicAt:"]}),
+messageSends: ["at:"]}),
 smalltalk.Smalltalk);
 
 smalltalk.addMethod(
@@ -1740,11 +1755,11 @@ $1;
 } else {
 self._error_("Already exists a package called: ".__comma(newName));
 };
-_st(self._basicAt_("packages"))._at_put_(newName,pkg);
+_st(self._at_("packages"))._at_put_(newName,pkg);
 _st(pkg)._name_(newName);
 self._deletePackage_(packageName);
 return self}, function($ctx1) {$ctx1.fill(self,"renamePackage:to:",{packageName:packageName,newName:newName,pkg:pkg},smalltalk.Smalltalk)})},
-messageSends: ["packageAt:ifAbsent:", "error:", ",", "ifNotNil:", "packageAt:", "at:put:", "basicAt:", "name:", "deletePackage:"]}),
+messageSends: ["packageAt:ifAbsent:", "error:", ",", "ifNotNil:", "packageAt:", "at:put:", "at:", "name:", "deletePackage:"]}),
 smalltalk.Smalltalk);
 
 smalltalk.addMethod(
@@ -1770,7 +1785,6 @@ messageSends: []}),
 smalltalk.Smalltalk);
 
 
-smalltalk.Smalltalk.klass.iVarNames = ['current'];
 smalltalk.addMethod(
 smalltalk.method({
 selector: "current",

+ 37 - 18
js/Kernel-Infrastructure.js

@@ -1848,12 +1848,12 @@ fn: function (){
 var self=this;
 return smalltalk.withContext(function($ctx1) { 
 var $1;
-$1=self._basicAt_("amdRequire");
+$1=self._at_("amdRequire");
 return $1;
 }, function($ctx1) {$ctx1.fill(self,"amdRequire",{},smalltalk.Smalltalk)})},
 args: [],
-source: "amdRequire\x0a\x09^ self basicAt: 'amdRequire'",
-messageSends: ["basicAt:"],
+source: "amdRequire\x0a\x09^ self at: 'amdRequire'",
+messageSends: ["at:"],
 referencedClasses: []
 }),
 smalltalk.Smalltalk);
@@ -1893,11 +1893,31 @@ category: 'accessing',
 fn: function (aString){
 var self=this;
 return smalltalk.withContext(function($ctx1) { 
-return self[aString];
-return self}, function($ctx1) {$ctx1.fill(self,"at:",{aString:aString},smalltalk.Smalltalk)})},
+var $1;
+$1=self._basicAt_(aString);
+return $1;
+}, function($ctx1) {$ctx1.fill(self,"at:",{aString:aString},smalltalk.Smalltalk)})},
 args: ["aString"],
-source: "at: aString\x0a\x09<return self[aString]>",
-messageSends: [],
+source: "at: aString\x0a\x09^ self basicAt: aString",
+messageSends: ["basicAt:"],
+referencedClasses: []
+}),
+smalltalk.Smalltalk);
+
+smalltalk.addMethod(
+smalltalk.method({
+selector: "at:put:",
+category: 'accessing',
+fn: function (aString,anObject){
+var self=this;
+return smalltalk.withContext(function($ctx1) { 
+var $1;
+$1=self._basicAt_put_(aString,anObject);
+return $1;
+}, function($ctx1) {$ctx1.fill(self,"at:put:",{aString:aString,anObject:anObject},smalltalk.Smalltalk)})},
+args: ["aString", "anObject"],
+source: "at: aString put: anObject\x0a\x09^ self basicAt: aString put: anObject",
+messageSends: ["basicAt:put:"],
 referencedClasses: []
 }),
 smalltalk.Smalltalk);
@@ -1955,7 +1975,7 @@ smalltalk.Smalltalk);
 smalltalk.addMethod(
 smalltalk.method({
 selector: "createPackage:",
-category: 'private',
+category: 'packages',
 fn: function (packageName){
 var self=this;
 return smalltalk.withContext(function($ctx1) { 
@@ -1999,12 +2019,12 @@ fn: function (){
 var self=this;
 return smalltalk.withContext(function($ctx1) { 
 var $1;
-$1=self._basicAt_("defaultAMDNamespace");
+$1=self._at_("defaultAMDNamespace");
 return $1;
 }, function($ctx1) {$ctx1.fill(self,"defaultAMDNamespace",{},smalltalk.Smalltalk)})},
 args: [],
-source: "defaultAMDNamespace\x0a\x09^ self basicAt: 'defaultAMDNamespace'",
-messageSends: ["basicAt:"],
+source: "defaultAMDNamespace\x0a\x09^ self at: 'defaultAMDNamespace'",
+messageSends: ["at:"],
 referencedClasses: []
 }),
 smalltalk.Smalltalk);
@@ -2028,7 +2048,7 @@ smalltalk.Smalltalk);
 smalltalk.addMethod(
 smalltalk.method({
 selector: "deleteClass:",
-category: 'classes',
+category: 'private',
 fn: function (aClass){
 var self=this;
 return smalltalk.withContext(function($ctx1) { 
@@ -2062,7 +2082,7 @@ smalltalk.Smalltalk);
 smalltalk.addMethod(
 smalltalk.method({
 selector: "deletePackage:",
-category: 'packages',
+category: 'private',
 fn: function (packageName){
 var self=this;
 return smalltalk.withContext(function($ctx1) { 
@@ -2210,7 +2230,7 @@ smalltalk.Smalltalk);
 smalltalk.addMethod(
 smalltalk.method({
 selector: "pseudoVariableNames",
-category: 'packages',
+category: 'accessing',
 fn: function (){
 var self=this;
 return smalltalk.withContext(function($ctx1) { 
@@ -2312,13 +2332,13 @@ $1;
 } else {
 self._error_("Already exists a package called: ".__comma(newName));
 };
-_st(self._basicAt_("packages"))._at_put_(newName,pkg);
+_st(self._at_("packages"))._at_put_(newName,pkg);
 _st(pkg)._name_(newName);
 self._deletePackage_(packageName);
 return self}, function($ctx1) {$ctx1.fill(self,"renamePackage:to:",{packageName:packageName,newName:newName,pkg:pkg},smalltalk.Smalltalk)})},
 args: ["packageName", "newName"],
-source: "renamePackage: packageName to: newName\x0a\x09\x22Rename a package.\x22\x0a\x0a\x09| pkg |\x0a\x09pkg := self packageAt: packageName ifAbsent: [self error: 'Missing package: ', packageName].\x0a\x09(self packageAt: newName) ifNotNil: [self error: 'Already exists a package called: ', newName].\x0a\x09(self basicAt: 'packages') at: newName put: pkg.\x0a\x09pkg name: newName.\x0a\x09self deletePackage: packageName.",
-messageSends: ["packageAt:ifAbsent:", "error:", ",", "ifNotNil:", "packageAt:", "at:put:", "basicAt:", "name:", "deletePackage:"],
+source: "renamePackage: packageName to: newName\x0a\x09\x22Rename a package.\x22\x0a\x0a\x09| pkg |\x0a\x09pkg := self packageAt: packageName ifAbsent: [self error: 'Missing package: ', packageName].\x0a\x09(self packageAt: newName) ifNotNil: [self error: 'Already exists a package called: ', newName].\x0a\x09(self at: 'packages') at: newName put: pkg.\x0a\x09pkg name: newName.\x0a\x09self deletePackage: packageName.",
+messageSends: ["packageAt:ifAbsent:", "error:", ",", "ifNotNil:", "packageAt:", "at:put:", "at:", "name:", "deletePackage:"],
 referencedClasses: []
 }),
 smalltalk.Smalltalk);
@@ -2356,7 +2376,6 @@ referencedClasses: []
 smalltalk.Smalltalk);
 
 
-smalltalk.Smalltalk.klass.iVarNames = ['current'];
 smalltalk.addMethod(
 smalltalk.method({
 selector: "current",

+ 28 - 26
st/Kernel-Infrastructure.st

@@ -750,7 +750,11 @@ It requires the `Compiler` package and the `js/parser.js` parser file in order t
 !Smalltalk methodsFor: 'accessing'!
 
 at: aString
-	<return self[aString]>
+	^ self basicAt: aString
+!
+
+at: aString put: anObject
+	^ self basicAt: aString put: anObject
 !
 
 parse: aString
@@ -765,6 +769,10 @@ parse: aString
 		yourself
 !
 
+pseudoVariableNames
+	^ #('self' 'super' 'nil' 'true' 'false' 'thisContext')
+!
+
 readJSObject: anObject
 	<return self.readJSObject(anObject)>
 !
@@ -783,11 +791,11 @@ version
 !Smalltalk methodsFor: 'accessing amd'!
 
 amdRequire
-	^ self basicAt: 'amdRequire'
+	^ self at: 'amdRequire'
 !
 
 defaultAMDNamespace
-	^ self basicAt: 'defaultAMDNamespace'
+	^ self at: 'defaultAMDNamespace'
 !
 
 defaultAMDNamespace: aString
@@ -800,12 +808,6 @@ classes
 	<return self.classes()>
 !
 
-deleteClass: aClass
-	"Deletes a class by deleting its binding only. Use #removeClass instead"
-	
-	<self.removeClass(aClass)>
-!
-
 removeClass: aClass
 	aClass isMetaclass ifTrue: [self error: aClass asString, ' is a Metaclass and cannot be removed!!'].
 	
@@ -854,11 +856,9 @@ createDefaultPackage: packageName
 	^ (self createPackage: packageName) withDefaultTransport
 !
 
-deletePackage: packageName
-	"Deletes a package by deleting its binding, but does not check if it contains classes etc.
-	To remove a package, use #removePackage instead."
-
-	<delete smalltalk.packages[packageName]>
+createPackage: packageName
+	"Create and bind a new bare package with given name and return it."
+	<return smalltalk.addPackage(packageName)>
 !
 
 packageAt: packageName
@@ -875,10 +875,6 @@ packages
 	<return self.packages.all()>
 !
 
-pseudoVariableNames
-	^ #('self' 'super' 'nil' 'true' 'false' 'thisContext')
-!
-
 removePackage: packageName
 	"Removes a package and all its classes."
 
@@ -895,7 +891,7 @@ renamePackage: packageName to: newName
 	| pkg |
 	pkg := self packageAt: packageName ifAbsent: [self error: 'Missing package: ', packageName].
 	(self packageAt: newName) ifNotNil: [self error: 'Already exists a package called: ', newName].
-	(self basicAt: 'packages') at: newName put: pkg.
+	(self at: 'packages') at: newName put: pkg.
 	pkg name: newName.
 	self deletePackage: packageName.
 ! !
@@ -906,17 +902,25 @@ basicParse: aString
 	<return smalltalk.parser.parse(aString)>
 !
 
-createPackage: packageName
-	"Create and bind a new bare package with given name and return it."
-	<return smalltalk.addPackage(packageName)>
-!
-
 createPackage: packageName properties: aDict
 	"Needed to import .st files: they begin with this call."
 	self deprecatedAPI.
 	
 	aDict isEmpty ifFalse: [ self error: 'createPackage:properties: called with nonempty properties' ].
 	^ self createPackage: packageName
+!
+
+deleteClass: aClass
+	"Deletes a class by deleting its binding only. Use #removeClass instead"
+	
+	<self.removeClass(aClass)>
+!
+
+deletePackage: packageName
+	"Deletes a package by deleting its binding, but does not check if it contains classes etc.
+	To remove a package, use #removePackage instead."
+
+	<delete smalltalk.packages[packageName]>
 ! !
 
 !Smalltalk methodsFor: 'testing'!
@@ -928,8 +932,6 @@ isSmalltalkObject: anObject
 	<return typeof anObject.klass !!== 'undefined'>
 ! !
 
-Smalltalk class instanceVariableNames: 'current'!
-
 !Smalltalk class methodsFor: 'accessing'!
 
 current