Helios-Environments.js 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395
  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. "_addInstVarNamed_to_",
  6. smalltalk.method({
  7. selector: "addInstVarNamed:to:",
  8. category: 'compiling',
  9. fn: function (aString,aClass){
  10. var self=this;
  11. return smalltalk.withContext(function($ctx1) { var $1,$2;
  12. $1=_st(_st(aClass)._instanceVariableNames())._copy();
  13. _st($1)._add_(aString);
  14. $2=_st($1)._yourself();
  15. _st(_st(self)._classBuilder())._addSubclassOf_named_instanceVariableNames_package_(_st(aClass)._superclass(),_st(aClass)._name(),$2,_st(_st(aClass)._package())._name());
  16. return self}, function($ctx1) {$ctx1.fill(self,"addInstVarNamed:to:",{aString:aString,aClass:aClass}, smalltalk.HLEnvironment)})},
  17. args: ["aString", "aClass"],
  18. source: "addInstVarNamed: aString to: aClass\x0a\x09self classBuilder\x0a\x09\x09addSubclassOf: aClass superclass \x0a\x09\x09named: aClass name \x0a\x09\x09instanceVariableNames: (aClass instanceVariableNames copy add: aString; yourself)\x0a\x09\x09package: aClass package name",
  19. messageSends: ["addSubclassOf:named:instanceVariableNames:package:", "superclass", "name", "add:", "copy", "instanceVariableNames", "yourself", "package", "classBuilder"],
  20. referencedClasses: []
  21. }),
  22. smalltalk.HLEnvironment);
  23. smalltalk.addMethod(
  24. "_availableClassNames",
  25. smalltalk.method({
  26. selector: "availableClassNames",
  27. category: 'accessing',
  28. fn: function (){
  29. var self=this;
  30. return smalltalk.withContext(function($ctx1) { _st(self)._subclassResponsibility();
  31. return self}, function($ctx1) {$ctx1.fill(self,"availableClassNames",{},smalltalk.HLEnvironment)})},
  32. args: [],
  33. source: "availableClassNames\x0a\x09self subclassResponsibility",
  34. messageSends: ["subclassResponsibility"],
  35. referencedClasses: []
  36. }),
  37. smalltalk.HLEnvironment);
  38. smalltalk.addMethod(
  39. "_classBuilder",
  40. smalltalk.method({
  41. selector: "classBuilder",
  42. category: 'accessing',
  43. fn: function (){
  44. var self=this;
  45. return smalltalk.withContext(function($ctx1) { var $1;
  46. $1=_st(self)._subclassResponsibility();
  47. return $1;
  48. }, function($ctx1) {$ctx1.fill(self,"classBuilder",{}, smalltalk.HLEnvironment)})},
  49. args: [],
  50. source: "classBuilder\x0a\x09^ self subclassResponsibility",
  51. messageSends: ["subclassResponsibility"],
  52. referencedClasses: []
  53. }),
  54. smalltalk.HLEnvironment);
  55. smalltalk.addMethod(
  56. "_compileClassComment_for_",
  57. smalltalk.method({
  58. selector: "compileClassComment:for:",
  59. category: 'compiling',
  60. fn: function (aString,aClass){
  61. var self=this;
  62. return smalltalk.withContext(function($ctx1) { _st(aClass)._comment_(aString);
  63. return self}, function($ctx1) {$ctx1.fill(self,"compileClassComment:for:",{aString:aString,aClass:aClass}, smalltalk.HLEnvironment)})},
  64. args: ["aString", "aClass"],
  65. source: "compileClassComment: aString for: aClass\x0a\x09aClass comment: aString",
  66. messageSends: ["comment:"],
  67. referencedClasses: []
  68. }),
  69. smalltalk.HLEnvironment);
  70. smalltalk.addMethod(
  71. "_compileClassDefinition_",
  72. smalltalk.method({
  73. selector: "compileClassDefinition:",
  74. category: 'compiling',
  75. fn: function (aString){
  76. var self=this;
  77. return smalltalk.withContext(function($ctx1) { _st(self)._eval_on_(aString,_st((smalltalk.DoIt || DoIt))._new());
  78. return self}, function($ctx1) {$ctx1.fill(self,"compileClassDefinition:",{aString:aString}, smalltalk.HLEnvironment)})},
  79. args: ["aString"],
  80. source: "compileClassDefinition: aString\x0a\x09self eval: aString on: DoIt new",
  81. messageSends: ["eval:on:", "new"],
  82. referencedClasses: ["DoIt"]
  83. }),
  84. smalltalk.HLEnvironment);
  85. smalltalk.addMethod(
  86. "_compileMethod_for_protocol_",
  87. smalltalk.method({
  88. selector: "compileMethod:for:protocol:",
  89. category: 'compiling',
  90. fn: function (sourceCode,class_,protocol){
  91. var self=this;
  92. return smalltalk.withContext(function($ctx1) { _st(class_)._compile_category_(sourceCode,protocol);
  93. return self}, function($ctx1) {$ctx1.fill(self,"compileMethod:for:protocol:",{sourceCode:sourceCode,class_:class_,protocol:protocol}, smalltalk.HLEnvironment)})},
  94. args: ["sourceCode", "class", "protocol"],
  95. source: "compileMethod: sourceCode for: class protocol: protocol\x0a\x09class\x0a\x09\x09compile: sourceCode\x0a\x09\x09category: protocol",
  96. messageSends: ["compile:category:"],
  97. referencedClasses: []
  98. }),
  99. smalltalk.HLEnvironment);
  100. smalltalk.addMethod(
  101. "_eval_on_",
  102. smalltalk.method({
  103. selector: "eval:on:",
  104. category: 'actions',
  105. fn: function (someCode,aReceiver){
  106. var self=this;
  107. return smalltalk.withContext(function($ctx1) { var $1;
  108. $1=_st(self)._subclassResponsibility();
  109. return $1;
  110. }, function($ctx1) {$ctx1.fill(self,"eval:on:",{someCode:someCode,aReceiver:aReceiver}, smalltalk.HLEnvironment)})},
  111. args: ["someCode", "aReceiver"],
  112. source: "eval: someCode on: aReceiver\x0a\x0a\x09^ self subclassResponsibility",
  113. messageSends: ["subclassResponsibility"],
  114. referencedClasses: []
  115. }),
  116. smalltalk.HLEnvironment);
  117. smalltalk.addMethod(
  118. "_moveMethod_toClass_",
  119. smalltalk.method({
  120. selector: "moveMethod:toClass:",
  121. category: 'actions',
  122. fn: function (aMethod,aClassName){
  123. var self=this;
  124. return smalltalk.withContext(function($ctx1) { _st(self)._subclassResponsibility();
  125. return self}, function($ctx1) {$ctx1.fill(self,"moveMethod:toClass:",{aMethod:aMethod,aClassName:aClassName},smalltalk.HLEnvironment)})},
  126. args: ["aMethod", "aClassName"],
  127. source: "moveMethod: aMethod toClass: aClassName\x0a\x09self subclassResponsibility",
  128. messageSends: ["subclassResponsibility"],
  129. referencedClasses: []
  130. }),
  131. smalltalk.HLEnvironment);
  132. smalltalk.addMethod(
  133. "_packages",
  134. smalltalk.method({
  135. selector: "packages",
  136. category: 'accessing',
  137. fn: function (){
  138. var self=this;
  139. return smalltalk.withContext(function($ctx1) { var $1;
  140. $1=_st(self)._subclassResponsibility();
  141. return $1;
  142. }, function($ctx1) {$ctx1.fill(self,"packages",{}, smalltalk.HLEnvironment)})},
  143. args: [],
  144. source: "packages\x0a\x09^ self subclassResponsibility",
  145. messageSends: ["subclassResponsibility"],
  146. referencedClasses: []
  147. }),
  148. smalltalk.HLEnvironment);
  149. smalltalk.addClass('HLLocalEnvironment', smalltalk.HLEnvironment, [], 'Helios-Environments');
  150. smalltalk.addMethod(
  151. "_availableClassNames",
  152. smalltalk.method({
  153. selector: "availableClassNames",
  154. category: 'accessing',
  155. fn: function (){
  156. var self=this;
  157. return smalltalk.withContext(function($ctx1) { var $1;
  158. $1=_st(_st(_st((smalltalk.Smalltalk || Smalltalk))._current())._classes())._collect_((function(each){
  159. return smalltalk.withContext(function($ctx2) { return _st(each)._name();
  160. }, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1)})}));
  161. return $1;
  162. }, function($ctx1) {$ctx1.fill(self,"availableClassNames",{},smalltalk.HLLocalEnvironment)})},
  163. args: [],
  164. source: "availableClassNames\x0a\x09^ Smalltalk current classes \x0a\x09\x09collect: [ :each | each name ]",
  165. messageSends: ["collect:", "name", "classes", "current"],
  166. referencedClasses: ["Smalltalk"]
  167. }),
  168. smalltalk.HLLocalEnvironment);
  169. smalltalk.addMethod(
  170. "_classBuilder",
  171. smalltalk.method({
  172. selector: "classBuilder",
  173. category: 'accessing',
  174. fn: function (){
  175. var self=this;
  176. return smalltalk.withContext(function($ctx1) { var $1;
  177. $1=_st((smalltalk.ClassBuilder || ClassBuilder))._new();
  178. return $1;
  179. }, function($ctx1) {$ctx1.fill(self,"classBuilder",{}, smalltalk.HLLocalEnvironment)})},
  180. args: [],
  181. source: "classBuilder\x0a\x09^ ClassBuilder new",
  182. messageSends: ["new"],
  183. referencedClasses: ["ClassBuilder"]
  184. }),
  185. smalltalk.HLLocalEnvironment);
  186. smalltalk.addMethod(
  187. "_eval_on_",
  188. smalltalk.method({
  189. selector: "eval:on:",
  190. category: 'actions',
  191. fn: function (aString,aReceiver){
  192. var self=this;
  193. var compiler;
  194. return smalltalk.withContext(function($ctx1) { var $1,$2;
  195. var $early={};
  196. try {
  197. compiler=_st((smalltalk.Compiler || Compiler))._new();
  198. _st((function(){
  199. return smalltalk.withContext(function($ctx2) { return _st(compiler)._parseExpression_(aString);
  200. }, function($ctx2) {$ctx2.fillBlock({},$ctx1)})}))._on_do_((smalltalk.Error || Error),(function(ex){
  201. return smalltalk.withContext(function($ctx2) { $1=_st(window)._alert_(_st(ex)._messageText());
  202. throw $early=[$1];
  203. }, function($ctx2) {$ctx2.fillBlock({ex:ex},$ctx1)})}));
  204. $2=_st(compiler)._evaluateExpression_on_(aString,aReceiver);
  205. return $2;
  206. }
  207. catch(e) {if(e===$early)return e[0]; throw e}
  208. }, function($ctx1) {$ctx1.fill(self,"eval:on:",{aString:aString,aReceiver:aReceiver,compiler:compiler}, smalltalk.HLLocalEnvironment)})},
  209. args: ["aString", "aReceiver"],
  210. source: "eval: aString on: aReceiver\x0a\x09| compiler |\x0a\x09compiler := Compiler new.\x0a\x09[ compiler parseExpression: aString ] on: Error do: [ :ex |\x0a\x09\x09^ window alert: ex messageText ].\x0a\x09^ compiler evaluateExpression: aString on: aReceiver",
  211. messageSends: ["new", "on:do:", "alert:", "messageText", "parseExpression:", "evaluateExpression:on:"],
  212. referencedClasses: ["Compiler", "Error"]
  213. }),
  214. smalltalk.HLLocalEnvironment);
  215. smalltalk.addMethod(
  216. "_moveMethod_toClass_",
  217. smalltalk.method({
  218. selector: "moveMethod:toClass:",
  219. category: 'actions',
  220. fn: function (aMethod,aClassName){
  221. var self=this;
  222. var destinationClass;
  223. return smalltalk.withContext(function($ctx1) { var $1,$2,$3;
  224. destinationClass=_st(_st((smalltalk.Smalltalk || Smalltalk))._current())._at_(_st(aClassName)._asSymbol());
  225. $1=destinationClass;
  226. if(($receiver = $1) == nil || $receiver == undefined){
  227. _st(self)._error_("Invalid class name");
  228. } else {
  229. $1;
  230. };
  231. $2=_st(destinationClass).__eq_eq(_st(aMethod)._methodClass());
  232. if(smalltalk.assert($2)){
  233. $3=self;
  234. return $3;
  235. };
  236. _st(destinationClass)._adoptMethod_(aMethod);
  237. _st(_st(aMethod)._methodClass())._forsakeMethod_(aMethod);
  238. return self}, function($ctx1) {$ctx1.fill(self,"moveMethod:toClass:",{aMethod:aMethod,aClassName:aClassName,destinationClass:destinationClass},smalltalk.HLLocalEnvironment)})},
  239. args: ["aMethod", "aClassName"],
  240. source: "moveMethod: aMethod toClass: aClassName\x0a\x09| destinationClass |\x0a\x09\x0a\x09destinationClass := Smalltalk current at: aClassName asSymbol.\x0a\x09destinationClass ifNil: [ self error: 'Invalid class name' ].\x0a\x09destinationClass == aMethod methodClass ifTrue: [ ^ self ].\x0a\x09\x0a\x09destinationClass adoptMethod: aMethod.\x0a\x09aMethod methodClass forsakeMethod: aMethod.\x0a\x09",
  241. messageSends: ["at:", "asSymbol", "current", "ifNil:", "error:", "ifTrue:", "==", "methodClass", "adoptMethod:", "forsakeMethod:"],
  242. referencedClasses: ["Smalltalk"]
  243. }),
  244. smalltalk.HLLocalEnvironment);
  245. smalltalk.addMethod(
  246. "_packages",
  247. smalltalk.method({
  248. selector: "packages",
  249. category: 'accessing',
  250. fn: function (){
  251. var self=this;
  252. return smalltalk.withContext(function($ctx1) { var $1;
  253. $1=_st(_st((smalltalk.Smalltalk || Smalltalk))._current())._packages();
  254. return $1;
  255. }, function($ctx1) {$ctx1.fill(self,"packages",{}, smalltalk.HLLocalEnvironment)})},
  256. args: [],
  257. source: "packages\x0a\x09^ Smalltalk current packages",
  258. messageSends: ["packages", "current"],
  259. referencedClasses: ["Smalltalk"]
  260. }),
  261. smalltalk.HLLocalEnvironment);
  262. smalltalk.addClass('HLRemoteEnvironment', smalltalk.HLEnvironment, [], 'Helios-Environments');
  263. smalltalk.addMethod(
  264. "_eval_on_",
  265. smalltalk.method({
  266. selector: "eval:on:",
  267. category: 'actions',
  268. fn: function (someCode,aReceiver){
  269. var self=this;
  270. return smalltalk.withContext(function($ctx1) { _st(self)._notYetImplemented();
  271. return self}, function($ctx1) {$ctx1.fill(self,"eval:on:",{someCode:someCode,aReceiver:aReceiver}, smalltalk.HLRemoteEnvironment)})},
  272. args: ["someCode", "aReceiver"],
  273. 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",
  274. messageSends: ["notYetImplemented"],
  275. referencedClasses: []
  276. }),
  277. smalltalk.HLRemoteEnvironment);
  278. smalltalk.addMethod(
  279. "_packages",
  280. smalltalk.method({
  281. selector: "packages",
  282. category: 'accessing',
  283. fn: function (){
  284. var self=this;
  285. return smalltalk.withContext(function($ctx1) { return self}, function($ctx1) {$ctx1.fill(self,"packages",{}, smalltalk.HLRemoteEnvironment)})},
  286. args: [],
  287. 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",
  288. messageSends: [],
  289. referencedClasses: []
  290. }),
  291. smalltalk.HLRemoteEnvironment);
  292. smalltalk.addClass('HLRemoteObject', smalltalk.Object, [], 'Helios-Environments');
  293. 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"
  294. smalltalk.addMethod(
  295. "_doesNotUnderstand_",
  296. smalltalk.method({
  297. selector: "doesNotUnderstand:",
  298. category: 'actions',
  299. fn: function (aMessage){
  300. var self=this;
  301. return smalltalk.withContext(function($ctx1) { return self}, function($ctx1) {$ctx1.fill(self,"doesNotUnderstand:",{aMessage:aMessage}, smalltalk.HLRemoteObject)})},
  302. args: ["aMessage"],
  303. source: "doesNotUnderstand: aMessage\x0a\x0a\x09\x22to-do\x0a\x0a\x09aham, blah blah\x0a\x0a\x09super doesNotUnderstand: aMessage\x22",
  304. messageSends: [],
  305. referencedClasses: []
  306. }),
  307. smalltalk.HLRemoteObject);
  308. smalltalk.addMethod(
  309. "_inspectOn_",
  310. smalltalk.method({
  311. selector: "inspectOn:",
  312. category: 'actions',
  313. fn: function (anInspector){
  314. var self=this;
  315. return smalltalk.withContext(function($ctx1) { return self}, function($ctx1) {$ctx1.fill(self,"inspectOn:",{anInspector:anInspector}, smalltalk.HLRemoteObject)})},
  316. args: ["anInspector"],
  317. source: "inspectOn: anInspector\x0a\x0a\x09\x22to-do\x22\x0a\x0a\x09\x22this is a source of so much fun...\x22\x0a",
  318. messageSends: [],
  319. referencedClasses: []
  320. }),
  321. smalltalk.HLRemoteObject);
  322. smalltalk.addMethod(
  323. "_printString",
  324. smalltalk.method({
  325. selector: "printString",
  326. category: 'actions',
  327. fn: function (){
  328. var self=this;
  329. return smalltalk.withContext(function($ctx1) { return "this is a remote object";
  330. }, function($ctx1) {$ctx1.fill(self,"printString",{}, smalltalk.HLRemoteObject)})},
  331. args: [],
  332. source: "printString\x0a\x09^ 'this is a remote object'",
  333. messageSends: [],
  334. referencedClasses: []
  335. }),
  336. smalltalk.HLRemoteObject);
  337. smalltalk.addMethod(
  338. "_adoptMethod_",
  339. smalltalk.method({
  340. selector: "adoptMethod:",
  341. category: '*Helios-Environments',
  342. fn: function (aMethod){
  343. var self=this;
  344. return smalltalk.withContext(function($ctx1) { _st(self)._compile_category_(_st(aMethod)._source(),_st(aMethod)._protocol());
  345. return self}, function($ctx1) {$ctx1.fill(self,"adoptMethod:",{aMethod:aMethod},smalltalk.Behavior)})},
  346. args: ["aMethod"],
  347. source: "adoptMethod: aMethod\x0a\x09self \x0a\x09\x09compile: aMethod source\x0a\x09\x09category: aMethod protocol.",
  348. messageSends: ["compile:category:", "source", "protocol"],
  349. referencedClasses: []
  350. }),
  351. smalltalk.Behavior);
  352. smalltalk.addMethod(
  353. "_forsakeMethod_",
  354. smalltalk.method({
  355. selector: "forsakeMethod:",
  356. category: '*Helios-Environments',
  357. fn: function (aMethod){
  358. var self=this;
  359. return smalltalk.withContext(function($ctx1) { _st(self)._removeCompiledMethod_(aMethod);
  360. return self}, function($ctx1) {$ctx1.fill(self,"forsakeMethod:",{aMethod:aMethod},smalltalk.Behavior)})},
  361. args: ["aMethod"],
  362. source: "forsakeMethod: aMethod\x0a\x09self removeCompiledMethod: aMethod",
  363. messageSends: ["removeCompiledMethod:"],
  364. referencedClasses: []
  365. }),
  366. smalltalk.Behavior);