Kernel-Transcript.js 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219
  1. smalltalk.addPackage('Kernel-Transcript');
  2. smalltalk.addClass('ConsoleTranscript', smalltalk.Object, ['textarea'], 'Kernel-Transcript');
  3. smalltalk.ConsoleTranscript.comment="I am a specific transcript emitting to the JavaScript console.\x0a\x0aIf no other transcript is registered, I am the default."
  4. smalltalk.addMethod(
  5. smalltalk.method({
  6. selector: "clear",
  7. category: 'printing',
  8. fn: function (){
  9. var self=this;
  10. return smalltalk.withContext(function($ctx1) {
  11. return self}, function($ctx1) {$ctx1.fill(self,"clear",{},smalltalk.ConsoleTranscript)})},
  12. args: [],
  13. source: "clear\x0a\x09\x22no op\x22",
  14. messageSends: [],
  15. referencedClasses: []
  16. }),
  17. smalltalk.ConsoleTranscript);
  18. smalltalk.addMethod(
  19. smalltalk.method({
  20. selector: "cr",
  21. category: 'printing',
  22. fn: function (){
  23. var self=this;
  24. return smalltalk.withContext(function($ctx1) {
  25. return self}, function($ctx1) {$ctx1.fill(self,"cr",{},smalltalk.ConsoleTranscript)})},
  26. args: [],
  27. source: "cr\x0a\x09\x22no op\x22",
  28. messageSends: [],
  29. referencedClasses: []
  30. }),
  31. smalltalk.ConsoleTranscript);
  32. smalltalk.addMethod(
  33. smalltalk.method({
  34. selector: "open",
  35. category: 'actions',
  36. fn: function (){
  37. var self=this;
  38. return smalltalk.withContext(function($ctx1) {
  39. return self}, function($ctx1) {$ctx1.fill(self,"open",{},smalltalk.ConsoleTranscript)})},
  40. args: [],
  41. source: "open",
  42. messageSends: [],
  43. referencedClasses: []
  44. }),
  45. smalltalk.ConsoleTranscript);
  46. smalltalk.addMethod(
  47. smalltalk.method({
  48. selector: "show:",
  49. category: 'printing',
  50. fn: function (anObject){
  51. var self=this;
  52. return smalltalk.withContext(function($ctx1) {
  53. console.log(String(_st(anObject)._asString()));
  54. return self}, function($ctx1) {$ctx1.fill(self,"show:",{anObject:anObject},smalltalk.ConsoleTranscript)})},
  55. args: ["anObject"],
  56. source: "show: anObject\x0a\x22Smalltalk objects should have no trouble displaying themselves on the Transcript; Javascript objects don't know how, so must be wrapped in a JSObectProxy.\x22\x0a<console.log(String(_st(anObject)._asString()))>",
  57. messageSends: [],
  58. referencedClasses: []
  59. }),
  60. smalltalk.ConsoleTranscript);
  61. smalltalk.addMethod(
  62. smalltalk.method({
  63. selector: "initialize",
  64. category: 'initialization',
  65. fn: function (){
  66. var self=this;
  67. function $Transcript(){return smalltalk.Transcript||(typeof Transcript=="undefined"?nil:Transcript)}
  68. return smalltalk.withContext(function($ctx1) {
  69. _st($Transcript())._register_(_st(self)._new());
  70. return self}, function($ctx1) {$ctx1.fill(self,"initialize",{},smalltalk.ConsoleTranscript.klass)})},
  71. args: [],
  72. source: "initialize\x0a\x09Transcript register: self new",
  73. messageSends: ["register:", "new"],
  74. referencedClasses: ["Transcript"]
  75. }),
  76. smalltalk.ConsoleTranscript.klass);
  77. smalltalk.addClass('Transcript', smalltalk.Object, [], 'Kernel-Transcript');
  78. smalltalk.Transcript.comment="I am a facade for Transcript actions.\x0a\x0aI delegate actions to the currently registered transcript.\x0a\x0a## API\x0a\x0a Transcript \x0a show: 'hello world';\x0a cr;\x0a show: anObject."
  79. smalltalk.Transcript.klass.iVarNames = ['current'];
  80. smalltalk.addMethod(
  81. smalltalk.method({
  82. selector: "clear",
  83. category: 'printing',
  84. fn: function (){
  85. var self=this;
  86. return smalltalk.withContext(function($ctx1) {
  87. _st(_st(self)._current())._clear();
  88. return self}, function($ctx1) {$ctx1.fill(self,"clear",{},smalltalk.Transcript.klass)})},
  89. args: [],
  90. source: "clear\x0a\x09self current clear",
  91. messageSends: ["clear", "current"],
  92. referencedClasses: []
  93. }),
  94. smalltalk.Transcript.klass);
  95. smalltalk.addMethod(
  96. smalltalk.method({
  97. selector: "cr",
  98. category: 'printing',
  99. fn: function (){
  100. var self=this;
  101. function $String(){return smalltalk.String||(typeof String=="undefined"?nil:String)}
  102. return smalltalk.withContext(function($ctx1) {
  103. _st(_st(self)._current())._show_(_st($String())._cr());
  104. return self}, function($ctx1) {$ctx1.fill(self,"cr",{},smalltalk.Transcript.klass)})},
  105. args: [],
  106. source: "cr\x0a\x09self current show: String cr",
  107. messageSends: ["show:", "cr", "current"],
  108. referencedClasses: ["String"]
  109. }),
  110. smalltalk.Transcript.klass);
  111. smalltalk.addMethod(
  112. smalltalk.method({
  113. selector: "current",
  114. category: 'instance creation',
  115. fn: function (){
  116. var self=this;
  117. return smalltalk.withContext(function($ctx1) {
  118. var $1;
  119. $1=self["@current"];
  120. return $1;
  121. }, function($ctx1) {$ctx1.fill(self,"current",{},smalltalk.Transcript.klass)})},
  122. args: [],
  123. source: "current\x0a\x09^current",
  124. messageSends: [],
  125. referencedClasses: []
  126. }),
  127. smalltalk.Transcript.klass);
  128. smalltalk.addMethod(
  129. smalltalk.method({
  130. selector: "inspect:",
  131. category: 'printing',
  132. fn: function (anObject){
  133. var self=this;
  134. return smalltalk.withContext(function($ctx1) {
  135. _st(self)._show_(anObject);
  136. return self}, function($ctx1) {$ctx1.fill(self,"inspect:",{anObject:anObject},smalltalk.Transcript.klass)})},
  137. args: ["anObject"],
  138. source: "inspect: anObject\x0a\x09self show: anObject",
  139. messageSends: ["show:"],
  140. referencedClasses: []
  141. }),
  142. smalltalk.Transcript.klass);
  143. smalltalk.addMethod(
  144. smalltalk.method({
  145. selector: "new",
  146. category: 'instance creation',
  147. fn: function (){
  148. var self=this;
  149. return smalltalk.withContext(function($ctx1) {
  150. _st(self)._shouldNotImplement();
  151. return self}, function($ctx1) {$ctx1.fill(self,"new",{},smalltalk.Transcript.klass)})},
  152. args: [],
  153. source: "new\x0a\x09self shouldNotImplement",
  154. messageSends: ["shouldNotImplement"],
  155. referencedClasses: []
  156. }),
  157. smalltalk.Transcript.klass);
  158. smalltalk.addMethod(
  159. smalltalk.method({
  160. selector: "open",
  161. category: 'instance creation',
  162. fn: function (){
  163. var self=this;
  164. return smalltalk.withContext(function($ctx1) {
  165. _st(_st(self)._current())._open();
  166. return self}, function($ctx1) {$ctx1.fill(self,"open",{},smalltalk.Transcript.klass)})},
  167. args: [],
  168. source: "open\x0a\x09self current open",
  169. messageSends: ["open", "current"],
  170. referencedClasses: []
  171. }),
  172. smalltalk.Transcript.klass);
  173. smalltalk.addMethod(
  174. smalltalk.method({
  175. selector: "register:",
  176. category: 'instance creation',
  177. fn: function (aTranscript){
  178. var self=this;
  179. return smalltalk.withContext(function($ctx1) {
  180. self["@current"]=aTranscript;
  181. return self}, function($ctx1) {$ctx1.fill(self,"register:",{aTranscript:aTranscript},smalltalk.Transcript.klass)})},
  182. args: ["aTranscript"],
  183. source: "register: aTranscript\x0a\x09current := aTranscript",
  184. messageSends: [],
  185. referencedClasses: []
  186. }),
  187. smalltalk.Transcript.klass);
  188. smalltalk.addMethod(
  189. smalltalk.method({
  190. selector: "show:",
  191. category: 'printing',
  192. fn: function (anObject){
  193. var self=this;
  194. return smalltalk.withContext(function($ctx1) {
  195. _st(_st(self)._current())._show_(anObject);
  196. return self}, function($ctx1) {$ctx1.fill(self,"show:",{anObject:anObject},smalltalk.Transcript.klass)})},
  197. args: ["anObject"],
  198. source: "show: anObject\x0a\x09self current show: anObject",
  199. messageSends: ["show:", "current"],
  200. referencedClasses: []
  201. }),
  202. smalltalk.Transcript.klass);