Ver código fonte

Fixes the way Helios gets parent globals.

May fail if every code is new-style and no-one actually loads
the deprecated amber_vm/globals.
Herbert Vojčík 10 anos atrás
pai
commit
28ede7a88c
2 arquivos alterados com 30 adições e 15 exclusões
  1. 28 14
      src/Helios-Core.js
  2. 2 1
      src/Helios-Core.st

+ 28 - 14
src/Helios-Core.js

@@ -3575,8 +3575,9 @@ fn: function (){
 var self=this;
 var parent,parentSmalltalkGlobals;
 function $Environment(){return globals.Environment||(typeof Environment=="undefined"?nil:Environment)}
+function $Error(){return globals.Error||(typeof Error=="undefined"?nil:Error)}
 return smalltalk.withContext(function($ctx1) { 
-var $1,$2,$3,$4,$5,$6,$7,$receiver;
+var $1,$2,$3,$5,$4,$6,$7,$8,$9,$receiver;
 $1=_st(window)._opener();
 if(($receiver = $1) == null || $receiver.isNil){
 parent=_st(window)._parent();
@@ -3591,24 +3592,37 @@ return $3;
 } else {
 $2;
 };
-$4=_st(parent)._at_("requirejs");
-$ctx1.sendIdx["at:"]=1;
-parentSmalltalkGlobals=_st($4)._value_("amber_vm/globals");
-$5=parentSmalltalkGlobals;
-if(($receiver = $5) == null || $receiver.isNil){
-$6=_st($Environment())._new();
+_st((function(){
+return smalltalk.withContext(function($ctx2) {
+$5=_st(parent)._at_("requirejs");
+$ctx2.sendIdx["at:"]=2;
+$4=_st($5)._value_("amber/boot");
+$ctx2.sendIdx["value:"]=1;
+parentSmalltalkGlobals=_st($4)._at_("globals");
+$ctx2.sendIdx["at:"]=1;
+return parentSmalltalkGlobals;
+}, function($ctx2) {$ctx2.fillBlock({},$ctx1,3)})}))._on_do_($Error(),(function(){
+return smalltalk.withContext(function($ctx2) {
+$6=_st(parent)._at_("requirejs");
+$ctx2.sendIdx["at:"]=3;
+parentSmalltalkGlobals=_st($6)._value_("amber_vm/globals");
+return parentSmalltalkGlobals;
+}, function($ctx2) {$ctx2.fillBlock({},$ctx1,4)})}));
+$7=parentSmalltalkGlobals;
+if(($receiver = $7) == null || $receiver.isNil){
+$8=_st($Environment())._new();
 $ctx1.sendIdx["new"]=2;
-return $6;
+return $8;
 } else {
-$5;
+$7;
 };
-$7=_st(_st(parentSmalltalkGlobals)._at_("Environment"))._new();
-return $7;
+$9=_st(_st(parentSmalltalkGlobals)._at_("Environment"))._new();
+return $9;
 }, function($ctx1) {$ctx1.fill(self,"defaultEnvironment",{parent:parent,parentSmalltalkGlobals:parentSmalltalkGlobals},globals.HLManager)})},
 args: [],
-source: "defaultEnvironment\x0a\x09\x22If helios is loaded from within a frame, answer the parent window environment\x22\x0a\x09\x0a\x09| parent parentSmalltalkGlobals |\x0a\x09\x0a\x09parent := window opener ifNil: [ window parent ].\x0a\x09parent ifNil: [ ^ Environment new ].\x0a\x09\x0a\x09parentSmalltalkGlobals := (parent at: 'requirejs') value: 'amber_vm/globals'.\x0a\x09parentSmalltalkGlobals ifNil: [ ^ Environment new ].\x0a\x09\x0a\x09^ (parentSmalltalkGlobals at: 'Environment') new",
-messageSends: ["ifNil:", "opener", "parent", "new", "value:", "at:"],
-referencedClasses: ["Environment"]
+source: "defaultEnvironment\x0a\x09\x22If helios is loaded from within a frame, answer the parent window environment\x22\x0a\x09\x0a\x09| parent parentSmalltalkGlobals |\x0a\x09\x0a\x09parent := window opener ifNil: [ window parent ].\x0a\x09parent ifNil: [ ^ Environment new ].\x0a\x09\x0a\x09[ parentSmalltalkGlobals := ((parent at: 'requirejs') value: 'amber/boot') at: 'globals' ]\x0a\x09on: Error do: [ parentSmalltalkGlobals := (parent at: 'requirejs') value: 'amber_vm/globals' ].\x0a\x09parentSmalltalkGlobals ifNil: [ ^ Environment new ].\x0a\x09\x0a\x09^ (parentSmalltalkGlobals at: 'Environment') new",
+messageSends: ["ifNil:", "opener", "parent", "new", "on:do:", "at:", "value:"],
+referencedClasses: ["Environment", "Error"]
 }),
 globals.HLManager);
 

+ 2 - 1
src/Helios-Core.st

@@ -1317,7 +1317,8 @@ defaultEnvironment
 	parent := window opener ifNil: [ window parent ].
 	parent ifNil: [ ^ Environment new ].
 	
-	parentSmalltalkGlobals := (parent at: 'requirejs') value: 'amber_vm/globals'.
+	[ parentSmalltalkGlobals := ((parent at: 'requirejs') value: 'amber/boot') at: 'globals' ]
+	on: Error do: [ parentSmalltalkGlobals := (parent at: 'requirejs') value: 'amber_vm/globals' ].
 	parentSmalltalkGlobals ifNil: [ ^ Environment new ].
 	
 	^ (parentSmalltalkGlobals at: 'Environment') new