Helios-Environments.st 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155
  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
  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
  59. | destinationClass |
  60. destinationClass := Smalltalk current at: aClassName asSymbol.
  61. destinationClass ifNil: [ self error: 'Invalid class name' ].
  62. destinationClass == aMethod methodClass ifTrue: [ ^ self ].
  63. destinationClass adoptMethod: aMethod.
  64. aMethod methodClass forsakeMethod: aMethod.
  65. ! !
  66. HLEnvironment subclass: #HLRemoteEnvironment
  67. instanceVariableNames: ''
  68. package: 'Helios-Environments'!
  69. !HLRemoteEnvironment methodsFor: 'accessing'!
  70. packages
  71. "Answer the remote environment's packages"
  72. "to-do"
  73. "Note for future self and friends:
  74. the problem with remote stuff is that the answers shouldn't be expected to be
  75. received in a syncrhonous fashion. Everything network is asyc, so you *are going to deal with callbacks* here"
  76. ! !
  77. !HLRemoteEnvironment methodsFor: 'actions'!
  78. eval: someCode on: aReceiver
  79. "Note for future self and friends:
  80. whatever way this compilation happens on the other side,
  81. it should return a proxy to the remote resulting object"
  82. self notYetImplemented
  83. ! !
  84. Object subclass: #HLRemoteObject
  85. instanceVariableNames: ''
  86. package: 'Helios-Environments'!
  87. !HLRemoteObject commentStamp!
  88. This is a local proxy to a remote object.
  89. Tipically useful for evaluating and inspecting and interacting with instances of a remote VM.!
  90. !HLRemoteObject methodsFor: 'actions'!
  91. doesNotUnderstand: aMessage
  92. "to-do
  93. aham, blah blah
  94. super doesNotUnderstand: aMessage"
  95. !
  96. inspectOn: anInspector
  97. "to-do"
  98. "this is a source of so much fun..."
  99. !
  100. printString
  101. ^ 'this is a remote object'
  102. ! !
  103. !Behavior methodsFor: '*Helios-Environments'!
  104. adoptMethod: aMethod
  105. self
  106. compile: aMethod source
  107. category: aMethod protocol.
  108. !
  109. forsakeMethod: aMethod
  110. self removeCompiledMethod: aMethod
  111. ! !