Explorar el Código

Get rid of basicAt: remnants in Organizers.

Herbert Vojčík hace 7 años
padre
commit
60ce49c2c8
Se han modificado 4 ficheros con 96 adiciones y 167 borrados
  1. 23 41
      src/Kernel-Classes.js
  2. 7 7
      src/Kernel-Classes.st
  3. 51 97
      src/Kernel-Infrastructure.js
  4. 15 22
      src/Kernel-Infrastructure.st

+ 23 - 41
src/Kernel-Classes.js

@@ -7,7 +7,7 @@ $core.addPackage("Kernel-Classes");
 $core.packages["Kernel-Classes"].innerEval = function (expr) { return eval(expr); };
 $core.packages["Kernel-Classes"].transport = {"type":"amd","amdNamespace":"amber_core"};
 
-$core.addClass("Behavior", $globals.Object, [], "Kernel-Classes");
+$core.addClass("Behavior", $globals.Object, ["organization"], "Kernel-Classes");
 //>>excludeStart("ide", pragmas.excludeIdeData);
 $globals.Behavior.comment="I am the superclass of all class objects.\x0a\x0aIn addition to BehaviorBody, I define superclass/subclass relationships and instantiation.\x0a\x0aI define the protocol for creating instances of a class with `#basicNew` and `#new` (see `boot.js` for class constructors details).\x0a\x0aMy instances know about the subclass/superclass relationships between classes and contain the description that instances are created from.\x0a\x0aI also provide iterating over the class hierarchy.";
 //>>excludeEnd("ide");
@@ -218,20 +218,15 @@ selector: "basicOrganization",
 protocol: "accessing",
 fn: function (){
 var self=this,$self=this;
-//>>excludeStart("ctx", pragmas.excludeDebugContexts);
-return $core.withContext(function($ctx1) {
-//>>excludeEnd("ctx");
-return $self._basicAt_("organization");
-//>>excludeStart("ctx", pragmas.excludeDebugContexts);
-}, function($ctx1) {$ctx1.fill(self,"basicOrganization",{},$globals.Behavior)});
-//>>excludeEnd("ctx");
+return $self["@organization"];
+
 },
 //>>excludeStart("ide", pragmas.excludeIdeData);
 args: [],
-source: "basicOrganization\x0a\x09^ self basicAt: 'organization'",
+source: "basicOrganization\x0a\x09^ organization",
 referencedClasses: [],
 //>>excludeEnd("ide");
-messageSends: ["basicAt:"]
+messageSends: []
 }),
 $globals.Behavior);
 
@@ -241,20 +236,16 @@ selector: "basicOrganization:",
 protocol: "accessing",
 fn: function (aClassOrganizer){
 var self=this,$self=this;
-//>>excludeStart("ctx", pragmas.excludeDebugContexts);
-return $core.withContext(function($ctx1) {
-//>>excludeEnd("ctx");
-return $self._basicAt_put_("organization",aClassOrganizer);
-//>>excludeStart("ctx", pragmas.excludeDebugContexts);
-}, function($ctx1) {$ctx1.fill(self,"basicOrganization:",{aClassOrganizer:aClassOrganizer},$globals.Behavior)});
-//>>excludeEnd("ctx");
+$self["@organization"]=aClassOrganizer;
+return self;
+
 },
 //>>excludeStart("ide", pragmas.excludeIdeData);
 args: ["aClassOrganizer"],
-source: "basicOrganization: aClassOrganizer\x0a\x09^ self basicAt: 'organization' put:aClassOrganizer",
+source: "basicOrganization: aClassOrganizer\x0a\x09organization := aClassOrganizer",
 referencedClasses: [],
 //>>excludeEnd("ide");
-messageSends: ["basicAt:put:"]
+messageSends: []
 }),
 $globals.Behavior);
 
