Browse Source

Get rid of basicXxx in Package.

Herbert Vojčík 7 years ago
parent
commit
245b334405

+ 6 - 0
API-CHANGES.txt

@@ -20,6 +20,9 @@
   + stubToAtMost:
   + stubToAtMost:
 + NonBooleanReceiver class >>
 + NonBooleanReceiver class >>
   + signalOn:
   + signalOn:
++ Package >>
+  + evalBlock
+  + evalBlock:
 + Package class >>
 + Package class >>
   + named:javaScriptDescriptor:
   + named:javaScriptDescriptor:
 + SmalltalkImage >>
 + SmalltalkImage >>
@@ -30,6 +33,9 @@
 + UndefinedObject >>
 + UndefinedObject >>
   + ==
   + ==
 
 
+- Package >>
+  - basicName:
+  - basicImports
 - ProtoObject >>
 - ProtoObject >>
   - isSameInstanceAs:
   - isSameInstanceAs:
 - ObjectTest >>
 - ObjectTest >>

+ 11 - 6
src/Compiler-Core.js

@@ -656,20 +656,25 @@ var self=this,$self=this;
 //>>excludeStart("ctx", pragmas.excludeDebugContexts);
 //>>excludeStart("ctx", pragmas.excludeDebugContexts);
 return $core.withContext(function($ctx1) {
 return $core.withContext(function($ctx1) {
 //>>excludeEnd("ctx");
 //>>excludeEnd("ctx");
-return aPackage && aPackage.innerEval
-		? aPackage.innerEval(aString)
-		: eval(aString);
-return self;
+var $receiver;
+if(($receiver = aPackage) == null || $receiver.a$nil){
+return $self._eval_(aString);
+//>>excludeStart("ctx", pragmas.excludeDebugContexts);
+$ctx1.sendIdx["eval:"]=1;
+//>>excludeEnd("ctx");
+} else {
+return $recv(aPackage)._eval_(aString);
+}
 //>>excludeStart("ctx", pragmas.excludeDebugContexts);
 //>>excludeStart("ctx", pragmas.excludeDebugContexts);
 }, function($ctx1) {$ctx1.fill(self,"eval:forPackage:",{aString:aString,aPackage:aPackage},$globals.Compiler)});
 }, function($ctx1) {$ctx1.fill(self,"eval:forPackage:",{aString:aString,aPackage:aPackage},$globals.Compiler)});
 //>>excludeEnd("ctx");
 //>>excludeEnd("ctx");
 },
 },
 //>>excludeStart("ide", pragmas.excludeIdeData);
 //>>excludeStart("ide", pragmas.excludeIdeData);
 args: ["aString", "aPackage"],
 args: ["aString", "aPackage"],
-source: "eval: aString forPackage: aPackage\x0a\x09<inlineJS: 'return aPackage && aPackage.innerEval\x0a\x09\x09? aPackage.innerEval(aString)\x0a\x09\x09: eval(aString)'>",
+source: "eval: aString forPackage: aPackage\x0a\x09^ aPackage\x0a\x09\x09ifNil: [ self eval: aString ]\x0a\x09\x09ifNotNil: [ aPackage eval: aString ]",
 referencedClasses: [],
 referencedClasses: [],
 //>>excludeEnd("ide");
 //>>excludeEnd("ide");
-messageSends: []
+messageSends: ["ifNil:ifNotNil:", "eval:"]
 }),
 }),
 $globals.Compiler);
 $globals.Compiler);
 
 

+ 3 - 3
src/Compiler-Core.st

@@ -176,9 +176,9 @@ eval: aString
 !
 !
 
 
 eval: aString forPackage: aPackage
 eval: aString forPackage: aPackage
-	<inlineJS: 'return aPackage && aPackage.innerEval
-		? aPackage.innerEval(aString)
-		: eval(aString)'>
+	^ aPackage
+		ifNil: [ self eval: aString ]
+		ifNotNil: [ aPackage eval: aString ]
 !
 !
 
 
 evaluateExpression: aString
 evaluateExpression: aString

+ 111 - 125
src/Kernel-Infrastructure.js

