Kernel-Exceptions.js 30 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009
  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.transport = {"type":"amd","amdNamespace":"amber/core"};
  5. $core.addClass("Error", $globals.Object, "Kernel-Exceptions");
  6. $core.setSlots($globals.Error, ["message", "stack", "amberHandled", "context", "smalltalkError"]);
  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. var $1;
  345. return $recv(aContext)._findContextSuchThat_((function(one){
  346. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  347. return $core.withContext(function($ctx2) {
  348. //>>excludeEnd("ctx");
  349. if($core.assert([$recv([$recv(one)._receiver()
  350. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  351. ,$ctx2.sendIdx["receiver"]=1
  352. //>>excludeEnd("ctx");
  353. ][0]).__eq_eq(self)
  354. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  355. ,$ctx2.sendIdx["=="]=1
  356. //>>excludeEnd("ctx");
  357. ][0])){
  358. $1=true;
  359. } else {
  360. $1=$recv($recv(one)._receiver()).__eq_eq($self._class());
  361. }
  362. return $recv($1)._not();
  363. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  364. }, function($ctx2) {$ctx2.fillBlock({one:one},$ctx1,1)});
  365. //>>excludeEnd("ctx");
  366. }));
  367. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  368. }, function($ctx1) {$ctx1.fill(self,"signalerContextFrom:",{aContext:aContext})});
  369. //>>excludeEnd("ctx");
  370. }; }),
  371. $globals.Error);
  372. $core.addMethod(
  373. $core.method({
  374. selector: "wasHandled",
  375. protocol: "testing",
  376. //>>excludeStart("ide", pragmas.excludeIdeData);
  377. args: [],
  378. source: "wasHandled\x0a\x09^ amberHandled == true",
  379. referencedClasses: [],
  380. //>>excludeEnd("ide");
  381. pragmas: [],
  382. messageSends: ["=="]
  383. }, function ($methodClass){ return function (){
  384. var self=this,$self=this;
  385. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  386. return $core.withContext(function($ctx1) {
  387. //>>excludeEnd("ctx");
  388. return $recv($self.amberHandled).__eq_eq(true);
  389. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  390. }, function($ctx1) {$ctx1.fill(self,"wasHandled",{})});
  391. //>>excludeEnd("ctx");
  392. }; }),
  393. $globals.Error);
  394. $core.addMethod(
  395. $core.method({
  396. selector: "classTag",
  397. protocol: "accessing",
  398. //>>excludeStart("ide", pragmas.excludeIdeData);
  399. args: [],
  400. 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'",
  401. referencedClasses: [],
  402. //>>excludeEnd("ide");
  403. pragmas: [],
  404. messageSends: []
  405. }, function ($methodClass){ return function (){
  406. var self=this,$self=this;
  407. return "exception";
  408. }; }),
  409. $globals.Error.a$cls);
  410. $core.addMethod(
  411. $core.method({
  412. selector: "messageText:",
  413. protocol: "instance creation",
  414. //>>excludeStart("ide", pragmas.excludeIdeData);
  415. args: ["aString"],
  416. source: "messageText: aString\x0a\x09^ self new\x0a\x09\x09messageText: aString;\x0a\x09\x09yourself",
  417. referencedClasses: [],
  418. //>>excludeEnd("ide");
  419. pragmas: [],
  420. messageSends: ["messageText:", "new", "yourself"]
  421. }, function ($methodClass){ return function (aString){
  422. var self=this,$self=this;
  423. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  424. return $core.withContext(function($ctx1) {
  425. //>>excludeEnd("ctx");
  426. var $1;
  427. $1=$self._new();
  428. $recv($1)._messageText_(aString);
  429. return $recv($1)._yourself();
  430. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  431. }, function($ctx1) {$ctx1.fill(self,"messageText:",{aString:aString})});
  432. //>>excludeEnd("ctx");
  433. }; }),
  434. $globals.Error.a$cls);
  435. $core.addMethod(
  436. $core.method({
  437. selector: "signal",
  438. protocol: "instance creation",
  439. //>>excludeStart("ide", pragmas.excludeIdeData);
  440. args: [],
  441. source: "signal\x0a\x09^ self new signal",
  442. referencedClasses: [],
  443. //>>excludeEnd("ide");
  444. pragmas: [],
  445. messageSends: ["signal", "new"]
  446. }, function ($methodClass){ return function (){
  447. var self=this,$self=this;
  448. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  449. return $core.withContext(function($ctx1) {
  450. //>>excludeEnd("ctx");
  451. return $recv($self._new())._signal();
  452. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  453. }, function($ctx1) {$ctx1.fill(self,"signal",{})});
  454. //>>excludeEnd("ctx");
  455. }; }),
  456. $globals.Error.a$cls);
  457. $core.addMethod(
  458. $core.method({
  459. selector: "signal:",
  460. protocol: "instance creation",
  461. //>>excludeStart("ide", pragmas.excludeIdeData);
  462. args: ["aString"],
  463. source: "signal: aString\x0a\x09^ self new\x0a\x09\x09signal: aString",
  464. referencedClasses: [],
  465. //>>excludeEnd("ide");
  466. pragmas: [],
  467. messageSends: ["signal:", "new"]
  468. }, function ($methodClass){ return function (aString){
  469. var self=this,$self=this;
  470. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  471. return $core.withContext(function($ctx1) {
  472. //>>excludeEnd("ctx");
  473. return $recv($self._new())._signal_(aString);
  474. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  475. }, function($ctx1) {$ctx1.fill(self,"signal:",{aString:aString})});
  476. //>>excludeEnd("ctx");
  477. }; }),
  478. $globals.Error.a$cls);
  479. $core.addClass("Halt", $globals.Error, "Kernel-Exceptions");
  480. //>>excludeStart("ide", pragmas.excludeIdeData);
  481. $globals.Halt.comment="I am provided to support `Object>>#halt`.";
  482. //>>excludeEnd("ide");
  483. $core.addMethod(
  484. $core.method({
  485. selector: "messageText",
  486. protocol: "accessing",
  487. //>>excludeStart("ide", pragmas.excludeIdeData);
  488. args: [],
  489. source: "messageText\x0a\x09^ 'Halt encountered'",
  490. referencedClasses: [],
  491. //>>excludeEnd("ide");
  492. pragmas: [],
  493. messageSends: []
  494. }, function ($methodClass){ return function (){
  495. var self=this,$self=this;
  496. return "Halt encountered";
  497. }; }),
  498. $globals.Halt);
  499. $core.addMethod(
  500. $core.method({
  501. selector: "signalerContextFrom:",
  502. protocol: "accessing",
  503. //>>excludeStart("ide", pragmas.excludeIdeData);
  504. args: ["aContext"],
  505. 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 ]",
  506. referencedClasses: [],
  507. //>>excludeEnd("ide");
  508. pragmas: [],
  509. messageSends: ["findContextSuchThat:", "not", "or:", "==", "receiver", "class", "=", "selector", "method"]
  510. }, function ($methodClass){ return function (aContext){
  511. var self=this,$self=this;
  512. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  513. return $core.withContext(function($ctx1) {
  514. //>>excludeEnd("ctx");
  515. var $1;
  516. return $recv(aContext)._findContextSuchThat_((function(one){
  517. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  518. return $core.withContext(function($ctx2) {
  519. //>>excludeEnd("ctx");
  520. if($core.assert([$recv([$recv(one)._receiver()
  521. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  522. ,$ctx2.sendIdx["receiver"]=1
  523. //>>excludeEnd("ctx");
  524. ][0]).__eq_eq(self)
  525. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  526. ,$ctx2.sendIdx["=="]=1
  527. //>>excludeEnd("ctx");
  528. ][0])){
  529. $1=true;
  530. } else {
  531. if($core.assert($recv($recv(one)._receiver()).__eq_eq($self._class()))){
  532. $1=true;
  533. } else {
  534. $1=$recv($recv($recv(one)._method())._selector()).__eq("halt");
  535. }
  536. }
  537. return $recv($1)._not();
  538. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  539. }, function($ctx2) {$ctx2.fillBlock({one:one},$ctx1,1)});
  540. //>>excludeEnd("ctx");
  541. }));
  542. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  543. }, function($ctx1) {$ctx1.fill(self,"signalerContextFrom:",{aContext:aContext})});
  544. //>>excludeEnd("ctx");
  545. }; }),
  546. $globals.Halt);
  547. $core.addClass("JavaScriptException", $globals.Error, "Kernel-Exceptions");
  548. $core.setSlots($globals.JavaScriptException, ["exception"]);
  549. //>>excludeStart("ide", pragmas.excludeIdeData);
  550. $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:`";
  551. //>>excludeEnd("ide");
  552. $core.addMethod(
  553. $core.method({
  554. selector: "exception",
  555. protocol: "accessing",
  556. //>>excludeStart("ide", pragmas.excludeIdeData);
  557. args: [],
  558. source: "exception\x0a\x09^ exception",
  559. referencedClasses: [],
  560. //>>excludeEnd("ide");
  561. pragmas: [],
  562. messageSends: []
  563. }, function ($methodClass){ return function (){
  564. var self=this,$self=this;
  565. return $self.exception;
  566. }; }),
  567. $globals.JavaScriptException);
  568. $core.addMethod(
  569. $core.method({
  570. selector: "exception:",
  571. protocol: "accessing",
  572. //>>excludeStart("ide", pragmas.excludeIdeData);
  573. args: ["anException"],
  574. source: "exception: anException\x0a\x09exception := anException",
  575. referencedClasses: [],
  576. //>>excludeEnd("ide");
  577. pragmas: [],
  578. messageSends: []
  579. }, function ($methodClass){ return function (anException){
  580. var self=this,$self=this;
  581. $self.exception=anException;
  582. return self;
  583. }; }),
  584. $globals.JavaScriptException);
  585. $core.addMethod(
  586. $core.method({
  587. selector: "messageText",
  588. protocol: "accessing",
  589. //>>excludeStart("ide", pragmas.excludeIdeData);
  590. args: [],
  591. source: "messageText\x0a\x09<inlineJS: 'return \x22JavaScript exception: \x22 + $self.exception.toString()'>",
  592. referencedClasses: [],
  593. //>>excludeEnd("ide");
  594. pragmas: [["inlineJS:", ["return \x22JavaScript exception: \x22 + $self.exception.toString()"]]],
  595. messageSends: []
  596. }, function ($methodClass){ return function (){
  597. var self=this,$self=this;
  598. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  599. return $core.withContext(function($ctx1) {
  600. //>>excludeEnd("ctx");
  601. return "JavaScript exception: " + $self.exception.toString();
  602. return self;
  603. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  604. }, function($ctx1) {$ctx1.fill(self,"messageText",{})});
  605. //>>excludeEnd("ctx");
  606. }; }),
  607. $globals.JavaScriptException);
  608. $core.addMethod(
  609. $core.method({
  610. selector: "on:",
  611. protocol: "instance creation",
  612. //>>excludeStart("ide", pragmas.excludeIdeData);
  613. args: ["anException"],
  614. source: "on: anException\x0a\x09^ self new\x0a\x09\x09exception: anException;\x0a\x09\x09yourself",
  615. referencedClasses: [],
  616. //>>excludeEnd("ide");
  617. pragmas: [],
  618. messageSends: ["exception:", "new", "yourself"]
  619. }, function ($methodClass){ return function (anException){
  620. var self=this,$self=this;
  621. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  622. return $core.withContext(function($ctx1) {
  623. //>>excludeEnd("ctx");
  624. var $1;
  625. $1=$self._new();
  626. $recv($1)._exception_(anException);
  627. return $recv($1)._yourself();
  628. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  629. }, function($ctx1) {$ctx1.fill(self,"on:",{anException:anException})});
  630. //>>excludeEnd("ctx");
  631. }; }),
  632. $globals.JavaScriptException.a$cls);
  633. $core.addMethod(
  634. $core.method({
  635. selector: "on:context:",
  636. protocol: "instance creation",
  637. //>>excludeStart("ide", pragmas.excludeIdeData);
  638. args: ["anException", "aMethodContext"],
  639. source: "on: anException context: aMethodContext\x0a\x09^ self new\x0a\x09\x09exception: anException;\x0a\x09\x09context: aMethodContext;\x0a\x09\x09yourself",
  640. referencedClasses: [],
  641. //>>excludeEnd("ide");
  642. pragmas: [],
  643. messageSends: ["exception:", "new", "context:", "yourself"]
  644. }, function ($methodClass){ return function (anException,aMethodContext){
  645. var self=this,$self=this;
  646. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  647. return $core.withContext(function($ctx1) {
  648. //>>excludeEnd("ctx");
  649. var $1;
  650. $1=$self._new();
  651. $recv($1)._exception_(anException);
  652. $recv($1)._context_(aMethodContext);
  653. return $recv($1)._yourself();
  654. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  655. }, function($ctx1) {$ctx1.fill(self,"on:context:",{anException:anException,aMethodContext:aMethodContext})});
  656. //>>excludeEnd("ctx");
  657. }; }),
  658. $globals.JavaScriptException.a$cls);
  659. $core.addClass("MessageNotUnderstood", $globals.Error, "Kernel-Exceptions");
  660. $core.setSlots($globals.MessageNotUnderstood, ["smalltalkMessage", "receiver"]);
  661. //>>excludeStart("ide", pragmas.excludeIdeData);
  662. $globals.MessageNotUnderstood.comment="This exception is provided to support `Object>>doesNotUnderstand:`.";
  663. //>>excludeEnd("ide");
  664. $core.addMethod(
  665. $core.method({
  666. selector: "message",
  667. protocol: "accessing",
  668. //>>excludeStart("ide", pragmas.excludeIdeData);
  669. args: [],
  670. source: "message\x0a\x09^ smalltalkMessage",
  671. referencedClasses: [],
  672. //>>excludeEnd("ide");
  673. pragmas: [],
  674. messageSends: []
  675. }, function ($methodClass){ return function (){
  676. var self=this,$self=this;
  677. return $self.smalltalkMessage;
  678. }; }),
  679. $globals.MessageNotUnderstood);
  680. $core.addMethod(
  681. $core.method({
  682. selector: "message:",
  683. protocol: "accessing",
  684. //>>excludeStart("ide", pragmas.excludeIdeData);
  685. args: ["aMessage"],
  686. source: "message: aMessage\x0a\x09smalltalkMessage := aMessage",
  687. referencedClasses: [],
  688. //>>excludeEnd("ide");
  689. pragmas: [],
  690. messageSends: []
  691. }, function ($methodClass){ return function (aMessage){
  692. var self=this,$self=this;
  693. $self.smalltalkMessage=aMessage;
  694. return self;
  695. }; }),
  696. $globals.MessageNotUnderstood);
  697. $core.addMethod(
  698. $core.method({
  699. selector: "messageText",
  700. protocol: "accessing",
  701. //>>excludeStart("ide", pragmas.excludeIdeData);
  702. args: [],
  703. source: "messageText\x0a\x09^ self receiver asString, ' does not understand #', self message selector",
  704. referencedClasses: [],
  705. //>>excludeEnd("ide");
  706. pragmas: [],
  707. messageSends: [",", "asString", "receiver", "selector", "message"]
  708. }, function ($methodClass){ return function (){
  709. var self=this,$self=this;
  710. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  711. return $core.withContext(function($ctx1) {
  712. //>>excludeEnd("ctx");
  713. return [$recv($recv($recv($self._receiver())._asString()).__comma(" does not understand #")).__comma($recv($self._message())._selector())
  714. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  715. ,$ctx1.sendIdx[","]=1
  716. //>>excludeEnd("ctx");
  717. ][0];
  718. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  719. }, function($ctx1) {$ctx1.fill(self,"messageText",{})});
  720. //>>excludeEnd("ctx");
  721. }; }),
  722. $globals.MessageNotUnderstood);
  723. $core.addMethod(
  724. $core.method({
  725. selector: "receiver",
  726. protocol: "accessing",
  727. //>>excludeStart("ide", pragmas.excludeIdeData);
  728. args: [],
  729. source: "receiver\x0a\x09^ receiver",
  730. referencedClasses: [],
  731. //>>excludeEnd("ide");
  732. pragmas: [],
  733. messageSends: []
  734. }, function ($methodClass){ return function (){
  735. var self=this,$self=this;
  736. return $self.receiver;
  737. }; }),
  738. $globals.MessageNotUnderstood);
  739. $core.addMethod(
  740. $core.method({
  741. selector: "receiver:",
  742. protocol: "accessing",
  743. //>>excludeStart("ide", pragmas.excludeIdeData);
  744. args: ["anObject"],
  745. source: "receiver: anObject\x0a\x09receiver := anObject",
  746. referencedClasses: [],
  747. //>>excludeEnd("ide");
  748. pragmas: [],
  749. messageSends: []
  750. }, function ($methodClass){ return function (anObject){
  751. var self=this,$self=this;
  752. $self.receiver=anObject;
  753. return self;
  754. }; }),
  755. $globals.MessageNotUnderstood);
  756. $core.addClass("NonBooleanReceiver", $globals.Error, "Kernel-Exceptions");
  757. $core.setSlots($globals.NonBooleanReceiver, ["object"]);
  758. //>>excludeStart("ide", pragmas.excludeIdeData);
  759. $globals.NonBooleanReceiver.comment="NonBooleanReceiver exceptions may be thrown when executing inlined methods such as `#ifTrue:` with a non boolean receiver.";
  760. //>>excludeEnd("ide");
  761. $core.addMethod(
  762. $core.method({
  763. selector: "object",
  764. protocol: "accessing",
  765. //>>excludeStart("ide", pragmas.excludeIdeData);
  766. args: [],
  767. source: "object\x0a\x09^ object",
  768. referencedClasses: [],
  769. //>>excludeEnd("ide");
  770. pragmas: [],
  771. messageSends: []
  772. }, function ($methodClass){ return function (){
  773. var self=this,$self=this;
  774. return $self.object;
  775. }; }),
  776. $globals.NonBooleanReceiver);
  777. $core.addMethod(
  778. $core.method({
  779. selector: "object:",
  780. protocol: "accessing",
  781. //>>excludeStart("ide", pragmas.excludeIdeData);
  782. args: ["anObject"],
  783. source: "object: anObject\x0a\x09object := anObject",
  784. referencedClasses: [],
  785. //>>excludeEnd("ide");
  786. pragmas: [],
  787. messageSends: []
  788. }, function ($methodClass){ return function (anObject){
  789. var self=this,$self=this;
  790. $self.object=anObject;
  791. return self;
  792. }; }),
  793. $globals.NonBooleanReceiver);
  794. $core.addMethod(
  795. $core.method({
  796. selector: "signalOn:",
  797. protocol: "instance creation",
  798. //>>excludeStart("ide", pragmas.excludeIdeData);
  799. args: ["anObject"],
  800. source: "signalOn: anObject\x0a\x09^ self new\x0a\x09\x09object: anObject;\x0a\x09\x09signal",
  801. referencedClasses: [],
  802. //>>excludeEnd("ide");
  803. pragmas: [],
  804. messageSends: ["object:", "new", "signal"]
  805. }, function ($methodClass){ return function (anObject){
  806. var self=this,$self=this;
  807. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  808. return $core.withContext(function($ctx1) {
  809. //>>excludeEnd("ctx");
  810. var $1;
  811. $1=$self._new();
  812. $recv($1)._object_(anObject);
  813. return $recv($1)._signal();
  814. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  815. }, function($ctx1) {$ctx1.fill(self,"signalOn:",{anObject:anObject})});
  816. //>>excludeEnd("ctx");
  817. }; }),
  818. $globals.NonBooleanReceiver.a$cls);
  819. $core.addClass("NonLifoReturn", $globals.Error, "Kernel-Exceptions");
  820. $core.setSlots($globals.NonLifoReturn, ["value"]);
  821. $core.addMethod(
  822. $core.method({
  823. selector: "messageText",
  824. protocol: "accessing",
  825. //>>excludeStart("ide", pragmas.excludeIdeData);
  826. args: [],
  827. source: "messageText\x0a\x09^ 'Non-LIFO return: ', self value asString",
  828. referencedClasses: [],
  829. //>>excludeEnd("ide");
  830. pragmas: [],
  831. messageSends: [",", "asString", "value"]
  832. }, function ($methodClass){ return function (){
  833. var self=this,$self=this;
  834. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  835. return $core.withContext(function($ctx1) {
  836. //>>excludeEnd("ctx");
  837. return "Non-LIFO return: ".__comma($recv($self._value())._asString());
  838. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  839. }, function($ctx1) {$ctx1.fill(self,"messageText",{})});
  840. //>>excludeEnd("ctx");
  841. }; }),
  842. $globals.NonLifoReturn);
  843. $core.addMethod(
  844. $core.method({
  845. selector: "value",
  846. protocol: "accessing",
  847. //>>excludeStart("ide", pragmas.excludeIdeData);
  848. args: [],
  849. source: "value\x0a\x09^ value",
  850. referencedClasses: [],
  851. //>>excludeEnd("ide");
  852. pragmas: [],
  853. messageSends: []
  854. }, function ($methodClass){ return function (){
  855. var self=this,$self=this;
  856. return $self.value;
  857. }; }),
  858. $globals.NonLifoReturn);
  859. $core.addMethod(
  860. $core.method({
  861. selector: "value:",
  862. protocol: "accessing",
  863. //>>excludeStart("ide", pragmas.excludeIdeData);
  864. args: ["anObject"],
  865. source: "value: anObject\x0a\x09value := anObject",
  866. referencedClasses: [],
  867. //>>excludeEnd("ide");
  868. pragmas: [],
  869. messageSends: []
  870. }, function ($methodClass){ return function (anObject){
  871. var self=this,$self=this;
  872. $self.value=anObject;
  873. return self;
  874. }; }),
  875. $globals.NonLifoReturn);
  876. $core.addMethod(
  877. $core.method({
  878. selector: "reifyIfFeasible:",
  879. protocol: "instance creation",
  880. //>>excludeStart("ide", pragmas.excludeIdeData);
  881. args: ["anObject"],
  882. source: "reifyIfFeasible: anObject\x0a\x09\x22If anObject represents non-local return, reify it as my instance.\x0a\x09Otherwise, return anObject as-is.\x22\x0a\x09<inlineJS: '\x0a\x09\x09return Array.isArray(anObject) && anObject.length === 1 ?\x0a\x09\x09\x09$self._value_(anObject[0]) : anObject\x0a\x09'>",
  883. referencedClasses: [],
  884. //>>excludeEnd("ide");
  885. pragmas: [["inlineJS:", ["\x0a\x09\x09return Array.isArray(anObject) && anObject.length === 1 ?\x0a\x09\x09\x09$self._value_(anObject[0]) : anObject\x0a\x09"]]],
  886. messageSends: []
  887. }, function ($methodClass){ return function (anObject){
  888. var self=this,$self=this;
  889. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  890. return $core.withContext(function($ctx1) {
  891. //>>excludeEnd("ctx");
  892. return Array.isArray(anObject) && anObject.length === 1 ?
  893. $self._value_(anObject[0]) : anObject
  894. ;
  895. return self;
  896. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  897. }, function($ctx1) {$ctx1.fill(self,"reifyIfFeasible:",{anObject:anObject})});
  898. //>>excludeEnd("ctx");
  899. }; }),
  900. $globals.NonLifoReturn.a$cls);
  901. $core.addMethod(
  902. $core.method({
  903. selector: "value:",
  904. protocol: "instance creation",
  905. //>>excludeStart("ide", pragmas.excludeIdeData);
  906. args: ["anObject"],
  907. source: "value: anObject\x0a\x09^ super new\x0a\x09\x09value: anObject;\x0a\x09\x09yourself",
  908. referencedClasses: [],
  909. //>>excludeEnd("ide");
  910. pragmas: [],
  911. messageSends: ["value:", "new", "yourself"]
  912. }, function ($methodClass){ return function (anObject){
  913. var self=this,$self=this;
  914. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  915. return $core.withContext(function($ctx1) {
  916. //>>excludeEnd("ctx");
  917. var $1;
  918. $1=[(
  919. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  920. $ctx1.supercall = true,
  921. //>>excludeEnd("ctx");
  922. ($methodClass.superclass||$boot.nilAsClass).fn.prototype._new.call($self))
  923. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  924. ,$ctx1.supercall = false
  925. //>>excludeEnd("ctx");
  926. ][0];
  927. $recv($1)._value_(anObject);
  928. return $recv($1)._yourself();
  929. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  930. }, function($ctx1) {$ctx1.fill(self,"value:",{anObject:anObject})});
  931. //>>excludeEnd("ctx");
  932. }; }),
  933. $globals.NonLifoReturn.a$cls);
  934. });