2
0

REPL.js 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  1. smalltalk.addPackage('REPL', {});
  2. smalltalk.addClass('Repl', smalltalk.Object, ['readline', 'interface', 'util'], 'REPL');
  3. smalltalk.addMethod(
  4. unescape('_prompt'),
  5. smalltalk.method({
  6. selector: unescape('prompt'),
  7. category: 'accessing',
  8. fn: function (){
  9. var self=this;
  10. return unescape("amber%20%3E%3E%20");
  11. return self;},
  12. args: [],
  13. source: unescape('prompt%0A%09%5E%27amber%20%3E%3E%20%27'),
  14. messageSends: [],
  15. referencedClasses: []
  16. }),
  17. smalltalk.Repl);
  18. smalltalk.addMethod(
  19. unescape('_createInterface'),
  20. smalltalk.method({
  21. selector: unescape('createInterface'),
  22. category: 'actions',
  23. fn: function (){
  24. var self=this;
  25. (self['@interface']=smalltalk.send(self['@readline'], "_createInterface_stdout_", [smalltalk.send((typeof process == 'undefined' ? nil : process), "_stdin", []), smalltalk.send((typeof process == 'undefined' ? nil : process), "_stdout", [])]));
  26. smalltalk.send(self['@interface'], "_on_do_", ["line", (function(buffer){return smalltalk.send(self, "_eval_", [buffer]);})]);
  27. smalltalk.send(self['@interface'], "_on_do_", ["close", (function(){return smalltalk.send(self, "_close", []);})]);
  28. smalltalk.send(self, "_setPrompt", []);
  29. smalltalk.send(self['@interface'], "_prompt", []);
  30. return self;},
  31. args: [],
  32. source: unescape('createInterface%0A%09%22No%20completion%20for%20now%22%0A%09interface%20%3A%3D%20readline%20createInterface%3A%20process%20stdin%20stdout%3A%20process%20stdout.%0A%09interface%20on%3A%20%27line%27%20do%3A%20%5B%3Abuffer%20%20%7C%20self%20eval%3A%20buffer%5D.%0A%09interface%20on%3A%20%27close%27%20do%3A%20%5Bself%20close%5D.%0A%09self%20setPrompt.%0A%09interface%20prompt'),
  33. messageSends: ["createInterface:stdout:", "stdin", "stdout", "on:do:", "eval:", "close", "setPrompt", "prompt"],
  34. referencedClasses: []
  35. }),
  36. smalltalk.Repl);
  37. smalltalk.addMethod(
  38. unescape('_setPrompt'),
  39. smalltalk.method({
  40. selector: unescape('setPrompt'),
  41. category: 'actions',
  42. fn: function (){
  43. var self=this;
  44. smalltalk.send(self['@interface'], "_setPrompt_", [smalltalk.send(self, "_prompt", [])]);
  45. return self;},
  46. args: [],
  47. source: unescape('setPrompt%0A%09interface%20setPrompt%3A%20self%20prompt'),
  48. messageSends: ["setPrompt:", "prompt"],
  49. referencedClasses: []
  50. }),
  51. smalltalk.Repl);
  52. smalltalk.addMethod(
  53. unescape('_close'),
  54. smalltalk.method({
  55. selector: unescape('close'),
  56. category: 'actions',
  57. fn: function (){
  58. var self=this;
  59. smalltalk.send(smalltalk.send((typeof process == 'undefined' ? nil : process), "_stdin", []), "_destroy", []);
  60. return self;},
  61. args: [],
  62. source: unescape('close%0A%09process%20stdin%20destroy'),
  63. messageSends: ["destroy", "stdin"],
  64. referencedClasses: []
  65. }),
  66. smalltalk.Repl);
  67. smalltalk.addMethod(
  68. unescape('_eval_'),
  69. smalltalk.method({
  70. selector: unescape('eval%3A'),
  71. category: 'actions',
  72. fn: function (buffer){
  73. var self=this;
  74. var result=nil;
  75. ((($receiver = smalltalk.send(buffer, "_isEmpty", [])).klass === smalltalk.Boolean) ? (! $receiver ? (function(){return smalltalk.send(self, "_try_catch_", [(function(){(result=smalltalk.send(smalltalk.send((smalltalk.Compiler || Compiler), "_new", []), "_loadExpression_", [buffer]));return smalltalk.send((smalltalk.Transcript || Transcript), "_show_", [result]);}), (function(e){return ((($receiver = smalltalk.send(e, "_isSmalltalkError", [])).klass === smalltalk.Boolean) ? ($receiver ? (function(){return smalltalk.send(smalltalk.send((smalltalk.ErrorHandler || ErrorHandler), "_new", []), "_handleError_", [e]);})() : (function(){return smalltalk.send(smalltalk.send((typeof process == 'undefined' ? nil : process), "_stdout", []), "_write_", [smalltalk.send(e, "_jsStack", [])]);})()) : smalltalk.send($receiver, "_ifTrue_ifFalse_", [(function(){return smalltalk.send(smalltalk.send((smalltalk.ErrorHandler || ErrorHandler), "_new", []), "_handleError_", [e]);}), (function(){return smalltalk.send(smalltalk.send((typeof process == 'undefined' ? nil : process), "_stdout", []), "_write_", [smalltalk.send(e, "_jsStack", [])]);})]));})]);})() : nil) : smalltalk.send($receiver, "_ifFalse_", [(function(){return smalltalk.send(self, "_try_catch_", [(function(){(result=smalltalk.send(smalltalk.send((smalltalk.Compiler || Compiler), "_new", []), "_loadExpression_", [buffer]));return smalltalk.send((smalltalk.Transcript || Transcript), "_show_", [result]);}), (function(e){return ((($receiver = smalltalk.send(e, "_isSmalltalkError", [])).klass === smalltalk.Boolean) ? ($receiver ? (function(){return smalltalk.send(smalltalk.send((smalltalk.ErrorHandler || ErrorHandler), "_new", []), "_handleError_", [e]);})() : (function(){return smalltalk.send(smalltalk.send((typeof process == 'undefined' ? nil : process), "_stdout", []), "_write_", [smalltalk.send(e, "_jsStack", [])]);})()) : smalltalk.send($receiver, "_ifTrue_ifFalse_", [(function(){return smalltalk.send(smalltalk.send((smalltalk.ErrorHandler || ErrorHandler), "_new", []), "_handleError_", [e]);}), (function(){return smalltalk.send(smalltalk.send((typeof process == 'undefined' ? nil : process), "_stdout", []), "_write_", [smalltalk.send(e, "_jsStack", [])]);})]));})]);})]));
  76. smalltalk.send(self['@interface'], "_prompt", []);
  77. return self;},
  78. args: ["buffer"],
  79. source: unescape('eval%3A%20buffer%0A%09%7C%20result%20%7C%0A%09buffer%20isEmpty%20ifFalse%3A%20%5B%0A%09%09self%20try%3A%20%5B%0A%09%09%09result%20%3A%3D%20Compiler%20new%20loadExpression%3A%20buffer.%0A%09%09%09Transcript%20show%3A%20result%5D%0A%09%09catch%3A%20%5B%3Ae%20%7C%0A%09%09%09e%20isSmalltalkError%0A%09%09%09%20%20%20%20ifTrue%3A%20%5BErrorHandler%20new%20handleError%3A%20e%5D%0A%09%09%09%20%20%20%20ifFalse%3A%20%5Bprocess%20stdout%20write%3A%20e%20jsStack%5D%5D%5D.%0A%09interface%20prompt'),
  80. messageSends: ["ifFalse:", "isEmpty", "try:catch:", "loadExpression:", "new", "show:", "ifTrue:ifFalse:", "isSmalltalkError", "handleError:", "write:", "stdout", "jsStack", "prompt"],
  81. referencedClasses: ["Compiler", "Transcript", "ErrorHandler"]
  82. }),
  83. smalltalk.Repl);
  84. smalltalk.addMethod(
  85. unescape('_initialize'),
  86. smalltalk.method({
  87. selector: unescape('initialize'),
  88. category: 'initialization',
  89. fn: function (){
  90. var self=this;
  91. smalltalk.send(self, "_initialize", [], smalltalk.Object);
  92. (self['@readline']=smalltalk.send((typeof require == 'undefined' ? nil : require), "_value_", ["readline"]));
  93. (self['@util']=smalltalk.send((typeof require == 'undefined' ? nil : require), "_value_", ["util"]));
  94. return self;},
  95. args: [],
  96. source: unescape('initialize%0A%09super%20initialize.%0A%09readline%20%3A%3D%20require%20value%3A%20%27readline%27.%0A%09util%20%3A%3D%20require%20value%3A%20%27util%27'),
  97. messageSends: ["initialize", "value:"],
  98. referencedClasses: []
  99. }),
  100. smalltalk.Repl);
  101. smalltalk.addMethod(
  102. unescape('_main'),
  103. smalltalk.method({
  104. selector: unescape('main'),
  105. category: 'not yet classified',
  106. fn: function (){
  107. var self=this;
  108. smalltalk.send(smalltalk.send(self, "_new", []), "_createInterface", []);
  109. return self;},
  110. args: [],
  111. source: unescape('main%0A%09self%20new%20createInterface'),
  112. messageSends: ["createInterface", "new"],
  113. referencedClasses: []
  114. }),
  115. smalltalk.Repl.klass);