@@ -965,76 +965,22 @@ $globals.PackageOrganizer);
 
 
 
 
 
 
-$core.addClass("Package", $globals.Object, ["transport", "imports", "dirty"], "Kernel-Infrastructure");
+$core.addClass("Package", $globals.Object, ["evalBlock", "basicTransport", "name", "transport", "imports", "dirty", "organization"], "Kernel-Infrastructure");
 //>>excludeStart("ide", pragmas.excludeIdeData);
 //>>excludeStart("ide", pragmas.excludeIdeData);
 $globals.Package.comment="I am similar to a \x22class category\x22 typically found in other Smalltalks like Pharo or Squeak. Amber does not have class categories anymore, it had in the beginning but now each class in the system knows which package it belongs to.\x0a\x0aEach package has a name and can be queried for its classes, but it will then resort to a reverse scan of all classes to find them.\x0a\x0a## API\x0a\x0aPackages are manipulated through \x22Smalltalk current\x22, like for example finding one based on a name or with `Package class >> #name` directly:\x0a\x0a    Smalltalk current packageAt: 'Kernel'\x0a    Package named: 'Kernel'\x0a\x0aA package differs slightly from a Monticello package which can span multiple class categories using a naming convention based on hyphenation. But just as in Monticello a package supports \x22class extensions\x22 so a package can define behaviors in foreign classes using a naming convention for method categories where the category starts with an asterisk and then the name of the owning package follows.\x0a\x0aYou can fetch a package from the server:\x0a\x0a\x09Package load: 'Additional-Examples'";
 $globals.Package.comment="I am similar to a \x22class category\x22 typically found in other Smalltalks like Pharo or Squeak. Amber does not have class categories anymore, it had in the beginning but now each class in the system knows which package it belongs to.\x0a\x0aEach package has a name and can be queried for its classes, but it will then resort to a reverse scan of all classes to find them.\x0a\x0a## API\x0a\x0aPackages are manipulated through \x22Smalltalk current\x22, like for example finding one based on a name or with `Package class >> #name` directly:\x0a\x0a    Smalltalk current packageAt: 'Kernel'\x0a    Package named: 'Kernel'\x0a\x0aA package differs slightly from a Monticello package which can span multiple class categories using a naming convention based on hyphenation. But just as in Monticello a package supports \x22class extensions\x22 so a package can define behaviors in foreign classes using a naming convention for method categories where the category starts with an asterisk and then the name of the owning package follows.\x0a\x0aYou can fetch a package from the server:\x0a\x0a\x09Package load: 'Additional-Examples'";
 //>>excludeEnd("ide");
 //>>excludeEnd("ide");