@@ -2875,17 +2866,17 @@ var self=this,$self=this;
 //>>excludeStart("ctx", pragmas.excludeDebugContexts);
 return $core.withContext(function($ctx1) {
 //>>excludeEnd("ctx");
-return $recv($recv($self._organization())._elements())._sorted();
+return $recv($recv($recv($self._organization())._elements())._asArray())._sorted();
 //>>excludeStart("ctx", pragmas.excludeDebugContexts);
 }, function($ctx1) {$ctx1.fill(self,"protocols",{},$globals.TBehaviorProvider)});
 //>>excludeEnd("ctx");
 },
 //>>excludeStart("ide", pragmas.excludeIdeData);
 args: [],
-source: "protocols\x0a\x09^ self organization elements sorted",
+source: "protocols\x0a\x09^ self organization elements asArray sorted",
 referencedClasses: [],
 //>>excludeEnd("ide");
-messageSends: ["sorted", "elements", "organization"]
+messageSends: ["sorted", "asArray", "elements", "organization"]
 }),
 $globals.TBehaviorProvider);
 
@@ -3572,7 +3563,7 @@ messageSends: []
 $globals.TMasterBehavior);
 
 
-$core.addClass("Trait", $globals.Object, [], "Kernel-Classes");
+$core.addClass("Trait", $globals.Object, ["organization"], "Kernel-Classes");
 $core.addMethod(
 $core.method({
 selector: "-",
@@ -3671,20 +3662,15 @@ selector: "basicOrganization",
 protocol: "accessing",
 fn: function (){
 var self=this,$self=this;
-//>>excludeStart("ctx", pragmas.excludeDebugContexts);
-return $core.withContext(function($ctx1) {
-//>>excludeEnd("ctx");
-return $self._basicAt_("organization");
-//>>excludeStart("ctx", pragmas.excludeDebugContexts);
-}, function($ctx1) {$ctx1.fill(self,"basicOrganization",{},$globals.Trait)});
-//>>excludeEnd("ctx");
+return $self["@organization"];
+
 },
 //>>excludeStart("ide", pragmas.excludeIdeData);
 args: [],
-source: "basicOrganization\x0a\x09^ self basicAt: 'organization'",
+source: "basicOrganization\x0a\x09^ organization",
 referencedClasses: [],
 //>>excludeEnd("ide");
-messageSends: ["basicAt:"]
+messageSends: []
 }),
 $globals.Trait);
 
@@ -3694,20 +3680,16 @@ selector: "basicOrganization:",
 protocol: "accessing",
 fn: function (aClassOrganizer){
 var self=this,$self=this;
-//>>excludeStart("ctx", pragmas.excludeDebugContexts);
-return $core.withContext(function($ctx1) {
-//>>excludeEnd("ctx");
-return $self._basicAt_put_("organization",aClassOrganizer);
-//>>excludeStart("ctx", pragmas.excludeDebugContexts);
-}, function($ctx1) {$ctx1.fill(self,"basicOrganization:",{aClassOrganizer:aClassOrganizer},$globals.Trait)});
-//>>excludeEnd("ctx");
+$self["@organization"]=aClassOrganizer;
+return self;
+
 },
 //>>excludeStart("ide", pragmas.excludeIdeData);
 args: ["aClassOrganizer"],
-source: "basicOrganization: aClassOrganizer\x0a\x09^ self basicAt: 'organization' put: aClassOrganizer",
+source: "basicOrganization: aClassOrganizer\x0a\x09organization := aClassOrganizer",
 referencedClasses: [],
 //>>excludeEnd("ide");
-messageSends: ["basicAt:put:"]
+messageSends: []
 }),
 $globals.Trait);
 

+ 7 - 7
src/Kernel-Classes.st

@@ -1,6 +1,6 @@
 Smalltalk createPackage: 'Kernel-Classes'!
 Object subclass: #Behavior
-	instanceVariableNames: ''
+	instanceVariableNames: 'organization'
 	package: 'Kernel-Classes'!
 !Behavior commentStamp!
 I am the superclass of all class objects.
