2
0

Helios-Environments.js 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176
  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. return smalltalk.withContext(function($ctx1) { var $1;
  12. $1=_st(self)._subclassResponsibility();
  13. return $1;
  14. }, function($ctx1) {$ctx1.fill(self,"eval:on:",{someCode:someCode,aReceiver:aReceiver}, smalltalk.HLEnvironment)})},
  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. return smalltalk.withContext(function($ctx1) { var $1;
  29. $1=_st(self)._subclassResponsibility();
  30. return $1;
  31. }, function($ctx1) {$ctx1.fill(self,"packages",{}, smalltalk.HLEnvironment)})},
  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 compiler;
  47. return smalltalk.withContext(function($ctx1) { var $1,$2;
  48. var $early={};
  49. try {
  50. compiler=_st((smalltalk.Compiler || Compiler))._new();
  51. _st((function(){
  52. return smalltalk.withContext(function($ctx2) { return _st(compiler)._parseExpression_(someCode);
  53. }, function($ctx2) {$ctx2.fillBlock({},$ctx1)})}))._on_do_((smalltalk.Error || Error),(function(ex){
  54. return smalltalk.withContext(function($ctx2) { $1=_st(window)._alert_(_st(ex)._messageText());
  55. throw $early=[$1];
  56. }, function($ctx2) {$ctx2.fillBlock({ex:ex},$ctx1)})}));
  57. $2=_st(_st(_st(compiler)._eval_(_st(compiler)._compile_forClass_(_st(_st("doIt ^[").__comma(someCode)).__comma("] value"),(smalltalk.DoIt || DoIt))))._fn())._applyTo_arguments_(aReceiver,[]);
  58. return $2;
  59. }
  60. catch(e) {if(e===$early)return e[0]; throw e}
  61. }, function($ctx1) {$ctx1.fill(self,"eval:on:",{someCode:someCode,aReceiver:aReceiver,compiler:compiler}, smalltalk.HLLocalEnvironment)})},
  62. args: ["someCode", "aReceiver"],
  63. 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: #()",
  64. messageSends: ["new", "on:do:", "alert:", "messageText", "parseExpression:", "applyTo:arguments:", "fn", "eval:", "compile:forClass:", ","],
  65. referencedClasses: ["Compiler", "Error", "DoIt"]
  66. }),
  67. smalltalk.HLLocalEnvironment);
  68. smalltalk.addMethod(
  69. "_packages",
  70. smalltalk.method({
  71. selector: "packages",
  72. category: 'accessing',
  73. fn: function (){
  74. var self=this;
  75. return smalltalk.withContext(function($ctx1) { var $1;
  76. $1=_st(_st((smalltalk.Smalltalk || Smalltalk))._current())._packages();
  77. return $1;
  78. }, function($ctx1) {$ctx1.fill(self,"packages",{}, smalltalk.HLLocalEnvironment)})},
  79. args: [],
  80. source: "packages\x0a\x0a\x09^ Smalltalk current packages",
  81. messageSends: ["packages", "current"],
  82. referencedClasses: ["Smalltalk"]
  83. }),
  84. smalltalk.HLLocalEnvironment);
  85. smalltalk.addClass('HLRemoteEnvironment', smalltalk.HLEnvironment, [], 'Helios-Environments');
  86. smalltalk.addMethod(
  87. "_eval_on_",
  88. smalltalk.method({
  89. selector: "eval:on:",
  90. category: 'actions',
  91. fn: function (someCode,aReceiver){
  92. var self=this;
  93. return smalltalk.withContext(function($ctx1) { _st(self)._notYetImplemented();
  94. return self}, function($ctx1) {$ctx1.fill(self,"eval:on:",{someCode:someCode,aReceiver:aReceiver}, smalltalk.HLRemoteEnvironment)})},
  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 smalltalk.withContext(function($ctx1) { return self}, function($ctx1) {$ctx1.fill(self,"packages",{}, smalltalk.HLRemoteEnvironment)})},
  109. args: [],
  110. 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",
  111. messageSends: [],
  112. referencedClasses: []
  113. }),
  114. smalltalk.HLRemoteEnvironment);
  115. smalltalk.addClass('HLRemoteObject', smalltalk.Object, [], 'Helios-Environments');
  116. 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"
  117. smalltalk.addMethod(
  118. "_doesNotUnderstand_",
  119. smalltalk.method({
  120. selector: "doesNotUnderstand:",
  121. category: 'actions',
  122. fn: function (aMessage){
  123. var self=this;
  124. return smalltalk.withContext(function($ctx1) { return self}, function($ctx1) {$ctx1.fill(self,"doesNotUnderstand:",{aMessage:aMessage}, smalltalk.HLRemoteObject)})},
  125. args: ["aMessage"],
  126. source: "doesNotUnderstand: aMessage\x0a\x0a\x09\x22to-do\x0a\x0a\x09aham, blah blah\x0a\x0a\x09super doesNotUnderstand: aMessage\x22",
  127. messageSends: [],
  128. referencedClasses: []
  129. }),
  130. smalltalk.HLRemoteObject);
  131. smalltalk.addMethod(
  132. "_inspectOn_",
  133. smalltalk.method({
  134. selector: "inspectOn:",
  135. category: 'actions',
  136. fn: function (anInspector){
  137. var self=this;
  138. return smalltalk.withContext(function($ctx1) { return self}, function($ctx1) {$ctx1.fill(self,"inspectOn:",{anInspector:anInspector}, smalltalk.HLRemoteObject)})},
  139. args: ["anInspector"],
  140. source: "inspectOn: anInspector\x0a\x0a\x09\x22to-do\x22\x0a\x0a\x09\x22this is a source of so much fun...\x22\x0a",
  141. messageSends: [],
  142. referencedClasses: []
  143. }),
  144. smalltalk.HLRemoteObject);
  145. smalltalk.addMethod(
  146. "_printString",
  147. smalltalk.method({
  148. selector: "printString",
  149. category: 'actions',
  150. fn: function (){
  151. var self=this;
  152. return smalltalk.withContext(function($ctx1) { return "this is a remote object";
  153. }, function($ctx1) {$ctx1.fill(self,"printString",{}, smalltalk.HLRemoteObject)})},
  154. args: [],
  155. source: "printString\x0a\x09^ 'this is a remote object'",
  156. messageSends: [],
  157. referencedClasses: []
  158. }),
  159. smalltalk.HLRemoteObject);