-$core.addMethod(
-$core.method({
-selector: "basicImports",
-protocol: "private",
-fn: function (){
-var self=this,$self=this;
-//>>excludeStart("ctx", pragmas.excludeDebugContexts);
-return $core.withContext(function($ctx1) {
-//>>excludeEnd("ctx");
-return self.imports || [];
-return self;
-//>>excludeStart("ctx", pragmas.excludeDebugContexts);
-}, function($ctx1) {$ctx1.fill(self,"basicImports",{},$globals.Package)});
-//>>excludeEnd("ctx");
-},
-//>>excludeStart("ide", pragmas.excludeIdeData);
-args: [],
-source: "basicImports\x0a\x09\x22Answer the imports literal JavaScript object as setup in the JavaScript file, if any\x22\x0a\x09\x0a\x09<inlineJS: 'return self.imports || []'>",
-referencedClasses: [],
-//>>excludeEnd("ide");
-messageSends: []
-}),
-$globals.Package);
-
-$core.addMethod(
-$core.method({
-selector: "basicName:",
-protocol: "private",
-fn: function (aString){
-var self=this,$self=this;
-//>>excludeStart("ctx", pragmas.excludeDebugContexts);
-return $core.withContext(function($ctx1) {
-//>>excludeEnd("ctx");
-self.pkgName = aString;
-return self;
-//>>excludeStart("ctx", pragmas.excludeDebugContexts);
-}, function($ctx1) {$ctx1.fill(self,"basicName:",{aString:aString},$globals.Package)});
-//>>excludeEnd("ctx");
-},
-//>>excludeStart("ide", pragmas.excludeIdeData);
-args: ["aString"],
-source: "basicName: aString\x0a\x09<inlineJS: 'self.pkgName = aString'>",
-referencedClasses: [],
-//>>excludeEnd("ide");
-messageSends: []
-}),
-$globals.Package);
-
 $core.addMethod(
 $core.addMethod(
 $core.method({
 $core.method({
 selector: "basicTransport",
 selector: "basicTransport",
 protocol: "private",
 protocol: "private",
 fn: function (){
 fn: function (){
 var self=this,$self=this;
 var self=this,$self=this;
-//>>excludeStart("ctx", pragmas.excludeDebugContexts);
-return $core.withContext(function($ctx1) {
-//>>excludeEnd("ctx");
-return self.transport;
-return self;
-//>>excludeStart("ctx", pragmas.excludeDebugContexts);
-}, function($ctx1) {$ctx1.fill(self,"basicTransport",{},$globals.Package)});
-//>>excludeEnd("ctx");
+return $self["@basicTransport"];
+
 },
 },
 //>>excludeStart("ide", pragmas.excludeIdeData);
 //>>excludeStart("ide", pragmas.excludeIdeData);
 args: [],
 args: [],
-source: "basicTransport\x0a\x09\x22Answer the transport literal JavaScript object as setup in the JavaScript file, if any\x22\x0a\x09\x0a\x09<inlineJS: 'return self.transport'>",
+source: "basicTransport\x0a\x09\x22Answer the transport literal JavaScript object as setup in the JavaScript file, if any\x22\x0a\x09\x0a\x09^ basicTransport",
 referencedClasses: [],
 referencedClasses: [],
 //>>excludeEnd("ide");
 //>>excludeEnd("ide");
 messageSends: []
 messageSends: []
@@ -1241,6 +1187,72 @@ messageSends: ["streamContents:", "write:", "name", "class", "lf", "tab", "print
 }),
 }),
 $globals.Package);
 $globals.Package);
 
 
+$core.addMethod(
+$core.method({
+selector: "eval:",
+protocol: "evaluating",
+fn: function (aString){
+var self=this,$self=this;
+//>>excludeStart("ctx", pragmas.excludeDebugContexts);
+return $core.withContext(function($ctx1) {
+//>>excludeEnd("ctx");
+var $1,$receiver;
+$1=$self["@evalBlock"];
+if(($receiver = $1) == null || $receiver.a$nil){
+return $recv($globals.Compiler)._eval_(aString);
+} else {
+return $recv($self["@evalBlock"])._value_(aString);
+}
+//>>excludeStart("ctx", pragmas.excludeDebugContexts);
+}, function($ctx1) {$ctx1.fill(self,"eval:",{aString:aString},$globals.Package)});
+//>>excludeEnd("ctx");
+},
+//>>excludeStart("ide", pragmas.excludeIdeData);
+args: ["aString"],
+source: "eval: aString\x0a\x09^ evalBlock\x0a\x09\x09ifNotNil: [ evalBlock value: aString ]\x0a\x09\x09ifNil: [ Compiler eval: aString ]",
+referencedClasses: ["Compiler"],
+//>>excludeEnd("ide");
+messageSends: ["ifNotNil:ifNil:", "value:", "eval:"]
+}),
+$globals.Package);
+
+$core.addMethod(
+$core.method({
+selector: "evalBlock",
+protocol: "accessing",
+fn: function (){
+var self=this,$self=this;
+return $self["@evalBlock"];
+
+},
+//>>excludeStart("ide", pragmas.excludeIdeData);
+args: [],
+source: "evalBlock\x0a\x09^ evalBlock",
+referencedClasses: [],
+//>>excludeEnd("ide");
+messageSends: []
+}),
+$globals.Package);
+
+$core.addMethod(
+$core.method({
+selector: "evalBlock:",
+protocol: "accessing",
+fn: function (aBlock){
+var self=this,$self=this;
+$self["@evalBlock"]=aBlock;
+return self;
+
+},
+//>>excludeStart("ide", pragmas.excludeIdeData);
+args: ["aBlock"],
+source: "evalBlock: aBlock\x0a\x09evalBlock := aBlock",
+referencedClasses: [],
+//>>excludeEnd("ide");
+messageSends: []
+}),
+$globals.Package);
+
 $core.addMethod(
 $core.addMethod(
 $core.method({
 $core.method({
 selector: "imports",
 selector: "imports",
@@ -1253,10 +1265,7 @@ return $core.withContext(function($ctx1) {
 var $1,$receiver;
 var $1,$receiver;
 $1=$self["@imports"];
 $1=$self["@imports"];
 if(($receiver = $1) == null || $receiver.a$nil){
 if(($receiver = $1) == null || $receiver.a$nil){
-var parsed;
-parsed=$self._importsFromJson_($self._basicImports());
-parsed;
-$self._imports_(parsed);
+$self._imports_([]);
 return $self["@imports"];
 return $self["@imports"];
 } else {
 } else {
 return $1;
 return $1;
@@ -1267,10 +1276,10 @@ return $1;
 },
 },
 //>>excludeStart("ide", pragmas.excludeIdeData);
 //>>excludeStart("ide", pragmas.excludeIdeData);
 args: [],
 args: [],
-source: "imports\x0a\x09^ imports ifNil: [\x0a\x09\x09| parsed |\x0a\x09\x09parsed := self importsFromJson: self basicImports.\x0a\x09\x09self imports: parsed.\x0a\x09\x09imports ]",
+source: "imports\x0a\x09^ imports ifNil: [\x0a\x09\x09self imports: #().\x0a\x09\x09imports ]",
 referencedClasses: [],
 referencedClasses: [],
 //>>excludeEnd("ide");
 //>>excludeEnd("ide");
-messageSends: ["ifNil:", "importsFromJson:", "basicImports", "imports:"]
+messageSends: ["ifNil:", "imports:"]
 }),
 }),
 $globals.Package);
 $globals.Package);
 
 
@@ -1454,7 +1463,8 @@ $ctx1.supercall = true,
 //>>excludeStart("ctx", pragmas.excludeDebugContexts);
 //>>excludeStart("ctx", pragmas.excludeDebugContexts);
 $ctx1.supercall = false;
 $ctx1.supercall = false;
 //>>excludeEnd("ctx");;
 //>>excludeEnd("ctx");;
-$self._basicAt_put_("organization",$recv($globals.PackageOrganizer)._new());
+$self["@organization"]=$recv($globals.PackageOrganizer)._new();
+$self["@evalBlock"]=nil;
 $self["@dirty"]=nil;
 $self["@dirty"]=nil;
 $self["@imports"]=nil;
 $self["@imports"]=nil;
 $self["@transport"]=nil;
 $self["@transport"]=nil;
@@ -1465,10 +1475,10 @@ return self;
 },
 },
 //>>excludeStart("ide", pragmas.excludeIdeData);
 //>>excludeStart("ide", pragmas.excludeIdeData);
 args: [],
 args: [],
-source: "initialize\x0a\x09super initialize.\x0a\x0a\x09self basicAt: 'organization' put: PackageOrganizer new.\x0a\x09dirty := nil.\x0a\x09imports := nil.\x0a\x09transport := nil",
+source: "initialize\x0a\x09super initialize.\x0a\x0a\x09organization := PackageOrganizer new.\x0a\x09evalBlock := nil.\x0a\x09dirty := nil.\x0a\x09imports := nil.\x0a\x09transport := nil",
 referencedClasses: ["PackageOrganizer"],
 referencedClasses: ["PackageOrganizer"],
 //>>excludeEnd("ide");
 //>>excludeEnd("ide");
-messageSends: ["initialize", "basicAt:put:", "new"]
+messageSends: ["initialize", "new"]
 }),
 }),
 $globals.Package);
 $globals.Package);
 
 