@@ -45,11 +45,11 @@ allSuperclasses
 !
 
 basicOrganization
-	^ self basicAt: 'organization'
+	^ organization
 !
 
 basicOrganization: aClassOrganizer
-	^ self basicAt: 'organization' put:aClassOrganizer
+	organization := aClassOrganizer
 !
 
 instanceVariableNames
@@ -698,7 +698,7 @@ packageOfProtocol: aString
 !
 
 protocols
-	^ self organization elements sorted
+	^ self organization elements asArray sorted
 !
 
 removeProtocolIfEmpty: aString
@@ -912,17 +912,17 @@ asJavaScriptSource
 ! !
 
 Object subclass: #Trait
-	instanceVariableNames: ''
+	instanceVariableNames: 'organization'
 	package: 'Kernel-Classes'!
 
 !Trait methodsFor: 'accessing'!
 
 basicOrganization
-	^ self basicAt: 'organization'
+	^ organization
 !
 
 basicOrganization: aClassOrganizer
-	^ self basicAt: 'organization' put: aClassOrganizer
+	organization := aClassOrganizer
 !
 
 classTag

+ 51 - 97
src/Kernel-Infrastructure.js

@@ -788,7 +788,7 @@ messageSends: ["new", "jsObject:ofProxy:"]
 $globals.JSObjectProxy.a$cls);
 
 
-$core.addClass("Organizer", $globals.Object, [], "Kernel-Infrastructure");
+$core.addClass("Organizer", $globals.Object, ["elements"], "Kernel-Infrastructure");
 //>>excludeStart("ide", pragmas.excludeIdeData);
 $globals.Organizer.comment="I represent categorization information. \x0a\x0a## API\x0a\x0aUse `#addElement:` and `#removeElement:` to manipulate instances.";
 //>>excludeEnd("ide");
@@ -801,7 +801,7 @@ var self=this,$self=this;
 //>>excludeStart("ctx", pragmas.excludeDebugContexts);
 return $core.withContext(function($ctx1) {
 //>>excludeEnd("ctx");
-$core.addElement(self.elements, anObject);
+$recv($self._elements())._add_(anObject);
 return self;
 //>>excludeStart("ctx", pragmas.excludeDebugContexts);
 }, function($ctx1) {$ctx1.fill(self,"addElement:",{anObject:anObject},$globals.Organizer)});
@@ -809,10 +809,10 @@ return self;
 },
 //>>excludeStart("ide", pragmas.excludeIdeData);
 args: ["anObject"],
-source: "addElement: anObject\x0a\x09<inlineJS: '$core.addElement(self.elements, anObject)'>",
+source: "addElement: anObject\x0a\x09self elements add: anObject",
 referencedClasses: [],
 //>>excludeEnd("ide");
-messageSends: []
+messageSends: ["add:", "elements"]
 }),
 $globals.Organizer);
 
@@ -822,20 +822,47 @@ selector: "elements",
 protocol: "accessing",
 fn: function (){
 var self=this,$self=this;
+return $self["@elements"];
+
+},
+//>>excludeStart("ide", pragmas.excludeIdeData);
+args: [],
+source: "elements\x0a\x09^ elements",
+referencedClasses: [],
+//>>excludeEnd("ide");
+messageSends: []
+}),
+$globals.Organizer);
+
+$core.addMethod(
+$core.method({
+selector: "initialize",
+protocol: "initialization",
+fn: function (){
+var self=this,$self=this;
 //>>excludeStart("ctx", pragmas.excludeDebugContexts);
 return $core.withContext(function($ctx1) {
 //>>excludeEnd("ctx");
-return $recv($self._basicAt_("elements"))._copy();
+(
+//>>excludeStart("ctx", pragmas.excludeDebugContexts);
+$ctx1.supercall = true,
+//>>excludeEnd("ctx");
+($globals.Organizer.superclass||$boot.nilAsClass).fn.prototype._initialize.apply($self, []));
+//>>excludeStart("ctx", pragmas.excludeDebugContexts);
+$ctx1.supercall = false;
+//>>excludeEnd("ctx");;
+$self["@elements"]=$recv($globals.Set)._new();
+return self;
 //>>excludeStart("ctx", pragmas.excludeDebugContexts);
-}, function($ctx1) {$ctx1.fill(self,"elements",{},$globals.Organizer)});
+}, function($ctx1) {$ctx1.fill(self,"initialize",{},$globals.Organizer)});
 //>>excludeEnd("ctx");
 },
 //>>excludeStart("ide", pragmas.excludeIdeData);
 args: [],
-source: "elements\x0a\x09^ (self basicAt: 'elements') copy",
-referencedClasses: [],
+source: "initialize\x0a\x09super initialize.\x0a\x09elements := Set new",
+referencedClasses: ["Set"],
 //>>excludeEnd("ide");
-messageSends: ["copy", "basicAt:"]
+messageSends: ["initialize", "new"]
 }),
 $globals.Organizer);
 
