Kernel-Exceptions.js 28 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908
  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: "resignal",
  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. self.amberHandled = false;
  192. throw(self);
  193. ;
  194. return self;
  195. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  196. }, function($ctx1) {$ctx1.fill(self,"resignal",{},$globals.Error)});
  197. //>>excludeEnd("ctx");
  198. },
  199. //>>excludeStart("ide", pragmas.excludeIdeData);
  200. args: [],
  201. 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'>",
  202. referencedClasses: [],
  203. //>>excludeEnd("ide");
  204. messageSends: []
  205. }),
  206. $globals.Error);
  207. $core.addMethod(
  208. $core.method({
  209. selector: "signal",
  210. protocol: "signaling",
  211. fn: function (){
  212. var self=this,$self=this;
  213. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  214. return $core.withContext(function($ctx1) {
  215. //>>excludeEnd("ctx");
  216. self.amberHandled = false;
  217. self.context = $core.getThisContext();
  218. self.smalltalkError = true;
  219. throw self;
  220. ;
  221. return self;
  222. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  223. }, function($ctx1) {$ctx1.fill(self,"signal",{},$globals.Error)});
  224. //>>excludeEnd("ctx");
  225. },
  226. //>>excludeStart("ide", pragmas.excludeIdeData);
  227. args: [],
  228. 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'>",
  229. referencedClasses: [],
  230. //>>excludeEnd("ide");
  231. messageSends: []
  232. }),
  233. $globals.Error);
  234. $core.addMethod(
  235. $core.method({
  236. selector: "signal:",
  237. protocol: "signaling",
  238. fn: function (aString){
  239. var self=this,$self=this;
  240. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  241. return $core.withContext(function($ctx1) {
  242. //>>excludeEnd("ctx");
  243. $self._messageText_(aString);
  244. $self._signal();
  245. return self;
  246. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  247. }, function($ctx1) {$ctx1.fill(self,"signal:",{aString:aString},$globals.Error)});
  248. //>>excludeEnd("ctx");
  249. },
  250. //>>excludeStart("ide", pragmas.excludeIdeData);
  251. args: ["aString"],
  252. source: "signal: aString\x0a\x09self messageText: aString.\x0a\x09self signal",
  253. referencedClasses: [],
  254. //>>excludeEnd("ide");
  255. messageSends: ["messageText:", "signal"]
  256. }),
  257. $globals.Error);
  258. $core.addMethod(
  259. $core.method({
  260. selector: "signalerContext",
  261. protocol: "accessing",
  262. fn: function (){
  263. var self=this,$self=this;
  264. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  265. return $core.withContext(function($ctx1) {
  266. //>>excludeEnd("ctx");
  267. return $self._signalerContextFrom_($self._context());
  268. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  269. }, function($ctx1) {$ctx1.fill(self,"signalerContext",{},$globals.Error)});
  270. //>>excludeEnd("ctx");
  271. },
  272. //>>excludeStart("ide", pragmas.excludeIdeData);
  273. args: [],
  274. source: "signalerContext\x0a\x09^ self signalerContextFrom: self context",
  275. referencedClasses: [],
  276. //>>excludeEnd("ide");
  277. messageSends: ["signalerContextFrom:", "context"]
  278. }),
  279. $globals.Error);
  280. $core.addMethod(
  281. $core.method({
  282. selector: "signalerContextFrom:",
  283. protocol: "accessing",
  284. fn: function (aContext){
  285. var self=this,$self=this;
  286. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  287. return $core.withContext(function($ctx1) {
  288. //>>excludeEnd("ctx");
  289. var $3,$2,$1;
  290. return $recv(aContext)._findContextSuchThat_((function(context){
  291. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  292. return $core.withContext(function($ctx2) {
  293. //>>excludeEnd("ctx");
  294. $3=$recv(context)._receiver();
  295. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  296. $ctx2.sendIdx["receiver"]=1;
  297. //>>excludeEnd("ctx");
  298. $2=$recv($3).__eq_eq(self);
  299. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  300. $ctx2.sendIdx["=="]=1;
  301. //>>excludeEnd("ctx");
  302. $1=$recv($2)._or_((function(){
  303. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  304. return $core.withContext(function($ctx3) {
  305. //>>excludeEnd("ctx");
  306. return $recv($recv(context)._receiver()).__eq_eq($self._class());
  307. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  308. }, function($ctx3) {$ctx3.fillBlock({},$ctx2,2)});
  309. //>>excludeEnd("ctx");
  310. }));
  311. return $recv($1)._not();
  312. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  313. }, function($ctx2) {$ctx2.fillBlock({context:context},$ctx1,1)});
  314. //>>excludeEnd("ctx");
  315. }));
  316. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  317. }, function($ctx1) {$ctx1.fill(self,"signalerContextFrom:",{aContext:aContext},$globals.Error)});
  318. //>>excludeEnd("ctx");
  319. },
  320. //>>excludeStart("ide", pragmas.excludeIdeData);
  321. args: ["aContext"],
  322. 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 ]",
  323. referencedClasses: [],
  324. //>>excludeEnd("ide");
  325. messageSends: ["findContextSuchThat:", "not", "or:", "==", "receiver", "class"]
  326. }),
  327. $globals.Error);
  328. $core.addMethod(
  329. $core.method({
  330. selector: "wasHandled",
  331. protocol: "testing",
  332. fn: function (){
  333. var self=this,$self=this;
  334. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  335. return $core.withContext(function($ctx1) {
  336. //>>excludeEnd("ctx");
  337. return self.amberHandled || false;
  338. return self;
  339. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  340. }, function($ctx1) {$ctx1.fill(self,"wasHandled",{},$globals.Error)});
  341. //>>excludeEnd("ctx");
  342. },
  343. //>>excludeStart("ide", pragmas.excludeIdeData);
  344. args: [],
  345. source: "wasHandled\x0a\x09<inlineJS: 'return self.amberHandled || false'>",
  346. referencedClasses: [],
  347. //>>excludeEnd("ide");
  348. messageSends: []
  349. }),
  350. $globals.Error);
  351. $core.addMethod(
  352. $core.method({
  353. selector: "classTag",
  354. protocol: "accessing",
  355. fn: function (){
  356. var self=this,$self=this;
  357. return "exception";
  358. },
  359. //>>excludeStart("ide", pragmas.excludeIdeData);
  360. args: [],
  361. 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'",
  362. referencedClasses: [],
  363. //>>excludeEnd("ide");
  364. messageSends: []
  365. }),
  366. $globals.Error.a$cls);
  367. $core.addMethod(
  368. $core.method({
  369. selector: "signal",
  370. protocol: "instance creation",
  371. fn: function (){
  372. var self=this,$self=this;
  373. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  374. return $core.withContext(function($ctx1) {
  375. //>>excludeEnd("ctx");
  376. return $recv($self._new())._signal();
  377. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  378. }, function($ctx1) {$ctx1.fill(self,"signal",{},$globals.Error.a$cls)});
  379. //>>excludeEnd("ctx");
  380. },
  381. //>>excludeStart("ide", pragmas.excludeIdeData);
  382. args: [],
  383. source: "signal\x0a\x09^ self new signal",
  384. referencedClasses: [],
  385. //>>excludeEnd("ide");
  386. messageSends: ["signal", "new"]
  387. }),
  388. $globals.Error.a$cls);
  389. $core.addMethod(
  390. $core.method({
  391. selector: "signal:",
  392. protocol: "instance creation",
  393. fn: function (aString){
  394. var self=this,$self=this;
  395. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  396. return $core.withContext(function($ctx1) {
  397. //>>excludeEnd("ctx");
  398. return $recv($self._new())._signal_(aString);
  399. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  400. }, function($ctx1) {$ctx1.fill(self,"signal:",{aString:aString},$globals.Error.a$cls)});
  401. //>>excludeEnd("ctx");
  402. },
  403. //>>excludeStart("ide", pragmas.excludeIdeData);
  404. args: ["aString"],
  405. source: "signal: aString\x0a\x09^ self new\x0a\x09\x09signal: aString",
  406. referencedClasses: [],
  407. //>>excludeEnd("ide");
  408. messageSends: ["signal:", "new"]
  409. }),
  410. $globals.Error.a$cls);
  411. $core.addClass("Halt", $globals.Error, [], "Kernel-Exceptions");
  412. //>>excludeStart("ide", pragmas.excludeIdeData);
  413. $globals.Halt.comment="I am provided to support `Object>>#halt`.";
  414. //>>excludeEnd("ide");
  415. $core.addMethod(
  416. $core.method({
  417. selector: "messageText",
  418. protocol: "accessing",
  419. fn: function (){
  420. var self=this,$self=this;
  421. return "Halt encountered";
  422. },
  423. //>>excludeStart("ide", pragmas.excludeIdeData);
  424. args: [],
  425. source: "messageText\x0a\x09^ 'Halt encountered'",
  426. referencedClasses: [],
  427. //>>excludeEnd("ide");
  428. messageSends: []
  429. }),
  430. $globals.Halt);
  431. $core.addMethod(
  432. $core.method({
  433. selector: "signalerContextFrom:",
  434. protocol: "accessing",
  435. fn: function (aContext){
  436. var self=this,$self=this;
  437. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  438. return $core.withContext(function($ctx1) {
  439. //>>excludeEnd("ctx");
  440. var $3,$2,$1;
  441. return $recv(aContext)._findContextSuchThat_((function(context){
  442. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  443. return $core.withContext(function($ctx2) {
  444. //>>excludeEnd("ctx");
  445. $3=$recv(context)._receiver();
  446. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  447. $ctx2.sendIdx["receiver"]=1;
  448. //>>excludeEnd("ctx");
  449. $2=$recv($3).__eq_eq(self);
  450. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  451. $ctx2.sendIdx["=="]=1;
  452. //>>excludeEnd("ctx");
  453. $1=$recv($2)._or_((function(){
  454. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  455. return $core.withContext(function($ctx3) {
  456. //>>excludeEnd("ctx");
  457. return $recv($recv($recv(context)._receiver()).__eq_eq($self._class()))._or_((function(){
  458. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  459. return $core.withContext(function($ctx4) {
  460. //>>excludeEnd("ctx");
  461. return $recv($recv($recv(context)._method())._selector()).__eq("halt");
  462. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  463. }, function($ctx4) {$ctx4.fillBlock({},$ctx3,3)});
  464. //>>excludeEnd("ctx");
  465. }));
  466. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  467. }, function($ctx3) {$ctx3.fillBlock({},$ctx2,2)});
  468. //>>excludeEnd("ctx");
  469. }));
  470. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  471. $ctx2.sendIdx["or:"]=1;
  472. //>>excludeEnd("ctx");
  473. return $recv($1)._not();
  474. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  475. }, function($ctx2) {$ctx2.fillBlock({context:context},$ctx1,1)});
  476. //>>excludeEnd("ctx");
  477. }));
  478. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  479. }, function($ctx1) {$ctx1.fill(self,"signalerContextFrom:",{aContext:aContext},$globals.Halt)});
  480. //>>excludeEnd("ctx");
  481. },
  482. //>>excludeStart("ide", pragmas.excludeIdeData);
  483. args: ["aContext"],
  484. 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 ]",
  485. referencedClasses: [],
  486. //>>excludeEnd("ide");
  487. messageSends: ["findContextSuchThat:", "not", "or:", "==", "receiver", "class", "=", "selector", "method"]
  488. }),
  489. $globals.Halt);
  490. $core.addClass("JavaScriptException", $globals.Error, ["exception"], "Kernel-Exceptions");
  491. //>>excludeStart("ide", pragmas.excludeIdeData);
  492. $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:`";
  493. //>>excludeEnd("ide");
  494. $core.addMethod(
  495. $core.method({
  496. selector: "context:",
  497. protocol: "accessing",
  498. fn: function (aMethodContext){
  499. var self=this,$self=this;
  500. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  501. return $core.withContext(function($ctx1) {
  502. //>>excludeEnd("ctx");
  503. self.context = aMethodContext;
  504. return self;
  505. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  506. }, function($ctx1) {$ctx1.fill(self,"context:",{aMethodContext:aMethodContext},$globals.JavaScriptException)});
  507. //>>excludeEnd("ctx");
  508. },
  509. //>>excludeStart("ide", pragmas.excludeIdeData);
  510. args: ["aMethodContext"],
  511. 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'>",
  512. referencedClasses: [],
  513. //>>excludeEnd("ide");
  514. messageSends: []
  515. }),
  516. $globals.JavaScriptException);
  517. $core.addMethod(
  518. $core.method({
  519. selector: "exception",
  520. protocol: "accessing",
  521. fn: function (){
  522. var self=this,$self=this;
  523. return $self["@exception"];
  524. },
  525. //>>excludeStart("ide", pragmas.excludeIdeData);
  526. args: [],
  527. source: "exception\x0a\x09^ exception",
  528. referencedClasses: [],
  529. //>>excludeEnd("ide");
  530. messageSends: []
  531. }),
  532. $globals.JavaScriptException);
  533. $core.addMethod(
  534. $core.method({
  535. selector: "exception:",
  536. protocol: "accessing",
  537. fn: function (anException){
  538. var self=this,$self=this;
  539. $self["@exception"]=anException;
  540. return self;
  541. },
  542. //>>excludeStart("ide", pragmas.excludeIdeData);
  543. args: ["anException"],
  544. source: "exception: anException\x0a\x09exception := anException",
  545. referencedClasses: [],
  546. //>>excludeEnd("ide");
  547. messageSends: []
  548. }),
  549. $globals.JavaScriptException);
  550. $core.addMethod(
  551. $core.method({
  552. selector: "messageText",
  553. protocol: "accessing",
  554. fn: function (){
  555. var self=this,$self=this;
  556. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  557. return $core.withContext(function($ctx1) {
  558. //>>excludeEnd("ctx");
  559. return "JavaScript exception: " + $self["@exception"].toString();
  560. return self;
  561. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  562. }, function($ctx1) {$ctx1.fill(self,"messageText",{},$globals.JavaScriptException)});
  563. //>>excludeEnd("ctx");
  564. },
  565. //>>excludeStart("ide", pragmas.excludeIdeData);
  566. args: [],
  567. source: "messageText\x0a\x09<inlineJS: 'return \x22JavaScript exception: \x22 + $self[\x22@exception\x22].toString()'>",
  568. referencedClasses: [],
  569. //>>excludeEnd("ide");
  570. messageSends: []
  571. }),
  572. $globals.JavaScriptException);
  573. $core.addMethod(
  574. $core.method({
  575. selector: "shouldBeStubbed",
  576. protocol: "testing",
  577. fn: function (){
  578. var self=this,$self=this;
  579. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  580. return $core.withContext(function($ctx1) {
  581. //>>excludeEnd("ctx");
  582. return $self["@exception"] instanceof RangeError;
  583. return self;
  584. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  585. }, function($ctx1) {$ctx1.fill(self,"shouldBeStubbed",{},$globals.JavaScriptException)});
  586. //>>excludeEnd("ctx");
  587. },
  588. //>>excludeStart("ide", pragmas.excludeIdeData);
  589. args: [],
  590. source: "shouldBeStubbed\x0a\x09<inlineJS: 'return $self[\x22@exception\x22] instanceof RangeError'>",
  591. referencedClasses: [],
  592. //>>excludeEnd("ide");
  593. messageSends: []
  594. }),
  595. $globals.JavaScriptException);
  596. $core.addMethod(
  597. $core.method({
  598. selector: "wrap",
  599. protocol: "error handling",
  600. fn: function (){
  601. var self=this,$self=this;
  602. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  603. return $core.withContext(function($ctx1) {
  604. //>>excludeEnd("ctx");
  605. var $1;
  606. $recv((function(){
  607. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  608. return $core.withContext(function($ctx2) {
  609. //>>excludeEnd("ctx");
  610. return $self._signal();
  611. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  612. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,1)});
  613. //>>excludeEnd("ctx");
  614. }))._tryCatch_((function(){
  615. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  616. return $core.withContext(function($ctx2) {
  617. //>>excludeEnd("ctx");
  618. $1=$self._shouldBeStubbed();
  619. if($core.assert($1)){
  620. return $recv($self._context())._stubToAtMost_((100));
  621. }
  622. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  623. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,2)});
  624. //>>excludeEnd("ctx");
  625. }));
  626. return self;
  627. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  628. }, function($ctx1) {$ctx1.fill(self,"wrap",{},$globals.JavaScriptException)});
  629. //>>excludeEnd("ctx");
  630. },
  631. //>>excludeStart("ide", pragmas.excludeIdeData);
  632. args: [],
  633. source: "wrap\x0a\x09[ self signal ] tryCatch:\x0a\x09\x09[ self shouldBeStubbed ifTrue: [ self context stubToAtMost: 100 ] ]",
  634. referencedClasses: [],
  635. //>>excludeEnd("ide");
  636. messageSends: ["tryCatch:", "signal", "ifTrue:", "shouldBeStubbed", "stubToAtMost:", "context"]
  637. }),
  638. $globals.JavaScriptException);
  639. $core.addMethod(
  640. $core.method({
  641. selector: "on:",
  642. protocol: "instance creation",
  643. fn: function (anException){
  644. var self=this,$self=this;
  645. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  646. return $core.withContext(function($ctx1) {
  647. //>>excludeEnd("ctx");
  648. var $1;
  649. $1=$self._new();
  650. $recv($1)._exception_(anException);
  651. return $recv($1)._yourself();
  652. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  653. }, function($ctx1) {$ctx1.fill(self,"on:",{anException:anException},$globals.JavaScriptException.a$cls)});
  654. //>>excludeEnd("ctx");
  655. },
  656. //>>excludeStart("ide", pragmas.excludeIdeData);
  657. args: ["anException"],
  658. source: "on: anException\x0a\x09^ self new\x0a\x09\x09exception: anException;\x0a\x09\x09yourself",
  659. referencedClasses: [],
  660. //>>excludeEnd("ide");
  661. messageSends: ["exception:", "new", "yourself"]
  662. }),
  663. $globals.JavaScriptException.a$cls);
  664. $core.addMethod(
  665. $core.method({
  666. selector: "on:context:",
  667. protocol: "instance creation",
  668. fn: function (anException,aMethodContext){
  669. var self=this,$self=this;
  670. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  671. return $core.withContext(function($ctx1) {
  672. //>>excludeEnd("ctx");
  673. var $1;
  674. $1=$self._new();
  675. $recv($1)._exception_(anException);
  676. $recv($1)._context_(aMethodContext);
  677. return $recv($1)._yourself();
  678. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  679. }, function($ctx1) {$ctx1.fill(self,"on:context:",{anException:anException,aMethodContext:aMethodContext},$globals.JavaScriptException.a$cls)});
  680. //>>excludeEnd("ctx");
  681. },
  682. //>>excludeStart("ide", pragmas.excludeIdeData);
  683. args: ["anException", "aMethodContext"],
  684. source: "on: anException context: aMethodContext\x0a\x09^ self new\x0a\x09\x09exception: anException;\x0a\x09\x09context: aMethodContext;\x0a\x09\x09yourself",
  685. referencedClasses: [],
  686. //>>excludeEnd("ide");
  687. messageSends: ["exception:", "new", "context:", "yourself"]
  688. }),
  689. $globals.JavaScriptException.a$cls);
  690. $core.addClass("MessageNotUnderstood", $globals.Error, ["message", "receiver"], "Kernel-Exceptions");
  691. //>>excludeStart("ide", pragmas.excludeIdeData);
  692. $globals.MessageNotUnderstood.comment="This exception is provided to support `Object>>doesNotUnderstand:`.";
  693. //>>excludeEnd("ide");
  694. $core.addMethod(
  695. $core.method({
  696. selector: "message",
  697. protocol: "accessing",
  698. fn: function (){
  699. var self=this,$self=this;
  700. return $self["@message"];
  701. },
  702. //>>excludeStart("ide", pragmas.excludeIdeData);
  703. args: [],
  704. source: "message\x0a\x09^ message",
  705. referencedClasses: [],
  706. //>>excludeEnd("ide");
  707. messageSends: []
  708. }),
  709. $globals.MessageNotUnderstood);
  710. $core.addMethod(
  711. $core.method({
  712. selector: "message:",
  713. protocol: "accessing",
  714. fn: function (aMessage){
  715. var self=this,$self=this;
  716. $self["@message"]=aMessage;
  717. return self;
  718. },
  719. //>>excludeStart("ide", pragmas.excludeIdeData);
  720. args: ["aMessage"],
  721. source: "message: aMessage\x0a\x09message := aMessage",
  722. referencedClasses: [],
  723. //>>excludeEnd("ide");
  724. messageSends: []
  725. }),
  726. $globals.MessageNotUnderstood);
  727. $core.addMethod(
  728. $core.method({
  729. selector: "messageText",
  730. protocol: "accessing",
  731. fn: function (){
  732. var self=this,$self=this;
  733. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  734. return $core.withContext(function($ctx1) {
  735. //>>excludeEnd("ctx");
  736. var $1;
  737. $1=$recv($recv($recv($self._receiver())._asString()).__comma(" does not understand #")).__comma($recv($self._message())._selector());
  738. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  739. $ctx1.sendIdx[","]=1;
  740. //>>excludeEnd("ctx");
  741. return $1;
  742. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  743. }, function($ctx1) {$ctx1.fill(self,"messageText",{},$globals.MessageNotUnderstood)});
  744. //>>excludeEnd("ctx");
  745. },
  746. //>>excludeStart("ide", pragmas.excludeIdeData);
  747. args: [],
  748. source: "messageText\x0a\x09^ self receiver asString, ' does not understand #', self message selector",
  749. referencedClasses: [],
  750. //>>excludeEnd("ide");
  751. messageSends: [",", "asString", "receiver", "selector", "message"]
  752. }),
  753. $globals.MessageNotUnderstood);
  754. $core.addMethod(
  755. $core.method({
  756. selector: "receiver",
  757. protocol: "accessing",
  758. fn: function (){
  759. var self=this,$self=this;
  760. return $self["@receiver"];
  761. },
  762. //>>excludeStart("ide", pragmas.excludeIdeData);
  763. args: [],
  764. source: "receiver\x0a\x09^ receiver",
  765. referencedClasses: [],
  766. //>>excludeEnd("ide");
  767. messageSends: []
  768. }),
  769. $globals.MessageNotUnderstood);
  770. $core.addMethod(
  771. $core.method({
  772. selector: "receiver:",
  773. protocol: "accessing",
  774. fn: function (anObject){
  775. var self=this,$self=this;
  776. $self["@receiver"]=anObject;
  777. return self;
  778. },
  779. //>>excludeStart("ide", pragmas.excludeIdeData);
  780. args: ["anObject"],
  781. source: "receiver: anObject\x0a\x09receiver := anObject",
  782. referencedClasses: [],
  783. //>>excludeEnd("ide");
  784. messageSends: []
  785. }),
  786. $globals.MessageNotUnderstood);
  787. $core.addClass("NonBooleanReceiver", $globals.Error, ["object"], "Kernel-Exceptions");
  788. //>>excludeStart("ide", pragmas.excludeIdeData);
  789. $globals.NonBooleanReceiver.comment="NonBooleanReceiver exceptions may be thrown when executing inlined methods such as `#ifTrue:` with a non boolean receiver.";
  790. //>>excludeEnd("ide");
  791. $core.addMethod(
  792. $core.method({
  793. selector: "object",
  794. protocol: "accessing",
  795. fn: function (){
  796. var self=this,$self=this;
  797. return $self["@object"];
  798. },
  799. //>>excludeStart("ide", pragmas.excludeIdeData);
  800. args: [],
  801. source: "object\x0a\x09^ object",
  802. referencedClasses: [],
  803. //>>excludeEnd("ide");
  804. messageSends: []
  805. }),
  806. $globals.NonBooleanReceiver);
  807. $core.addMethod(
  808. $core.method({
  809. selector: "object:",
  810. protocol: "accessing",
  811. fn: function (anObject){
  812. var self=this,$self=this;
  813. $self["@object"]=anObject;
  814. return self;
  815. },
  816. //>>excludeStart("ide", pragmas.excludeIdeData);
  817. args: ["anObject"],
  818. source: "object: anObject\x0a\x09object := anObject",
  819. referencedClasses: [],
  820. //>>excludeEnd("ide");
  821. messageSends: []
  822. }),
  823. $globals.NonBooleanReceiver);
  824. $core.addMethod(
  825. $core.method({
  826. selector: "signalOn:",
  827. protocol: "instance creation",
  828. fn: function (anObject){
  829. var self=this,$self=this;
  830. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  831. return $core.withContext(function($ctx1) {
  832. //>>excludeEnd("ctx");
  833. var $1;
  834. $1=$self._new();
  835. $recv($1)._object_(anObject);
  836. return $recv($1)._signal();
  837. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  838. }, function($ctx1) {$ctx1.fill(self,"signalOn:",{anObject:anObject},$globals.NonBooleanReceiver.a$cls)});
  839. //>>excludeEnd("ctx");
  840. },
  841. //>>excludeStart("ide", pragmas.excludeIdeData);
  842. args: ["anObject"],
  843. source: "signalOn: anObject\x0a\x09^ self new\x0a\x09\x09object: anObject;\x0a\x09\x09signal",
  844. referencedClasses: [],
  845. //>>excludeEnd("ide");
  846. messageSends: ["object:", "new", "signal"]
  847. }),
  848. $globals.NonBooleanReceiver.a$cls);
  849. });