@@ -1525,7 +1535,7 @@ selector: "javaScriptDescriptor:",
 protocol: "accessing",
 protocol: "accessing",
 fn: function (anObject){
 fn: function (anObject){
 var self=this,$self=this;
 var self=this,$self=this;
-var basicEval,basicImports,basicTransport;
+var basicEval,basicImports;
 //>>excludeStart("ctx", pragmas.excludeDebugContexts);
 //>>excludeStart("ctx", pragmas.excludeDebugContexts);
 return $core.withContext(function($ctx1) {
 return $core.withContext(function($ctx1) {
 //>>excludeEnd("ctx");
 //>>excludeEnd("ctx");
@@ -1548,29 +1558,22 @@ return [];
 //>>excludeStart("ctx", pragmas.excludeDebugContexts);
 //>>excludeStart("ctx", pragmas.excludeDebugContexts);
 $ctx1.sendIdx["at:ifAbsent:"]=2;
 $ctx1.sendIdx["at:ifAbsent:"]=2;
 //>>excludeEnd("ctx");
 //>>excludeEnd("ctx");
-basicTransport=$recv(anObject)._at_ifAbsent_("transport",(function(){
+$self["@basicTransport"]=$recv(anObject)._at_ifAbsent_("transport",(function(){
 
 
 }));
 }));
-$self._basicAt_put_("innerEval",basicEval);
-//>>excludeStart("ctx", pragmas.excludeDebugContexts);
-$ctx1.sendIdx["basicAt:put:"]=1;
-//>>excludeEnd("ctx");
-$self._basicAt_put_("imports",basicImports);
-//>>excludeStart("ctx", pragmas.excludeDebugContexts);
-$ctx1.sendIdx["basicAt:put:"]=2;
-//>>excludeEnd("ctx");
-$self._basicAt_put_("transport",basicTransport);
+$self._evalBlock_(basicEval);
+$self._imports_($self._importsFromJson_(basicImports));
 return self;
 return self;
 //>>excludeStart("ctx", pragmas.excludeDebugContexts);
 //>>excludeStart("ctx", pragmas.excludeDebugContexts);
-}, function($ctx1) {$ctx1.fill(self,"javaScriptDescriptor:",{anObject:anObject,basicEval:basicEval,basicImports:basicImports,basicTransport:basicTransport},$globals.Package)});
+}, function($ctx1) {$ctx1.fill(self,"javaScriptDescriptor:",{anObject:anObject,basicEval:basicEval,basicImports:basicImports},$globals.Package)});
 //>>excludeEnd("ctx");
 //>>excludeEnd("ctx");
 },
 },
 //>>excludeStart("ide", pragmas.excludeIdeData);
 //>>excludeStart("ide", pragmas.excludeIdeData);
 args: ["anObject"],
 args: ["anObject"],
