Kernel-Exceptions.js 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431
  1. define("amber_core/Kernel-Exceptions", ["amber_vm/smalltalk", "amber_vm/nil", "amber_vm/_st", "amber_core/Kernel-Objects"], function(smalltalk,nil,_st){
  2. smalltalk.addPackage('Kernel-Exceptions');
  3. smalltalk.packages["Kernel-Exceptions"].transport = {"type":"amd","amdNamespace":"amber_core"};
  4. smalltalk.addClass('Error', smalltalk.Object, ['messageText'], 'Kernel-Exceptions');
  5. smalltalk.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.";
  6. smalltalk.addMethod(
  7. smalltalk.method({
  8. selector: "context",
  9. protocol: 'accessing',
  10. fn: function (){
  11. var self=this;
  12. return self.context;
  13. return self},
  14. args: [],
  15. source: "context\x0a\x09<return self.context>",
  16. messageSends: [],
  17. referencedClasses: []
  18. }),
  19. smalltalk.Error);
  20. smalltalk.addMethod(
  21. smalltalk.method({
  22. selector: "initialize",
  23. protocol: 'initialization',
  24. fn: function (){
  25. var self=this;
  26. return smalltalk.withContext(function($ctx1) {
  27. self._messageText_("Errorclass: ".__comma(_st(self._class())._name()));
  28. return self}, function($ctx1) {$ctx1.fill(self,"initialize",{},smalltalk.Error)})},
  29. args: [],
  30. source: "initialize\x0a\x09self messageText: 'Errorclass: ', (self class name).",
  31. messageSends: ["messageText:", ",", "name", "class"],
  32. referencedClasses: []
  33. }),
  34. smalltalk.Error);
  35. smalltalk.addMethod(
  36. smalltalk.method({
  37. selector: "isSmalltalkError",
  38. protocol: 'testing',
  39. fn: function (){
  40. var self=this;
  41. return self.smalltalkError === true;
  42. return self},
  43. args: [],
  44. source: "isSmalltalkError\x0a\x09<return self.smalltalkError === true>",
  45. messageSends: [],
  46. referencedClasses: []
  47. }),
  48. smalltalk.Error);
  49. smalltalk.addMethod(
  50. smalltalk.method({
  51. selector: "jsStack",
  52. protocol: 'accessing',
  53. fn: function (){
  54. var self=this;
  55. return self.stack;
  56. return self},
  57. args: [],
  58. source: "jsStack\x0a\x09<return self.stack>",
  59. messageSends: [],
  60. referencedClasses: []
  61. }),
  62. smalltalk.Error);
  63. smalltalk.addMethod(
  64. smalltalk.method({
  65. selector: "messageText",
  66. protocol: 'accessing',
  67. fn: function (){
  68. var self=this;
  69. var $1;
  70. $1=self["@messageText"];
  71. return $1;
  72. },
  73. args: [],
  74. source: "messageText\x0a\x09^ messageText",
  75. messageSends: [],
  76. referencedClasses: []
  77. }),
  78. smalltalk.Error);
  79. smalltalk.addMethod(
  80. smalltalk.method({
  81. selector: "messageText:",
  82. protocol: 'accessing',
  83. fn: function (aString){
  84. var self=this;
  85. self["@messageText"]=aString;
  86. return self},
  87. args: ["aString"],
  88. source: "messageText: aString\x0a\x09messageText := aString",
  89. messageSends: [],
  90. referencedClasses: []
  91. }),
  92. smalltalk.Error);
  93. smalltalk.addMethod(
  94. smalltalk.method({
  95. selector: "resignal",
  96. protocol: 'signaling',
  97. fn: function (){
  98. var self=this;
  99. throw(self);
  100. return self},
  101. args: [],
  102. source: "resignal\x0a\x09\x22Resignal the receiver without changing its exception context\x22\x0a\x09\x0a\x09<throw(self)>",
  103. messageSends: [],
  104. referencedClasses: []
  105. }),
  106. smalltalk.Error);
  107. smalltalk.addMethod(
  108. smalltalk.method({
  109. selector: "signal",
  110. protocol: 'signaling',
  111. fn: function (){
  112. var self=this;
  113. self.context = smalltalk.getThisContext(); self.smalltalkError = true; throw(self);
  114. return self},
  115. args: [],
  116. source: "signal\x0a\x09<self.context = smalltalk.getThisContext(); self.smalltalkError = true; throw(self)>",
  117. messageSends: [],
  118. referencedClasses: []
  119. }),
  120. smalltalk.Error);
  121. smalltalk.addMethod(
  122. smalltalk.method({
  123. selector: "signal:",
  124. protocol: 'signaling',
  125. fn: function (aString){
  126. var self=this;
  127. return smalltalk.withContext(function($ctx1) {
  128. self._messageText_(aString);
  129. self._signal();
  130. return self}, function($ctx1) {$ctx1.fill(self,"signal:",{aString:aString},smalltalk.Error)})},
  131. args: ["aString"],
  132. source: "signal: aString\x0a\x09self messageText: aString.\x0a\x09self signal",
  133. messageSends: ["messageText:", "signal"],
  134. referencedClasses: []
  135. }),
  136. smalltalk.Error);
  137. smalltalk.addMethod(
  138. smalltalk.method({
  139. selector: "heliosClass",
  140. protocol: 'helios',
  141. fn: function (){
  142. var self=this;
  143. return "exception";
  144. },
  145. args: [],
  146. source: "heliosClass\x0a\x09^ 'exception'",
  147. messageSends: [],
  148. referencedClasses: []
  149. }),
  150. smalltalk.Error.klass);
  151. smalltalk.addMethod(
  152. smalltalk.method({
  153. selector: "signal",
  154. protocol: 'instance creation',
  155. fn: function (){
  156. var self=this;
  157. return smalltalk.withContext(function($ctx1) {
  158. var $1;
  159. $1=_st(self._new())._signal();
  160. return $1;
  161. }, function($ctx1) {$ctx1.fill(self,"signal",{},smalltalk.Error.klass)})},
  162. args: [],
  163. source: "signal\x0a\x09^ self new signal",
  164. messageSends: ["signal", "new"],
  165. referencedClasses: []
  166. }),
  167. smalltalk.Error.klass);
  168. smalltalk.addMethod(
  169. smalltalk.method({
  170. selector: "signal:",
  171. protocol: 'instance creation',
  172. fn: function (aString){
  173. var self=this;
  174. return smalltalk.withContext(function($ctx1) {
  175. var $1;
  176. $1=_st(self._new())._signal_(aString);
  177. return $1;
  178. }, function($ctx1) {$ctx1.fill(self,"signal:",{aString:aString},smalltalk.Error.klass)})},
  179. args: ["aString"],
  180. source: "signal: aString\x0a\x09^ self new\x0a\x09\x09signal: aString",
  181. messageSends: ["signal:", "new"],
  182. referencedClasses: []
  183. }),
  184. smalltalk.Error.klass);
  185. smalltalk.addClass('JavaScriptException', smalltalk.Error, ['exception'], 'Kernel-Exceptions');
  186. smalltalk.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:`";
  187. smalltalk.addMethod(
  188. smalltalk.method({
  189. selector: "context:",
  190. protocol: 'accessing',
  191. fn: function (aMethodContext){
  192. var self=this;
  193. self.context = aMethodContext;
  194. return self},
  195. args: ["aMethodContext"],
  196. 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>",
  197. messageSends: [],
  198. referencedClasses: []
  199. }),
  200. smalltalk.JavaScriptException);
  201. smalltalk.addMethod(
  202. smalltalk.method({
  203. selector: "exception",
  204. protocol: 'accessing',
  205. fn: function (){
  206. var self=this;
  207. var $1;
  208. $1=self["@exception"];
  209. return $1;
  210. },
  211. args: [],
  212. source: "exception\x0a\x09^ exception",
  213. messageSends: [],
  214. referencedClasses: []
  215. }),
  216. smalltalk.JavaScriptException);
  217. smalltalk.addMethod(
  218. smalltalk.method({
  219. selector: "exception:",
  220. protocol: 'accessing',
  221. fn: function (anException){
  222. var self=this;
  223. self["@exception"]=anException;
  224. return self},
  225. args: ["anException"],
  226. source: "exception: anException\x0a\x09exception := anException",
  227. messageSends: [],
  228. referencedClasses: []
  229. }),
  230. smalltalk.JavaScriptException);
  231. smalltalk.addMethod(
  232. smalltalk.method({
  233. selector: "messageText",
  234. protocol: 'accessing',
  235. fn: function (){
  236. var self=this;
  237. return 'JavaScript exception: ' + self["@exception"].toString();
  238. return self},
  239. args: [],
  240. source: "messageText\x0a\x09<return 'JavaScript exception: ' + self[\x22@exception\x22].toString()>",
  241. messageSends: [],
  242. referencedClasses: []
  243. }),
  244. smalltalk.JavaScriptException);
  245. smalltalk.addMethod(
  246. smalltalk.method({
  247. selector: "on:",
  248. protocol: 'instance creation',
  249. fn: function (anException){
  250. var self=this;
  251. return smalltalk.withContext(function($ctx1) {
  252. var $2,$3,$1;
  253. $2=self._new();
  254. _st($2)._exception_(anException);
  255. $3=_st($2)._yourself();
  256. $1=$3;
  257. return $1;
  258. }, function($ctx1) {$ctx1.fill(self,"on:",{anException:anException},smalltalk.JavaScriptException.klass)})},
  259. args: ["anException"],
  260. source: "on: anException\x0a\x09^ self new\x0a\x09\x09exception: anException;\x0a\x09\x09yourself",
  261. messageSends: ["exception:", "new", "yourself"],
  262. referencedClasses: []
  263. }),
  264. smalltalk.JavaScriptException.klass);
  265. smalltalk.addMethod(
  266. smalltalk.method({
  267. selector: "on:context:",
  268. protocol: 'instance creation',
  269. fn: function (anException,aMethodContext){
  270. var self=this;
  271. return smalltalk.withContext(function($ctx1) {
  272. var $2,$3,$1;
  273. $2=self._new();
  274. _st($2)._exception_(anException);
  275. _st($2)._context_(aMethodContext);
  276. $3=_st($2)._yourself();
  277. $1=$3;
  278. return $1;
  279. }, function($ctx1) {$ctx1.fill(self,"on:context:",{anException:anException,aMethodContext:aMethodContext},smalltalk.JavaScriptException.klass)})},
  280. args: ["anException", "aMethodContext"],
  281. source: "on: anException context: aMethodContext\x0a\x09^ self new\x0a\x09\x09exception: anException;\x0a\x09\x09context: aMethodContext;\x0a\x09\x09yourself",
  282. messageSends: ["exception:", "new", "context:", "yourself"],
  283. referencedClasses: []
  284. }),
  285. smalltalk.JavaScriptException.klass);
  286. smalltalk.addClass('MessageNotUnderstood', smalltalk.Error, ['message', 'receiver'], 'Kernel-Exceptions');
  287. smalltalk.MessageNotUnderstood.comment="This exception is provided to support `Object>>doesNotUnderstand:`.";
  288. smalltalk.addMethod(
  289. smalltalk.method({
  290. selector: "message",
  291. protocol: 'accessing',
  292. fn: function (){
  293. var self=this;
  294. var $1;
  295. $1=self["@message"];
  296. return $1;
  297. },
  298. args: [],
  299. source: "message\x0a\x09^ message",
  300. messageSends: [],
  301. referencedClasses: []
  302. }),
  303. smalltalk.MessageNotUnderstood);
  304. smalltalk.addMethod(
  305. smalltalk.method({
  306. selector: "message:",
  307. protocol: 'accessing',
  308. fn: function (aMessage){
  309. var self=this;
  310. self["@message"]=aMessage;
  311. return self},
  312. args: ["aMessage"],
  313. source: "message: aMessage\x0a\x09message := aMessage",
  314. messageSends: [],
  315. referencedClasses: []
  316. }),
  317. smalltalk.MessageNotUnderstood);
  318. smalltalk.addMethod(
  319. smalltalk.method({
  320. selector: "messageText",
  321. protocol: 'accessing',
  322. fn: function (){
  323. var self=this;
  324. return smalltalk.withContext(function($ctx1) {
  325. var $1;
  326. $1=_st(_st(_st(self._receiver())._asString()).__comma(" does not understand #")).__comma(_st(self._message())._selector());
  327. $ctx1.sendIdx[","]=1;
  328. return $1;
  329. }, function($ctx1) {$ctx1.fill(self,"messageText",{},smalltalk.MessageNotUnderstood)})},
  330. args: [],
  331. source: "messageText\x0a\x09^ self receiver asString, ' does not understand #', self message selector",
  332. messageSends: [",", "asString", "receiver", "selector", "message"],
  333. referencedClasses: []
  334. }),
  335. smalltalk.MessageNotUnderstood);
  336. smalltalk.addMethod(
  337. smalltalk.method({
  338. selector: "receiver",
  339. protocol: 'accessing',
  340. fn: function (){
  341. var self=this;
  342. var $1;
  343. $1=self["@receiver"];
  344. return $1;
  345. },
  346. args: [],
  347. source: "receiver\x0a\x09^ receiver",
  348. messageSends: [],
  349. referencedClasses: []
  350. }),
  351. smalltalk.MessageNotUnderstood);
  352. smalltalk.addMethod(
  353. smalltalk.method({
  354. selector: "receiver:",
  355. protocol: 'accessing',
  356. fn: function (anObject){
  357. var self=this;
  358. self["@receiver"]=anObject;
  359. return self},
  360. args: ["anObject"],
  361. source: "receiver: anObject\x0a\x09receiver := anObject",
  362. messageSends: [],
  363. referencedClasses: []
  364. }),
  365. smalltalk.MessageNotUnderstood);
  366. smalltalk.addClass('NonBooleanReceiver', smalltalk.Error, ['object'], 'Kernel-Exceptions');
  367. smalltalk.NonBooleanReceiver.comment="NonBooleanReceiver exceptions may be thrown when executing inlined methods such as `#ifTrue:` with a non boolean receiver.";
  368. smalltalk.addMethod(
  369. smalltalk.method({
  370. selector: "object",
  371. protocol: 'accessing',
  372. fn: function (){
  373. var self=this;
  374. var $1;
  375. $1=self["@object"];
  376. return $1;
  377. },
  378. args: [],
  379. source: "object\x0a\x09^ object",
  380. messageSends: [],
  381. referencedClasses: []
  382. }),
  383. smalltalk.NonBooleanReceiver);
  384. smalltalk.addMethod(
  385. smalltalk.method({
  386. selector: "object:",
  387. protocol: 'accessing',
  388. fn: function (anObject){
  389. var self=this;
  390. self["@object"]=anObject;
  391. return self},
  392. args: ["anObject"],
  393. source: "object: anObject\x0a\x09object := anObject",
  394. messageSends: [],
  395. referencedClasses: []
  396. }),
  397. smalltalk.NonBooleanReceiver);
  398. });