@@ -848,7 +875,9 @@ var self=this,$self=this;
 //>>excludeStart("ctx", pragmas.excludeDebugContexts);
 return $core.withContext(function($ctx1) {
 //>>excludeEnd("ctx");
-$core.removeElement(self.elements, anObject);
+$recv($self._elements())._remove_ifAbsent_(anObject,(function(){
+
+}));
 return self;
 //>>excludeStart("ctx", pragmas.excludeDebugContexts);
 }, function($ctx1) {$ctx1.fill(self,"removeElement:",{anObject:anObject},$globals.Organizer)});
@@ -856,16 +885,16 @@ return self;
 },
 //>>excludeStart("ide", pragmas.excludeIdeData);
 args: ["anObject"],
-source: "removeElement: anObject\x0a\x09<inlineJS: '$core.removeElement(self.elements, anObject)'>",
+source: "removeElement: anObject\x0a\x09self elements remove: anObject ifAbsent: []",
 referencedClasses: [],
 //>>excludeEnd("ide");
-messageSends: []
+messageSends: ["remove:ifAbsent:", "elements"]
 }),
 $globals.Organizer);
 
 
 
-$core.addClass("ClassOrganizer", $globals.Organizer, [], "Kernel-Infrastructure");
+$core.addClass("ClassOrganizer", $globals.Organizer, ["traitOrBehavior"], "Kernel-Infrastructure");
 //>>excludeStart("ide", pragmas.excludeIdeData);
 $globals.ClassOrganizer.comment="I am an organizer specific to classes. I hold method categorization information for classes.";
 //>>excludeEnd("ide");
@@ -907,38 +936,6 @@ messageSends: ["addElement:", "announce:", "current", "protocol:", "new", "theCl
 }),
 $globals.ClassOrganizer);
 