-source: "javaScriptDescriptor: anObject\x0a\x09| basicEval basicImports basicTransport |\x0a\x0a\x09basicEval := (anObject at: 'innerEval' ifAbsent: [ nil asJavaScriptObject ]).\x0a\x09basicImports := (anObject at: 'imports' ifAbsent: [ #() ]).\x0a\x09basicTransport := (anObject at: 'transport' ifAbsent: []).\x0a\x09\x09\x09\x0a\x09self\x0a\x09\x09basicAt: 'innerEval' put: basicEval;\x0a\x09\x09basicAt: 'imports' put: basicImports;\x0a\x09\x09basicAt: 'transport' put: basicTransport\x0a\x09\x09\x09\x0a\x09\x09\x09",
+source: "javaScriptDescriptor: anObject\x0a\x09| basicEval basicImports |\x0a\x0a\x09basicEval := (anObject at: 'innerEval' ifAbsent: [ nil asJavaScriptObject ]).\x0a\x09basicImports := (anObject at: 'imports' ifAbsent: [ #() ]).\x0a\x09basicTransport := (anObject at: 'transport' ifAbsent: []).\x0a\x09\x09\x09\x0a\x09self\x0a\x09\x09evalBlock: basicEval;\x0a\x09\x09imports: (self importsFromJson: basicImports)\x09\x09\x09",
 referencedClasses: [],
 referencedClasses: [],
 //>>excludeEnd("ide");
 //>>excludeEnd("ide");
-messageSends: ["at:ifAbsent:", "asJavaScriptObject", "basicAt:put:"]
+messageSends: ["at:ifAbsent:", "asJavaScriptObject", "evalBlock:", "imports:", "importsFromJson:"]
 }),
 }),
 $globals.Package);
 $globals.Package);
 
 
@@ -1717,18 +1720,12 @@ selector: "name",
 protocol: "accessing",
 protocol: "accessing",
 fn: function (){
 fn: function (){
 var self=this,$self=this;
 var self=this,$self=this;
-//>>excludeStart("ctx", pragmas.excludeDebugContexts);
-return $core.withContext(function($ctx1) {
-//>>excludeEnd("ctx");
-return self.pkgName;
-return self;
-//>>excludeStart("ctx", pragmas.excludeDebugContexts);
-}, function($ctx1) {$ctx1.fill(self,"name",{},$globals.Package)});
-//>>excludeEnd("ctx");
+return $self["@name"];
+
 },
 },
 //>>excludeStart("ide", pragmas.excludeIdeData);
 //>>excludeStart("ide", pragmas.excludeIdeData);
 args: [],
 args: [],
-source: "name\x0a\x09<inlineJS: 'return self.pkgName'>",
+source: "name\x0a\x09^ name",
 referencedClasses: [],
 referencedClasses: [],
 //>>excludeEnd("ide");
 //>>excludeEnd("ide");
 messageSends: []
 messageSends: []
@@ -1741,22 +1738,16 @@ selector: "name:",
 protocol: "accessing",
 protocol: "accessing",
 fn: function (aString){
 fn: function (aString){
 var self=this,$self=this;
 var self=this,$self=this;
-//>>excludeStart("ctx", pragmas.excludeDebugContexts);
-return $core.withContext(function($ctx1) {
-//>>excludeEnd("ctx");
-$self._basicName_(aString);
-$self._beDirty();
+$self["@name"]=aString;
 return self;
 return self;
-//>>excludeStart("ctx", pragmas.excludeDebugContexts);
-}, function($ctx1) {$ctx1.fill(self,"name:",{aString:aString},$globals.Package)});
-//>>excludeEnd("ctx");
+
 },
 },
 //>>excludeStart("ide", pragmas.excludeIdeData);
 //>>excludeStart("ide", pragmas.excludeIdeData);
 args: ["aString"],
 args: ["aString"],
-source: "name: aString\x0a\x09self basicName: aString.\x0a\x09self beDirty",
+source: "name: aString\x0a\x09name := aString",
 referencedClasses: [],
 referencedClasses: [],
 //>>excludeEnd("ide");
 //>>excludeEnd("ide");
-messageSends: ["basicName:", "beDirty"]
+messageSends: []
 }),
 }),
 $globals.Package);
 $globals.Package);
 
 
@@ -1766,20 +1757,15 @@ selector: "organization",
 protocol: "accessing",
 protocol: "accessing",
 fn: function (){
 fn: function (){
 var self=this,$self=this;
 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,"organization",{},$globals.Package)});
-//>>excludeEnd("ctx");
+return $self["@organization"];
+
 },
 },
 //>>excludeStart("ide", pragmas.excludeIdeData);
 //>>excludeStart("ide", pragmas.excludeIdeData);
 args: [],
 args: [],
-source: "organization\x0a\x09^ self basicAt: 'organization'",
+source: "organization\x0a\x09^ organization",
 referencedClasses: [],
 referencedClasses: [],
 //>>excludeEnd("ide");
 //>>excludeEnd("ide");
-messageSends: ["basicAt:"]
+messageSends: []
 }),
 }),
 $globals.Package);
 $globals.Package);
 
 
