Kernel-Exceptions.js 24 KB

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