1
0

Helios-Environments.st 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  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. !HLEnvironment methodsFor: 'compiling'!
  19. addInstVarNamed: aString to: aClass
  20. self classBuilder
  21. addSubclassOf: aClass superclass
  22. named: aClass name
  23. instanceVariableNames: (aClass instanceVariableNames copy add: aString; yourself)
  24. package: aClass package name
  25. !
  26. compileClassComment: aString for: aClass
  27. aClass comment: aString
  28. !
  29. compileClassDefinition: aString
  30. self eval: aString on: DoIt new
  31. !
  32. compileMethod: sourceCode for: class protocol: protocol
  33. class
  34. compile: sourceCode
  35. category: protocol
  36. ! !
  37. HLEnvironment subclass: #HLLocalEnvironment
  38. instanceVariableNames: ''
  39. package: 'Helios-Environments'!
  40. !HLLocalEnvironment methodsFor: 'accessing'!
  41. classBuilder
  42. ^ ClassBuilder new
  43. !
  44. packages
  45. ^ Smalltalk current packages
  46. ! !
  47. !HLLocalEnvironment methodsFor: 'actions'!
  48. eval: aString on: aReceiver
  49. | compiler |
  50. compiler := Compiler new.
  51. [ compiler parseExpression: aString ] on: Error do: [ :ex |
  52. ^ window alert: ex messageText ].
  53. ^ compiler evaluateExpression: aString on: aReceiver
  54. ! !
  55. HLEnvironment subclass: #HLRemoteEnvironment
  56. instanceVariableNames: ''
  57. package: 'Helios-Environments'!
  58. !HLRemoteEnvironment methodsFor: 'accessing'!
  59. packages
  60. "Answer the remote environment's packages"
  61. "to-do"
  62. "Note for future self and friends:
  63. the problem with remote stuff is that the answers shouldn't be expected to be
  64. received in a syncrhonous fashion. Everything network is asyc, so you *are going to deal with callbacks* here"
  65. ! !
  66. !HLRemoteEnvironment methodsFor: 'actions'!
  67. eval: someCode on: aReceiver
  68. "Note for future self and friends:
  69. whatever way this compilation happens on the other side,
  70. it should return a proxy to the remote resulting object"
  71. self notYetImplemented
  72. ! !
  73. Object subclass: #HLRemoteObject
  74. instanceVariableNames: ''
  75. package: 'Helios-Environments'!
  76. !HLRemoteObject commentStamp!
  77. This is a local proxy to a remote object.
  78. Tipically useful for evaluating and inspecting and interacting with instances of a remote VM.!
  79. !HLRemoteObject methodsFor: 'actions'!
  80. doesNotUnderstand: aMessage
  81. "to-do
  82. aham, blah blah
  83. super doesNotUnderstand: aMessage"
  84. !
  85. inspectOn: anInspector
  86. "to-do"
  87. "this is a source of so much fun..."
  88. !
  89. printString
  90. ^ 'this is a remote object'
  91. ! !