Helios-Environments.st 3.4 KB

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