Kernel-Exceptions.js 28 KB

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