@@ -2013,12 +1999,10 @@ var self=this,$self=this;
 //>>excludeStart("ctx", pragmas.excludeDebugContexts);
 //>>excludeStart("ctx", pragmas.excludeDebugContexts);
 return $core.withContext(function($ctx1) {
 return $core.withContext(function($ctx1) {
 //>>excludeEnd("ctx");
 //>>excludeEnd("ctx");
-var $1,$2,$receiver;
+var $1,$receiver;
 $1=$self["@transport"];
 $1=$self["@transport"];
 if(($receiver = $1) == null || $receiver.a$nil){
 if(($receiver = $1) == null || $receiver.a$nil){
-$2=$recv($globals.PackageTransport)._fromJson_($self._basicTransport());
-$recv($2)._package_(self);
-$self["@transport"]=$recv($2)._yourself();
+$self._transport_($recv($globals.PackageTransport)._fromJson_($self._basicTransport()));
 return $self["@transport"];
 return $self["@transport"];
 } else {
 } else {
 return $1;
 return $1;
@@ -2029,10 +2013,10 @@ return $1;
 },
 },
 //>>excludeStart("ide", pragmas.excludeIdeData);
 //>>excludeStart("ide", pragmas.excludeIdeData);
 args: [],
 args: [],
-source: "transport\x0a\x09^ transport ifNil: [ \x0a\x09\x09transport := (PackageTransport fromJson: self basicTransport)\x0a\x09\x09\x09package: self;\x0a\x09\x09\x09yourself ]",
+source: "transport\x0a\x09^ transport ifNil: [ \x0a\x09\x09self transport: (PackageTransport fromJson: self basicTransport).\x0a\x09\x09transport ]",
 referencedClasses: ["PackageTransport"],
 referencedClasses: ["PackageTransport"],
 //>>excludeEnd("ide");
 //>>excludeEnd("ide");
-messageSends: ["ifNil:", "package:", "fromJson:", "basicTransport", "yourself"]
+messageSends: ["ifNil:", "transport:", "fromJson:", "basicTransport"]
 }),
 }),
 $globals.Package);
 $globals.Package);
 
 
@@ -2271,7 +2255,7 @@ return $core.withContext(function($ctx1) {
 //>>excludeEnd("ctx");
 //>>excludeEnd("ctx");
 var $1;
 var $1;
 $1=$recv($globals.Package)._new();
 $1=$recv($globals.Package)._new();
-$recv($1)._basicName_(aString);
+$recv($1)._name_(aString);
 return $recv($1)._yourself();
 return $recv($1)._yourself();
 //>>excludeStart("ctx", pragmas.excludeDebugContexts);
 //>>excludeStart("ctx", pragmas.excludeDebugContexts);
 }, function($ctx1) {$ctx1.fill(self,"new:",{aString:aString},$globals.Package.a$cls)});
 }, function($ctx1) {$ctx1.fill(self,"new:",{aString:aString},$globals.Package.a$cls)});
@@ -2279,10 +2263,10 @@ return $recv($1)._yourself();
 },
 },
 //>>excludeStart("ide", pragmas.excludeIdeData);
 //>>excludeStart("ide", pragmas.excludeIdeData);
 args: ["aString"],
 args: ["aString"],
-source: "new: aString\x0a\x09^ Package new\x0a\x09\x09basicName: aString;\x0a\x09\x09yourself",
+source: "new: aString\x0a\x09^ Package new\x0a\x09\x09name: aString;\x0a\x09\x09yourself",
 referencedClasses: ["Package"],
 referencedClasses: ["Package"],
 //>>excludeEnd("ide");
 //>>excludeEnd("ide");
-messageSends: ["basicName:", "new", "yourself"]
+messageSends: ["name:", "new", "yourself"]
 }),
 }),
 $globals.Package.a$cls);
 $globals.Package.a$cls);
 
 
