REPL.js 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  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 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 smalltalk.send(smalltalk.send((typeof process == 'undefined' ? nil : process), "_stdout", []), "_write_", [smalltalk.send(e, "_jsStack", [])]);})]);})]));
  76. smalltalk.send(self, "_setPrompt", []);
  77. smalltalk.send(self['@interface'], "_prompt", []);
  78. return self;},
  79. args: ["buffer"],
  80. 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%09process%20stdout%20write%3A%20e%20jsStack%5D%5D.%0A%09self%20setPrompt.%0A%09interface%20prompt'),
  81. messageSends: ["ifFalse:", "isEmpty", "try:catch:", "loadExpression:", "new", "show:", "write:", "stdout", "jsStack", "setPrompt", "prompt"],
  82. referencedClasses: ["Compiler", "Transcript"]
  83. }),
  84. smalltalk.Repl);
  85. smalltalk.addMethod(
  86. unescape('_initialize'),
  87. smalltalk.method({
  88. selector: unescape('initialize'),
  89. category: 'initialization',
  90. fn: function (){
  91. var self=this;
  92. smalltalk.send(self, "_initialize", [], smalltalk.Object);
  93. self['@readline']=smalltalk.send((typeof require == 'undefined' ? nil : require), "_value_", ["readline"]);
  94. self['@util']=smalltalk.send((typeof require == 'undefined' ? nil : require), "_value_", ["util"]);
  95. return self;},
  96. args: [],
  97. 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'),
  98. messageSends: ["initialize", "value:"],
  99. referencedClasses: []
  100. }),
  101. smalltalk.Repl);
  102. smalltalk.addMethod(
  103. unescape('_main'),
  104. smalltalk.method({
  105. selector: unescape('main'),
  106. category: 'not yet classified',
  107. fn: function (){
  108. var self=this;
  109. smalltalk.send(smalltalk.send(self, "_new", []), "_createInterface", []);
  110. return self;},
  111. args: [],
  112. source: unescape('main%0A%09self%20new%20createInterface'),
  113. messageSends: ["createInterface", "new"],
  114. referencedClasses: []
  115. }),
  116. smalltalk.Repl.klass);