1
0

Compiler-Tests.st 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668
  1. Smalltalk current createPackage: 'Compiler-Tests'!
  2. TestCase subclass: #AbstractASTInterpreterTest
  3. instanceVariableNames: ''
  4. package: 'Compiler-Tests'!
  5. !AbstractASTInterpreterTest methodsFor: 'accessing'!
  6. interpreter
  7. ^ self subclassResponsibility
  8. ! !
  9. !AbstractASTInterpreterTest methodsFor: 'interpreting'!
  10. analyze: aNode forClass: aClass
  11. (SemanticAnalyzer on: aClass) visit: aNode.
  12. ^ aNode
  13. !
  14. interpret: aString
  15. ^ self
  16. interpret: aString
  17. withArguments: Dictionary new
  18. !
  19. interpret: aString receiver: anObject withArguments: aDictionary
  20. "The food is a methodNode. Interpret the sequenceNode only"
  21. | ctx |
  22. ctx := AIContext new.
  23. ctx receiver: anObject.
  24. aDictionary keysAndValuesDo: [ :key :value |
  25. ctx localAt: key put: value ].
  26. ^ self interpreter
  27. context: ctx;
  28. interpret: (self parse: aString forClass: anObject class)
  29. nodes first;
  30. result
  31. !
  32. interpret: aString withArguments: aDictionary
  33. ^ self
  34. interpret: aString
  35. receiver: Object new
  36. withArguments: aDictionary
  37. ! !
  38. !AbstractASTInterpreterTest methodsFor: 'parsing'!
  39. parse: aString
  40. ^ Smalltalk current parse: aString
  41. !
  42. parse: aString forClass: aClass
  43. ^ self analyze: (self parse: aString) forClass: aClass
  44. ! !
  45. AbstractASTInterpreterTest subclass: #ASTInterpreterTest
  46. instanceVariableNames: ''
  47. package: 'Compiler-Tests'!
  48. !ASTInterpreterTest methodsFor: 'accessing'!
  49. interpreter
  50. ^ ASTInterpreter new
  51. ! !
  52. !ASTInterpreterTest methodsFor: 'tests'!
  53. testBinarySend
  54. self assert: (self interpret: 'foo 2+3+4') equals: 9
  55. !
  56. testBlockLiteral
  57. self assert: (self interpret: 'foo ^ true ifTrue: [ 1 ] ifFalse: [ 2 ]') equals: 1.
  58. self assert: (self interpret: 'foo true ifTrue: [ ^ 1 ] ifFalse: [ 2 ]') equals: 1.
  59. self assert: (self interpret: 'foo ^ false ifTrue: [ 1 ] ifFalse: [ 2 ]') equals: 2
  60. !
  61. testCascade
  62. self assert: (self interpret: 'foo ^ OrderedCollection new add: 2; add: 3; yourself') equals: (OrderedCollection with: 2 with: 3)
  63. !
  64. testDynamicArray
  65. self assert: (self interpret: 'foo ^ {1+1. 2+2}') equals: #(2 4)
  66. !
  67. testDynamicDictionary
  68. self assert: (self interpret: 'foo ^ #{1->1. 2->3}') equals: #{1->1. 2->3}
  69. !
  70. testInlinedJSStatement
  71. self assert: (self interpret: 'foo <return 2+3>') equals: 5.
  72. self
  73. assert: (self
  74. interpret: 'foo: anInteger <return 2 + anInteger>'
  75. withArguments: #{ 'anInteger' -> 3})
  76. equals: 5
  77. !
  78. testInstVarAccess
  79. self
  80. assert: (self
  81. interpret: 'foo ^ x'
  82. receiver: 2@3
  83. withArguments: #{})
  84. equals: 2
  85. !
  86. testInstVarAssignment
  87. self
  88. assert: (self
  89. interpret: 'foo: anInteger x := anInteger. ^ x'
  90. receiver: Point new
  91. withArguments: #{'anInteger' -> 2})
  92. equals: 2
  93. !
  94. testNonlocalReturn
  95. self assert: (self interpret: 'foo true ifTrue: [ ^ 1 ]. ^2') equals: 1
  96. !
  97. testReceiver
  98. self
  99. assert: (self
  100. interpret: 'foo ^ self'
  101. receiver: 2@3
  102. withArguments: #{})
  103. equals: 2@3
  104. !
  105. testSuper
  106. self
  107. assert: (self
  108. interpret: 'foo ^ super isBoolean'
  109. receiver: true
  110. withArguments: Dictionary new)
  111. equals: false
  112. !
  113. testTempAssignment
  114. self assert: (self interpret: 'foo | a | a := 2. ^ a') equals: 2
  115. !
  116. testThisContext
  117. self assert: (self interpret: 'foo ^ thisContext') outerContext isNil.
  118. self assert: (self interpret: 'foo ^ [ thisContext ] value') outerContext notNil.
  119. self assert: (self interpret: 'foo ^ [ thisContext ] value outerContext == thisContext')
  120. ! !
  121. AbstractASTInterpreterTest subclass: #ASTSteppingInterpreterTest
  122. instanceVariableNames: 'interpreter'
  123. package: 'Compiler-Tests'!
  124. !ASTSteppingInterpreterTest methodsFor: 'accessing'!
  125. interpreter
  126. ^ interpreter ifNil: [ interpreter := ASTSteppingInterpreter new ]
  127. ! !
  128. !ASTSteppingInterpreterTest methodsFor: 'tests'!
  129. testAtEnd
  130. self interpret: 'foo 1 + 2'.
  131. self deny: self interpreter atEnd.
  132. self interpreter step.
  133. self deny: self interpreter atEnd.
  134. self interpreter step.
  135. self deny: self interpreter atEnd.
  136. self interpreter step.
  137. self deny: self interpreter atEnd.
  138. self interpreter step.
  139. self assert: self interpreter atEnd
  140. !
  141. testMessageSend
  142. self interpret: 'foo 1 + 2'.
  143. "SequenceNode"
  144. self interpreter step.
  145. "SendNode"
  146. self interpreter step.
  147. "ValueNode"
  148. self interpreter step.
  149. self assert: self interpreter currentNode value equals: 1.
  150. "ValueNode"
  151. self interpreter step.
  152. self assert: self interpreter currentNode value equals: 2.
  153. "Result"
  154. self interpreter step.
  155. self assert: self interpreter result equals: 3
  156. !
  157. testSimpleStepping
  158. self interpret: 'foo 1'.
  159. "SequenceNode"
  160. self interpreter step.
  161. self assert: self interpreter result isNil.
  162. "ValueNode"
  163. self interpreter step.
  164. self assert: self interpreter result equals: 1
  165. ! !
  166. TestCase subclass: #CodeGeneratorTest
  167. instanceVariableNames: 'receiver'
  168. package: 'Compiler-Tests'!
  169. !CodeGeneratorTest methodsFor: 'accessing'!
  170. codeGeneratorClass
  171. ^ CodeGenerator
  172. !
  173. targetClass
  174. ^ DoIt
  175. ! !
  176. !CodeGeneratorTest methodsFor: 'factory'!
  177. compiler
  178. ^ Compiler new
  179. codeGeneratorClass: self codeGeneratorClass;
  180. yourself
  181. ! !
  182. !CodeGeneratorTest methodsFor: 'initialization'!
  183. setUp
  184. receiver := self targetClass new
  185. !
  186. tearDown
  187. "receiver := nil"
  188. ! !
  189. !CodeGeneratorTest methodsFor: 'testing'!
  190. should: aString return: anObject
  191. | method result |
  192. method := self compiler install: aString forClass: self targetClass category: 'tests'.
  193. result := receiver perform: method selector.
  194. self targetClass removeCompiledMethod: method.
  195. self assert: anObject equals: result
  196. ! !
  197. !CodeGeneratorTest methodsFor: 'tests'!
  198. testAssignment
  199. self should: 'foo | a | a := true ifTrue: [ 1 ]. ^ a' return: 1.
  200. self should: 'foo | a | a := false ifTrue: [ 1 ]. ^ a' return: nil.
  201. self should: 'foo | a | ^ a := true ifTrue: [ 1 ]' return: 1
  202. !
  203. testBackslashSelectors
  204. self should: '\ arg ^ 4' return: 4.
  205. self should: '\\ arg ^ 42' return: 42
  206. !
  207. testBlockReturn
  208. self should: 'foo ^ #(1 2 3) collect: [ :each | true ifTrue: [ each + 1 ] ]' return: #(2 3 4).
  209. self should: 'foo ^ #(1 2 3) collect: [ :each | false ifFalse: [ each + 1 ] ]' return: #(2 3 4).
  210. self should: 'foo ^ #(1 2 3) collect: [ :each | each odd ifTrue: [ each + 1 ] ifFalse: [ each - 1 ] ]' return: #(2 1 4).
  211. !
  212. testCascades
  213. self should: 'foo ^ Array new add: 3; add: 4; yourself' return: #(3 4)
  214. !
  215. testDynamicArrayElementsOrdered
  216. self should: 'foo
  217. | x |
  218. x := 1.
  219. ^ { x. true ifTrue: [ x := 2 ] }
  220. ' return: #(1 2).
  221. !
  222. testDynamicDictionaryElementsOrdered
  223. self should: 'foo
  224. | x |
  225. x := ''foo''->1.
  226. ^ #{ x. (true ifTrue: [ x := ''bar''->2 ]) }
  227. ' return: #{'foo'->1. 'bar'->2}.
  228. !
  229. testInnerTemporalDependentElementsOrdered
  230. self should: 'foo
  231. | x |
  232. x := Array.
  233. ^ x with: ''foo''->x with: ''bar''->(true ifTrue: [ x := 2 ])
  234. ' return: {'foo'->Array. 'bar'->2}.
  235. self should: 'foo
  236. | x |
  237. x := 1.
  238. ^ Array with: ''foo''->x with: ''bar''->(true ifTrue: [ x := 2 ])
  239. ' return: {'foo'->1. 'bar'->2}.
  240. self should: 'foo
  241. | x |
  242. x := 1.
  243. ^ { ''foo''->x. ''bar''->(true ifTrue: [ x := 2 ]) }
  244. ' return: {'foo'->1. 'bar'->2}.
  245. self should: 'foo
  246. | x |
  247. x := 1.
  248. ^ #{ ''foo''->x. ''bar''->(true ifTrue: [ x := 2 ]) }
  249. ' return: #{'foo'->1. 'bar'->2}.
  250. !
  251. testLiterals
  252. self should: 'foo ^ 1' return: 1.
  253. self should: 'foo ^ ''hello''' return: 'hello'.
  254. self should: 'foo ^ #(1 2 3 4)' return: #(1 2 3 4).
  255. self should: 'foo ^ {1. [:x | x ] value: 2. 3. [4] value}' return: #(1 2 3 4).
  256. self should: 'foo ^ true' return: true.
  257. self should: 'foo ^ false' return: false.
  258. self should: 'foo ^ #{1->2. 3->4}' return: #{1->2. 3->4}.
  259. self should: 'foo ^ #hello' return: #hello.
  260. self should: 'foo ^ -123.456' return: -123.456
  261. !
  262. testLocalReturn
  263. self should: 'foo ^ 1' return: 1.
  264. self should: 'foo ^ 1 + 1' return: 2.
  265. self should: 'foo ' return: receiver.
  266. self should: 'foo self asString' return: receiver.
  267. self should: 'foo | a b | a := 1. b := 2. ^ a + b' return: 3
  268. !
  269. testMessageSends
  270. self should: 'foo ^ 1 asString' return: '1'.
  271. self should: 'foo ^ 1 + 1' return: 2.
  272. self should: 'foo ^ 1 + 2 * 3' return: 9.
  273. self should: 'foo ^ 1 to: 3' return: #(1 2 3).
  274. self should: 'foo ^ 1 to: 5 by: 2' return: #(1 3 5)
  275. !
  276. testMutableLiterals
  277. "Mutable literals must be aliased in cascades.
  278. See https://github.com/amber-smalltalk/amber/issues/428"
  279. self
  280. should: 'foo ^ #( 1 2 ) at: 1 put: 3; yourself'
  281. return: #(3 2)
  282. !
  283. testNestedIfTrue
  284. self should: 'foo ^ true ifTrue: [ false ifFalse: [ 1 ] ]' return: 1.
  285. self should: 'foo ^ true ifTrue: [ false ifTrue: [ 1 ] ]' return: nil.
  286. self should: 'foo true ifTrue: [ false ifFalse: [ ^ 1 ] ]' return: 1.
  287. self should: 'foo true ifTrue: [ false ifTrue: [ ^ 1 ] ]' return: receiver.
  288. !
  289. testNonLocalReturn
  290. self should: 'foo [ ^ 1 ] value' return: 1.
  291. self should: 'foo [ ^ 1 + 1 ] value' return: 2.
  292. self should: 'foo | a b | a := 1. b := 2. [ ^ a + b ] value. self halt' return: 3.
  293. self should: 'foo [ :x | ^ x + x ] value: 4. ^ 2' return: 8
  294. !
  295. testPascalCaseGlobal
  296. self should: 'foo ^Object' return: (smalltalk at: 'Object').
  297. self should: 'foo ^NonExistent' return: nil
  298. !
  299. testSendReceiverAndArgumentsOrdered
  300. self should: 'foo
  301. | x |
  302. x := 1.
  303. ^ Array with: x with: (true ifTrue: [ x := 2 ])
  304. ' return: #(1 2).
  305. self should: 'foo
  306. | x |
  307. x := Array.
  308. ^ x with: x with: (true ifTrue: [ x := 2 ])
  309. ' return: {Array. 2}.
  310. !
  311. testifFalse
  312. self should: 'foo true ifFalse: [ ^ 1 ]' return: receiver.
  313. self should: 'foo false ifFalse: [ ^ 2 ]' return: 2.
  314. self should: 'foo ^ true ifFalse: [ 1 ]' return: nil.
  315. self should: 'foo ^ false ifFalse: [ 2 ]' return: 2.
  316. !
  317. testifFalseIfTrue
  318. self should: 'foo true ifFalse: [ ^ 1 ] ifTrue: [ ^ 2 ]' return: 2.
  319. self should: 'foo false ifFalse: [ ^ 2 ] ifTrue: [ ^1 ]' return: 2.
  320. self should: 'foo ^ true ifFalse: [ 1 ] ifTrue: [ 2 ]' return: 2.
  321. self should: 'foo ^ false ifFalse: [ 2 ] ifTrue: [ 1 ]' return: 2.
  322. !
  323. testifNil
  324. self should: 'foo ^ 1 ifNil: [ 2 ]' return: 1.
  325. self should: 'foo ^ nil ifNil: [ 2 ]' return: 2.
  326. self should: 'foo 1 ifNil: [ ^ 2 ]' return: receiver.
  327. self should: 'foo nil ifNil: [ ^ 2 ]' return: 2.
  328. !
  329. testifNilIfNotNil
  330. self should: 'foo ^ 1 ifNil: [ 2 ] ifNotNil: [ 3 ]' return: 3.
  331. self should: 'foo ^ nil ifNil: [ 2 ] ifNotNil: [ 3 ]' return: 2.
  332. self should: 'foo 1 ifNil: [ ^ 2 ] ifNotNil: [ ^3 ]' return: 3.
  333. self should: 'foo nil ifNil: [ ^ 2 ] ifNotNil: [ ^3 ]' return: 2.
  334. !
  335. testifNotNil
  336. self should: 'foo ^ 1 ifNotNil: [ 2 ]' return: 2.
  337. self should: 'foo ^ nil ifNotNil: [ 2 ]' return: nil.
  338. self should: 'foo 1 ifNotNil: [ ^ 2 ]' return: 2.
  339. self should: 'foo nil ifNotNil: [ ^ 2 ]' return: receiver.
  340. !
  341. testifNotNilWithArgument
  342. self should: 'foo ^ 1 ifNotNil: [ :val | val + 2 ]' return: 3.
  343. self should: 'foo ^ nil ifNotNil: [ :val | val + 2 ]' return: nil.
  344. self should: 'foo ^ 1 ifNil: [ 5 ] ifNotNil: [ :val | val + 2 ]' return: 3.
  345. self should: 'foo ^ nil ifNil: [ 5 ] ifNotNil: [ :val | val + 2 ]' return: 5.
  346. self should: 'foo ^ 1 ifNotNil: [ :val | val + 2 ] ifNil: [ 5 ]' return: 3.
  347. self should: 'foo ^ nil ifNotNil: [ :val | val + 2 ] ifNil: [ 5 ]' return: 5
  348. !
  349. testifTrue
  350. self should: 'foo false ifTrue: [ ^ 1 ]' return: receiver.
  351. self should: 'foo true ifTrue: [ ^ 2 ]' return: 2.
  352. self should: 'foo ^ false ifTrue: [ 1 ]' return: nil.
  353. self should: 'foo ^ true ifTrue: [ 2 ]' return: 2.
  354. !
  355. testifTrueIfFalse
  356. self should: 'foo false ifTrue: [ ^ 1 ] ifFalse: [ ^2 ]' return: 2.
  357. self should: 'foo true ifTrue: [ ^ 1 ] ifFalse: [ ^ 2 ]' return: 1.
  358. self should: 'foo ^ false ifTrue: [ 2 ] ifFalse: [ 1 ]' return: 1.
  359. self should: 'foo ^ true ifTrue: [ 2 ] ifFalse: [ 1 ]' return: 2.
  360. ! !
  361. CodeGeneratorTest subclass: #InliningCodeGeneratorTest
  362. instanceVariableNames: ''
  363. package: 'Compiler-Tests'!
  364. !InliningCodeGeneratorTest methodsFor: 'accessing'!
  365. codeGeneratorClass
  366. ^ InliningCodeGenerator
  367. ! !
  368. TestCase subclass: #ScopeVarTest
  369. instanceVariableNames: ''
  370. package: 'Compiler-Tests'!
  371. !ScopeVarTest methodsFor: 'tests'!
  372. testClassRefVar
  373. | node |
  374. node := ClassReferenceNode new
  375. value: 'Object';
  376. yourself.
  377. SemanticAnalyzer new visit: node.
  378. self assert: node binding isClassRefVar
  379. !
  380. testInstanceVar
  381. | node scope |
  382. node := VariableNode new
  383. value: 'bzzz';
  384. yourself.
  385. scope := MethodLexicalScope new.
  386. scope addIVar: 'bzzz'.
  387. self assert: (scope bindingFor: node) isInstanceVar
  388. !
  389. testPseudoVar
  390. | node pseudoVars |
  391. pseudoVars := #('self' 'super' 'true' 'false' 'nil').
  392. pseudoVars do: [:each |
  393. node := VariableNode new
  394. value: each;
  395. yourself.
  396. self assert: (MethodLexicalScope new bindingFor: node) isPseudoVar ]
  397. !
  398. testTempVar
  399. | node scope |
  400. node := VariableNode new
  401. value: 'bzzz';
  402. yourself.
  403. scope := MethodLexicalScope new.
  404. scope addTemp: 'bzzz'.
  405. self assert: (scope bindingFor: node) isTempVar
  406. !
  407. testUnknownVar
  408. | node |
  409. node := VariableNode new
  410. value: 'bzzz';
  411. yourself.
  412. self assert: (MethodLexicalScope new bindingFor: node) isNil
  413. ! !
  414. TestCase subclass: #SemanticAnalyzerTest
  415. instanceVariableNames: 'analyzer'
  416. package: 'Compiler-Tests'!
  417. !SemanticAnalyzerTest methodsFor: 'running'!
  418. setUp
  419. analyzer := SemanticAnalyzer on: Object
  420. ! !
  421. !SemanticAnalyzerTest methodsFor: 'tests'!
  422. testAssignment
  423. | src ast |
  424. src := 'foo self := 1'.
  425. ast := smalltalk parse: src.
  426. self should: [analyzer visit: ast] raise: InvalidAssignmentError
  427. !
  428. testNonLocalReturn
  429. | src ast |
  430. src := 'foo | a | a + 1. ^ a'.
  431. ast := smalltalk parse: src.
  432. analyzer visit: ast.
  433. self deny: ast scope hasNonLocalReturn
  434. !
  435. testNonLocalReturn2
  436. | src ast |
  437. src := 'foo | a | a + 1. [ [ ^ a] ]'.
  438. ast := smalltalk parse: src.
  439. analyzer visit: ast.
  440. self assert: ast scope hasNonLocalReturn
  441. !
  442. testScope
  443. | src ast |
  444. src := 'foo | a | a + 1. [ | b | b := a ]'.
  445. ast := smalltalk parse: src.
  446. analyzer visit: ast.
  447. self deny: ast nodes first nodes last scope == ast scope.
  448. !
  449. testScope2
  450. | src ast |
  451. src := 'foo | a | a + 1. [ [ | b | b := a ] ]'.
  452. ast := smalltalk parse: src.
  453. analyzer visit: ast.
  454. self deny: ast nodes first nodes last nodes first nodes first scope == ast scope.
  455. !
  456. testScopeLevel
  457. | src ast |
  458. src := 'foo | a | a + 1. [ [ | b | b := a ] ]'.
  459. ast := smalltalk parse: src.
  460. analyzer visit: ast.
  461. self assert: ast scope scopeLevel equals: 1.
  462. self assert: ast nodes first nodes last nodes first nodes first scope scopeLevel equals: 3
  463. !
  464. testUnknownVariables
  465. | src ast |
  466. src := 'foo | a | b + a'.
  467. ast := smalltalk parse: src.
  468. self should: [ analyzer visit: ast ] raise: UnknownVariableError
  469. !
  470. testUnknownVariablesWithScope
  471. | src ast |
  472. src := 'foo | a b | [ c + 1. [ a + 1. d + 1 ]]'.
  473. ast := smalltalk parse: src.
  474. self should: [ analyzer visit: ast ] raise: UnknownVariableError
  475. !
  476. testVariableShadowing
  477. | src ast |
  478. src := 'foo | a | a + 1'.
  479. ast := smalltalk parse: src.
  480. analyzer visit: ast
  481. !
  482. testVariableShadowing2
  483. | src ast |
  484. src := 'foo | a | a + 1. [ | a | a := 2 ]'.
  485. ast := smalltalk parse: src.
  486. self should: [analyzer visit: ast] raise: ShadowingVariableError
  487. !
  488. testVariableShadowing3
  489. | src ast |
  490. src := 'foo | a | a + 1. [ | b | b := 2 ]'.
  491. ast := smalltalk parse: src.
  492. analyzer visit: ast
  493. !
  494. testVariableShadowing4
  495. | src ast |
  496. src := 'foo | a | a + 1. [ [ [ | b | b := 2 ] ] ]'.
  497. ast := smalltalk parse: src.
  498. analyzer visit: ast
  499. !
  500. testVariableShadowing5
  501. | src ast |
  502. src := 'foo | a | a + 1. [ [ [ | a | a := 2 ] ] ]'.
  503. ast := smalltalk parse: src.
  504. self should: [analyzer visit: ast] raise: ShadowingVariableError
  505. !
  506. testVariablesLookup
  507. | src ast |
  508. src := 'foo | a | a + 1. [ | b | b := a ]'.
  509. ast := smalltalk parse: src.
  510. analyzer visit: ast.
  511. "Binding for `a` in the message send"
  512. self assert: ast nodes first nodes first receiver binding isTempVar.
  513. self assert: ast nodes first nodes first receiver binding scope == ast scope.
  514. "Binding for `b`"
  515. self assert: ast nodes first nodes last nodes first nodes first left binding isTempVar.
  516. self assert: ast nodes first nodes last nodes first nodes first left binding scope == ast nodes first nodes last scope.
  517. ! !