@@ -3733,7 +3717,7 @@ var pkg;
 //>>excludeStart("ctx", pragmas.excludeDebugContexts);
 //>>excludeStart("ctx", pragmas.excludeDebugContexts);
 return $core.withContext(function($ctx1) {
 return $core.withContext(function($ctx1) {
 //>>excludeEnd("ctx");
 //>>excludeEnd("ctx");
-var $1,$2;
+var $1,$2,$3;
 pkg=$self._packageAt_ifAbsent_(packageName,(function(){
 pkg=$self._packageAt_ifAbsent_(packageName,(function(){
 //>>excludeStart("ctx", pragmas.excludeDebugContexts);
 //>>excludeStart("ctx", pragmas.excludeDebugContexts);
 return $core.withContext(function($ctx2) {
 return $core.withContext(function($ctx2) {
@@ -3762,10 +3746,12 @@ return $self._error_("Already exists a package called: ".__comma(newName));
 }, function($ctx2) {$ctx2.fillBlock({},$ctx1,2)});
 }, function($ctx2) {$ctx2.fillBlock({},$ctx1,2)});
 //>>excludeEnd("ctx");
 //>>excludeEnd("ctx");
 }));
 }));
-$recv(pkg)._name_(newName);
-$2=$self._packageDictionary();
-$recv($2)._at_put_(newName,pkg);
-$recv($2)._removeKey_(packageName);
+$2=pkg;
+$recv($2)._name_(newName);
+$recv($2)._beDirty();
+$3=$self._packageDictionary();
+$recv($3)._at_put_(newName,pkg);
+$recv($3)._removeKey_(packageName);
 return self;
 return self;
 //>>excludeStart("ctx", pragmas.excludeDebugContexts);
 //>>excludeStart("ctx", pragmas.excludeDebugContexts);
 }, function($ctx1) {$ctx1.fill(self,"renamePackage:to:",{packageName:packageName,newName:newName,pkg:pkg},$globals.SmalltalkImage)});
 }, function($ctx1) {$ctx1.fill(self,"renamePackage:to:",{packageName:packageName,newName:newName,pkg:pkg},$globals.SmalltalkImage)});
@@ -3773,10 +3759,10 @@ return self;
 },
 },
 //>>excludeStart("ide", pragmas.excludeIdeData);
 //>>excludeStart("ide", pragmas.excludeIdeData);
 args: ["packageName", "newName"],
 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\x09self packageAt: newName ifAbsent: [ self error: 'Already exists a package called: ', newName ].\x0a\x09pkg name: newName.\x0a\x09self packageDictionary\x0a\x09\x09at: newName put: pkg;\x0a\x09\x09removeKey: packageName",
+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\x09self packageAt: newName ifAbsent: [ self error: 'Already exists a package called: ', newName ].\x0a\x09pkg name: newName; beDirty.\x0a\x09self packageDictionary\x0a\x09\x09at: newName put: pkg;\x0a\x09\x09removeKey: packageName",
 referencedClasses: [],
 referencedClasses: [],
 //>>excludeEnd("ide");
 //>>excludeEnd("ide");
-messageSends: ["packageAt:ifAbsent:", "error:", ",", "name:", "at:put:", "packageDictionary", "removeKey:"]
+messageSends: ["packageAt:ifAbsent:", "error:", ",", "name:", "beDirty", "at:put:", "packageDictionary", "removeKey:"]
 }),
 }),
 $globals.SmalltalkImage);
 $globals.SmalltalkImage);
 
 

+ 31 - 29
src/Kernel-Infrastructure.st

@@ -288,7 +288,7 @@ initialize
 ! !
 ! !
 
 
 Object subclass: #Package
 Object subclass: #Package
-	instanceVariableNames: 'transport imports dirty'
+	instanceVariableNames: 'evalBlock basicTransport name transport imports dirty organization'
 	package: 'Kernel-Infrastructure'!
 	package: 'Kernel-Infrastructure'!
 !Package commentStamp!
 !Package commentStamp!
 I am similar to a "class category" typically found in other Smalltalks like Pharo or Squeak. Amber does not have class categories anymore, it had in the beginning but now each class in the system knows which package it belongs to.
 I am similar to a "class category" typically found in other Smalltalks like Pharo or Squeak. Amber does not have class categories anymore, it had in the beginning but now each class in the system knows which package it belongs to.
@@ -341,11 +341,17 @@ definition
 		tab; write: { 'transport: ('. self transport definition. ')' } ]
 		tab; write: { 'transport: ('. self transport definition. ')' } ]
 !
 !
 
 
+evalBlock
+	^ evalBlock
+!
+
+evalBlock: aBlock
+	evalBlock := aBlock
+!
+
 imports
 imports
 	^ imports ifNil: [
 	^ imports ifNil: [
-		| parsed |
-		parsed := self importsFromJson: self basicImports.
-		self imports: parsed.
+		self imports: #().
 		imports ]
 		imports ]
 !
 !
 
 
@@ -364,36 +370,33 @@ importsDefinition
 !
 !
 
 
 javaScriptDescriptor: anObject
 javaScriptDescriptor: anObject
