Helios-Environments.js 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179
  1. smalltalk.addPackage('Helios-Environments', {});
  2. smalltalk.addClass('HLEnvironment', smalltalk.Object, [], 'Helios-Environments');
  3. smalltalk.HLEnvironment.comment="Abstract class defining common behavior for local and remote environments"
  4. smalltalk.addMethod(
  5. "_eval_on_",
  6. smalltalk.method({
  7. selector: "eval:on:",
  8. category: 'actions',
  9. fn: function (someCode, aReceiver) {
  10. var self = this;
  11. var $1;
  12. $1 = smalltalk.send(self, "_subclassResponsibility", []);
  13. return $1;
  14. },
  15. args: ["someCode", "aReceiver"],
  16. source: "eval: someCode on: aReceiver\x0a\x0a\x09^ self subclassResponsibility",
  17. messageSends: ["subclassResponsibility"],
  18. referencedClasses: []
  19. }),
  20. smalltalk.HLEnvironment);
  21. smalltalk.addMethod(
  22. "_packages",
  23. smalltalk.method({
  24. selector: "packages",
  25. category: 'accessing',
  26. fn: function () {
  27. var self = this;
  28. var $1;
  29. $1 = smalltalk.send(self, "_subclassResponsibility", []);
  30. return $1;
  31. },
  32. args: [],
  33. source: "packages\x0a\x0a\x09^ self subclassResponsibility",
  34. messageSends: ["subclassResponsibility"],
  35. referencedClasses: []
  36. }),
  37. smalltalk.HLEnvironment);
  38. smalltalk.addClass('HLLocalEnvironment', smalltalk.HLEnvironment, [], 'Helios-Environments');
  39. smalltalk.addMethod(
  40. "_eval_on_",
  41. smalltalk.method({
  42. selector: "eval:on:",
  43. category: 'actions',
  44. fn: function (someCode, aReceiver) {
  45. var self = this;
  46. var $1, $2;
  47. var $early = {};
  48. try {
  49. var compiler;
  50. compiler = smalltalk.send(smalltalk.Compiler || Compiler, "_new", []);
  51. smalltalk.send(function () {return smalltalk.send(compiler, "_parseExpression_", [someCode]);}, "_on_do_", [smalltalk.Error || Error, function (ex) {$1 = smalltalk.send(window, "_alert_", [smalltalk.send(ex, "_messageText", [])]);throw $early = [$1];}]);
  52. $2 = smalltalk.send(smalltalk.send(smalltalk.send(compiler, "_eval_", [smalltalk.send(compiler, "_compile_forClass_", [smalltalk.send(smalltalk.send("doIt ^[", "__comma", [someCode]), "__comma", ["] value"]), smalltalk.DoIt || DoIt])]), "_fn", []), "_applyTo_arguments_", [aReceiver, []]);
  53. return $2;
  54. } catch (e) {
  55. if (e === $early) {
  56. return e[0];
  57. }
  58. throw e;
  59. }
  60. },
  61. args: ["someCode", "aReceiver"],
  62. source: "eval: someCode on: aReceiver\x0a\x09| compiler |\x0a\x09compiler := Compiler new.\x0a\x09[compiler parseExpression: someCode] on: Error do: [:ex |\x0a\x09\x09^window alert: ex messageText].\x0a\x09^(compiler eval: (compiler compile: 'doIt ^[', someCode, '] value' forClass: DoIt)) fn applyTo: aReceiver arguments: #()",
  63. messageSends: ["new", "on:do:", "alert:", "messageText", "parseExpression:", "applyTo:arguments:", "fn", "eval:", "compile:forClass:", ","],
  64. referencedClasses: ["Compiler", "Error", "DoIt"]
  65. }),
  66. smalltalk.HLLocalEnvironment);
  67. smalltalk.addMethod(
  68. "_packages",
  69. smalltalk.method({
  70. selector: "packages",
  71. category: 'accessing',
  72. fn: function () {
  73. var self = this;
  74. var $1;
  75. $1 = smalltalk.send(smalltalk.send(smalltalk.Smalltalk || Smalltalk, "_current", []), "_packages", []);
  76. return $1;
  77. },
  78. args: [],
  79. source: "packages\x0a\x0a\x09^ Smalltalk current packages",
  80. messageSends: ["packages", "current"],
  81. referencedClasses: ["Smalltalk"]
  82. }),
  83. smalltalk.HLLocalEnvironment);
  84. smalltalk.addClass('HLRemoteEnvironment', smalltalk.HLEnvironment, [], 'Helios-Environments');
  85. smalltalk.addMethod(
  86. "_eval_on_",
  87. smalltalk.method({
  88. selector: "eval:on:",
  89. category: 'actions',
  90. fn: function (someCode, aReceiver) {
  91. var self = this;
  92. smalltalk.send(self, "_notYetImplemented", []);
  93. return self;
  94. },
  95. args: ["someCode", "aReceiver"],
  96. source: "eval: someCode on: aReceiver\x0a\x0a\x09\x22Note for future self and friends:\x0a whatever way this compilation happens on the other side, \x0a it should return a proxy to the remote resulting object\x22\x0a \x0a self notYetImplemented",
  97. messageSends: ["notYetImplemented"],
  98. referencedClasses: []
  99. }),
  100. smalltalk.HLRemoteEnvironment);
  101. smalltalk.addMethod(
  102. "_packages",
  103. smalltalk.method({
  104. selector: "packages",
  105. category: 'accessing',
  106. fn: function () {
  107. var self = this;
  108. return self;
  109. },
  110. args: [],
  111. source: "packages\x0a\x09\x22Answer the remote environment's packages\x22\x0a \x0a\x09\x22to-do\x22\x0a \x0a \x22Note for future self and friends:\x0a the problem with remote stuff is that the answers shouldn't be expected to be\x0a received in a syncrhonous fashion. Everything network is asyc, so you *are going to deal with callbacks* here\x22",
  112. messageSends: [],
  113. referencedClasses: []
  114. }),
  115. smalltalk.HLRemoteEnvironment);
  116. smalltalk.addClass('HLRemoteObject', smalltalk.Object, [], 'Helios-Environments');
  117. smalltalk.HLRemoteObject.comment="This is a local proxy to a remote object.\x0aTipically useful for evaluating and inspecting and interacting with instances of a remote VM.\x0a"
  118. smalltalk.addMethod(
  119. "_doesNotUnderstand_",
  120. smalltalk.method({
  121. selector: "doesNotUnderstand:",
  122. category: 'actions',
  123. fn: function (aMessage) {
  124. var self = this;
  125. return self;
  126. },
  127. args: ["aMessage"],
  128. source: "doesNotUnderstand: aMessage\x0a\x0a\x09\x22to-do\x0a\x0a\x09aham, blah blah\x0a\x0a\x09super doesNotUnderstand: aMessage\x22",
  129. messageSends: [],
  130. referencedClasses: []
  131. }),
  132. smalltalk.HLRemoteObject);
  133. smalltalk.addMethod(
  134. "_inspectOn_",
  135. smalltalk.method({
  136. selector: "inspectOn:",
  137. category: 'actions',
  138. fn: function (anInspector) {
  139. var self = this;
  140. return self;
  141. },
  142. args: ["anInspector"],
  143. source: "inspectOn: anInspector\x0a\x0a\x09\x22to-do\x22\x0a\x0a\x09\x22this is a source of so much fun...\x22\x0a",
  144. messageSends: [],
  145. referencedClasses: []
  146. }),
  147. smalltalk.HLRemoteObject);
  148. smalltalk.addMethod(
  149. "_printString",
  150. smalltalk.method({
  151. selector: "printString",
  152. category: 'actions',
  153. fn: function () {
  154. var self = this;
  155. return "this is a remote object";
  156. },
  157. args: [],
  158. source: "printString\x0a\x09^ 'this is a remote object'",
  159. messageSends: [],
  160. referencedClasses: []
  161. }),
  162. smalltalk.HLRemoteObject);