-$core.addMethod(
-$core.method({
-selector: "initialize",
-protocol: "initialization",
-fn: function (){
-var self=this,$self=this;
-//>>excludeStart("ctx", pragmas.excludeDebugContexts);
-return $core.withContext(function($ctx1) {
-//>>excludeEnd("ctx");
-(
-//>>excludeStart("ctx", pragmas.excludeDebugContexts);
-$ctx1.supercall = true,
-//>>excludeEnd("ctx");
-($globals.ClassOrganizer.superclass||$boot.nilAsClass).fn.prototype._initialize.apply($self, []));
-//>>excludeStart("ctx", pragmas.excludeDebugContexts);
-$ctx1.supercall = false;
-//>>excludeEnd("ctx");;
-$self._basicAt_put_("elements",[]);
-return self;
-//>>excludeStart("ctx", pragmas.excludeDebugContexts);
-}, function($ctx1) {$ctx1.fill(self,"initialize",{},$globals.ClassOrganizer)});
-//>>excludeEnd("ctx");
-},
-//>>excludeStart("ide", pragmas.excludeIdeData);
-args: [],
-source: "initialize\x0a\x09super initialize.\x0a\x09self basicAt: 'elements' put: #()",
-referencedClasses: [],
-//>>excludeEnd("ide");
-messageSends: ["initialize", "basicAt:put:"]
-}),
-$globals.ClassOrganizer);
-
 $core.addMethod(
 $core.method({
 selector: "removeElement:",
@@ -983,18 +980,12 @@ selector: "theClass",
 protocol: "accessing",
 fn: function (){
 var self=this,$self=this;
-//>>excludeStart("ctx", pragmas.excludeDebugContexts);
-return $core.withContext(function($ctx1) {
-//>>excludeEnd("ctx");
-return self.theClass;
-return self;
-//>>excludeStart("ctx", pragmas.excludeDebugContexts);
-}, function($ctx1) {$ctx1.fill(self,"theClass",{},$globals.ClassOrganizer)});
-//>>excludeEnd("ctx");
+return $self["@traitOrBehavior"];
+
 },
 //>>excludeStart("ide", pragmas.excludeIdeData);
 args: [],
-source: "theClass\x0a\x09<inlineJS: 'return self.theClass'>",
+source: "theClass\x0a\x09^ traitOrBehavior",
 referencedClasses: [],
 //>>excludeEnd("ide");
 messageSends: []
@@ -1007,18 +998,13 @@ selector: "theClass:",
 protocol: "accessing",
 fn: function (aClass){
 var self=this,$self=this;
-//>>excludeStart("ctx", pragmas.excludeDebugContexts);
-return $core.withContext(function($ctx1) {
-//>>excludeEnd("ctx");
-self.theClass = aClass;
+$self["@traitOrBehavior"]=aClass;
 return self;
-//>>excludeStart("ctx", pragmas.excludeDebugContexts);
-}, function($ctx1) {$ctx1.fill(self,"theClass:",{aClass:aClass},$globals.ClassOrganizer)});
-//>>excludeEnd("ctx");
+
 },
 //>>excludeStart("ide", pragmas.excludeIdeData);
 args: ["aClass"],
-source: "theClass: aClass\x0a\x09<inlineJS: 'self.theClass = aClass'>",
+source: "theClass: aClass\x0a\x09traitOrBehavior := aClass",
 referencedClasses: [],
 //>>excludeEnd("ide");
 messageSends: []
@@ -1057,38 +1043,6 @@ $core.addClass("PackageOrganizer", $globals.Organizer, [], "Kernel-Infrastructur
 //>>excludeStart("ide", pragmas.excludeIdeData);
 $globals.PackageOrganizer.comment="I am an organizer specific to packages. I hold classes categorization information.";
 //>>excludeEnd("ide");
-$core.addMethod(
-$core.method({
-selector: "initialize",
-protocol: "initialization",
-fn: function (){
-var self=this,$self=this;
-//>>excludeStart("ctx", pragmas.excludeDebugContexts);
-return $core.withContext(function($ctx1) {
-//>>excludeEnd("ctx");
-(
-//>>excludeStart("ctx", pragmas.excludeDebugContexts);
-$ctx1.supercall = true,
-//>>excludeEnd("ctx");
-($globals.PackageOrganizer.superclass||$boot.nilAsClass).fn.prototype._initialize.apply($self, []));
-//>>excludeStart("ctx", pragmas.excludeDebugContexts);
-$ctx1.supercall = false;
-//>>excludeEnd("ctx");;
-$self._basicAt_put_("elements",[]);
-return self;
-//>>excludeStart("ctx", pragmas.excludeDebugContexts);
-}, function($ctx1) {$ctx1.fill(self,"initialize",{},$globals.PackageOrganizer)});
-//>>excludeEnd("ctx");
-},
-//>>excludeStart("ide", pragmas.excludeIdeData);
-args: [],
-source: "initialize\x0a\x09super initialize.\x0a\x09self basicAt: 'elements' put: #()",
-referencedClasses: [],
-//>>excludeEnd("ide");
-messageSends: ["initialize", "basicAt:put:"]
-}),
-$globals.PackageOrganizer);
-
 
 
 $core.addClass("Package", $globals.Object, ["evalBlock", "basicTransport", "name", "transport", "imports", "dirty", "organization"], "Kernel-Infrastructure");
@@ -1232,17 +1186,17 @@ var self=this,$self=this;
 //>>excludeStart("ctx", pragmas.excludeDebugContexts);
 return $core.withContext(function($ctx1) {
 //>>excludeEnd("ctx");
-return $recv($self._organization())._elements();
+return $recv($recv($self._organization())._elements())._copy();
 //>>excludeStart("ctx", pragmas.excludeDebugContexts);
 }, function($ctx1) {$ctx1.fill(self,"classes",{},$globals.Package)});
 //>>excludeEnd("ctx");
 },
 //>>excludeStart("ide", pragmas.excludeIdeData);
 args: [],
-source: "classes\x0a\x09^ self organization elements",
+source: "classes\x0a\x09^ self organization elements copy",
 referencedClasses: [],
 //>>excludeEnd("ide");
-messageSends: ["elements", "organization"]
+messageSends: ["copy", "elements", "organization"]
 }),
 $globals.Package);
 