-	| basicEval basicImports basicTransport |
+	| basicEval basicImports |
 
 
 	basicEval := (anObject at: 'innerEval' ifAbsent: [ nil asJavaScriptObject ]).
 	basicEval := (anObject at: 'innerEval' ifAbsent: [ nil asJavaScriptObject ]).
 	basicImports := (anObject at: 'imports' ifAbsent: [ #() ]).
 	basicImports := (anObject at: 'imports' ifAbsent: [ #() ]).
 	basicTransport := (anObject at: 'transport' ifAbsent: []).
 	basicTransport := (anObject at: 'transport' ifAbsent: []).
 			
 			
 	self
 	self
-		basicAt: 'innerEval' put: basicEval;
-		basicAt: 'imports' put: basicImports;
-		basicAt: 'transport' put: basicTransport
+		evalBlock: basicEval;
+		imports: (self importsFromJson: basicImports)
 !
 !
 
 
 name
 name
-	<inlineJS: 'return self.pkgName'>
+	^ name
 !
 !
 
 
 name: aString
 name: aString
-	self basicName: aString.
-	self beDirty
+	name := aString
 !
 !
 
 
 organization
 organization
-	^ self basicAt: 'organization'
+	^ organization
 !
 !
 
 
 transport
 transport
 	^ transport ifNil: [ 
 	^ transport ifNil: [ 
-		transport := (PackageTransport fromJson: self basicTransport)
-			package: self;
-			yourself ]
+		self transport: (PackageTransport fromJson: self basicTransport).
+		transport ]
 !
 !
 
 
 transport: aPackageTransport
 transport: aPackageTransport
@@ -479,12 +482,21 @@ traitCompositions
 	^ traitCompositions reject: [ :each | each isEmpty ]
 	^ traitCompositions reject: [ :each | each isEmpty ]
 ! !
 ! !
 
 
+!Package methodsFor: 'evaluating'!
+
+eval: aString
+	^ evalBlock
+		ifNotNil: [ evalBlock value: aString ]
+		ifNil: [ Compiler eval: aString ]
+! !
+
 !Package methodsFor: 'initialization'!
 !Package methodsFor: 'initialization'!
 
 
 initialize
 initialize
 	super initialize.
 	super initialize.
 
 
-	self basicAt: 'organization' put: PackageOrganizer new.
+	organization := PackageOrganizer new.
+	evalBlock := nil.
 	dirty := nil.
 	dirty := nil.
 	imports := nil.
 	imports := nil.
 	transport := nil
 	transport := nil
@@ -502,20 +514,10 @@ printOn: aStream
 
 
 !Package methodsFor: 'private'!
 !Package methodsFor: 'private'!
 
 
-basicImports
-	"Answer the imports literal JavaScript object as setup in the JavaScript file, if any"
-	
-	<inlineJS: 'return self.imports || []'>
-!
-
-basicName: aString
-	<inlineJS: 'self.pkgName = aString'>
-!
-
 basicTransport
 basicTransport
 	"Answer the transport literal JavaScript object as setup in the JavaScript file, if any"
 	"Answer the transport literal JavaScript object as setup in the JavaScript file, if any"
 	
 	
-	<inlineJS: 'return self.transport'>
+	^ basicTransport
 !
 !
 
 
 sortedImportsAsArray
 sortedImportsAsArray
@@ -599,7 +601,7 @@ named: aString javaScriptDescriptor: anObject
 
 
 new: aString
 new: aString
 	^ Package new
 	^ Package new
-		basicName: aString;
+		name: aString;
 		yourself
 		yourself
 ! !
 ! !
 
 
@@ -985,7 +987,7 @@ renamePackage: packageName to: newName
 	| pkg |
 	| pkg |
 	pkg := self packageAt: packageName ifAbsent: [ self error: 'Missing package: ', packageName ].
 	pkg := self packageAt: packageName ifAbsent: [ self error: 'Missing package: ', packageName ].
 	self packageAt: newName ifAbsent: [ self error: 'Already exists a package called: ', newName ].
 	self packageAt: newName ifAbsent: [ self error: 'Already exists a package called: ', newName ].
-	pkg name: newName.
+	pkg name: newName; beDirty.
 	self packageDictionary
 	self packageDictionary
 		at: newName put: pkg;
 		at: newName put: pkg;
 		removeKey: packageName
 		removeKey: packageName

+ 1 - 1
support/kernel-fundamentals.js

@@ -161,7 +161,7 @@ define(['./compatibility' /* TODO remove */], function () {
             var traitOrClass = globals.hasOwnProperty(builder.className) && globals[builder.className];
             var traitOrClass = globals.hasOwnProperty(builder.className) && globals[builder.className];
             if (traitOrClass) {
             if (traitOrClass) {
                 if (!traitOrClass.pkg) throw new Error("Updated trait or class must have package: " + traitOrClass.className);
                 if (!traitOrClass.pkg) throw new Error("Updated trait or class must have package: " + traitOrClass.className);
-                if (traitOrClass.pkg.pkgName !== pkgName) throw new Error("Incompatible cross-package update of trait or class: " + traitOrClass.className);
+                // if (traitOrClass.pkg.pkgName !== pkgName) throw new Error("Incompatible cross-package update of trait or class: " + traitOrClass.className);
                 builder.updateExisting(traitOrClass);
                 builder.updateExisting(traitOrClass);
             } else {
             } else {
                 traitOrClass = builder.make();
                 traitOrClass = builder.make();