Compiler.st 36 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442
  1. Smalltalk current createPackage: 'Compiler' properties: #{}!
  2. Object subclass: #ChunkParser
  3. instanceVariableNames: 'stream'
  4. package: 'Compiler'!
  5. !ChunkParser methodsFor: 'accessing'!
  6. stream: aStream
  7. stream := aStream
  8. ! !
  9. !ChunkParser methodsFor: 'reading'!
  10. nextChunk
  11. "The chunk format (Smalltalk Interchange Format or Fileout format)
  12. is a trivial format but can be a bit tricky to understand:
  13. - Uses the exclamation mark as delimiter of chunks.
  14. - Inside a chunk a normal exclamation mark must be doubled.
  15. - A non empty chunk must be a valid Smalltalk expression.
  16. - A chunk on top level with a preceding empty chunk is an instruction chunk:
  17. - The object created by the expression then takes over reading chunks.
  18. This metod returns next chunk as a String (trimmed), empty String (all whitespace) or nil."
  19. | char result chunk |
  20. result := '' writeStream.
  21. [char := stream next.
  22. char notNil] whileTrue: [
  23. char = '!!' ifTrue: [
  24. stream peek = '!!'
  25. ifTrue: [stream next "skipping the escape double"]
  26. ifFalse: [^result contents trimBoth "chunk end marker found"]].
  27. result nextPut: char].
  28. ^nil "a chunk needs to end with !!"
  29. ! !
  30. !ChunkParser class methodsFor: 'not yet classified'!
  31. on: aStream
  32. ^self new stream: aStream
  33. ! !
  34. Object subclass: #DoIt
  35. instanceVariableNames: ''
  36. package: 'Compiler'!
  37. Object subclass: #Exporter
  38. instanceVariableNames: ''
  39. package: 'Compiler'!
  40. !Exporter methodsFor: 'fileOut'!
  41. exportAll
  42. "Export all packages in the system."
  43. ^String streamContents: [:stream |
  44. Smalltalk current packages do: [:pkg |
  45. stream nextPutAll: (self exportPackage: pkg name)]]
  46. !
  47. exportClass: aClass
  48. "Export a single class. Subclasses override these methods."
  49. ^String streamContents: [:stream |
  50. self exportDefinitionOf: aClass on: stream.
  51. self exportMethodsOf: aClass on: stream.
  52. self exportMetaDefinitionOf: aClass on: stream.
  53. self exportMethodsOf: aClass class on: stream]
  54. !
  55. exportPackage: packageName
  56. "Export a given package by name."
  57. | package |
  58. ^String streamContents: [:stream |
  59. package := Smalltalk current packageAt: packageName.
  60. self exportPackageDefinitionOf: package on: stream.
  61. "Export classes in dependency order.
  62. Update (issue #171): Remove duplicates for export"
  63. package sortedClasses asSet do: [:each |
  64. stream nextPutAll: (self exportClass: each)].
  65. self exportPackageExtensionsOf: package on: stream]
  66. ! !
  67. !Exporter methodsFor: 'private'!
  68. classNameFor: aClass
  69. ^aClass isMetaclass
  70. ifTrue: [aClass instanceClass name, '.klass']
  71. ifFalse: [
  72. aClass isNil
  73. ifTrue: ['nil']
  74. ifFalse: [aClass name]]
  75. !
  76. exportDefinitionOf: aClass on: aStream
  77. aStream
  78. nextPutAll: 'smalltalk.addClass(';
  79. nextPutAll: '''', (self classNameFor: aClass), ''', ';
  80. nextPutAll: 'smalltalk.', (self classNameFor: aClass superclass);
  81. nextPutAll: ', ['.
  82. aClass instanceVariableNames
  83. do: [:each | aStream nextPutAll: '''', each, '''']
  84. separatedBy: [aStream nextPutAll: ', '].
  85. aStream
  86. nextPutAll: '], ''';
  87. nextPutAll: aClass category, '''';
  88. nextPutAll: ');'.
  89. aClass comment notEmpty ifTrue: [
  90. aStream
  91. lf;
  92. nextPutAll: 'smalltalk.';
  93. nextPutAll: (self classNameFor: aClass);
  94. nextPutAll: '.comment=';
  95. nextPutAll: aClass comment asJavascript].
  96. aStream lf
  97. !
  98. exportMetaDefinitionOf: aClass on: aStream
  99. aClass class instanceVariableNames isEmpty ifFalse: [
  100. aStream
  101. nextPutAll: 'smalltalk.', (self classNameFor: aClass class);
  102. nextPutAll: '.iVarNames = ['.
  103. aClass class instanceVariableNames
  104. do: [:each | aStream nextPutAll: '''', each, '''']
  105. separatedBy: [aStream nextPutAll: ','].
  106. aStream nextPutAll: '];', String lf]
  107. !
  108. exportMethod: aMethod of: aClass on: aStream
  109. aStream
  110. nextPutAll: 'smalltalk.addMethod(';lf;
  111. nextPutAll: aMethod selector asSelector asJavascript, ',';lf;
  112. nextPutAll: 'smalltalk.method({';lf;
  113. nextPutAll: 'selector: ', aMethod selector asJavascript, ',';lf;
  114. nextPutAll: 'category: ''', aMethod category, ''',';lf;
  115. nextPutAll: 'fn: ', aMethod fn compiledSource, ',';lf;
  116. nextPutAll: 'args: ', aMethod arguments asJavascript, ','; lf;
  117. nextPutAll: 'source: ', aMethod source asJavascript, ',';lf;
  118. nextPutAll: 'messageSends: ', aMethod messageSends asJavascript, ',';lf;
  119. nextPutAll: 'referencedClasses: ', aMethod referencedClasses asJavascript.
  120. aStream
  121. lf;
  122. nextPutAll: '}),';lf;
  123. nextPutAll: 'smalltalk.', (self classNameFor: aClass);
  124. nextPutAll: ');';lf;lf
  125. !
  126. exportMethodsOf: aClass on: aStream
  127. "Issue #143: sort methods alphabetically"
  128. ((aClass methodDictionary values) sorted: [:a :b | a selector <= b selector]) do: [:each |
  129. (each category match: '^\*') ifFalse: [
  130. self exportMethod: each of: aClass on: aStream]].
  131. aStream lf
  132. !
  133. exportPackageDefinitionOf: package on: aStream
  134. aStream
  135. nextPutAll: 'smalltalk.addPackage(';
  136. nextPutAll: '''', package name, ''', ', package propertiesAsJSON , ');'.
  137. aStream lf
  138. !
  139. exportPackageExtensionsOf: package on: aStream
  140. "Issue #143: sort classes and methods alphabetically"
  141. | name |
  142. name := package name.
  143. (Package sortedClasses: Smalltalk current classes) do: [:each |
  144. {each. each class} do: [:aClass |
  145. ((aClass methodDictionary values) sorted: [:a :b | a selector <= b selector]) do: [:method |
  146. (method category match: '^\*', name) ifTrue: [
  147. self exportMethod: method of: aClass on: aStream ]]]]
  148. ! !
  149. Exporter subclass: #ChunkExporter
  150. instanceVariableNames: ''
  151. package: 'Compiler'!
  152. !ChunkExporter methodsFor: 'not yet classified'!
  153. chunkEscape: aString
  154. "Replace all occurrences of !! with !!!! and trim at both ends."
  155. ^(aString replace: '!!' with: '!!!!') trimBoth
  156. !
  157. classNameFor: aClass
  158. ^aClass isMetaclass
  159. ifTrue: [aClass instanceClass name, ' class']
  160. ifFalse: [
  161. aClass isNil
  162. ifTrue: ['nil']
  163. ifFalse: [aClass name]]
  164. !
  165. exportDefinitionOf: aClass on: aStream
  166. "Chunk format."
  167. aStream
  168. nextPutAll: (self classNameFor: aClass superclass);
  169. nextPutAll: ' subclass: #', (self classNameFor: aClass); lf;
  170. nextPutAll: ' instanceVariableNames: '''.
  171. aClass instanceVariableNames
  172. do: [:each | aStream nextPutAll: each]
  173. separatedBy: [aStream nextPutAll: ' '].
  174. aStream
  175. nextPutAll: ''''; lf;
  176. nextPutAll: ' package: ''', aClass category, '''!!'; lf.
  177. aClass comment notEmpty ifTrue: [
  178. aStream
  179. nextPutAll: '!!', (self classNameFor: aClass), ' commentStamp!!';lf;
  180. nextPutAll: (self chunkEscape: aClass comment), '!!';lf].
  181. aStream lf
  182. !
  183. exportMetaDefinitionOf: aClass on: aStream
  184. aClass class instanceVariableNames isEmpty ifFalse: [
  185. aStream
  186. nextPutAll: (self classNameFor: aClass class);
  187. nextPutAll: ' instanceVariableNames: '''.
  188. aClass class instanceVariableNames
  189. do: [:each | aStream nextPutAll: each]
  190. separatedBy: [aStream nextPutAll: ' '].
  191. aStream
  192. nextPutAll: '''!!'; lf; lf]
  193. !
  194. exportMethod: aMethod of: aClass on: aStream
  195. aStream
  196. lf; lf; nextPutAll: (self chunkEscape: aMethod source); lf;
  197. nextPutAll: '!!'
  198. !
  199. exportMethods: methods category: category of: aClass on: aStream
  200. "Issue #143: sort methods alphabetically"
  201. aStream
  202. nextPutAll: '!!', (self classNameFor: aClass);
  203. nextPutAll: ' methodsFor: ''', category, '''!!'.
  204. (methods sorted: [:a :b | a selector <= b selector]) do: [:each |
  205. self exportMethod: each of: aClass on: aStream].
  206. aStream nextPutAll: ' !!'; lf; lf
  207. !
  208. exportMethodsOf: aClass on: aStream
  209. "Issue #143: sort protocol alphabetically"
  210. | map |
  211. map := Dictionary new.
  212. aClass protocolsDo: [:category :methods |
  213. (category match: '^\*') ifFalse: [ map at: category put: methods ]].
  214. (map keys sorted: [:a :b | a <= b ]) do: [:category | | methods |
  215. methods := map at: category.
  216. self
  217. exportMethods: methods
  218. category: category
  219. of: aClass
  220. on: aStream ]
  221. !
  222. exportPackageDefinitionOf: package on: aStream
  223. "Chunk format."
  224. aStream
  225. nextPutAll: 'Smalltalk current createPackage: ''', package name,
  226. ''' properties: ', package properties storeString, '!!'; lf.
  227. !
  228. exportPackageExtensionsOf: package on: aStream
  229. "We need to override this one too since we need to group
  230. all methods in a given protocol under a leading methodsFor: chunk
  231. for that class."
  232. "Issue #143: sort protocol alphabetically"
  233. | name map |
  234. name := package name.
  235. (Package sortedClasses: Smalltalk current classes) do: [:each |
  236. {each. each class} do: [:aClass |
  237. map := Dictionary new.
  238. aClass protocolsDo: [:category :methods |
  239. (category match: '^\*', name) ifTrue: [ map at: category put: methods ]].
  240. (map keys sorted: [:a :b | a <= b ]) do: [:category | | methods |
  241. methods := map at: category.
  242. self exportMethods: methods category: category of: aClass on: aStream ]]]
  243. ! !
  244. Exporter subclass: #StrippedExporter
  245. instanceVariableNames: ''
  246. package: 'Compiler'!
  247. !StrippedExporter methodsFor: 'private'!
  248. exportDefinitionOf: aClass on: aStream
  249. aStream
  250. nextPutAll: 'smalltalk.addClass(';
  251. nextPutAll: '''', (self classNameFor: aClass), ''', ';
  252. nextPutAll: 'smalltalk.', (self classNameFor: aClass superclass);
  253. nextPutAll: ', ['.
  254. aClass instanceVariableNames
  255. do: [:each | aStream nextPutAll: '''', each, '''']
  256. separatedBy: [aStream nextPutAll: ', '].
  257. aStream
  258. nextPutAll: '], ''';
  259. nextPutAll: aClass category, '''';
  260. nextPutAll: ');'.
  261. aStream lf
  262. !
  263. exportMethod: aMethod of: aClass on: aStream
  264. aStream
  265. nextPutAll: 'smalltalk.addMethod(';lf;
  266. nextPutAll: aMethod selector asSelector asJavascript, ',';lf;
  267. nextPutAll: 'smalltalk.method({';lf;
  268. nextPutAll: 'selector: ', aMethod selector asJavascript, ',';lf;
  269. nextPutAll: 'fn: ', aMethod fn compiledSource;lf;
  270. nextPutAll: '}),';lf;
  271. nextPutAll: 'smalltalk.', (self classNameFor: aClass);
  272. nextPutAll: ');';lf;lf
  273. ! !
  274. Object subclass: #Importer
  275. instanceVariableNames: ''
  276. package: 'Compiler'!
  277. !Importer methodsFor: 'fileIn'!
  278. import: aStream
  279. | chunk result parser lastEmpty |
  280. parser := ChunkParser on: aStream.
  281. lastEmpty := false.
  282. [chunk := parser nextChunk.
  283. chunk isNil] whileFalse: [
  284. chunk isEmpty
  285. ifTrue: [lastEmpty := true]
  286. ifFalse: [
  287. result := Compiler new loadExpression: chunk.
  288. lastEmpty
  289. ifTrue: [
  290. lastEmpty := false.
  291. result scanFrom: parser]]]
  292. ! !
  293. Object subclass: #Node
  294. instanceVariableNames: 'nodes'
  295. package: 'Compiler'!
  296. !Node methodsFor: 'accessing'!
  297. addNode: aNode
  298. self nodes add: aNode
  299. !
  300. nodes
  301. ^nodes ifNil: [nodes := Array new]
  302. ! !
  303. !Node methodsFor: 'building'!
  304. nodes: aCollection
  305. nodes := aCollection
  306. ! !
  307. !Node methodsFor: 'testing'!
  308. isBlockNode
  309. ^false
  310. !
  311. isBlockSequenceNode
  312. ^false
  313. !
  314. isValueNode
  315. ^false
  316. ! !
  317. !Node methodsFor: 'visiting'!
  318. accept: aVisitor
  319. aVisitor visitNode: self
  320. ! !
  321. Node subclass: #AssignmentNode
  322. instanceVariableNames: 'left right'
  323. package: 'Compiler'!
  324. !AssignmentNode methodsFor: 'accessing'!
  325. left
  326. ^left
  327. !
  328. left: aNode
  329. left := aNode.
  330. left assigned: true
  331. !
  332. right
  333. ^right
  334. !
  335. right: aNode
  336. right := aNode
  337. ! !
  338. !AssignmentNode methodsFor: 'visiting'!
  339. accept: aVisitor
  340. aVisitor visitAssignmentNode: self
  341. ! !
  342. Node subclass: #BlockNode
  343. instanceVariableNames: 'parameters inlined'
  344. package: 'Compiler'!
  345. !BlockNode methodsFor: 'accessing'!
  346. inlined
  347. ^inlined ifNil: [false]
  348. !
  349. inlined: aBoolean
  350. inlined := aBoolean
  351. !
  352. parameters
  353. ^parameters ifNil: [parameters := Array new]
  354. !
  355. parameters: aCollection
  356. parameters := aCollection
  357. ! !
  358. !BlockNode methodsFor: 'testing'!
  359. isBlockNode
  360. ^true
  361. ! !
  362. !BlockNode methodsFor: 'visiting'!
  363. accept: aVisitor
  364. aVisitor visitBlockNode: self
  365. ! !
  366. Node subclass: #CascadeNode
  367. instanceVariableNames: 'receiver'
  368. package: 'Compiler'!
  369. !CascadeNode methodsFor: 'accessing'!
  370. receiver
  371. ^receiver
  372. !
  373. receiver: aNode
  374. receiver := aNode
  375. ! !
  376. !CascadeNode methodsFor: 'visiting'!
  377. accept: aVisitor
  378. aVisitor visitCascadeNode: self
  379. ! !
  380. Node subclass: #DynamicArrayNode
  381. instanceVariableNames: ''
  382. package: 'Compiler'!
  383. !DynamicArrayNode methodsFor: 'visiting'!
  384. accept: aVisitor
  385. aVisitor visitDynamicArrayNode: self
  386. ! !
  387. Node subclass: #DynamicDictionaryNode
  388. instanceVariableNames: ''
  389. package: 'Compiler'!
  390. !DynamicDictionaryNode methodsFor: 'visiting'!
  391. accept: aVisitor
  392. aVisitor visitDynamicDictionaryNode: self
  393. ! !
  394. Node subclass: #JSStatementNode
  395. instanceVariableNames: 'source'
  396. package: 'Compiler'!
  397. !JSStatementNode methodsFor: 'accessing'!
  398. source
  399. ^source ifNil: ['']
  400. !
  401. source: aString
  402. source := aString
  403. ! !
  404. !JSStatementNode methodsFor: 'visiting'!
  405. accept: aVisitor
  406. aVisitor visitJSStatementNode: self
  407. ! !
  408. Node subclass: #MethodNode
  409. instanceVariableNames: 'selector arguments source'
  410. package: 'Compiler'!
  411. !MethodNode methodsFor: 'accessing'!
  412. arguments
  413. ^arguments ifNil: [#()]
  414. !
  415. arguments: aCollection
  416. arguments := aCollection
  417. !
  418. selector
  419. ^selector
  420. !
  421. selector: aString
  422. selector := aString
  423. !
  424. source
  425. ^source
  426. !
  427. source: aString
  428. source := aString
  429. ! !
  430. !MethodNode methodsFor: 'visiting'!
  431. accept: aVisitor
  432. aVisitor visitMethodNode: self
  433. ! !
  434. Node subclass: #ReturnNode
  435. instanceVariableNames: ''
  436. package: 'Compiler'!
  437. !ReturnNode methodsFor: 'visiting'!
  438. accept: aVisitor
  439. aVisitor visitReturnNode: self
  440. ! !
  441. Node subclass: #SendNode
  442. instanceVariableNames: 'selector arguments receiver'
  443. package: 'Compiler'!
  444. !SendNode methodsFor: 'accessing'!
  445. arguments
  446. ^arguments ifNil: [arguments := #()]
  447. !
  448. arguments: aCollection
  449. arguments := aCollection
  450. !
  451. cascadeNodeWithMessages: aCollection
  452. | first |
  453. first := SendNode new
  454. selector: self selector;
  455. arguments: self arguments;
  456. yourself.
  457. ^CascadeNode new
  458. receiver: self receiver;
  459. nodes: (Array with: first), aCollection;
  460. yourself
  461. !
  462. receiver
  463. ^receiver
  464. !
  465. receiver: aNode
  466. receiver := aNode
  467. !
  468. selector
  469. ^selector
  470. !
  471. selector: aString
  472. selector := aString
  473. !
  474. valueForReceiver: anObject
  475. ^SendNode new
  476. receiver: (self receiver
  477. ifNil: [anObject]
  478. ifNotNil: [self receiver valueForReceiver: anObject]);
  479. selector: self selector;
  480. arguments: self arguments;
  481. yourself
  482. ! !
  483. !SendNode methodsFor: 'visiting'!
  484. accept: aVisitor
  485. aVisitor visitSendNode: self
  486. ! !
  487. Node subclass: #SequenceNode
  488. instanceVariableNames: 'temps'
  489. package: 'Compiler'!
  490. !SequenceNode methodsFor: 'accessing'!
  491. temps
  492. ^temps ifNil: [#()]
  493. !
  494. temps: aCollection
  495. temps := aCollection
  496. ! !
  497. !SequenceNode methodsFor: 'testing'!
  498. asBlockSequenceNode
  499. ^BlockSequenceNode new
  500. nodes: self nodes;
  501. temps: self temps;
  502. yourself
  503. ! !
  504. !SequenceNode methodsFor: 'visiting'!
  505. accept: aVisitor
  506. aVisitor visitSequenceNode: self
  507. ! !
  508. SequenceNode subclass: #BlockSequenceNode
  509. instanceVariableNames: ''
  510. package: 'Compiler'!
  511. !BlockSequenceNode methodsFor: 'testing'!
  512. isBlockSequenceNode
  513. ^true
  514. ! !
  515. !BlockSequenceNode methodsFor: 'visiting'!
  516. accept: aVisitor
  517. aVisitor visitBlockSequenceNode: self
  518. ! !
  519. Node subclass: #ValueNode
  520. instanceVariableNames: 'value'
  521. package: 'Compiler'!
  522. !ValueNode methodsFor: 'accessing'!
  523. value
  524. ^value
  525. !
  526. value: anObject
  527. value := anObject
  528. ! !
  529. !ValueNode methodsFor: 'testing'!
  530. isValueNode
  531. ^true
  532. ! !
  533. !ValueNode methodsFor: 'visiting'!
  534. accept: aVisitor
  535. aVisitor visitValueNode: self
  536. ! !
  537. ValueNode subclass: #VariableNode
  538. instanceVariableNames: 'assigned'
  539. package: 'Compiler'!
  540. !VariableNode methodsFor: 'accessing'!
  541. assigned
  542. ^assigned ifNil: [false]
  543. !
  544. assigned: aBoolean
  545. assigned := aBoolean
  546. ! !
  547. !VariableNode methodsFor: 'visiting'!
  548. accept: aVisitor
  549. aVisitor visitVariableNode: self
  550. ! !
  551. VariableNode subclass: #ClassReferenceNode
  552. instanceVariableNames: ''
  553. package: 'Compiler'!
  554. !ClassReferenceNode methodsFor: 'visiting'!
  555. accept: aVisitor
  556. aVisitor visitClassReferenceNode: self
  557. ! !
  558. Object subclass: #NodeVisitor
  559. instanceVariableNames: ''
  560. package: 'Compiler'!
  561. !NodeVisitor methodsFor: 'visiting'!
  562. visit: aNode
  563. aNode accept: self
  564. !
  565. visitAssignmentNode: aNode
  566. self visitNode: aNode
  567. !
  568. visitBlockNode: aNode
  569. self visitNode: aNode
  570. !
  571. visitBlockSequenceNode: aNode
  572. self visitNode: aNode
  573. !
  574. visitCascadeNode: aNode
  575. self visitNode: aNode
  576. !
  577. visitClassReferenceNode: aNode
  578. self visitNode: aNode
  579. !
  580. visitDynamicArrayNode: aNode
  581. self visitNode: aNode
  582. !
  583. visitDynamicDictionaryNode: aNode
  584. self visitNode: aNode
  585. !
  586. visitJSStatementNode: aNode
  587. self visitNode: aNode
  588. !
  589. visitMethodNode: aNode
  590. self visitNode: aNode
  591. !
  592. visitNode: aNode
  593. !
  594. visitReturnNode: aNode
  595. self visitNode: aNode
  596. !
  597. visitSendNode: aNode
  598. self visitNode: aNode
  599. !
  600. visitSequenceNode: aNode
  601. self visitNode: aNode
  602. !
  603. visitValueNode: aNode
  604. self visitNode: aNode
  605. !
  606. visitVariableNode: aNode
  607. self visitNode: aNode
  608. ! !
  609. NodeVisitor subclass: #AbstractCompiler
  610. instanceVariableNames: 'currentClass source'
  611. package: 'Compiler'!
  612. !AbstractCompiler methodsFor: 'accessing'!
  613. classNameFor: aClass
  614. ^aClass isMetaclass
  615. ifTrue: [aClass instanceClass name, '.klass']
  616. ifFalse: [
  617. aClass isNil
  618. ifTrue: ['nil']
  619. ifFalse: [aClass name]]
  620. !
  621. currentClass
  622. ^currentClass
  623. !
  624. currentClass: aClass
  625. currentClass := aClass
  626. !
  627. pseudoVariables
  628. ^#('self' 'super' 'true' 'false' 'nil' 'thisContext')
  629. !
  630. safeVariableNameFor: aString
  631. ^(Smalltalk current reservedWords includes: aString)
  632. ifTrue: [aString, '_']
  633. ifFalse: [aString]
  634. !
  635. source
  636. ^source ifNil: ['']
  637. !
  638. source: aString
  639. source := aString
  640. ! !
  641. !AbstractCompiler methodsFor: 'compiling'!
  642. compile: aString
  643. ^self compileNode: (self parse: aString)
  644. !
  645. compile: aString forClass: aClass
  646. self currentClass: aClass.
  647. self source: aString.
  648. ^self compile: aString
  649. !
  650. compileExpression: aString
  651. self currentClass: DoIt.
  652. self source: 'doIt ^[', aString, '] value'.
  653. ^self compileNode: (self parse: self source)
  654. !
  655. eval: aString
  656. <return eval(aString)>
  657. !
  658. load: aString forClass: aClass
  659. | compiled |
  660. compiled := self eval: (self compile: aString forClass: aClass).
  661. self setupClass: aClass.
  662. ^compiled
  663. !
  664. loadExpression: aString
  665. | result |
  666. DoIt addCompiledMethod: (self eval: (self compileExpression: aString)).
  667. result := DoIt new doIt.
  668. DoIt removeCompiledMethod: (DoIt methodDictionary at: 'doIt').
  669. ^result
  670. !
  671. parse: aString
  672. ^Smalltalk current parse: aString
  673. !
  674. parseExpression: aString
  675. ^self parse: 'doIt ^[', aString, '] value'
  676. !
  677. recompile: aClass
  678. aClass methodDictionary do: [:each || method |
  679. method := self load: each source forClass: aClass.
  680. method category: each category.
  681. aClass addCompiledMethod: method].
  682. aClass isMetaclass ifFalse: [self recompile: aClass class]
  683. !
  684. recompileAll
  685. Smalltalk current classes do: [:each |
  686. Transcript show: each; cr.
  687. [self recompile: each] valueWithTimeout: 100]
  688. !
  689. setupClass: aClass
  690. <smalltalk.init(aClass)>
  691. ! !
  692. !AbstractCompiler class methodsFor: 'compiling'!
  693. recompile: aClass
  694. aClass methodDictionary do: [:each || method |
  695. method := self new load: each source forClass: aClass.
  696. method category: each category.
  697. aClass addCompiledMethod: method].
  698. aClass isMetaclass ifFalse: [self recompile: aClass class]
  699. !
  700. recompileAll
  701. Smalltalk current classes do: [:each |
  702. self recompile: each]
  703. ! !
  704. AbstractCompiler subclass: #Compiler
  705. instanceVariableNames: 'stream nestedBlocks earlyReturn currentSelector unknownVariables tempVariables messageSends referencedClasses classReferenced argVariables'
  706. package: 'Compiler'!
  707. !Compiler methodsFor: 'accessing'!
  708. argVariables
  709. ^argVariables copy
  710. !
  711. knownVariables
  712. ^self pseudoVariables
  713. addAll: self tempVariables;
  714. addAll: self argVariables;
  715. yourself
  716. !
  717. tempVariables
  718. ^tempVariables copy
  719. !
  720. unknownVariables
  721. ^unknownVariables copy
  722. ! !
  723. !Compiler methodsFor: 'compiling'!
  724. compileNode: aNode
  725. stream := '' writeStream.
  726. self visit: aNode.
  727. ^stream contents
  728. ! !
  729. !Compiler methodsFor: 'initialization'!
  730. initialize
  731. super initialize.
  732. stream := '' writeStream.
  733. unknownVariables := #().
  734. tempVariables := #().
  735. argVariables := #().
  736. messageSends := #().
  737. classReferenced := #()
  738. ! !
  739. !Compiler methodsFor: 'optimizations'!
  740. checkClass: aClassName for: receiver
  741. stream nextPutAll: '((($receiver = ', receiver, ').klass === smalltalk.', aClassName, ') ? '
  742. !
  743. inline: aSelector receiver: receiver argumentNodes: aCollection
  744. | inlined |
  745. inlined := false.
  746. "-- Booleans --"
  747. (aSelector = 'ifFalse:') ifTrue: [
  748. aCollection first isBlockNode ifTrue: [
  749. self checkClass: 'Boolean' for: receiver.
  750. stream nextPutAll: '(!! $receiver ? '.
  751. self visit: aCollection first.
  752. stream nextPutAll: '() : nil)'.
  753. inlined := true]].
  754. (aSelector = 'ifTrue:') ifTrue: [
  755. aCollection first isBlockNode ifTrue: [
  756. self checkClass: 'Boolean' for: receiver.
  757. stream nextPutAll: '($receiver ? '.
  758. self visit: aCollection first.
  759. stream nextPutAll: '() : nil)'.
  760. inlined := true]].
  761. (aSelector = 'ifTrue:ifFalse:') ifTrue: [
  762. (aCollection first isBlockNode and: [aCollection second isBlockNode]) ifTrue: [
  763. self checkClass: 'Boolean' for: receiver.
  764. stream nextPutAll: '($receiver ? '.
  765. self visit: aCollection first.
  766. stream nextPutAll: '() : '.
  767. self visit: aCollection second.
  768. stream nextPutAll: '())'.
  769. inlined := true]].
  770. (aSelector = 'ifFalse:ifTrue:') ifTrue: [
  771. (aCollection first isBlockNode and: [aCollection second isBlockNode]) ifTrue: [
  772. self checkClass: 'Boolean' for: receiver.
  773. stream nextPutAll: '(!! $receiver ? '.
  774. self visit: aCollection first.
  775. stream nextPutAll: '() : '.
  776. self visit: aCollection second.
  777. stream nextPutAll: '())'.
  778. inlined := true]].
  779. "-- Numbers --"
  780. (aSelector = '<') ifTrue: [
  781. self checkClass: 'Number' for: receiver.
  782. stream nextPutAll: '$receiver <'.
  783. self visit: aCollection first.
  784. inlined := true].
  785. (aSelector = '<=') ifTrue: [
  786. self checkClass: 'Number' for: receiver.
  787. stream nextPutAll: '$receiver <='.
  788. self visit: aCollection first.
  789. inlined := true].
  790. (aSelector = '>') ifTrue: [
  791. self checkClass: 'Number' for: receiver.
  792. stream nextPutAll: '$receiver >'.
  793. self visit: aCollection first.
  794. inlined := true].
  795. (aSelector = '>=') ifTrue: [
  796. self checkClass: 'Number' for: receiver.
  797. stream nextPutAll: '$receiver >='.
  798. self visit: aCollection first.
  799. inlined := true].
  800. (aSelector = '+') ifTrue: [
  801. self checkClass: 'Number' for: receiver.
  802. stream nextPutAll: '$receiver +'.
  803. self visit: aCollection first.
  804. inlined := true].
  805. (aSelector = '-') ifTrue: [
  806. self checkClass: 'Number' for: receiver.
  807. stream nextPutAll: '$receiver -'.
  808. self visit: aCollection first.
  809. inlined := true].
  810. (aSelector = '*') ifTrue: [
  811. self checkClass: 'Number' for: receiver.
  812. stream nextPutAll: '$receiver *'.
  813. self visit: aCollection first.
  814. inlined := true].
  815. (aSelector = '/') ifTrue: [
  816. self checkClass: 'Number' for: receiver.
  817. stream nextPutAll: '$receiver /'.
  818. self visit: aCollection first.
  819. inlined := true].
  820. ^inlined
  821. !
  822. inlineLiteral: aSelector receiverNode: anObject argumentNodes: aCollection
  823. | inlined |
  824. inlined := false.
  825. "-- BlockClosures --"
  826. (aSelector = 'whileTrue:') ifTrue: [
  827. (anObject isBlockNode and: [aCollection first isBlockNode]) ifTrue: [
  828. stream nextPutAll: '(function(){while('.
  829. self visit: anObject.
  830. stream nextPutAll: '()) {'.
  831. self visit: aCollection first.
  832. stream nextPutAll: '()}})()'.
  833. inlined := true]].
  834. (aSelector = 'whileFalse:') ifTrue: [
  835. (anObject isBlockNode and: [aCollection first isBlockNode]) ifTrue: [
  836. stream nextPutAll: '(function(){while(!!'.
  837. self visit: anObject.
  838. stream nextPutAll: '()) {'.
  839. self visit: aCollection first.
  840. stream nextPutAll: '()}})()'.
  841. inlined := true]].
  842. (aSelector = 'whileTrue') ifTrue: [
  843. anObject isBlockNode ifTrue: [
  844. stream nextPutAll: '(function(){while('.
  845. self visit: anObject.
  846. stream nextPutAll: '()) {}})()'.
  847. inlined := true]].
  848. (aSelector = 'whileFalse') ifTrue: [
  849. anObject isBlockNode ifTrue: [
  850. stream nextPutAll: '(function(){while(!!'.
  851. self visit: anObject.
  852. stream nextPutAll: '()) {}})()'.
  853. inlined := true]].
  854. "-- Numbers --"
  855. (aSelector = '+') ifTrue: [
  856. (self isNode: anObject ofClass: Number) ifTrue: [
  857. self visit: anObject.
  858. stream nextPutAll: ' + '.
  859. self visit: aCollection first.
  860. inlined := true]].
  861. (aSelector = '-') ifTrue: [
  862. (self isNode: anObject ofClass: Number) ifTrue: [
  863. self visit: anObject.
  864. stream nextPutAll: ' - '.
  865. self visit: aCollection first.
  866. inlined := true]].
  867. (aSelector = '*') ifTrue: [
  868. (self isNode: anObject ofClass: Number) ifTrue: [
  869. self visit: anObject.
  870. stream nextPutAll: ' * '.
  871. self visit: aCollection first.
  872. inlined := true]].
  873. (aSelector = '/') ifTrue: [
  874. (self isNode: anObject ofClass: Number) ifTrue: [
  875. self visit: anObject.
  876. stream nextPutAll: ' / '.
  877. self visit: aCollection first.
  878. inlined := true]].
  879. (aSelector = '<') ifTrue: [
  880. (self isNode: anObject ofClass: Number) ifTrue: [
  881. self visit: anObject.
  882. stream nextPutAll: ' < '.
  883. self visit: aCollection first.
  884. inlined := true]].
  885. (aSelector = '<=') ifTrue: [
  886. (self isNode: anObject ofClass: Number) ifTrue: [
  887. self visit: anObject.
  888. stream nextPutAll: ' <= '.
  889. self visit: aCollection first.
  890. inlined := true]].
  891. (aSelector = '>') ifTrue: [
  892. (self isNode: anObject ofClass: Number) ifTrue: [
  893. self visit: anObject.
  894. stream nextPutAll: ' > '.
  895. self visit: aCollection first.
  896. inlined := true]].
  897. (aSelector = '>=') ifTrue: [
  898. (self isNode: anObject ofClass: Number) ifTrue: [
  899. self visit: anObject.
  900. stream nextPutAll: ' >= '.
  901. self visit: aCollection first.
  902. inlined := true]].
  903. "-- UndefinedObject --"
  904. (aSelector = 'ifNil:') ifTrue: [
  905. aCollection first isBlockNode ifTrue: [
  906. stream nextPutAll: '(($receiver = '.
  907. self visit: anObject.
  908. stream nextPutAll: ') == nil || $receiver == undefined) ? '.
  909. self visit: aCollection first.
  910. stream nextPutAll: '() : $receiver'.
  911. inlined := true]].
  912. (aSelector = 'ifNotNil:') ifTrue: [
  913. aCollection first isBlockNode ifTrue: [
  914. stream nextPutAll: '(($receiver = '.
  915. self visit: anObject.
  916. stream nextPutAll: ') !!= nil && $receiver !!= undefined) ? '.
  917. self visit: aCollection first.
  918. stream nextPutAll: '() : nil'.
  919. inlined := true]].
  920. (aSelector = 'ifNil:ifNotNil:') ifTrue: [
  921. (aCollection first isBlockNode and: [aCollection second isBlockNode]) ifTrue: [
  922. stream nextPutAll: '(($receiver = '.
  923. self visit: anObject.
  924. stream nextPutAll: ') == nil || $receiver == undefined) ? '.
  925. self visit: aCollection first.
  926. stream nextPutAll: '() : '.
  927. self visit: aCollection second.
  928. stream nextPutAll: '()'.
  929. inlined := true]].
  930. (aSelector = 'ifNotNil:ifNil:') ifTrue: [
  931. (aCollection first isBlockNode and: [aCollection second isBlockNode]) ifTrue: [
  932. stream nextPutAll: '(($receiver = '.
  933. self visit: anObject.
  934. stream nextPutAll: ') == nil || $receiver == undefined) ? '.
  935. self visit: aCollection second.
  936. stream nextPutAll: '() : '.
  937. self visit: aCollection first.
  938. stream nextPutAll: '()'.
  939. inlined := true]].
  940. ^inlined
  941. !
  942. isNode: aNode ofClass: aClass
  943. ^aNode isValueNode and: [
  944. aNode value class = aClass or: [
  945. aNode value = 'self' and: [self currentClass = aClass]]]
  946. ! !
  947. !Compiler methodsFor: 'testing'!
  948. performOptimizations
  949. ^self class performOptimizations
  950. ! !
  951. !Compiler methodsFor: 'visiting'!
  952. send: aSelector to: aReceiver arguments: aCollection superSend: aBoolean
  953. ^String streamContents: [:str || tmp |
  954. tmp := stream.
  955. str nextPutAll: 'smalltalk.send('.
  956. str nextPutAll: aReceiver.
  957. str nextPutAll: ', "', aSelector asSelector, '", ['.
  958. stream := str.
  959. aCollection
  960. do: [:each | self visit: each]
  961. separatedBy: [stream nextPutAll: ', '].
  962. stream := tmp.
  963. str nextPutAll: ']'.
  964. aBoolean ifTrue: [
  965. str nextPutAll: ', smalltalk.', (self classNameFor: self currentClass superclass)].
  966. str nextPutAll: ')']
  967. !
  968. visit: aNode
  969. aNode accept: self
  970. !
  971. visitAssignmentNode: aNode
  972. stream nextPutAll: '('.
  973. self visit: aNode left.
  974. stream nextPutAll: '='.
  975. self visit: aNode right.
  976. stream nextPutAll: ')'
  977. !
  978. visitBlockNode: aNode
  979. stream nextPutAll: '(function('.
  980. aNode parameters
  981. do: [:each |
  982. tempVariables add: each.
  983. stream nextPutAll: each]
  984. separatedBy: [stream nextPutAll: ', '].
  985. stream nextPutAll: '){'.
  986. aNode nodes do: [:each | self visit: each].
  987. stream nextPutAll: '})'
  988. !
  989. visitBlockSequenceNode: aNode
  990. | index |
  991. nestedBlocks := nestedBlocks + 1.
  992. aNode nodes isEmpty
  993. ifTrue: [
  994. stream nextPutAll: 'return nil;']
  995. ifFalse: [
  996. aNode temps do: [:each | | temp |
  997. temp := self safeVariableNameFor: each.
  998. tempVariables add: temp.
  999. stream nextPutAll: 'var ', temp, '=nil;'; lf].
  1000. index := 0.
  1001. aNode nodes do: [:each |
  1002. index := index + 1.
  1003. index = aNode nodes size ifTrue: [
  1004. stream nextPutAll: 'return '].
  1005. self visit: each.
  1006. stream nextPutAll: ';']].
  1007. nestedBlocks := nestedBlocks - 1
  1008. !
  1009. visitCascadeNode: aNode
  1010. | index |
  1011. index := 0.
  1012. (tempVariables includes: '$rec') ifFalse: [
  1013. tempVariables add: '$rec'].
  1014. stream nextPutAll: '(function($rec){'.
  1015. aNode nodes do: [:each |
  1016. index := index + 1.
  1017. index = aNode nodes size ifTrue: [
  1018. stream nextPutAll: 'return '].
  1019. each receiver: (VariableNode new value: '$rec').
  1020. self visit: each.
  1021. stream nextPutAll: ';'].
  1022. stream nextPutAll: '})('.
  1023. self visit: aNode receiver.
  1024. stream nextPutAll: ')'
  1025. !
  1026. visitClassReferenceNode: aNode
  1027. (referencedClasses includes: aNode value) ifFalse: [
  1028. referencedClasses add: aNode value].
  1029. stream nextPutAll: '(smalltalk.', aNode value, ' || ', aNode value, ')'
  1030. !
  1031. visitDynamicArrayNode: aNode
  1032. stream nextPutAll: '['.
  1033. aNode nodes
  1034. do: [:each | self visit: each]
  1035. separatedBy: [stream nextPutAll: ','].
  1036. stream nextPutAll: ']'
  1037. !
  1038. visitDynamicDictionaryNode: aNode
  1039. stream nextPutAll: 'smalltalk.HashedCollection._fromPairs_(['.
  1040. aNode nodes
  1041. do: [:each | self visit: each]
  1042. separatedBy: [stream nextPutAll: ','].
  1043. stream nextPutAll: '])'
  1044. !
  1045. visitFailure: aFailure
  1046. self error: aFailure asString
  1047. !
  1048. visitJSStatementNode: aNode
  1049. stream nextPutAll: (aNode source replace: '>>' with: '>')
  1050. !
  1051. visitMethodNode: aNode
  1052. | str currentSelector |
  1053. currentSelector := aNode selector asSelector.
  1054. nestedBlocks := 0.
  1055. earlyReturn := false.
  1056. messageSends := #().
  1057. referencedClasses := #().
  1058. unknownVariables := #().
  1059. tempVariables := #().
  1060. argVariables := #().
  1061. stream
  1062. nextPutAll: 'smalltalk.method({'; lf;
  1063. nextPutAll: 'selector: "', aNode selector, '",'; lf.
  1064. stream nextPutAll: 'source: ', self source asJavascript, ',';lf.
  1065. stream nextPutAll: 'fn: function('.
  1066. aNode arguments
  1067. do: [:each |
  1068. argVariables add: each.
  1069. stream nextPutAll: each]
  1070. separatedBy: [stream nextPutAll: ', '].
  1071. stream
  1072. nextPutAll: '){'; lf;
  1073. nextPutAll: 'var self=this;'; lf.
  1074. str := stream.
  1075. stream := '' writeStream.
  1076. aNode nodes do: [:each |
  1077. self visit: each].
  1078. earlyReturn ifTrue: [
  1079. str nextPutAll: 'var $early={};'; lf; nextPutAll: 'try{'].
  1080. str nextPutAll: stream contents.
  1081. stream := str.
  1082. stream
  1083. lf;
  1084. nextPutAll: 'return self;'.
  1085. earlyReturn ifTrue: [
  1086. stream lf; nextPutAll: '} catch(e) {if(e===$early)return e(); throw e}'].
  1087. stream nextPutAll: '}'.
  1088. stream
  1089. nextPutAll: ',', String lf, 'messageSends: ';
  1090. nextPutAll: messageSends asJavascript, ','; lf;
  1091. nextPutAll: 'args: ', argVariables asJavascript, ','; lf;
  1092. nextPutAll: 'referencedClasses: ['.
  1093. referencedClasses
  1094. do: [:each | stream nextPutAll: each printString]
  1095. separatedBy: [stream nextPutAll: ','].
  1096. stream nextPutAll: ']'.
  1097. stream nextPutAll: '})'
  1098. !
  1099. visitReturnNode: aNode
  1100. nestedBlocks > 0 ifTrue: [
  1101. earlyReturn := true].
  1102. nestedBlocks > 0
  1103. ifTrue: [
  1104. stream
  1105. nextPutAll: '(function(){throw $early=function(){return ']
  1106. ifFalse: [stream nextPutAll: 'return '].
  1107. aNode nodes do: [:each |
  1108. self visit: each].
  1109. nestedBlocks > 0 ifTrue: [
  1110. stream nextPutAll: '}})()']
  1111. !
  1112. visitSendNode: aNode
  1113. | str receiver superSend inlined |
  1114. str := stream.
  1115. (messageSends includes: aNode selector) ifFalse: [
  1116. messageSends add: aNode selector].
  1117. stream := '' writeStream.
  1118. self visit: aNode receiver.
  1119. superSend := stream contents = 'super'.
  1120. receiver := superSend ifTrue: ['self'] ifFalse: [stream contents].
  1121. stream := str.
  1122. self performOptimizations
  1123. ifTrue: [
  1124. (self inlineLiteral: aNode selector receiverNode: aNode receiver argumentNodes: aNode arguments) ifFalse: [
  1125. (self inline: aNode selector receiver: receiver argumentNodes: aNode arguments)
  1126. ifTrue: [stream nextPutAll: ' : ', (self send: aNode selector to: '$receiver' arguments: aNode arguments superSend: superSend), ')']
  1127. ifFalse: [stream nextPutAll: (self send: aNode selector to: receiver arguments: aNode arguments superSend: superSend)]]]
  1128. ifFalse: [stream nextPutAll: (self send: aNode selector to: receiver arguments: aNode arguments superSend: superSend)]
  1129. !
  1130. visitSequenceNode: aNode
  1131. aNode temps do: [:each || temp |
  1132. temp := self safeVariableNameFor: each.
  1133. tempVariables add: temp.
  1134. stream nextPutAll: 'var ', temp, '=nil;'; lf].
  1135. aNode nodes do: [:each |
  1136. self visit: each.
  1137. stream nextPutAll: ';']
  1138. separatedBy: [stream lf]
  1139. !
  1140. visitValueNode: aNode
  1141. stream nextPutAll: aNode value asJavascript
  1142. !
  1143. visitVariableNode: aNode
  1144. | varName |
  1145. (self currentClass allInstanceVariableNames includes: aNode value)
  1146. ifTrue: [stream nextPutAll: 'self[''@', aNode value, ''']']
  1147. ifFalse: [
  1148. varName := self safeVariableNameFor: aNode value.
  1149. (self knownVariables includes: varName)
  1150. ifFalse: [
  1151. unknownVariables add: aNode value.
  1152. aNode assigned
  1153. ifTrue: [stream nextPutAll: varName]
  1154. ifFalse: [stream nextPutAll: '(typeof ', varName, ' == ''undefined'' ? nil : ', varName, ')']]
  1155. ifTrue: [
  1156. aNode value = 'thisContext'
  1157. ifTrue: [stream nextPutAll: '(smalltalk.getThisContext())']
  1158. ifFalse: [stream nextPutAll: varName]]]
  1159. ! !
  1160. Compiler class instanceVariableNames: 'performOptimizations'!
  1161. !Compiler class methodsFor: 'accessing'!
  1162. performOptimizations
  1163. ^performOptimizations ifNil: [true]
  1164. !
  1165. performOptimizations: aBoolean
  1166. performOptimizations := aBoolean
  1167. ! !