+ 15 - 22
src/Kernel-Infrastructure.st

@@ -228,7 +228,7 @@ lookupProperty: aString ofProxy: aProxy
 ! !
 
 Object subclass: #Organizer
-	instanceVariableNames: ''
+	instanceVariableNames: 'elements'
 	package: 'Kernel-Infrastructure'!
 !Organizer commentStamp!
 I represent categorization information. 
@@ -240,19 +240,26 @@ Use `#addElement:` and `#removeElement:` to manipulate instances.!
 !Organizer methodsFor: 'accessing'!
 
 addElement: anObject
-	<inlineJS: '$core.addElement(self.elements, anObject)'>
+	self elements add: anObject
 !
 
 elements
-	^ (self basicAt: 'elements') copy
+	^ elements
 !
 
 removeElement: anObject
-	<inlineJS: '$core.removeElement(self.elements, anObject)'>
+	self elements remove: anObject ifAbsent: []
+! !
+
+!Organizer methodsFor: 'initialization'!
+
+initialize
+	super initialize.
+	elements := Set new
 ! !
 
 Organizer subclass: #ClassOrganizer
-	instanceVariableNames: ''
+	instanceVariableNames: 'traitOrBehavior'
 	package: 'Kernel-Infrastructure'!
 !ClassOrganizer commentStamp!
 I am an organizer specific to classes. I hold method categorization information for classes.!
@@ -278,18 +285,11 @@ removeElement: aString
 !
 
 theClass
-	<inlineJS: 'return self.theClass'>
+	^ traitOrBehavior
 !
 
 theClass: aClass
-	<inlineJS: 'self.theClass = aClass'>
-! !
-
-!ClassOrganizer methodsFor: 'initialization'!
-
-initialize
-	super initialize.
-	self basicAt: 'elements' put: #()
+	traitOrBehavior := aClass
 ! !
 
 !ClassOrganizer class methodsFor: 'instance creation'!
@@ -306,13 +306,6 @@ Organizer subclass: #PackageOrganizer
 !PackageOrganizer commentStamp!
 I am an organizer specific to packages. I hold classes categorization information.!
 
-!PackageOrganizer methodsFor: 'initialization'!
-
-initialize
-	super initialize.
-	self basicAt: 'elements' put: #()
-! !
-
 Object subclass: #Package
 	instanceVariableNames: 'evalBlock basicTransport name transport imports dirty organization'
 	package: 'Kernel-Infrastructure'!
@@ -433,7 +426,7 @@ transport: aPackageTransport
 !Package methodsFor: 'classes'!
 
 classes
-	^ self organization elements
+	^ self organization elements copy
 !
 
 setupClasses