Kernel-Exceptions.js 28 KB

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