Kernel-Exceptions.js 28 KB

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