Kernel-Exceptions.js 26 KB

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