Kernel-Exceptions.js 29 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965
  1. define(["amber/boot", "require", "amber/core/Kernel-Objects"], function($boot,requirejs){"use strict";
  2. var $core=$boot.api,nil=$boot.nilAsValue,$nil=$boot.nilAsReceiver,$recv=$boot.asReceiver,$globals=$boot.globals;
  3. var $pkg = $core.addPackage("Kernel-Exceptions");
  4. $pkg.innerEval = function (expr) { return eval(expr); };
  5. $pkg.transport = {"type":"amd","amdNamespace":"amber/core"};
  6. $core.addClass("Error", $globals.Object, ["messageText"], "Kernel-Exceptions");
  7. //>>excludeStart("ide", pragmas.excludeIdeData);
  8. $globals.Error.comment="From the ANSI standard:\x0a\x0aThis protocol describes the behavior of instances of class `Error`.\x0aThese are used to represent error conditions that prevent the normal continuation of processing.\x0aActual error exceptions used by an application may be subclasses of this class.\x0aAs `Error` is explicitly specified to be subclassable, conforming implementations must implement its behavior in a non-fragile manner.";
  9. //>>excludeEnd("ide");
  10. $core.addMethod(
  11. $core.method({
  12. selector: "beHandled",
  13. protocol: "accessing",
  14. fn: function (){
  15. var self=this,$self=this;
  16. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  17. return $core.withContext(function($ctx1) {
  18. //>>excludeEnd("ctx");
  19. self.amberHandled = true;
  20. return self;
  21. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  22. }, function($ctx1) {$ctx1.fill(self,"beHandled",{},$globals.Error)});
  23. //>>excludeEnd("ctx");
  24. },
  25. //>>excludeStart("ide", pragmas.excludeIdeData);
  26. args: [],
  27. source: "beHandled\x0a\x09<inlineJS: 'self.amberHandled = true'>",
  28. referencedClasses: [],
  29. //>>excludeEnd("ide");
  30. messageSends: []
  31. }),
  32. $globals.Error);
  33. $core.addMethod(
  34. $core.method({
  35. selector: "beUnhandled",
  36. protocol: "accessing",
  37. fn: function (){
  38. var self=this,$self=this;
  39. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  40. return $core.withContext(function($ctx1) {
  41. //>>excludeEnd("ctx");
  42. self.amberHandled = false;
  43. return self;
  44. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  45. }, function($ctx1) {$ctx1.fill(self,"beUnhandled",{},$globals.Error)});
  46. //>>excludeEnd("ctx");
  47. },
  48. //>>excludeStart("ide", pragmas.excludeIdeData);
  49. args: [],
  50. source: "beUnhandled\x0a\x09<inlineJS: 'self.amberHandled = false'>",
  51. referencedClasses: [],
  52. //>>excludeEnd("ide");
  53. messageSends: []
  54. }),
  55. $globals.Error);
  56. $core.addMethod(
  57. $core.method({
  58. selector: "context",
  59. protocol: "accessing",
  60. fn: function (){
  61. var self=this,$self=this;
  62. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  63. return $core.withContext(function($ctx1) {
  64. //>>excludeEnd("ctx");
  65. return self.context;
  66. return self;
  67. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  68. }, function($ctx1) {$ctx1.fill(self,"context",{},$globals.Error)});
  69. //>>excludeEnd("ctx");
  70. },
  71. //>>excludeStart("ide", pragmas.excludeIdeData);
  72. args: [],
  73. source: "context\x0a\x09<inlineJS: 'return self.context'>",
  74. referencedClasses: [],
  75. //>>excludeEnd("ide");
  76. messageSends: []
  77. }),
  78. $globals.Error);
  79. $core.addMethod(
  80. $core.method({
  81. selector: "initialize",
  82. protocol: "initialization",
  83. fn: function (){
  84. var self=this,$self=this;
  85. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  86. return $core.withContext(function($ctx1) {
  87. //>>excludeEnd("ctx");
  88. $self._messageText_("Errorclass: ".__comma($recv($self._class())._name()));
  89. return self;
  90. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  91. }, function($ctx1) {$ctx1.fill(self,"initialize",{},$globals.Error)});
  92. //>>excludeEnd("ctx");
  93. },
  94. //>>excludeStart("ide", pragmas.excludeIdeData);
  95. args: [],
  96. source: "initialize\x0a\x09self messageText: 'Errorclass: ', (self class name).",
  97. referencedClasses: [],
  98. //>>excludeEnd("ide");
  99. messageSends: ["messageText:", ",", "name", "class"]
  100. }),
  101. $globals.Error);
  102. $core.addMethod(
  103. $core.method({
  104. selector: "isSmalltalkError",
  105. protocol: "testing",
  106. fn: function (){
  107. var self=this,$self=this;
  108. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  109. return $core.withContext(function($ctx1) {
  110. //>>excludeEnd("ctx");
  111. return self.smalltalkError === true;
  112. return self;
  113. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  114. }, function($ctx1) {$ctx1.fill(self,"isSmalltalkError",{},$globals.Error)});
  115. //>>excludeEnd("ctx");
  116. },
  117. //>>excludeStart("ide", pragmas.excludeIdeData);
  118. args: [],
  119. source: "isSmalltalkError\x0a\x09<inlineJS: 'return self.smalltalkError === true'>",
  120. referencedClasses: [],
  121. //>>excludeEnd("ide");
  122. messageSends: []
  123. }),
  124. $globals.Error);
  125. $core.addMethod(
  126. $core.method({
  127. selector: "jsStack",
  128. protocol: "accessing",
  129. fn: function (){
  130. var self=this,$self=this;
  131. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  132. return $core.withContext(function($ctx1) {
  133. //>>excludeEnd("ctx");
  134. return self.stack;
  135. return self;
  136. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  137. }, function($ctx1) {$ctx1.fill(self,"jsStack",{},$globals.Error)});
  138. //>>excludeEnd("ctx");
  139. },
  140. //>>excludeStart("ide", pragmas.excludeIdeData);
  141. args: [],
  142. source: "jsStack\x0a\x09<inlineJS: 'return self.stack'>",
  143. referencedClasses: [],
  144. //>>excludeEnd("ide");
  145. messageSends: []
  146. }),
  147. $globals.Error);
  148. $core.addMethod(
  149. $core.method({
  150. selector: "messageText",
  151. protocol: "accessing",
  152. fn: function (){
  153. var self=this,$self=this;
  154. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  155. return $core.withContext(function($ctx1) {
  156. //>>excludeEnd("ctx");
  157. var $1,$receiver;
  158. $1=$self.messageText;
  159. if(($receiver = $1) == null || $receiver.a$nil){
  160. return $self._basicAt_("message");
  161. } else {
  162. return $1;
  163. }
  164. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  165. }, function($ctx1) {$ctx1.fill(self,"messageText",{},$globals.Error)});
  166. //>>excludeEnd("ctx");
  167. },
  168. //>>excludeStart("ide", pragmas.excludeIdeData);
  169. args: [],
  170. source: "messageText\x0a\x09^ messageText ifNil: [ self basicAt: 'message' ]",
  171. referencedClasses: [],
  172. //>>excludeEnd("ide");
  173. messageSends: ["ifNil:", "basicAt:"]
  174. }),
  175. $globals.Error);
  176. $core.addMethod(
  177. $core.method({
  178. selector: "messageText:",
  179. protocol: "accessing",
  180. fn: function (aString){
  181. var self=this,$self=this;
  182. $self.messageText=aString;
  183. return self;
  184. },
  185. //>>excludeStart("ide", pragmas.excludeIdeData);
  186. args: ["aString"],
  187. source: "messageText: aString\x0a\x09messageText := aString",
  188. referencedClasses: [],
  189. //>>excludeEnd("ide");
  190. messageSends: []
  191. }),
  192. $globals.Error);
  193. $core.addMethod(
  194. $core.method({
  195. selector: "outer",
  196. protocol: "signaling",
  197. fn: function (){
  198. var self=this,$self=this;
  199. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  200. return $core.withContext(function($ctx1) {
  201. //>>excludeEnd("ctx");
  202. return $self._pass();
  203. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  204. }, function($ctx1) {$ctx1.fill(self,"outer",{},$globals.Error)});
  205. //>>excludeEnd("ctx");
  206. },
  207. //>>excludeStart("ide", pragmas.excludeIdeData);
  208. args: [],
  209. source: "outer\x0a\x09\x22Pharo compatibility. Just sends #pass.\x22\x0a\x09\x0a\x09^ self pass",
  210. referencedClasses: [],
  211. //>>excludeEnd("ide");
  212. messageSends: ["pass"]
  213. }),
  214. $globals.Error);
  215. $core.addMethod(
  216. $core.method({
  217. selector: "pass",
  218. protocol: "signaling",
  219. fn: function (){
  220. var self=this,$self=this;
  221. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  222. return $core.withContext(function($ctx1) {
  223. //>>excludeEnd("ctx");
  224. self.amberHandled = false;
  225. throw self;
  226. ;
  227. return self;
  228. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  229. }, function($ctx1) {$ctx1.fill(self,"pass",{},$globals.Error)});
  230. //>>excludeEnd("ctx");
  231. },
  232. //>>excludeStart("ide", pragmas.excludeIdeData);
  233. args: [],
  234. source: "pass\x0a\x09\x22Let outer handler take care of this.\x22\x0a\x09\x0a\x09<inlineJS: '\x0a\x09\x09self.amberHandled = false;\x0a\x09\x09throw self;\x0a\x09'>",
  235. referencedClasses: [],
  236. //>>excludeEnd("ide");
  237. messageSends: []
  238. }),
  239. $globals.Error);
  240. $core.addMethod(
  241. $core.method({
  242. selector: "resignal",
  243. protocol: "signaling",
  244. fn: function (){
  245. var self=this,$self=this;
  246. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  247. return $core.withContext(function($ctx1) {
  248. //>>excludeEnd("ctx");
  249. $self._deprecatedAPI_("Use #pass.");
  250. return $self._pass();
  251. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  252. }, function($ctx1) {$ctx1.fill(self,"resignal",{},$globals.Error)});
  253. //>>excludeEnd("ctx");
  254. },
  255. //>>excludeStart("ide", pragmas.excludeIdeData);
  256. args: [],
  257. source: "resignal\x0a\x09self deprecatedAPI: 'Use #pass.'.\x0a\x09^ self pass",
  258. referencedClasses: [],
  259. //>>excludeEnd("ide");
  260. messageSends: ["deprecatedAPI:", "pass"]
  261. }),
  262. $globals.Error);
  263. $core.addMethod(
  264. $core.method({
  265. selector: "signal",
  266. protocol: "signaling",
  267. fn: function (){
  268. var self=this,$self=this;
  269. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  270. return $core.withContext(function($ctx1) {
  271. //>>excludeEnd("ctx");
  272. self.amberHandled = false;
  273. self.context = $core.getThisContext();
  274. self.smalltalkError = true;
  275. throw self;
  276. ;
  277. return self;
  278. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  279. }, function($ctx1) {$ctx1.fill(self,"signal",{},$globals.Error)});
  280. //>>excludeEnd("ctx");
  281. },
  282. //>>excludeStart("ide", pragmas.excludeIdeData);
  283. args: [],
  284. source: "signal\x0a\x09<inlineJS: '\x0a\x09\x09self.amberHandled = false;\x0a\x09\x09self.context = $core.getThisContext(); \x0a\x09\x09self.smalltalkError = true;\x0a\x09\x09throw self;\x0a\x09'>",
  285. referencedClasses: [],
  286. //>>excludeEnd("ide");
  287. messageSends: []
  288. }),
  289. $globals.Error);
  290. $core.addMethod(
  291. $core.method({
  292. selector: "signal:",
  293. protocol: "signaling",
  294. fn: function (aString){
  295. var self=this,$self=this;
  296. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  297. return $core.withContext(function($ctx1) {
  298. //>>excludeEnd("ctx");
  299. $self._messageText_(aString);
  300. $self._signal();
  301. return self;
  302. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  303. }, function($ctx1) {$ctx1.fill(self,"signal:",{aString:aString},$globals.Error)});
  304. //>>excludeEnd("ctx");
  305. },
  306. //>>excludeStart("ide", pragmas.excludeIdeData);
  307. args: ["aString"],
  308. source: "signal: aString\x0a\x09self messageText: aString.\x0a\x09self signal",
  309. referencedClasses: [],
  310. //>>excludeEnd("ide");
  311. messageSends: ["messageText:", "signal"]
  312. }),
  313. $globals.Error);
  314. $core.addMethod(
  315. $core.method({
  316. selector: "signalerContext",
  317. protocol: "accessing",
  318. fn: function (){
  319. var self=this,$self=this;
  320. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  321. return $core.withContext(function($ctx1) {
  322. //>>excludeEnd("ctx");
  323. return $self._signalerContextFrom_($self._context());
  324. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  325. }, function($ctx1) {$ctx1.fill(self,"signalerContext",{},$globals.Error)});
  326. //>>excludeEnd("ctx");
  327. },
  328. //>>excludeStart("ide", pragmas.excludeIdeData);
  329. args: [],
  330. source: "signalerContext\x0a\x09^ self signalerContextFrom: self context",
  331. referencedClasses: [],
  332. //>>excludeEnd("ide");
  333. messageSends: ["signalerContextFrom:", "context"]
  334. }),
  335. $globals.Error);
  336. $core.addMethod(
  337. $core.method({
  338. selector: "signalerContextFrom:",
  339. protocol: "accessing",
  340. fn: function (aContext){
  341. var self=this,$self=this;
  342. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  343. return $core.withContext(function($ctx1) {
  344. //>>excludeEnd("ctx");
  345. var $3,$2,$1;
  346. return $recv(aContext)._findContextSuchThat_((function(context){
  347. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  348. return $core.withContext(function($ctx2) {
  349. //>>excludeEnd("ctx");
  350. $3=$recv(context)._receiver();
  351. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  352. $ctx2.sendIdx["receiver"]=1;
  353. //>>excludeEnd("ctx");
  354. $2=$recv($3).__eq_eq(self);
  355. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  356. $ctx2.sendIdx["=="]=1;
  357. //>>excludeEnd("ctx");
  358. $1=$recv($2)._or_((function(){
  359. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  360. return $core.withContext(function($ctx3) {
  361. //>>excludeEnd("ctx");
  362. return $recv($recv(context)._receiver()).__eq_eq($self._class());
  363. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  364. }, function($ctx3) {$ctx3.fillBlock({},$ctx2,2)});
  365. //>>excludeEnd("ctx");
  366. }));
  367. return $recv($1)._not();
  368. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  369. }, function($ctx2) {$ctx2.fillBlock({context:context},$ctx1,1)});
  370. //>>excludeEnd("ctx");
  371. }));
  372. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  373. }, function($ctx1) {$ctx1.fill(self,"signalerContextFrom:",{aContext:aContext},$globals.Error)});
  374. //>>excludeEnd("ctx");
  375. },
  376. //>>excludeStart("ide", pragmas.excludeIdeData);
  377. args: ["aContext"],
  378. source: "signalerContextFrom: aContext\x0a\x09\x22Find the first sender of signal(:), the first context which is neither \x0a\x09for an instance method nor for a class side method of Exception (or subclass).\x0a\x09This will make sure that the same context is found for both, `Error signal` \x0a\x09and `Error new signal`\x22\x0a\x0a\x09^ aContext findContextSuchThat: [ :context |\x0a\x09\x09(context receiver == self \x0a\x09\x09or: [ context receiver == self class ]) not ]",
  379. referencedClasses: [],
  380. //>>excludeEnd("ide");
  381. messageSends: ["findContextSuchThat:", "not", "or:", "==", "receiver", "class"]
  382. }),
  383. $globals.Error);
  384. $core.addMethod(
  385. $core.method({
  386. selector: "wasHandled",
  387. protocol: "testing",
  388. fn: function (){
  389. var self=this,$self=this;
  390. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  391. return $core.withContext(function($ctx1) {
  392. //>>excludeEnd("ctx");
  393. return self.amberHandled || false;
  394. return self;
  395. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  396. }, function($ctx1) {$ctx1.fill(self,"wasHandled",{},$globals.Error)});
  397. //>>excludeEnd("ctx");
  398. },
  399. //>>excludeStart("ide", pragmas.excludeIdeData);
  400. args: [],
  401. source: "wasHandled\x0a\x09<inlineJS: 'return self.amberHandled || false'>",
  402. referencedClasses: [],
  403. //>>excludeEnd("ide");
  404. messageSends: []
  405. }),
  406. $globals.Error);
  407. $core.addMethod(
  408. $core.method({
  409. selector: "classTag",
  410. protocol: "accessing",
  411. fn: function (){
  412. var self=this,$self=this;
  413. return "exception";
  414. },
  415. //>>excludeStart("ide", pragmas.excludeIdeData);
  416. args: [],
  417. source: "classTag\x0a\x09\x22Returns a tag or general category for this class.\x0a\x09Typically used to help tools do some reflection.\x0a\x09Helios, for example, uses this to decide what icon the class should display.\x22\x0a\x09\x0a\x09^ 'exception'",
  418. referencedClasses: [],
  419. //>>excludeEnd("ide");
  420. messageSends: []
  421. }),
  422. $globals.Error.a$cls);
  423. $core.addMethod(
  424. $core.method({
  425. selector: "signal",
  426. protocol: "instance creation",
  427. fn: function (){
  428. var self=this,$self=this;
  429. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  430. return $core.withContext(function($ctx1) {
  431. //>>excludeEnd("ctx");
  432. return $recv($self._new())._signal();
  433. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  434. }, function($ctx1) {$ctx1.fill(self,"signal",{},$globals.Error.a$cls)});
  435. //>>excludeEnd("ctx");
  436. },
  437. //>>excludeStart("ide", pragmas.excludeIdeData);
  438. args: [],
  439. source: "signal\x0a\x09^ self new signal",
  440. referencedClasses: [],
  441. //>>excludeEnd("ide");
  442. messageSends: ["signal", "new"]
  443. }),
  444. $globals.Error.a$cls);
  445. $core.addMethod(
  446. $core.method({
  447. selector: "signal:",
  448. protocol: "instance creation",
  449. fn: function (aString){
  450. var self=this,$self=this;
  451. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  452. return $core.withContext(function($ctx1) {
  453. //>>excludeEnd("ctx");
  454. return $recv($self._new())._signal_(aString);
  455. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  456. }, function($ctx1) {$ctx1.fill(self,"signal:",{aString:aString},$globals.Error.a$cls)});
  457. //>>excludeEnd("ctx");
  458. },
  459. //>>excludeStart("ide", pragmas.excludeIdeData);
  460. args: ["aString"],
  461. source: "signal: aString\x0a\x09^ self new\x0a\x09\x09signal: aString",
  462. referencedClasses: [],
  463. //>>excludeEnd("ide");
  464. messageSends: ["signal:", "new"]
  465. }),
  466. $globals.Error.a$cls);
  467. $core.addClass("Halt", $globals.Error, [], "Kernel-Exceptions");
  468. //>>excludeStart("ide", pragmas.excludeIdeData);
  469. $globals.Halt.comment="I am provided to support `Object>>#halt`.";
  470. //>>excludeEnd("ide");
  471. $core.addMethod(
  472. $core.method({
  473. selector: "messageText",
  474. protocol: "accessing",
  475. fn: function (){
  476. var self=this,$self=this;
  477. return "Halt encountered";
  478. },
  479. //>>excludeStart("ide", pragmas.excludeIdeData);
  480. args: [],
  481. source: "messageText\x0a\x09^ 'Halt encountered'",
  482. referencedClasses: [],
  483. //>>excludeEnd("ide");
  484. messageSends: []
  485. }),
  486. $globals.Halt);
  487. $core.addMethod(
  488. $core.method({
  489. selector: "signalerContextFrom:",
  490. protocol: "accessing",
  491. fn: function (aContext){
  492. var self=this,$self=this;
  493. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  494. return $core.withContext(function($ctx1) {
  495. //>>excludeEnd("ctx");
  496. var $3,$2,$1;
  497. return $recv(aContext)._findContextSuchThat_((function(context){
  498. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  499. return $core.withContext(function($ctx2) {
  500. //>>excludeEnd("ctx");
  501. $3=$recv(context)._receiver();
  502. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  503. $ctx2.sendIdx["receiver"]=1;
  504. //>>excludeEnd("ctx");
  505. $2=$recv($3).__eq_eq(self);
  506. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  507. $ctx2.sendIdx["=="]=1;
  508. //>>excludeEnd("ctx");
  509. $1=$recv($2)._or_((function(){
  510. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  511. return $core.withContext(function($ctx3) {
  512. //>>excludeEnd("ctx");
  513. return $recv($recv($recv(context)._receiver()).__eq_eq($self._class()))._or_((function(){
  514. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  515. return $core.withContext(function($ctx4) {
  516. //>>excludeEnd("ctx");
  517. return $recv($recv($recv(context)._method())._selector()).__eq("halt");
  518. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  519. }, function($ctx4) {$ctx4.fillBlock({},$ctx3,3)});
  520. //>>excludeEnd("ctx");
  521. }));
  522. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  523. }, function($ctx3) {$ctx3.fillBlock({},$ctx2,2)});
  524. //>>excludeEnd("ctx");
  525. }));
  526. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  527. $ctx2.sendIdx["or:"]=1;
  528. //>>excludeEnd("ctx");
  529. return $recv($1)._not();
  530. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  531. }, function($ctx2) {$ctx2.fillBlock({context:context},$ctx1,1)});
  532. //>>excludeEnd("ctx");
  533. }));
  534. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  535. }, function($ctx1) {$ctx1.fill(self,"signalerContextFrom:",{aContext:aContext},$globals.Halt)});
  536. //>>excludeEnd("ctx");
  537. },
  538. //>>excludeStart("ide", pragmas.excludeIdeData);
  539. args: ["aContext"],
  540. source: "signalerContextFrom: aContext\x0a\x09\x22specialized version to find the proper context to open the debugger on.\x0a\x09This will find the first context whose method is no longer on `Halt` or \x0a\x09`Halt class` nor is `#halt` method itself.\x22\x0a\x09\x0a\x09^ aContext findContextSuchThat: [ :context |\x0a\x09\x09(context receiver == self \x0a\x09\x09or: [ (context receiver == self class) \x0a\x09\x09or: [ context method selector = #halt ]]) not ]",
  541. referencedClasses: [],
  542. //>>excludeEnd("ide");
  543. messageSends: ["findContextSuchThat:", "not", "or:", "==", "receiver", "class", "=", "selector", "method"]
  544. }),
  545. $globals.Halt);
  546. $core.addClass("JavaScriptException", $globals.Error, ["exception"], "Kernel-Exceptions");
  547. //>>excludeStart("ide", pragmas.excludeIdeData);
  548. $globals.JavaScriptException.comment="A JavaScriptException is thrown when a non-Smalltalk exception occurs while in the Smalltalk stack.\x0aSee `boot.js` `inContext()` and `BlockClosure >> on:do:`";
  549. //>>excludeEnd("ide");
  550. $core.addMethod(
  551. $core.method({
  552. selector: "context:",
  553. protocol: "accessing",
  554. fn: function (aMethodContext){
  555. var self=this,$self=this;
  556. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  557. return $core.withContext(function($ctx1) {
  558. //>>excludeEnd("ctx");
  559. self.context = aMethodContext;
  560. return self;
  561. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  562. }, function($ctx1) {$ctx1.fill(self,"context:",{aMethodContext:aMethodContext},$globals.JavaScriptException)});
  563. //>>excludeEnd("ctx");
  564. },
  565. //>>excludeStart("ide", pragmas.excludeIdeData);
  566. args: ["aMethodContext"],
  567. source: "context: aMethodContext\x0a\x09\x22Set the context from the outside.\x0a\x09See boot.js `inContext()` exception handling\x22\x0a\x09\x0a\x09<inlineJS: 'self.context = aMethodContext'>",
  568. referencedClasses: [],
  569. //>>excludeEnd("ide");
  570. messageSends: []
  571. }),
  572. $globals.JavaScriptException);
  573. $core.addMethod(
  574. $core.method({
  575. selector: "exception",
  576. protocol: "accessing",
  577. fn: function (){
  578. var self=this,$self=this;
  579. return $self.exception;
  580. },
  581. //>>excludeStart("ide", pragmas.excludeIdeData);
  582. args: [],
  583. source: "exception\x0a\x09^ exception",
  584. referencedClasses: [],
  585. //>>excludeEnd("ide");
  586. messageSends: []
  587. }),
  588. $globals.JavaScriptException);
  589. $core.addMethod(
  590. $core.method({
  591. selector: "exception:",
  592. protocol: "accessing",
  593. fn: function (anException){
  594. var self=this,$self=this;
  595. $self.exception=anException;
  596. return self;
  597. },
  598. //>>excludeStart("ide", pragmas.excludeIdeData);
  599. args: ["anException"],
  600. source: "exception: anException\x0a\x09exception := anException",
  601. referencedClasses: [],
  602. //>>excludeEnd("ide");
  603. messageSends: []
  604. }),
  605. $globals.JavaScriptException);
  606. $core.addMethod(
  607. $core.method({
  608. selector: "messageText",
  609. protocol: "accessing",
  610. fn: function (){
  611. var self=this,$self=this;
  612. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  613. return $core.withContext(function($ctx1) {
  614. //>>excludeEnd("ctx");
  615. return "JavaScript exception: " + $self.exception.toString();
  616. return self;
  617. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  618. }, function($ctx1) {$ctx1.fill(self,"messageText",{},$globals.JavaScriptException)});
  619. //>>excludeEnd("ctx");
  620. },
  621. //>>excludeStart("ide", pragmas.excludeIdeData);
  622. args: [],
  623. source: "messageText\x0a\x09<inlineJS: 'return \x22JavaScript exception: \x22 + $self.exception.toString()'>",
  624. referencedClasses: [],
  625. //>>excludeEnd("ide");
  626. messageSends: []
  627. }),
  628. $globals.JavaScriptException);
  629. $core.addMethod(
  630. $core.method({
  631. selector: "shouldBeStubbed",
  632. protocol: "testing",
  633. fn: function (){
  634. var self=this,$self=this;
  635. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  636. return $core.withContext(function($ctx1) {
  637. //>>excludeEnd("ctx");
  638. return $self.exception instanceof RangeError;
  639. return self;
  640. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  641. }, function($ctx1) {$ctx1.fill(self,"shouldBeStubbed",{},$globals.JavaScriptException)});
  642. //>>excludeEnd("ctx");
  643. },
  644. //>>excludeStart("ide", pragmas.excludeIdeData);
  645. args: [],
  646. source: "shouldBeStubbed\x0a\x09<inlineJS: 'return $self.exception instanceof RangeError'>",
  647. referencedClasses: [],
  648. //>>excludeEnd("ide");
  649. messageSends: []
  650. }),
  651. $globals.JavaScriptException);
  652. $core.addMethod(
  653. $core.method({
  654. selector: "wrap",
  655. protocol: "error handling",
  656. fn: function (){
  657. var self=this,$self=this;
  658. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  659. return $core.withContext(function($ctx1) {
  660. //>>excludeEnd("ctx");
  661. var $1;
  662. $recv((function(){
  663. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  664. return $core.withContext(function($ctx2) {
  665. //>>excludeEnd("ctx");
  666. return $self._signal();
  667. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  668. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,1)});
  669. //>>excludeEnd("ctx");
  670. }))._tryCatch_((function(){
  671. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  672. return $core.withContext(function($ctx2) {
  673. //>>excludeEnd("ctx");
  674. $1=$self._shouldBeStubbed();
  675. if($core.assert($1)){
  676. return $recv($self._context())._stubToAtMost_((100));
  677. }
  678. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  679. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,2)});
  680. //>>excludeEnd("ctx");
  681. }));
  682. return self;
  683. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  684. }, function($ctx1) {$ctx1.fill(self,"wrap",{},$globals.JavaScriptException)});
  685. //>>excludeEnd("ctx");
  686. },
  687. //>>excludeStart("ide", pragmas.excludeIdeData);
  688. args: [],
  689. source: "wrap\x0a\x09[ self signal ] tryCatch:\x0a\x09\x09[ self shouldBeStubbed ifTrue: [ self context stubToAtMost: 100 ] ]",
  690. referencedClasses: [],
  691. //>>excludeEnd("ide");
  692. messageSends: ["tryCatch:", "signal", "ifTrue:", "shouldBeStubbed", "stubToAtMost:", "context"]
  693. }),
  694. $globals.JavaScriptException);
  695. $core.addMethod(
  696. $core.method({
  697. selector: "on:",
  698. protocol: "instance creation",
  699. fn: function (anException){
  700. var self=this,$self=this;
  701. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  702. return $core.withContext(function($ctx1) {
  703. //>>excludeEnd("ctx");
  704. var $1;
  705. $1=$self._new();
  706. $recv($1)._exception_(anException);
  707. return $recv($1)._yourself();
  708. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  709. }, function($ctx1) {$ctx1.fill(self,"on:",{anException:anException},$globals.JavaScriptException.a$cls)});
  710. //>>excludeEnd("ctx");
  711. },
  712. //>>excludeStart("ide", pragmas.excludeIdeData);
  713. args: ["anException"],
  714. source: "on: anException\x0a\x09^ self new\x0a\x09\x09exception: anException;\x0a\x09\x09yourself",
  715. referencedClasses: [],
  716. //>>excludeEnd("ide");
  717. messageSends: ["exception:", "new", "yourself"]
  718. }),
  719. $globals.JavaScriptException.a$cls);
  720. $core.addMethod(
  721. $core.method({
  722. selector: "on:context:",
  723. protocol: "instance creation",
  724. fn: function (anException,aMethodContext){
  725. var self=this,$self=this;
  726. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  727. return $core.withContext(function($ctx1) {
  728. //>>excludeEnd("ctx");
  729. var $1;
  730. $1=$self._new();
  731. $recv($1)._exception_(anException);
  732. $recv($1)._context_(aMethodContext);
  733. return $recv($1)._yourself();
  734. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  735. }, function($ctx1) {$ctx1.fill(self,"on:context:",{anException:anException,aMethodContext:aMethodContext},$globals.JavaScriptException.a$cls)});
  736. //>>excludeEnd("ctx");
  737. },
  738. //>>excludeStart("ide", pragmas.excludeIdeData);
  739. args: ["anException", "aMethodContext"],
  740. source: "on: anException context: aMethodContext\x0a\x09^ self new\x0a\x09\x09exception: anException;\x0a\x09\x09context: aMethodContext;\x0a\x09\x09yourself",
  741. referencedClasses: [],
  742. //>>excludeEnd("ide");
  743. messageSends: ["exception:", "new", "context:", "yourself"]
  744. }),
  745. $globals.JavaScriptException.a$cls);
  746. $core.addClass("MessageNotUnderstood", $globals.Error, ["message", "receiver"], "Kernel-Exceptions");
  747. //>>excludeStart("ide", pragmas.excludeIdeData);
  748. $globals.MessageNotUnderstood.comment="This exception is provided to support `Object>>doesNotUnderstand:`.";
  749. //>>excludeEnd("ide");
  750. $core.addMethod(
  751. $core.method({
  752. selector: "message",
  753. protocol: "accessing",
  754. fn: function (){
  755. var self=this,$self=this;
  756. return $self.message;
  757. },
  758. //>>excludeStart("ide", pragmas.excludeIdeData);
  759. args: [],
  760. source: "message\x0a\x09^ message",
  761. referencedClasses: [],
  762. //>>excludeEnd("ide");
  763. messageSends: []
  764. }),
  765. $globals.MessageNotUnderstood);
  766. $core.addMethod(
  767. $core.method({
  768. selector: "message:",
  769. protocol: "accessing",
  770. fn: function (aMessage){
  771. var self=this,$self=this;
  772. $self.message=aMessage;
  773. return self;
  774. },
  775. //>>excludeStart("ide", pragmas.excludeIdeData);
  776. args: ["aMessage"],
  777. source: "message: aMessage\x0a\x09message := aMessage",
  778. referencedClasses: [],
  779. //>>excludeEnd("ide");
  780. messageSends: []
  781. }),
  782. $globals.MessageNotUnderstood);
  783. $core.addMethod(
  784. $core.method({
  785. selector: "messageText",
  786. protocol: "accessing",
  787. fn: function (){
  788. var self=this,$self=this;
  789. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  790. return $core.withContext(function($ctx1) {
  791. //>>excludeEnd("ctx");
  792. var $1;
  793. $1=$recv($recv($recv($self._receiver())._asString()).__comma(" does not understand #")).__comma($recv($self._message())._selector());
  794. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  795. $ctx1.sendIdx[","]=1;
  796. //>>excludeEnd("ctx");
  797. return $1;
  798. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  799. }, function($ctx1) {$ctx1.fill(self,"messageText",{},$globals.MessageNotUnderstood)});
  800. //>>excludeEnd("ctx");
  801. },
  802. //>>excludeStart("ide", pragmas.excludeIdeData);
  803. args: [],
  804. source: "messageText\x0a\x09^ self receiver asString, ' does not understand #', self message selector",
  805. referencedClasses: [],
  806. //>>excludeEnd("ide");
  807. messageSends: [",", "asString", "receiver", "selector", "message"]
  808. }),
  809. $globals.MessageNotUnderstood);
  810. $core.addMethod(
  811. $core.method({
  812. selector: "receiver",
  813. protocol: "accessing",
  814. fn: function (){
  815. var self=this,$self=this;
  816. return $self.receiver;
  817. },
  818. //>>excludeStart("ide", pragmas.excludeIdeData);
  819. args: [],
  820. source: "receiver\x0a\x09^ receiver",
  821. referencedClasses: [],
  822. //>>excludeEnd("ide");
  823. messageSends: []
  824. }),
  825. $globals.MessageNotUnderstood);
  826. $core.addMethod(
  827. $core.method({
  828. selector: "receiver:",
  829. protocol: "accessing",
  830. fn: function (anObject){
  831. var self=this,$self=this;
  832. $self.receiver=anObject;
  833. return self;
  834. },
  835. //>>excludeStart("ide", pragmas.excludeIdeData);
  836. args: ["anObject"],
  837. source: "receiver: anObject\x0a\x09receiver := anObject",
  838. referencedClasses: [],
  839. //>>excludeEnd("ide");
  840. messageSends: []
  841. }),
  842. $globals.MessageNotUnderstood);
  843. $core.addClass("NonBooleanReceiver", $globals.Error, ["object"], "Kernel-Exceptions");
  844. //>>excludeStart("ide", pragmas.excludeIdeData);
  845. $globals.NonBooleanReceiver.comment="NonBooleanReceiver exceptions may be thrown when executing inlined methods such as `#ifTrue:` with a non boolean receiver.";
  846. //>>excludeEnd("ide");
  847. $core.addMethod(
  848. $core.method({
  849. selector: "object",
  850. protocol: "accessing",
  851. fn: function (){
  852. var self=this,$self=this;
  853. return $self.object;
  854. },
  855. //>>excludeStart("ide", pragmas.excludeIdeData);
  856. args: [],
  857. source: "object\x0a\x09^ object",
  858. referencedClasses: [],
  859. //>>excludeEnd("ide");
  860. messageSends: []
  861. }),
  862. $globals.NonBooleanReceiver);
  863. $core.addMethod(
  864. $core.method({
  865. selector: "object:",
  866. protocol: "accessing",
  867. fn: function (anObject){
  868. var self=this,$self=this;
  869. $self.object=anObject;
  870. return self;
  871. },
  872. //>>excludeStart("ide", pragmas.excludeIdeData);
  873. args: ["anObject"],
  874. source: "object: anObject\x0a\x09object := anObject",
  875. referencedClasses: [],
  876. //>>excludeEnd("ide");
  877. messageSends: []
  878. }),
  879. $globals.NonBooleanReceiver);
  880. $core.addMethod(
  881. $core.method({
  882. selector: "signalOn:",
  883. protocol: "instance creation",
  884. fn: function (anObject){
  885. var self=this,$self=this;
  886. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  887. return $core.withContext(function($ctx1) {
  888. //>>excludeEnd("ctx");
  889. var $1;
  890. $1=$self._new();
  891. $recv($1)._object_(anObject);
  892. return $recv($1)._signal();
  893. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  894. }, function($ctx1) {$ctx1.fill(self,"signalOn:",{anObject:anObject},$globals.NonBooleanReceiver.a$cls)});
  895. //>>excludeEnd("ctx");
  896. },
  897. //>>excludeStart("ide", pragmas.excludeIdeData);
  898. args: ["anObject"],
  899. source: "signalOn: anObject\x0a\x09^ self new\x0a\x09\x09object: anObject;\x0a\x09\x09signal",
  900. referencedClasses: [],
  901. //>>excludeEnd("ide");
  902. messageSends: ["object:", "new", "signal"]
  903. }),
  904. $globals.NonBooleanReceiver.a$cls);
  905. });