2
0

Kernel-Exceptions.js 12 KB

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