Helios-Environments.st 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154
  1. Smalltalk current createPackage: 'Helios-Environments'!
  2. Object subclass: #HLEnvironment
  3. instanceVariableNames: ''
  4. package: 'Helios-Environments'!
  5. !HLEnvironment commentStamp!
  6. Abstract class defining common behavior for local and remote environments!
  7. !HLEnvironment methodsFor: 'accessing'!
  8. classBuilder
  9. ^ self subclassResponsibility
  10. !
  11. packages
  12. ^ self subclassResponsibility
  13. ! !
  14. !HLEnvironment methodsFor: 'actions'!
  15. eval: someCode on: aReceiver
  16. ^ self subclassResponsibility
  17. !
  18. moveMethod: aMethod toClass: aClassName ifAbsent: aBlock
  19. self subclassResponsibility
  20. ! !
  21. !HLEnvironment methodsFor: 'compiling'!
  22. addInstVarNamed: aString to: aClass
  23. self classBuilder
  24. addSubclassOf: aClass superclass
  25. named: aClass name
  26. instanceVariableNames: (aClass instanceVariableNames copy add: aString; yourself)
  27. package: aClass package name
  28. !
  29. compileClassComment: aString for: aClass
  30. aClass comment: aString
  31. !
  32. compileClassDefinition: aString
  33. self eval: aString on: DoIt new
  34. !
  35. compileMethod: sourceCode for: class protocol: protocol
  36. class
  37. compile: sourceCode
  38. category: protocol
  39. ! !
  40. HLEnvironment subclass: #HLLocalEnvironment
  41. instanceVariableNames: ''
  42. package: 'Helios-Environments'!
  43. !HLLocalEnvironment methodsFor: 'accessing'!
  44. classBuilder
  45. ^ ClassBuilder new
  46. !
  47. packages
  48. ^ Smalltalk current packages
  49. ! !
  50. !HLLocalEnvironment methodsFor: 'actions'!
  51. eval: aString on: aReceiver
  52. | compiler |
  53. compiler := Compiler new.
  54. [ compiler parseExpression: aString ] on: Error do: [ :ex |
  55. ^ window alert: ex messageText ].
  56. ^ compiler evaluateExpression: aString on: aReceiver
  57. !
  58. moveMethod: aMethod toClass: aClassName ifAbsent: aBlock
  59. | destinationClass |
  60. destinationClass := Smalltalk current at: aClassName asSymbol.
  61. destinationClass ifNil: [ ^ aBlock value ].
  62. destinationClass adoptMethod: aMethod.
  63. aMethod methodClass forsakeMethod: aMethod.
  64. ! !
  65. HLEnvironment subclass: #HLRemoteEnvironment
  66. instanceVariableNames: ''
  67. package: 'Helios-Environments'!
  68. !HLRemoteEnvironment methodsFor: 'accessing'!
  69. packages
  70. "Answer the remote environment's packages"
  71. "to-do"
  72. "Note for future self and friends:
  73. the problem with remote stuff is that the answers shouldn't be expected to be
  74. received in a syncrhonous fashion. Everything network is asyc, so you *are going to deal with callbacks* here"
  75. ! !
  76. !HLRemoteEnvironment methodsFor: 'actions'!
  77. eval: someCode on: aReceiver
  78. "Note for future self and friends:
  79. whatever way this compilation happens on the other side,
  80. it should return a proxy to the remote resulting object"
  81. self notYetImplemented
  82. ! !
  83. Object subclass: #HLRemoteObject
  84. instanceVariableNames: ''
  85. package: 'Helios-Environments'!
  86. !HLRemoteObject commentStamp!
  87. This is a local proxy to a remote object.
  88. Tipically useful for evaluating and inspecting and interacting with instances of a remote VM.!
  89. !HLRemoteObject methodsFor: 'actions'!
  90. doesNotUnderstand: aMessage
  91. "to-do
  92. aham, blah blah
  93. super doesNotUnderstand: aMessage"
  94. !
  95. inspectOn: anInspector
  96. "to-do"
  97. "this is a source of so much fun..."
  98. !
  99. printString
  100. ^ 'this is a remote object'
  101. ! !
  102. !Behavior methodsFor: '*Helios-Environments'!
  103. adoptMethod: aMethod
  104. self
  105. compile: aMethod source;
  106. category: aMethod protocol.
  107. !
  108. forsakeMethod: aMethod
  109. self removeCompiledMethod: aMethod
  110. ! !