1
0

Kernel-Exceptions.js 29 KB

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