Kernel.st 45 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789
  1. nil subclass: #Object
  2. instanceVariableNames: ''
  3. category: 'Kernel'!
  4. !Object methodsFor: ''!
  5. foo ^ self
  6. ! !
  7. !Object methodsFor: 'accessing'!
  8. yourself
  9. ^self
  10. !
  11. class
  12. <return self.klass>
  13. !
  14. size
  15. self error: 'Object not indexable'
  16. !
  17. instVarAt: aString
  18. <return self['@'+aString]>
  19. !
  20. instVarAt: aString put: anObject
  21. <self['@' + aString] = anObject>
  22. !
  23. basicAt: aString
  24. <return self[aString]>
  25. !
  26. basicAt: aString put: anObject
  27. <return self[aString] = anObject>
  28. !
  29. basicDelete: aString
  30. <delete self[aString]>
  31. ! !
  32. !Object methodsFor: 'comparing'!
  33. = anObject
  34. <return self == anObject>
  35. !
  36. ~= anObject
  37. ^(self = anObject) = false
  38. ! !
  39. !Object methodsFor: 'converting'!
  40. -> anObject
  41. ^Association key: self value: anObject
  42. !
  43. asString
  44. ^self printString
  45. !
  46. asJavascript
  47. ^self asString
  48. !
  49. asJSON
  50. <return JSON.stringify(self._asJSONObject())>
  51. !
  52. asJSONObject
  53. | object |
  54. object := Object new.
  55. self class instanceVariableNames do: [:each |
  56. object basicAt: each put: (self instVarAt: each) asJSONObject].
  57. ^object
  58. ! !
  59. !Object methodsFor: 'copying'!
  60. copy
  61. ^self shallowCopy postCopy
  62. !
  63. shallowCopy
  64. <
  65. var copy = self.klass._new();
  66. for(var i in self) {
  67. if(/^@.+/.test(i)) {
  68. copy[i] = self[i];
  69. }
  70. }
  71. return copy;
  72. >
  73. !
  74. deepCopy
  75. <
  76. var copy = self.klass._new();
  77. for(var i in self) {
  78. if(/^@.+/.test(i)) {
  79. copy[i] = self[i]._deepCopy();
  80. }
  81. }
  82. return copy;
  83. >
  84. !
  85. postCopy
  86. ! !
  87. !Object methodsFor: 'error handling'!
  88. error: aString
  89. Error signal: aString
  90. !
  91. subclassResponsibility
  92. self error: 'This method is a responsibility of a subclass'
  93. !
  94. shouldNotImplement
  95. self error: 'This method should not be implemented in ', self class name
  96. !
  97. try: aBlock catch: anotherBlock
  98. <try{aBlock()} catch(e) {anotherBlock(e)}>
  99. !
  100. doesNotUnderstand: aMessage
  101. MessageNotUnderstood new
  102. receiver: self;
  103. message: aMessage;
  104. signal
  105. !
  106. halt
  107. self error: 'Halt encountered'
  108. ! !
  109. !Object methodsFor: 'initialization'!
  110. initialize
  111. ! !
  112. !Object methodsFor: 'message handling'!
  113. perform: aSymbol
  114. ^self perform: aSymbol withArguments: #()
  115. !
  116. perform: aSymbol withArguments: aCollection
  117. ^self basicPerform: aSymbol asSelector withArguments: aCollection
  118. !
  119. basicPerform: aSymbol
  120. ^self basicPerform: aSymbol withArguments: #()
  121. !
  122. basicPerform: aSymbol withArguments: aCollection
  123. <return self[aSymbol].apply(self, aCollection);>
  124. ! !
  125. !Object methodsFor: 'printing'!
  126. printString
  127. ^'a ', self class name
  128. !
  129. printNl
  130. <console.log(self)>
  131. !
  132. log: aString block: aBlock
  133. | result |
  134. console log: aString, ' time: ', (Date millisecondsToRun: [result := aBlock value]) printString.
  135. ^result
  136. ! !
  137. !Object methodsFor: 'testing'!
  138. isKindOf: aClass
  139. ^(self isMemberOf: aClass)
  140. ifTrue: [true]
  141. ifFalse: [self class inheritsFrom: aClass]
  142. !
  143. isMemberOf: aClass
  144. ^self class = aClass
  145. !
  146. ifNil: aBlock
  147. "inlined in the Compiler"
  148. ^self
  149. !
  150. ifNil: aBlock ifNotNil: anotherBlock
  151. "inlined in the Compiler"
  152. ^anotherBlock value
  153. !
  154. ifNotNil: aBlock
  155. "inlined in the Compiler"
  156. ^aBlock value
  157. !
  158. ifNotNil: aBlock ifNil: anotherBlock
  159. "inlined in the Compiler"
  160. ^aBlock value
  161. !
  162. isNil
  163. ^false
  164. !
  165. notNil
  166. ^self isNil not
  167. !
  168. isClass
  169. ^false
  170. !
  171. isMetaclass
  172. ^false
  173. !
  174. isNumber
  175. ^false
  176. !
  177. isString
  178. ^false
  179. !
  180. isParseFailure
  181. ^false
  182. ! !
  183. !Object class methodsFor: 'initialization'!
  184. initialize
  185. "no op"
  186. ! !
  187. Object subclass: #Smalltalk
  188. instanceVariableNames: ''
  189. category: 'Kernel'!
  190. !Smalltalk methodsFor: 'accessing'!
  191. classes
  192. <return self.classes()>
  193. !
  194. readJSON: anObject
  195. <return self.readJSObject(anObject)>
  196. !
  197. at: aString
  198. <return self[aString]>
  199. !
  200. removeClass: aClass
  201. aClass isMetaclass ifTrue: [self error: aClass asString, ' is a Metaclass and cannot be removed!!'].
  202. aClass methodDictionary values do: [:each |
  203. aClass removeCompiledMethod: each].
  204. aClass class methodDictionary values do: [:each |
  205. aClass class removeCompiledMethod: each].
  206. self basicDelete: aClass name
  207. !
  208. basicParse: aString
  209. <return smalltalk.parser.parse(aString)>
  210. !
  211. parse: aString
  212. | result |
  213. self try: [result := self basicParse: aString] catch: [:ex | (self parseError: ex parsing: aString) signal].
  214. ^result
  215. !
  216. parseError: anException parsing: aString
  217. | row col message lines badLine code |
  218. <row = anException.line;
  219. col = anException.column;
  220. message = anException.message;>.
  221. lines := aString lines.
  222. badLine := lines at: row.
  223. badLine := (badLine copyFrom: 1 to: col - 1), ' ===>', (badLine copyFrom: col to: badLine size).
  224. lines at: row put: badLine.
  225. code := String streamContents: [:s |
  226. lines withIndexDo: [:l :i |
  227. s nextPutAll: i asString, ': ', l, String lf]].
  228. ^ Error new messageText: ('Parse error on line ' , row , ' column ' , col , ' : ' , message , ' Below is code with line numbers and ===> marker inserted:' , String lf, code)
  229. !
  230. modules
  231. <return self.modules.all()>
  232. ! !
  233. Smalltalk class instanceVariableNames: 'current'!
  234. !Smalltalk class methodsFor: 'accessing'!
  235. current
  236. <return smalltalk>
  237. ! !
  238. Object subclass: #Module
  239. instanceVariableNames: ''
  240. category: 'Kernel'!
  241. !Module methodsFor: 'accessing'!
  242. name
  243. <return self.moduleName || nil>
  244. !
  245. requires
  246. <return self.requires || nil>
  247. !
  248. name: aString
  249. <return self.moduleName = aString>
  250. ! !
  251. Object subclass: #Behavior
  252. instanceVariableNames: ''
  253. category: 'Kernel'!
  254. !Behavior methodsFor: 'accessing'!
  255. name
  256. <return self.className || nil>
  257. !
  258. superclass
  259. <return self.superclass || nil>
  260. !
  261. subclasses
  262. <return smalltalk.subclasses(self)>
  263. !
  264. allSubclasses
  265. | result |
  266. result := self subclasses.
  267. self subclasses do: [:each |
  268. result addAll: each allSubclasses].
  269. ^result
  270. !
  271. withAllSubclasses
  272. ^(Array with: self) addAll: self allSubclasses; yourself
  273. !
  274. prototype
  275. <return self.fn.prototype>
  276. !
  277. methodDictionary
  278. <var dict = smalltalk.Dictionary._new();
  279. var methods = self.fn.prototype.methods;
  280. for(var i in methods) {
  281. if(methods[i].selector) {
  282. dict._at_put_(methods[i].selector, methods[i]);
  283. }
  284. };
  285. return dict>
  286. !
  287. methodsFor: aString
  288. ^ClassCategoryReader new
  289. class: self category: aString;
  290. yourself
  291. !
  292. addCompiledMethod: aMethod
  293. <smalltalk.addMethod(aMethod.selector._asSelector(), aMethod, self)>
  294. !
  295. instanceVariableNames
  296. <return self.iVarNames>
  297. !
  298. comment
  299. ^(self basicAt: 'comment') ifNil: ['']
  300. !
  301. comment: aString
  302. self basicAt: 'comment' put: aString
  303. !
  304. commentStamp
  305. ^ClassCommentReader new
  306. class: self;
  307. yourself
  308. !
  309. removeCompiledMethod: aMethod
  310. <delete self.fn.prototype[aMethod.selector._asSelector()];
  311. delete self.fn.prototype.methods[aMethod.selector];
  312. smalltalk.init(self);>
  313. !
  314. protocols
  315. | protocols |
  316. protocols := Array new.
  317. self methodDictionary do: [:each |
  318. (protocols includes: each category) ifFalse: [
  319. protocols add: each category]].
  320. ^protocols sort
  321. !
  322. protocolsDo: aBlock
  323. "Execute aBlock for each method category with
  324. its collection of methods in the sort order of category name."
  325. | methodsByCategory |
  326. methodsByCategory := Dictionary new.
  327. self methodDictionary values do: [:m |
  328. (methodsByCategory at: m category ifAbsentPut: [Array new])
  329. add: m].
  330. self protocols do: [:category |
  331. aBlock value: category value: (methodsByCategory at: category)]
  332. !
  333. allInstanceVariableNames
  334. | result |
  335. result := self instanceVariableNames copy.
  336. self superclass ifNotNil: [
  337. result addAll: self superclass allInstanceVariableNames].
  338. ^result
  339. !
  340. methodAt: aString
  341. <return smalltalk.methods(self)[aString]>
  342. !
  343. methodsFor: aString stamp: aStamp
  344. "Added for compatibility, right now ignores stamp."
  345. ^self methodsFor: aString
  346. !
  347. commentStamp: aStamp prior: prior
  348. ^self commentStamp
  349. ! !
  350. !Behavior methodsFor: 'compiling'!
  351. compile: aString
  352. self compile: aString category: ''
  353. !
  354. compile: aString category: anotherString
  355. | method |
  356. method := Compiler new load: aString forClass: self.
  357. method category: anotherString.
  358. self addCompiledMethod: method
  359. ! !
  360. !Behavior methodsFor: 'instance creation'!
  361. new
  362. ^self basicNew initialize
  363. !
  364. basicNew
  365. <return new self.fn()>
  366. !
  367. inheritsFrom: aClass
  368. ^aClass allSubclasses includes: self
  369. ! !
  370. Behavior subclass: #Class
  371. instanceVariableNames: ''
  372. category: 'Kernel'!
  373. !Class methodsFor: 'accessing'!
  374. category
  375. ^self module ifNil: ['unclassified'] ifNotNil: [self module name]
  376. !
  377. rename: aString
  378. <
  379. smalltalk[aString] = self;
  380. delete smalltalk[self.className];
  381. self.className = aString;
  382. >
  383. !
  384. module
  385. <return self.module>
  386. !
  387. module: aModule
  388. <self.module = aModule>
  389. ! !
  390. !Class methodsFor: 'class creation'!
  391. subclass: aString instanceVariableNames: anotherString
  392. "Kept for compatibility."
  393. ^self subclass: aString instanceVariableNames: anotherString module: nil
  394. !
  395. subclass: aString instanceVariableNames: aString2 category: aString3
  396. "Kept for compatibility."
  397. ^self subclass: aString instanceVariableNames: aString2 module: aString3
  398. !
  399. subclass: aString instanceVariableNames: aString2 classVariableNames: classVars poolDictionaries: pools category: aString3
  400. "Just ignore class variables and pools. Added for compatibility."
  401. ^self subclass: aString instanceVariableNames: aString2 module: aString3
  402. !
  403. subclass: aString instanceVariableNames: aString2 module: aString3
  404. ^ClassBuilder new
  405. superclass: self subclass: aString instanceVariableNames: aString2 module: aString3
  406. ! !
  407. !Class methodsFor: 'printing'!
  408. printString
  409. ^self name
  410. ! !
  411. !Class methodsFor: 'testing'!
  412. isClass
  413. ^true
  414. ! !
  415. Behavior subclass: #Metaclass
  416. instanceVariableNames: ''
  417. category: 'Kernel'!
  418. !Metaclass methodsFor: 'accessing'!
  419. instanceClass
  420. <return self.instanceClass>
  421. !
  422. instanceVariableNames: aCollection
  423. ClassBuilder new
  424. class: self instanceVariableNames: aCollection
  425. ! !
  426. !Metaclass methodsFor: 'printing'!
  427. printString
  428. ^self instanceClass name, ' class'
  429. ! !
  430. !Metaclass methodsFor: 'testing'!
  431. isMetaclass
  432. ^true
  433. ! !
  434. Object subclass: #CompiledMethod
  435. instanceVariableNames: ''
  436. category: 'Kernel'!
  437. !CompiledMethod methodsFor: 'accessing'!
  438. source
  439. ^(self basicAt: 'source') ifNil: ['']
  440. !
  441. source: aString
  442. self basicAt: 'source' put: aString
  443. !
  444. category
  445. ^(self basicAt: 'category') ifNil: ['']
  446. !
  447. category: aString
  448. self basicAt: 'category' put: aString
  449. !
  450. selector
  451. ^self basicAt: 'selector'
  452. !
  453. selector: aString
  454. self basicAt: 'selector' put: aString
  455. !
  456. fn
  457. ^self basicAt: 'fn'
  458. !
  459. fn: aBlock
  460. self basicAt: 'fn' put: aBlock
  461. !
  462. messageSends
  463. ^self basicAt: 'messageSends'
  464. !
  465. methodClass
  466. ^self basicAt: 'methodClass'
  467. !
  468. referencedClasses
  469. ^self basicAt: 'referencedClasses'
  470. ! !
  471. Object subclass: #Number
  472. instanceVariableNames: ''
  473. category: 'Kernel'!
  474. !Number methodsFor: 'arithmetic'!
  475. + aNumber
  476. "Inlined in the Compiler"
  477. <return self + aNumber>
  478. !
  479. - aNumber
  480. "Inlined in the Compiler"
  481. <return self - aNumber>
  482. !
  483. * aNumber
  484. "Inlined in the Compiler"
  485. <return self * aNumber>
  486. !
  487. / aNumber
  488. "Inlined in the Compiler"
  489. <return self / aNumber>
  490. !
  491. max: aNumber
  492. <return Math.max(self, aNumber);>
  493. !
  494. min: aNumber
  495. <return Math.min(self, aNumber);>
  496. !
  497. modulo: aNumber
  498. <return self % aNumber>
  499. !
  500. negated
  501. ^0 - self
  502. ! !
  503. !Number methodsFor: 'comparing'!
  504. = aNumber
  505. "Inlined in the Compiler"
  506. <return Number(self) == aNumber>
  507. !
  508. > aNumber
  509. "Inlined in the Compiler"
  510. <return self >> aNumber>
  511. !
  512. < aNumber
  513. "Inlined in the Compiler"
  514. <return self < aNumber>
  515. !
  516. >= aNumber
  517. "Inlined in the Compiler"
  518. <return self >>= aNumber>
  519. !
  520. <= aNumber
  521. "Inlined in the Compiler"
  522. <return self <= aNumber>
  523. ! !
  524. !Number methodsFor: 'converting'!
  525. rounded
  526. <return Math.round(self);>
  527. !
  528. truncated
  529. <return Math.floor(self);>
  530. !
  531. to: aNumber
  532. | array first last count |
  533. first := self truncated.
  534. last := aNumber truncated + 1.
  535. count := 1.
  536. (first <= last) ifFalse: [self error: 'Wrong interval'].
  537. array := Array new.
  538. (last - first) timesRepeat: [
  539. array at: count put: first.
  540. count := count + 1.
  541. first := first + 1].
  542. ^array
  543. !
  544. asString
  545. ^self printString
  546. !
  547. asJavascript
  548. ^'(', self printString, ')'
  549. !
  550. atRandom
  551. ^(Random new next * self) truncated + 1
  552. !
  553. @ aNumber
  554. ^Point x: self y: aNumber
  555. !
  556. asPoint
  557. ^Point x: self y: self
  558. !
  559. asJSONObject
  560. ^self
  561. ! !
  562. !Number methodsFor: 'enumerating'!
  563. timesRepeat: aBlock
  564. | integer count |
  565. integer := self truncated.
  566. count := 1.
  567. [count > self] whileFalse: [
  568. aBlock value.
  569. count := count + 1]
  570. !
  571. to: aNumber do: aBlock
  572. ^(self to: aNumber) do: aBlock
  573. ! !
  574. !Number methodsFor: 'printing'!
  575. printString
  576. <return String(self)>
  577. ! !
  578. !Number methodsFor: 'testing'!
  579. isNumber
  580. ^true
  581. !
  582. even
  583. ^ 0 = (self modulo: 2)
  584. !
  585. odd
  586. ^ self even not
  587. ! !
  588. !Number methodsFor: 'timeouts/intervals'!
  589. clearInterval
  590. <clearInterval(Number(self))>
  591. !
  592. clearTimeout
  593. <clearTimeout(Number(self))>
  594. ! !
  595. !Number class methodsFor: 'instance creation'!
  596. pi
  597. <return Math.PI>
  598. ! !
  599. Object subclass: #BlockClosure
  600. instanceVariableNames: ''
  601. category: 'Kernel'!
  602. !BlockClosure methodsFor: 'accessing'!
  603. compiledSource
  604. <return self.toString()>
  605. ! !
  606. !BlockClosure methodsFor: 'controlling'!
  607. whileTrue: aBlock
  608. "inlined in the Compiler"
  609. <while(self()) {aBlock()}>
  610. !
  611. whileFalse: aBlock
  612. "inlined in the Compiler"
  613. <while(!!self()) {aBlock()}>
  614. !
  615. whileFalse
  616. "inlined in the Compiler"
  617. self whileFalse: []
  618. !
  619. whileTrue
  620. "inlined in the Compiler"
  621. self whileTrue: []
  622. ! !
  623. !BlockClosure methodsFor: 'error handling'!
  624. on: anErrorClass do: aBlock
  625. self try: self catch: [:error |
  626. (error isKindOf: anErrorClass)
  627. ifTrue: [aBlock value: error]
  628. ifFalse: [error signal]]
  629. ! !
  630. !BlockClosure methodsFor: 'evaluating'!
  631. value
  632. "inlined in the Compiler"
  633. <return self();>
  634. !
  635. value: anArg
  636. "inlined in the Compiler"
  637. <return self(anArg);>
  638. !
  639. value: firstArg value: secondArg
  640. "inlined in the Compiler"
  641. <return self(firstArg, secondArg);>
  642. !
  643. value: firstArg value: secondArg value: thirdArg
  644. "inlined in the Compiler"
  645. <return self(firstArg, secondArg, thirdArg);>
  646. !
  647. valueWithPossibleArguments: aCollection
  648. <return self.apply(null, aCollection);>
  649. !
  650. new
  651. "Use the receiver as a JS constructor.
  652. *Do not* use this method to instanciate Smalltalk objects!!"
  653. <return new self()>
  654. !
  655. applyTo: anObject arguments: aCollection
  656. <return self.apply(anObject, aCollection)>
  657. !
  658. timeToRun
  659. "Answer the number of milliseconds taken to execute this block."
  660. ^ Date millisecondsToRun: self
  661. ! !
  662. !BlockClosure methodsFor: 'timeout/interval'!
  663. valueWithTimeout: aNumber
  664. <return setTimeout(self, aNumber)>
  665. !
  666. valueWithInterval: aNumber
  667. <return setInterval(self, aNumber)>
  668. ! !
  669. Object subclass: #Boolean
  670. instanceVariableNames: ''
  671. category: 'Kernel'!
  672. !Boolean methodsFor: 'comparing'!
  673. = aBoolean
  674. <return Boolean(self == true) == aBoolean>
  675. !
  676. asJSONObject
  677. ^self
  678. ! !
  679. !Boolean methodsFor: 'controlling'!
  680. ifTrue: aBlock
  681. "inlined in the Compiler"
  682. ^self ifTrue: aBlock ifFalse: []
  683. !
  684. ifFalse: aBlock
  685. "inlined in the Compiler"
  686. ^self ifTrue: [] ifFalse: aBlock
  687. !
  688. ifFalse: aBlock ifTrue: anotherBlock
  689. "inlined in the Compiler"
  690. ^self ifTrue: anotherBlock ifFalse: aBlock
  691. !
  692. ifTrue: aBlock ifFalse: anotherBlock
  693. "inlined in the Compiler"
  694. <
  695. if(self == true) {
  696. return aBlock();
  697. } else {
  698. return anotherBlock();
  699. }
  700. >
  701. !
  702. and: aBlock
  703. ^self = true
  704. ifTrue: aBlock
  705. ifFalse: [false]
  706. !
  707. or: aBlock
  708. ^self = true
  709. ifTrue: [true]
  710. ifFalse: aBlock
  711. !
  712. not
  713. ^self = false
  714. !
  715. & aBoolean
  716. <
  717. if(self == true) {
  718. return aBoolean;
  719. } else {
  720. return false;
  721. }
  722. >
  723. !
  724. | aBoolean
  725. <
  726. if(self == true) {
  727. return true;
  728. } else {
  729. return aBoolean;
  730. }
  731. >
  732. ! !
  733. !Boolean methodsFor: 'copying'!
  734. shallowCopy
  735. ^self
  736. !
  737. deepCopy
  738. ^self
  739. ! !
  740. !Boolean methodsFor: 'printing'!
  741. printString
  742. <return self.toString()>
  743. ! !
  744. Object subclass: #Date
  745. instanceVariableNames: ''
  746. category: 'Kernel'!
  747. !Date commentStamp!
  748. The Date class is used to work with dates and times.!
  749. !Date methodsFor: 'accessing'!
  750. year
  751. <return self.getFullYear()>
  752. !
  753. month
  754. <return self.getMonth() + 1>
  755. !
  756. month: aNumber
  757. <self.setMonth(aNumber - 1)>
  758. !
  759. day
  760. ^self dayOfWeek
  761. !
  762. dayOfWeek
  763. <return self.getDay() + 1>
  764. !
  765. dayOfWeek: aNumber
  766. <return self.setDay(aNumber - 1)>
  767. !
  768. day: aNumber
  769. self day: aNumber
  770. !
  771. year: aNumber
  772. <self.setFullYear(aNumber)>
  773. !
  774. dayOfMonth
  775. <return self.getDate()>
  776. !
  777. dayOfMonth: aNumber
  778. <self.setDate(aNumber)>
  779. !
  780. time
  781. <return self.getTime()>
  782. !
  783. time: aNumber
  784. <self.setTime(aNumber)>
  785. !
  786. hours: aNumber
  787. <self.setHours(aNumber)>
  788. !
  789. minutes: aNumber
  790. <self.setMinutes(aNumber)>
  791. !
  792. seconds: aNumber
  793. <self.setSeconds(aNumber)>
  794. !
  795. milliseconds: aNumber
  796. <self.setMilliseconds(aNumber)>
  797. !
  798. hours
  799. <return self.getHours()>
  800. !
  801. minutes
  802. <return self.getMinutes()>
  803. !
  804. seconds
  805. <return self.getSeconds()>
  806. !
  807. milliseconds
  808. <return self.getMilliseconds()>
  809. ! !
  810. !Date methodsFor: 'arithmetic'!
  811. - aDate
  812. <return self - aDate>
  813. !
  814. + aDate
  815. <return self + aDate>
  816. ! !
  817. !Date methodsFor: 'comparing'!
  818. < aDate
  819. <return self < aDate>
  820. !
  821. > aDate
  822. <return self >> aDate>
  823. !
  824. <= aDate
  825. <self <= aDate>
  826. !
  827. >= aDate
  828. <self >>= aDate>
  829. ! !
  830. !Date methodsFor: 'converting'!
  831. asString
  832. <return self.toString()>
  833. !
  834. asMilliseconds
  835. ^self time
  836. !
  837. asDateString
  838. <return self.toDateString()>
  839. !
  840. asTimeString
  841. <return self.toTimeString()>
  842. !
  843. asLocaleString
  844. <return self.toLocaleString()>
  845. !
  846. asNumber
  847. ^self asMilliseconds
  848. !
  849. asJSONObject
  850. ^self
  851. ! !
  852. !Date methodsFor: 'printing'!
  853. printString
  854. ^self asString
  855. ! !
  856. !Date class methodsFor: 'instance creation'!
  857. new: anObject
  858. <return new Date(anObject)>
  859. !
  860. fromString: aString
  861. "Example: Date fromString('2011/04/15 00:00:00')"
  862. ^self new: aString
  863. !
  864. fromSeconds: aNumber
  865. ^self fromMilliseconds: aNumber * 1000
  866. !
  867. fromMilliseconds: aNumber
  868. ^self new: aNumber
  869. !
  870. today
  871. ^self new
  872. !
  873. now
  874. ^self today
  875. !
  876. millisecondsToRun: aBlock
  877. | t |
  878. t := Date now.
  879. aBlock value.
  880. ^Date now - t
  881. ! !
  882. Object subclass: #UndefinedObject
  883. instanceVariableNames: ''
  884. category: 'Kernel'!
  885. !UndefinedObject methodsFor: 'class creation'!
  886. subclass: aString instanceVariableNames: anotherString
  887. ^self subclass: aString instanceVariableNames: anotherString module: nil
  888. !
  889. subclass: aString instanceVariableNames: aString2 category: aString3
  890. "Kept for compatibility."
  891. ^self subclass: aString instanceVariableNames: aString2 module: aString3
  892. !
  893. subclass: aString instanceVariableNames: aString2 module: aString3
  894. ^ClassBuilder new
  895. superclass: self subclass: aString instanceVariableNames: aString2 module: aString3
  896. ! !
  897. !UndefinedObject methodsFor: 'copying'!
  898. shallowCopy
  899. ^self
  900. !
  901. deepCopy
  902. ^self
  903. ! !
  904. !UndefinedObject methodsFor: 'printing'!
  905. printString
  906. ^'nil'
  907. ! !
  908. !UndefinedObject methodsFor: 'testing'!
  909. ifNil: aBlock
  910. "inlined in the Compiler"
  911. ^self ifNil: aBlock ifNotNil: []
  912. !
  913. ifNotNil: aBlock
  914. "inlined in the Compiler"
  915. ^self
  916. !
  917. ifNil: aBlock ifNotNil: anotherBlock
  918. "inlined in the Compiler"
  919. ^aBlock value
  920. !
  921. ifNotNil: aBlock ifNil: anotherBlock
  922. "inlined in the Compiler"
  923. ^anotherBlock value
  924. !
  925. isNil
  926. ^true
  927. !
  928. notNil
  929. ^false
  930. ! !
  931. !UndefinedObject class methodsFor: 'instance creation'!
  932. new
  933. self error: 'You cannot create new instances of UndefinedObject. Use nil'
  934. ! !
  935. Object subclass: #Collection
  936. instanceVariableNames: ''
  937. category: 'Kernel'!
  938. !Collection methodsFor: 'accessing'!
  939. size
  940. self subclassResponsibility
  941. !
  942. readStream
  943. ^self stream
  944. !
  945. writeStream
  946. ^self stream
  947. !
  948. stream
  949. ^self streamClass on: self
  950. !
  951. streamClass
  952. ^self class streamClass
  953. ! !
  954. !Collection methodsFor: 'adding/removing'!
  955. add: anObject
  956. self subclassResponsibility
  957. !
  958. addAll: aCollection
  959. aCollection do: [:each |
  960. self add: each].
  961. ^aCollection
  962. !
  963. remove: anObject
  964. self subclassResponsibility
  965. ! !
  966. !Collection methodsFor: 'converting'!
  967. asArray
  968. | array index |
  969. array := Array new.
  970. index := 0.
  971. self do: [:each |
  972. index := index + 1.
  973. array at: index put: each].
  974. ^array
  975. ! !
  976. !Collection methodsFor: 'copying'!
  977. , aCollection
  978. ^self copy
  979. addAll: aCollection;
  980. yourself
  981. !
  982. copyWith: anObject
  983. ^self copy add: anObject; yourself
  984. !
  985. copyWithAll: aCollection
  986. ^self copy addAll: aCollection; yourself
  987. ! !
  988. !Collection methodsFor: 'enumerating'!
  989. do: aBlock
  990. <for(var i=0;i<self.length;i++){aBlock(self[i]);}>
  991. !
  992. collect: aBlock
  993. | newCollection |
  994. newCollection := self class new.
  995. self do: [:each |
  996. newCollection add: (aBlock value: each)].
  997. ^newCollection
  998. !
  999. detect: aBlock
  1000. ^self detect: aBlock ifNone: [self errorNotFound]
  1001. !
  1002. detect: aBlock ifNone: anotherBlock
  1003. <
  1004. for(var i = 0; i < self.length; i++)
  1005. if(aBlock(self[i]))
  1006. return self[i];
  1007. return anotherBlock();
  1008. >
  1009. !
  1010. do: aBlock separatedBy: anotherBlock
  1011. | first |
  1012. first := true.
  1013. self do: [:each |
  1014. first
  1015. ifTrue: [first := false]
  1016. ifFalse: [anotherBlock value].
  1017. aBlock value: each]
  1018. !
  1019. inject: anObject into: aBlock
  1020. | result |
  1021. result := anObject.
  1022. self do: [:each |
  1023. result := aBlock value: result value: each].
  1024. ^result
  1025. !
  1026. reject: aBlock
  1027. ^self select: [:each | (aBlock value: each) = false]
  1028. !
  1029. select: aBlock
  1030. | stream |
  1031. stream := self class new writeStream.
  1032. self do: [:each |
  1033. (aBlock value: each) ifTrue: [
  1034. stream nextPut: each]].
  1035. ^stream contents
  1036. ! !
  1037. !Collection methodsFor: 'error handling'!
  1038. errorNotFound
  1039. self error: 'Object is not in the collection'
  1040. ! !
  1041. !Collection methodsFor: 'testing'!
  1042. includes: anObject
  1043. <
  1044. var i = self.length;
  1045. while (i--) {
  1046. if (smalltalk.send(self[i], "__eq", [anObject])) {return true;}
  1047. }
  1048. return false
  1049. >
  1050. !
  1051. notEmpty
  1052. ^self isEmpty not
  1053. !
  1054. isEmpty
  1055. ^self size = 0
  1056. ! !
  1057. !Collection class methodsFor: 'accessing'!
  1058. streamClass
  1059. ^Stream
  1060. ! !
  1061. !Collection class methodsFor: 'instance creation'!
  1062. with: anObject
  1063. ^self new
  1064. add: anObject;
  1065. yourself
  1066. !
  1067. with: anObject with: anotherObject
  1068. ^self new
  1069. add: anObject;
  1070. add: anotherObject;
  1071. yourself
  1072. !
  1073. with: firstObject with: secondObject with: thirdObject
  1074. ^self new
  1075. add: firstObject;
  1076. add: secondObject;
  1077. add: thirdObject;
  1078. yourself
  1079. !
  1080. withAll: aCollection
  1081. ^self new
  1082. addAll: aCollection;
  1083. yourself
  1084. ! !
  1085. Collection subclass: #SequenceableCollection
  1086. instanceVariableNames: ''
  1087. category: 'Kernel'!
  1088. !SequenceableCollection methodsFor: 'accessing'!
  1089. at: anIndex
  1090. ^self at: anIndex ifAbsent: [
  1091. self errorNotFound]
  1092. !
  1093. at: anIndex ifAbsent: aBlock
  1094. self subclassResponsibility
  1095. !
  1096. at: anIndex put: anObject
  1097. self subclassResponsibility
  1098. !
  1099. first
  1100. ^self at: 1
  1101. !
  1102. fourth
  1103. ^self at: 4
  1104. !
  1105. last
  1106. ^self at: self size
  1107. !
  1108. second
  1109. ^self at: 2
  1110. !
  1111. third
  1112. ^self at: 3
  1113. !
  1114. allButFirst
  1115. ^self copyFrom: 2 to: self size
  1116. !
  1117. allButLast
  1118. ^self copyFrom: 1 to: self size - 1
  1119. !
  1120. indexOf: anObject
  1121. ^self indexOf: anObject ifAbsent: [self errorNotFound]
  1122. !
  1123. indexOf: anObject ifAbsent: aBlock
  1124. <
  1125. for(var i=0;i<self.length;i++){
  1126. if(self[i].__eq(anObject)) {return i+1}
  1127. }
  1128. return aBlock();
  1129. >
  1130. !
  1131. indexOf: anObject startingAt: start ifAbsent: aBlock
  1132. <
  1133. for(var i=start-1;i<self.length;i++){
  1134. if(self[i].__eq(anObject)) {return i+1}
  1135. }
  1136. return aBlock();
  1137. >
  1138. !
  1139. indexOf: anObject startingAt: start
  1140. "Answer the index of the first occurence of anElement after start
  1141. within the receiver. If the receiver does not contain anElement,
  1142. answer 0."
  1143. ^self indexOf: anObject startingAt: start ifAbsent: [0]
  1144. ! !
  1145. !SequenceableCollection methodsFor: 'adding'!
  1146. removeLast
  1147. self remove: self last
  1148. !
  1149. addLast: anObject
  1150. self add: anObject
  1151. ! !
  1152. !SequenceableCollection methodsFor: 'converting'!
  1153. reversed
  1154. self subclassResponsibility
  1155. ! !
  1156. !SequenceableCollection methodsFor: 'copying'!
  1157. copyFrom: anIndex to: anotherIndex
  1158. self subclassResponsibility
  1159. ! !
  1160. !SequenceableCollection methodsFor: 'enumerating'!
  1161. withIndexDo: aBlock
  1162. <for(var i=0;i<self.length;i++){aBlock(self[i], i+1);}>
  1163. ! !
  1164. SequenceableCollection subclass: #String
  1165. instanceVariableNames: ''
  1166. category: 'Kernel'!
  1167. !String methodsFor: 'accessing'!
  1168. size
  1169. <return self.length>
  1170. !
  1171. at: anIndex
  1172. <return self[anIndex - 1]>
  1173. !
  1174. at: anIndex put: anObject
  1175. self errorReadOnly
  1176. !
  1177. at: anIndex ifAbsent: aBlock
  1178. (self at: anIndex) ifNil: [aBlock]
  1179. !
  1180. escaped
  1181. <return escape(self)>
  1182. !
  1183. unescaped
  1184. <return unescape(self)>
  1185. !
  1186. asciiValue
  1187. <return self.charCodeAt(0);>
  1188. ! !
  1189. !String methodsFor: 'adding'!
  1190. add: anObject
  1191. self errorReadOnly
  1192. !
  1193. remove: anObject
  1194. self errorReadOnly
  1195. ! !
  1196. !String methodsFor: 'comparing'!
  1197. = aString
  1198. <return String(self) == aString>
  1199. !
  1200. > aString
  1201. <return String(self) >> aString>
  1202. !
  1203. < aString
  1204. <return String(self) < aString>
  1205. !
  1206. >= aString
  1207. <return String(self) >>= aString>
  1208. !
  1209. <= aString
  1210. <return String(self) <= aString>
  1211. ! !
  1212. !String methodsFor: 'converting'!
  1213. asSelector
  1214. "If you change this method, change smalltalk.convertSelector too (see js/boot.js file)"
  1215. | selector |
  1216. selector := '_', self.
  1217. selector := selector replace: ':' with: '_'.
  1218. selector := selector replace: '[+]' with: '_plus'.
  1219. selector := selector replace: '-' with: '_minus'.
  1220. selector := selector replace: '[*]' with: '_star'.
  1221. selector := selector replace: '[/]' with: '_slash'.
  1222. selector := selector replace: '>' with: '_gt'.
  1223. selector := selector replace: '<' with: '_lt'.
  1224. selector := selector replace: '=' with: '_eq'.
  1225. selector := selector replace: ',' with: '_comma'.
  1226. selector := selector replace: '[@]' with: '_at'.
  1227. ^selector
  1228. !
  1229. asJavascript
  1230. <
  1231. if(self.search(/^[a-zA-Z0-9_:.$ ]*$/) == -1)
  1232. return "unescape(\"" + escape(self) + "\")";
  1233. else
  1234. return "\"" + self + "\"";
  1235. >
  1236. !
  1237. tokenize: aString
  1238. <return self.split(aString)>
  1239. !
  1240. asString
  1241. ^self
  1242. !
  1243. asNumber
  1244. <return Number(self)>
  1245. !
  1246. asJSONObject
  1247. ^self
  1248. !
  1249. asLowercase
  1250. <return self.toLowerCase()>
  1251. !
  1252. asUppercase
  1253. <return self.toUpperCase()>
  1254. !
  1255. reversed
  1256. <return self.split("").reverse().join("")>
  1257. ! !
  1258. !String methodsFor: 'copying'!
  1259. , aString
  1260. <return self + aString>
  1261. !
  1262. copyFrom: anIndex to: anotherIndex
  1263. <return self.substring(anIndex - 1, anotherIndex)>
  1264. !
  1265. shallowCopy
  1266. ^self class fromString: self
  1267. !
  1268. deepCopy
  1269. ^self shallowCopy
  1270. ! !
  1271. !String methodsFor: 'error handling'!
  1272. errorReadOnly
  1273. self error: 'Object is read-only'
  1274. ! !
  1275. !String methodsFor: 'printing'!
  1276. printString
  1277. ^'''', self, ''''
  1278. !
  1279. printNl
  1280. <console.log(self)>
  1281. ! !
  1282. !String methodsFor: 'regular expressions'!
  1283. replace: aString with: anotherString
  1284. ^self replaceRegexp: (RegularExpression fromString: aString flag: 'g') with: anotherString
  1285. !
  1286. replaceRegexp: aRegexp with: aString
  1287. <return self.replace(aRegexp, aString)>
  1288. !
  1289. match: aRegexp
  1290. <return self.search(aRegexp) !!= -1>
  1291. !
  1292. trimLeft: separators
  1293. ^self replaceRegexp: (RegularExpression fromString: '^[', separators, ']+' flag: 'g') with: ''
  1294. !
  1295. trimRight: separators
  1296. ^self replaceRegexp: (RegularExpression fromString: '[', separators, ']+$' flag: 'g') with: ''
  1297. !
  1298. trimLeft
  1299. ^self trimLeft: '\s'
  1300. !
  1301. trimRight
  1302. ^self trimRight: '\s'
  1303. !
  1304. trimBoth
  1305. ^self trimBoth: '\s'
  1306. !
  1307. trimBoth: separators
  1308. ^(self trimLeft: separators) trimRight: separators
  1309. ! !
  1310. !String methodsFor: 'split join'!
  1311. join: aCollection
  1312. ^ String
  1313. streamContents: [:stream | aCollection
  1314. do: [:each | stream nextPutAll: each asString]
  1315. separatedBy: [stream nextPutAll: self]]
  1316. !
  1317. lineIndicesDo: aBlock
  1318. "execute aBlock with 3 arguments for each line:
  1319. - start index of line
  1320. - end index of line without line delimiter
  1321. - end index of line including line delimiter(s) CR, LF or CRLF"
  1322. | cr lf start sz nextLF nextCR |
  1323. start := 1.
  1324. sz := self size.
  1325. cr := String cr.
  1326. nextCR := self indexOf: cr startingAt: 1.
  1327. lf := String lf.
  1328. nextLF := self indexOf: lf startingAt: 1.
  1329. [ start <= sz ] whileTrue: [
  1330. (nextLF = 0 and: [ nextCR = 0 ])
  1331. ifTrue: [ "No more CR, nor LF, the string is over"
  1332. aBlock value: start value: sz value: sz.
  1333. ^self ].
  1334. (nextCR = 0 or: [ 0 < nextLF and: [ nextLF < nextCR ] ])
  1335. ifTrue: [ "Found a LF"
  1336. aBlock value: start value: nextLF - 1 value: nextLF.
  1337. start := 1 + nextLF.
  1338. nextLF := self indexOf: lf startingAt: start ]
  1339. ifFalse: [ 1 + nextCR = nextLF
  1340. ifTrue: [ "Found a CR-LF pair"
  1341. aBlock value: start value: nextCR - 1 value: nextLF.
  1342. start := 1 + nextLF.
  1343. nextCR := self indexOf: cr startingAt: start.
  1344. nextLF := self indexOf: lf startingAt: start ]
  1345. ifFalse: [ "Found a CR"
  1346. aBlock value: start value: nextCR - 1 value: nextCR.
  1347. start := 1 + nextCR.
  1348. nextCR := self indexOf: cr startingAt: start ]]]
  1349. !
  1350. linesDo: aBlock
  1351. "Execute aBlock with each line in this string. The terminating line
  1352. delimiters CR, LF or CRLF pairs are not included in what is passed to aBlock"
  1353. self lineIndicesDo: [:start :endWithoutDelimiters :end |
  1354. aBlock value: (self copyFrom: start to: endWithoutDelimiters)]
  1355. !
  1356. lines
  1357. "Answer an array of lines composing this receiver without the line ending delimiters."
  1358. | lines |
  1359. lines := Array new.
  1360. self linesDo: [:aLine | lines add: aLine].
  1361. ^lines
  1362. !
  1363. lineNumber: anIndex
  1364. "Answer a string containing the characters in the given line number."
  1365. | lineCount |
  1366. lineCount := 0.
  1367. self lineIndicesDo: [:start :endWithoutDelimiters :end |
  1368. (lineCount := lineCount + 1) = anIndex ifTrue: [^self copyFrom: start to: endWithoutDelimiters]].
  1369. ^nil
  1370. ! !
  1371. !String methodsFor: 'testing'!
  1372. isString
  1373. ^true
  1374. !
  1375. includesSubString: subString
  1376. < return self.indexOf(subString) !!= -1 >
  1377. ! !
  1378. !String class methodsFor: 'accessing'!
  1379. streamClass
  1380. ^StringStream
  1381. !
  1382. cr
  1383. <return '\r'>
  1384. !
  1385. lf
  1386. <return '\n'>
  1387. !
  1388. space
  1389. <return ' '>
  1390. !
  1391. tab
  1392. <return '\t'>
  1393. !
  1394. crlf
  1395. <return '\r\n'>
  1396. ! !
  1397. !String class methodsFor: 'instance creation'!
  1398. fromString: aString
  1399. <return new self.fn(aString)>
  1400. !
  1401. streamContents: blockWithArg
  1402. |stream|
  1403. stream := (self streamClass on: String new).
  1404. blockWithArg value: stream.
  1405. ^ stream contents
  1406. !
  1407. value: aUTFCharCode
  1408. <return String.fromCharCode(aUTFCharCode);>
  1409. ! !
  1410. SequenceableCollection subclass: #Array
  1411. instanceVariableNames: ''
  1412. category: 'Kernel'!
  1413. !Array methodsFor: 'accessing'!
  1414. size
  1415. <return self.length>
  1416. !
  1417. at: anIndex put: anObject
  1418. <return self[anIndex - 1] = anObject>
  1419. !
  1420. at: anIndex ifAbsent: aBlock
  1421. <
  1422. var value = self[anIndex - 1];
  1423. if(value === undefined) {
  1424. return aBlock();
  1425. } else {
  1426. return value;
  1427. }
  1428. >
  1429. ! !
  1430. !Array methodsFor: 'adding/removing'!
  1431. add: anObject
  1432. <self.push(anObject); return anObject;>
  1433. !
  1434. remove: anObject
  1435. <
  1436. for(var i=0;i<self.length;i++) {
  1437. if(self[i] == anObject) {
  1438. self.splice(i,1);
  1439. break;
  1440. }
  1441. }
  1442. >
  1443. !
  1444. removeFrom: aNumber to: anotherNumber
  1445. <self.splice(aNumber - 1,anotherNumber - 1)>
  1446. ! !
  1447. !Array methodsFor: 'converting'!
  1448. asJavascript
  1449. ^'[', ((self collect: [:each | each asJavascript]) join: ', '), ']'
  1450. !
  1451. asJSONObject
  1452. ^self collect: [:each | each asJSONObject]
  1453. !
  1454. reversed
  1455. <return self._copy().reverse()>
  1456. ! !
  1457. !Array methodsFor: 'copying'!
  1458. shallowCopy
  1459. | newCollection |
  1460. newCollection := self class new.
  1461. self do: [:each | newCollection add: each].
  1462. ^newCollection
  1463. !
  1464. deepCopy
  1465. | newCollection |
  1466. newCollection := self class new.
  1467. self do: [:each | newCollection add: each deepCopy].
  1468. ^newCollection
  1469. !
  1470. copyFrom: anIndex to: anotherIndex
  1471. | array |
  1472. array := self class new.
  1473. anIndex to: anotherIndex do: [:each |
  1474. array add: (self at: each)].
  1475. ^array
  1476. ! !
  1477. !Array methodsFor: 'enumerating'!
  1478. join: aString
  1479. <return self.join(aString)>
  1480. !
  1481. sort
  1482. ^self basicPerform: 'sort'
  1483. !
  1484. sort: aBlock
  1485. <
  1486. return self.sort(function(a, b) {
  1487. if(aBlock(a,b)) {return -1} else {return 1}
  1488. })
  1489. >
  1490. !
  1491. sorted
  1492. ^self copy sort
  1493. !
  1494. sorted: aBlock
  1495. ^self copy sort: aBlock
  1496. !
  1497. printString
  1498. | str |
  1499. str := '' writeStream.
  1500. str nextPutAll: super printString, ' ('.
  1501. self
  1502. do: [:each | str nextPutAll: each printString]
  1503. separatedBy: [str nextPutAll: ' '].
  1504. str nextPutAll: ')'.
  1505. ^str contents
  1506. ! !
  1507. Object subclass: #RegularExpression
  1508. instanceVariableNames: ''
  1509. category: 'Kernel'!
  1510. !RegularExpression methodsFor: 'evaluating'!
  1511. compile: aString
  1512. <return self.compile(aString)>
  1513. !
  1514. exec: aString
  1515. <return self.exec(aString) || nil>
  1516. !
  1517. test: aString
  1518. <return self.test(aString)>
  1519. ! !
  1520. !RegularExpression class methodsFor: 'instance creation'!
  1521. fromString: aString flag: anotherString
  1522. <return new RegExp(aString, anotherString)>
  1523. !
  1524. fromString: aString
  1525. ^self fromString: aString flag: ''
  1526. ! !
  1527. Object subclass: #Error
  1528. instanceVariableNames: 'messageText'
  1529. category: 'Kernel'!
  1530. !Error methodsFor: 'accessing'!
  1531. messageText
  1532. ^messageText
  1533. !
  1534. messageText: aString
  1535. messageText := aString
  1536. !
  1537. context
  1538. <return self.context>
  1539. ! !
  1540. !Error methodsFor: 'signaling'!
  1541. signal
  1542. <self.context = thisContext; self.smalltalkError = true; throw(self)>
  1543. ! !
  1544. !Error class methodsFor: 'instance creation'!
  1545. signal: aString
  1546. ^self new
  1547. messageText: aString;
  1548. signal
  1549. ! !
  1550. Object subclass: #MethodContext
  1551. instanceVariableNames: ''
  1552. category: 'Kernel'!
  1553. !MethodContext methodsFor: 'accessing'!
  1554. receiver
  1555. <return self.receiver>
  1556. !
  1557. selector
  1558. <return smalltalk.convertSelector(self.selector)>
  1559. !
  1560. home
  1561. <return self.homeContext>
  1562. !
  1563. temps
  1564. <return self.temps>
  1565. !
  1566. printString
  1567. ^super printString, '(', self asString, ')'
  1568. !
  1569. asString
  1570. ^self receiver class printString, ' >> ', self selector
  1571. ! !
  1572. Object subclass: #Association
  1573. instanceVariableNames: 'key value'
  1574. category: 'Kernel'!
  1575. !Association methodsFor: 'accessing'!
  1576. key: aKey
  1577. key := aKey
  1578. !
  1579. key
  1580. ^key
  1581. !
  1582. value: aValue
  1583. value := aValue
  1584. !
  1585. value
  1586. ^value
  1587. ! !
  1588. !Association methodsFor: 'comparing'!
  1589. = anAssociation
  1590. ^self class = anAssociation class and: [
  1591. self key = anAssociation key and: [
  1592. self value = anAssociation value]]
  1593. ! !
  1594. !Association class methodsFor: 'instance creation'!
  1595. key: aKey value: aValue
  1596. ^self new
  1597. key: aKey;
  1598. value: aValue;
  1599. yourself
  1600. ! !
  1601. Collection subclass: #Dictionary
  1602. instanceVariableNames: 'keys'
  1603. category: 'Kernel'!
  1604. !Dictionary methodsFor: 'accessing'!
  1605. size
  1606. ^keys size
  1607. !
  1608. associations
  1609. | associations |
  1610. associations := #().
  1611. keys do: [:each |
  1612. associations add: (Association key: each value: (self at: each))].
  1613. ^associations
  1614. !
  1615. keys
  1616. ^keys copy
  1617. !
  1618. values
  1619. ^keys collect: [:each | self at: each]
  1620. !
  1621. at: aKey put: aValue
  1622. (keys includes: aKey) ifFalse: [keys add: aKey].
  1623. ^self basicAt: aKey put: aValue
  1624. !
  1625. at: aKey ifAbsent: aBlock
  1626. ^(self keys includes: aKey)
  1627. ifTrue: [self basicAt: aKey]
  1628. ifFalse: aBlock
  1629. !
  1630. at: aKey ifAbsentPut: aBlock
  1631. ^self at: aKey ifAbsent: [
  1632. self at: aKey put: aBlock value]
  1633. !
  1634. at: aKey ifPresent: aBlock
  1635. ^(self basicAt: aKey) ifNotNil: [aBlock value: (self at: aKey)]
  1636. !
  1637. at: aKey ifPresent: aBlock ifAbsent: anotherBlock
  1638. ^(self basicAt: aKey)
  1639. ifNil: anotherBlock
  1640. ifNotNil: [aBlock value: (self at: aKey)]
  1641. !
  1642. at: aKey
  1643. ^self at: aKey ifAbsent: [self errorNotFound]
  1644. ! !
  1645. !Dictionary methodsFor: 'adding/removing'!
  1646. add: anAssociation
  1647. self at: anAssociation key put: anAssociation value
  1648. !
  1649. addAll: aDictionary
  1650. super addAll: aDictionary associations.
  1651. ^aDictionary
  1652. !
  1653. remove: aKey
  1654. self removeKey: aKey
  1655. !
  1656. removeKey: aKey
  1657. keys remove: aKey
  1658. ! !
  1659. !Dictionary methodsFor: 'comparing'!
  1660. = aDictionary
  1661. self class = aDictionary class ifFalse: [^false].
  1662. self associationsDo: [:assoc |
  1663. (aDictionary at: assoc key ifAbsent: [^false]) = assoc value
  1664. ifFalse: [^false]].
  1665. ^true
  1666. ! !
  1667. !Dictionary methodsFor: 'converting'!
  1668. asJSONObject
  1669. | object |
  1670. object := Object new.
  1671. self keysAndValuesDo: [:key :value |
  1672. object basicAt: key put: value asJSONObject].
  1673. ^object
  1674. ! !
  1675. !Dictionary methodsFor: 'copying'!
  1676. shallowCopy
  1677. | copy |
  1678. copy := self class new.
  1679. self associationsDo: [:each |
  1680. copy at: each key put: each value].
  1681. ^copy
  1682. !
  1683. , aCollection
  1684. self shouldNotImplement
  1685. !
  1686. copyFrom: anIndex to: anotherIndex
  1687. self shouldNotImplement
  1688. ! !
  1689. !Dictionary methodsFor: 'enumerating'!
  1690. associationsDo: aBlock
  1691. self associations do: aBlock
  1692. !
  1693. keysAndValuesDo: aBlock
  1694. self associationsDo: [:each |
  1695. aBlock value: each key value: each value]
  1696. !
  1697. do: aBlock
  1698. self values do: aBlock
  1699. !
  1700. select: aBlock
  1701. | newDict |
  1702. newDict := self class new.
  1703. self keysAndValuesDo: [:key :value |
  1704. (aBlock value: value) ifTrue: [newDict at: key put: value]].
  1705. ^newDict
  1706. !
  1707. collect: aBlock
  1708. | newDict |
  1709. newDict := self class new.
  1710. self keysAndValuesDo: [:key :value |
  1711. newDict at: key put: (aBlock value: value)].
  1712. ^newDict
  1713. !
  1714. detect: aBlock ifNone: anotherBlock
  1715. ^self values detect: aBlock ifNone: anotherBlock
  1716. !
  1717. includes: anObject
  1718. ^self values includes: anObject
  1719. ! !
  1720. !Dictionary methodsFor: 'initialization'!
  1721. initialize
  1722. super initialize.
  1723. keys := #()
  1724. ! !
  1725. !Dictionary methodsFor: 'printing'!
  1726. printString
  1727. ^ String streamContents: [:aStream|
  1728. aStream
  1729. nextPutAll: super printString;
  1730. nextPutAll: '('.
  1731. self associations
  1732. do: [:anAssociation|
  1733. aStream
  1734. nextPutAll: anAssociation key printString;
  1735. nextPutAll: ' -> ';
  1736. nextPutAll: anAssociation value printString]
  1737. separatedBy: [aStream nextPutAll: ' , '].
  1738. aStream nextPutAll: ')'.
  1739. ]
  1740. ! !
  1741. !Dictionary class methodsFor: 'instance creation'!
  1742. fromPairs: aCollection
  1743. | dict |
  1744. dict := self new.
  1745. aCollection do: [:each | dict add: each].
  1746. ^dict
  1747. ! !
  1748. Object subclass: #ClassBuilder
  1749. instanceVariableNames: ''
  1750. category: 'Kernel'!
  1751. !ClassBuilder methodsFor: 'class creation'!
  1752. superclass: aClass subclass: aString
  1753. ^self superclass: aClass subclass: aString instanceVariableNames: '' module: nil
  1754. !
  1755. class: aClass instanceVariableNames: aString
  1756. aClass isMetaclass ifFalse: [self error: aClass name, ' is not a metaclass'].
  1757. aClass basicAt: 'iVarNames' put: (self instanceVariableNamesFor: aString).
  1758. self setupClass: aClass
  1759. !
  1760. superclass: aClass subclass: aString instanceVariableNames: aString2 module: aString3
  1761. | newClass |
  1762. newClass := self addSubclassOf: aClass
  1763. named: aString instanceVariableNames: (self instanceVariableNamesFor: aString2)
  1764. module: (aString3 ifNil: ['unclassified']).
  1765. self setupClass: newClass
  1766. ! !
  1767. !ClassBuilder methodsFor: 'private'!
  1768. instanceVariableNamesFor: aString
  1769. ^(aString tokenize: ' ') reject: [:each | each isEmpty]
  1770. !
  1771. addSubclassOf: aClass named: aString instanceVariableNames: aCollection
  1772. <smalltalk.addClass(aString, aClass, aCollection);
  1773. return smalltalk[aString]>
  1774. !
  1775. setupClass: aClass
  1776. <smalltalk.init(aClass);>
  1777. !
  1778. addSubclassOf: aClass named: aString instanceVariableNames: aCollection module: moduleName
  1779. <smalltalk.addClass(aString, aClass, aCollection, moduleName);
  1780. return smalltalk[aString]>
  1781. ! !
  1782. Object subclass: #ClassCategoryReader
  1783. instanceVariableNames: 'class category chunkParser'
  1784. category: 'Kernel'!
  1785. !ClassCategoryReader methodsFor: 'accessing'!
  1786. class: aClass category: aString
  1787. class := aClass.
  1788. category := aString
  1789. ! !
  1790. !ClassCategoryReader methodsFor: 'fileIn'!
  1791. scanFrom: aChunkParser
  1792. | chunk |
  1793. [chunk := aChunkParser nextChunk.
  1794. chunk isEmpty] whileFalse: [
  1795. self compileMethod: chunk]
  1796. ! !
  1797. !ClassCategoryReader methodsFor: 'initialization'!
  1798. initialize
  1799. super initialize.
  1800. chunkParser := ChunkParser new.
  1801. ! !
  1802. !ClassCategoryReader methodsFor: 'private'!
  1803. compileMethod: aString
  1804. | method |
  1805. method := Compiler new load: aString forClass: class.
  1806. method category: category.
  1807. class addCompiledMethod: method
  1808. ! !
  1809. Object subclass: #Stream
  1810. instanceVariableNames: 'collection position streamSize'
  1811. category: 'Kernel'!
  1812. !Stream methodsFor: 'accessing'!
  1813. collection
  1814. ^collection
  1815. !
  1816. setCollection: aCollection
  1817. collection := aCollection
  1818. !
  1819. position
  1820. ^position ifNil: [position := 0]
  1821. !
  1822. position: anInteger
  1823. position := anInteger
  1824. !
  1825. streamSize
  1826. ^streamSize
  1827. !
  1828. setStreamSize: anInteger
  1829. streamSize := anInteger
  1830. !
  1831. contents
  1832. ^self collection
  1833. copyFrom: 1
  1834. to: self streamSize
  1835. !
  1836. size
  1837. ^self streamSize
  1838. ! !
  1839. !Stream methodsFor: 'actions'!
  1840. reset
  1841. self position: 0
  1842. !
  1843. close
  1844. !
  1845. flush
  1846. !
  1847. resetContents
  1848. self reset.
  1849. self setStreamSize: 0
  1850. ! !
  1851. !Stream methodsFor: 'enumerating'!
  1852. do: aBlock
  1853. [self atEnd] whileFalse: [aBlock value: self next]
  1854. ! !
  1855. !Stream methodsFor: 'positioning'!
  1856. setToEnd
  1857. self position: self size
  1858. !
  1859. skip: anInteger
  1860. self position: ((self position + anInteger) min: self size max: 0)
  1861. ! !
  1862. !Stream methodsFor: 'reading'!
  1863. next
  1864. self position: self position + 1.
  1865. ^collection at: self position
  1866. !
  1867. next: anInteger
  1868. | tempCollection |
  1869. tempCollection := self collection class new.
  1870. anInteger timesRepeat: [
  1871. self atEnd ifFalse: [
  1872. tempCollection add: self next]].
  1873. ^tempCollection
  1874. !
  1875. peek
  1876. ^self atEnd ifFalse: [
  1877. self collection at: self position + 1]
  1878. ! !
  1879. !Stream methodsFor: 'testing'!
  1880. atEnd
  1881. ^self position = self size
  1882. !
  1883. atStart
  1884. ^self position = 0
  1885. !
  1886. isEmpty
  1887. ^self size = 0
  1888. ! !
  1889. !Stream methodsFor: 'writing'!
  1890. nextPut: anObject
  1891. self position: self position + 1.
  1892. self collection at: self position put: anObject.
  1893. self setStreamSize: (self streamSize max: self position)
  1894. !
  1895. nextPutAll: aCollection
  1896. aCollection do: [:each |
  1897. self nextPut: each]
  1898. ! !
  1899. !Stream class methodsFor: 'instance creation'!
  1900. on: aCollection
  1901. ^self new
  1902. setCollection: aCollection;
  1903. setStreamSize: aCollection size;
  1904. yourself
  1905. ! !
  1906. Stream subclass: #StringStream
  1907. instanceVariableNames: ''
  1908. category: 'Kernel'!
  1909. !StringStream methodsFor: 'reading'!
  1910. next: anInteger
  1911. | tempCollection |
  1912. tempCollection := self collection class new.
  1913. anInteger timesRepeat: [
  1914. self atEnd ifFalse: [
  1915. tempCollection := tempCollection, self next]].
  1916. ^tempCollection
  1917. ! !
  1918. !StringStream methodsFor: 'writing'!
  1919. nextPut: aString
  1920. self nextPutAll: aString
  1921. !
  1922. nextPutAll: aString
  1923. self setCollection:
  1924. (self collection copyFrom: 1 to: self position),
  1925. aString,
  1926. (self collection copyFrom: (self position + 1 + aString size) to: self collection size).
  1927. self position: self position + aString size.
  1928. self setStreamSize: (self streamSize max: self position)
  1929. !
  1930. cr
  1931. ^self nextPutAll: String cr
  1932. !
  1933. crlf
  1934. ^self nextPutAll: String crlf
  1935. !
  1936. lf
  1937. ^self nextPutAll: String lf
  1938. !
  1939. space
  1940. self nextPut: ' '
  1941. ! !
  1942. Object subclass: #ClassCommentReader
  1943. instanceVariableNames: 'class chunkParser'
  1944. category: 'Kernel'!
  1945. !ClassCommentReader methodsFor: 'accessing'!
  1946. class: aClass
  1947. class := aClass
  1948. ! !
  1949. !ClassCommentReader methodsFor: 'fileIn'!
  1950. scanFrom: aChunkParser
  1951. | chunk |
  1952. chunk := aChunkParser nextChunk.
  1953. chunk isEmpty ifFalse: [
  1954. self setComment: chunk].
  1955. ! !
  1956. !ClassCommentReader methodsFor: 'initialization'!
  1957. initialize
  1958. super initialize.
  1959. chunkParser := ChunkParser new.
  1960. ! !
  1961. !ClassCommentReader methodsFor: 'private'!
  1962. setComment: aString
  1963. class comment: aString
  1964. ! !
  1965. Object subclass: #Random
  1966. instanceVariableNames: ''
  1967. category: 'Kernel'!
  1968. !Random methodsFor: 'accessing'!
  1969. next
  1970. <return Math.random()>
  1971. !
  1972. next: anInteger
  1973. ^1 to: anInteger collect: [:each | self next]
  1974. ! !
  1975. Object subclass: #Point
  1976. instanceVariableNames: 'x y'
  1977. category: 'Kernel'!
  1978. !Point methodsFor: 'accessing'!
  1979. x
  1980. ^x
  1981. !
  1982. y
  1983. ^y
  1984. !
  1985. y: aNumber
  1986. y := aNumber
  1987. !
  1988. x: aNumber
  1989. x := aNumber
  1990. ! !
  1991. !Point methodsFor: 'arithmetic'!
  1992. * aPoint
  1993. ^Point x: self x * aPoint asPoint x y: self y * aPoint asPoint y
  1994. !
  1995. + aPoint
  1996. ^Point x: self x + aPoint asPoint x y: self y + aPoint asPoint y
  1997. !
  1998. - aPoint
  1999. ^Point x: self x - aPoint asPoint x y: self y - aPoint asPoint y
  2000. !
  2001. / aPoint
  2002. ^Point x: self x / aPoint asPoint x y: self y / aPoint asPoint y
  2003. ! !
  2004. !Point methodsFor: 'converting'!
  2005. asPoint
  2006. ^self
  2007. ! !
  2008. !Point class methodsFor: 'instance creation'!
  2009. x: aNumber y: anotherNumber
  2010. ^self new
  2011. x: aNumber;
  2012. y: anotherNumber;
  2013. yourself
  2014. ! !
  2015. Object subclass: #Message
  2016. instanceVariableNames: 'selector arguments'
  2017. category: 'Kernel'!
  2018. !Message methodsFor: 'accessing'!
  2019. selector
  2020. ^selector
  2021. !
  2022. selector: aString
  2023. selector := aString
  2024. !
  2025. arguments: anArray
  2026. arguments := anArray
  2027. !
  2028. arguments
  2029. ^arguments
  2030. ! !
  2031. !Message class methodsFor: 'instance creation'!
  2032. selector: aString arguments: anArray
  2033. ^self new
  2034. selector: aString;
  2035. arguments: anArray;
  2036. yourself
  2037. ! !
  2038. Error subclass: #MessageNotUnderstood
  2039. instanceVariableNames: 'message receiver'
  2040. category: 'Kernel'!
  2041. !MessageNotUnderstood methodsFor: 'accessing'!
  2042. message
  2043. ^message
  2044. !
  2045. message: aMessage
  2046. message := aMessage
  2047. !
  2048. receiver
  2049. ^receiver
  2050. !
  2051. receiver: anObject
  2052. receiver := anObject
  2053. !
  2054. messageText
  2055. ^self receiver asString, ' does not understand #', self message selector
  2056. ! !
  2057. Object subclass: #ErrorHandler
  2058. instanceVariableNames: ''
  2059. category: 'Kernel'!
  2060. !ErrorHandler methodsFor: 'error handling'!
  2061. handleError: anError
  2062. anError context ifNotNil: [self logErrorContext: anError context].
  2063. self logError: anError
  2064. ! !
  2065. !ErrorHandler methodsFor: 'private'!
  2066. logContext: aContext
  2067. aContext home ifNotNil: [
  2068. self logContext: aContext home].
  2069. self log: aContext receiver asString, '>>', aContext selector
  2070. !
  2071. logErrorContext: aContext
  2072. aContext ifNotNil: [
  2073. aContext home ifNotNil: [
  2074. self logContext: aContext home]]
  2075. !
  2076. logError: anError
  2077. self log: anError messageText
  2078. !
  2079. log: aString
  2080. console log: aString
  2081. ! !
  2082. ErrorHandler class instanceVariableNames: 'current'!
  2083. !ErrorHandler class methodsFor: 'accessing'!
  2084. current
  2085. ^current
  2086. !
  2087. setCurrent: anHandler
  2088. current := anHandler
  2089. ! !
  2090. !ErrorHandler class methodsFor: 'initialization'!
  2091. initialize
  2092. self register
  2093. !
  2094. register
  2095. ErrorHandler setCurrent: self new
  2096. ! !
  2097. Object subclass: #JSObjectProxy
  2098. instanceVariableNames: 'jsObject'
  2099. category: 'Kernel'!
  2100. !JSObjectProxy methodsFor: 'accessing'!
  2101. jsObject: aJSObject
  2102. jsObject := aJSObject
  2103. !
  2104. jsObject
  2105. ^jsObject
  2106. ! !
  2107. !JSObjectProxy methodsFor: 'proxy'!
  2108. printString
  2109. ^self jsObject toString
  2110. !
  2111. inspectOn: anInspector
  2112. | variables |
  2113. variables := Dictionary new.
  2114. variables at: '#self' put: self jsObject.
  2115. anInspector setLabel: self printString.
  2116. <for(var i in self['@jsObject']) {
  2117. variables._at_put_(i, self['@jsObject'][i]);
  2118. }>.
  2119. anInspector setVariables: variables
  2120. ! !
  2121. !JSObjectProxy class methodsFor: 'instance creation'!
  2122. on: aJSObject
  2123. ^self new
  2124. jsObject: aJSObject;
  2125. yourself
  2126. ! !