resin 0.2.2 → 0.2.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/amber/css/amber-normalize.css +73 -73
- data/amber/css/amber-normalize.less +1 -1
- data/amber/css/amber.css +106 -106
- data/amber/css/helios.css +242 -0
- data/amber/images/hsplitter.png +0 -0
- data/amber/images/vsplitter.png +0 -0
- data/amber/js/Benchfib.deploy.js +116 -38
- data/amber/js/Benchfib.js +120 -42
- data/amber/js/Canvas.deploy.js +674 -403
- data/amber/js/Canvas.js +682 -411
- data/amber/js/Compiler-AST.deploy.js +1150 -0
- data/amber/js/Compiler-AST.js +1591 -0
- data/amber/js/Compiler-Core.deploy.js +1562 -0
- data/amber/js/Compiler-Core.js +1972 -0
- data/amber/js/Compiler-Exceptions.deploy.js +114 -0
- data/amber/js/Compiler-Exceptions.js +161 -0
- data/amber/js/Compiler-IR.deploy.js +2326 -0
- data/amber/js/Compiler-IR.js +3146 -0
- data/amber/js/Compiler-Inlining.deploy.js +1147 -0
- data/amber/js/Compiler-Inlining.js +1514 -0
- data/amber/js/Compiler-Semantic.deploy.js +1207 -0
- data/amber/js/Compiler-Semantic.js +1628 -0
- data/amber/js/Compiler-Tests.deploy.js +646 -60
- data/amber/js/Compiler-Tests.js +843 -82
- data/amber/js/Compiler.deploy.js +1097 -159
- data/amber/js/Compiler.js +1414 -161
- data/amber/js/Examples.deploy.js +31 -15
- data/amber/js/Examples.js +33 -17
- data/amber/js/Helios-Announcements.deploy.js +127 -0
- data/amber/js/Helios-Announcements.js +157 -0
- data/amber/js/Helios-Browser.deploy.js +1473 -0
- data/amber/js/Helios-Browser.js +1953 -0
- data/amber/js/Helios-Commands.deploy.js +403 -0
- data/amber/js/Helios-Commands.js +563 -0
- data/amber/js/Helios-Core.deploy.js +1070 -0
- data/amber/js/Helios-Core.js +1445 -0
- data/amber/js/Helios-Environments.deploy.js +132 -0
- data/amber/js/Helios-Environments.js +179 -0
- data/amber/js/Helios-Inspector.deploy.js +855 -0
- data/amber/js/Helios-Inspector.js +1155 -0
- data/amber/js/Helios-KeyBindings.deploy.js +753 -0
- data/amber/js/Helios-KeyBindings.js +1023 -0
- data/amber/js/Helios-Layout.deploy.js +383 -0
- data/amber/js/Helios-Layout.js +523 -0
- data/amber/js/Helios-Workspace.deploy.js +799 -0
- data/amber/js/Helios-Workspace.js +1074 -0
- data/amber/js/IDE.deploy.js +2541 -1490
- data/amber/js/IDE.js +2721 -1660
- data/amber/js/Importer-Exporter.deploy.js +671 -0
- data/amber/js/Importer-Exporter.js +816 -0
- data/amber/js/Kernel-Announcements.deploy.js +137 -20
- data/amber/js/Kernel-Announcements.js +176 -22
- data/amber/js/Kernel-Classes.deploy.js +555 -168
- data/amber/js/Kernel-Classes.js +662 -205
- data/amber/js/Kernel-Collections.deploy.js +1403 -618
- data/amber/js/Kernel-Collections.js +1545 -690
- data/amber/js/Kernel-Exceptions.deploy.js +109 -45
- data/amber/js/Kernel-Exceptions.js +123 -49
- data/amber/js/Kernel-Methods.deploy.js +196 -81
- data/amber/js/Kernel-Methods.js +214 -89
- data/amber/js/Kernel-Objects.deploy.js +1542 -1117
- data/amber/js/Kernel-Objects.js +1593 -1148
- data/amber/js/Kernel-Tests.deploy.js +1725 -772
- data/amber/js/Kernel-Tests.js +2301 -1123
- data/amber/js/Kernel-Transcript.deploy.js +23 -25
- data/amber/js/Kernel-Transcript.js +24 -26
- data/amber/js/SUnit.deploy.js +204 -131
- data/amber/js/SUnit.js +222 -139
- data/amber/js/Spaces.deploy.js +240 -0
- data/amber/js/Spaces.js +326 -0
- data/amber/js/amber.js +26 -7
- data/amber/js/boot.js +65 -47
- data/amber/js/init.js +1 -1
- data/amber/js/lib/CodeMirror/amber.css +21 -21
- data/amber/js/lib/CodeMirror/codemirror.css +119 -13
- data/amber/js/lib/CodeMirror/codemirror.js +2219 -1220
- data/amber/js/lib/CodeMirror/smalltalk.js +134 -129
- data/amber/js/lib/bootstrap/css/bootstrap.css +5837 -0
- data/amber/js/lib/bootstrap/css/bootstrap.min.css +841 -0
- data/amber/js/lib/bootstrap/img/glyphicons-halflings-white.png +0 -0
- data/amber/js/lib/bootstrap/img/glyphicons-halflings.png +0 -0
- data/amber/js/lib/bootstrap/js/bootstrap.js +2038 -0
- data/amber/js/lib/bootstrap/js/bootstrap.min.js +7 -0
- data/amber/js/lib/jQuery/jquery-1.8.2.min.js +2 -0
- data/amber/js/lib/jQuery/jquery-ui-1.8.24.custom.min.js +125 -0
- data/amber/st/Compiler-AST.st +505 -0
- data/amber/st/Compiler-Core.st +835 -0
- data/amber/st/Compiler-Exceptions.st +87 -0
- data/amber/st/Compiler-IR.st +1097 -0
- data/amber/st/Compiler-Inlining.st +650 -0
- data/amber/st/Compiler-Semantic.st +558 -0
- data/amber/st/Compiler-Tests.st +285 -381
- data/amber/st/Compiler.st +725 -2
- data/amber/st/Helios-Announcements.st +104 -0
- data/amber/st/Helios-Browser.st +708 -0
- data/amber/st/Helios-Commands.st +223 -0
- data/amber/st/Helios-Core.st +532 -0
- data/amber/st/Helios-Environments.st +98 -0
- data/amber/st/Helios-Inspector.st +367 -0
- data/amber/st/Helios-KeyBindings.st +337 -0
- data/amber/st/Helios-Layout.st +199 -0
- data/amber/st/Helios-Workspace.st +367 -0
- data/amber/st/IDE.st +75 -53
- data/amber/st/Importer-Exporter.st +386 -0
- data/amber/st/Kernel-Announcements.st +92 -0
- data/amber/st/Kernel-Classes.st +137 -15
- data/amber/st/Kernel-Collections.st +137 -47
- data/amber/st/Kernel-Exceptions.st +14 -0
- data/amber/st/Kernel-Methods.st +9 -1
- data/amber/st/Kernel-Objects.st +29 -5
- data/amber/st/Kernel-Tests.st +545 -199
- data/amber/st/SUnit.st +10 -0
- data/amber/st/Spaces.st +142 -0
- data/lib/resin/app.rb +1 -1
- metadata +86 -31
- data/amber/js/lib/jQuery/jquery-1.4.4.min.js +0 -167
- data/amber/js/lib/jQuery/jquery-1.6.4.min.js +0 -4
data/amber/st/Compiler-Tests.st
CHANGED
|
@@ -1,471 +1,375 @@
|
|
|
1
1
|
Smalltalk current createPackage: 'Compiler-Tests' properties: #{}!
|
|
2
|
-
TestCase subclass: #
|
|
3
|
-
instanceVariableNames: ''
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
!ImporterTest methodsFor: 'private'!
|
|
7
|
-
|
|
8
|
-
chunkString
|
|
9
|
-
|
|
10
|
-
^'!!Object methodsFor: ''importer test method''!!
|
|
2
|
+
TestCase subclass: #CodeGeneratorTest
|
|
3
|
+
instanceVariableNames: 'receiver'
|
|
4
|
+
package: 'Compiler-Tests'!
|
|
11
5
|
|
|
12
|
-
|
|
6
|
+
!CodeGeneratorTest methodsFor: 'accessing'!
|
|
13
7
|
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
'
|
|
8
|
+
codeGeneratorClass
|
|
9
|
+
^ CodeGenerator
|
|
17
10
|
!
|
|
18
11
|
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
Object subclass: #CypressSnapshot
|
|
23
|
-
instanceVariableNames: ''definitions''
|
|
24
|
-
package: ''Cypress-Definitions''!!
|
|
25
|
-
|
|
26
|
-
!!CypressSnapshot methodsFor: ''not yet classified''!!
|
|
27
|
-
|
|
28
|
-
definitions: aDefinitions
|
|
29
|
-
|
|
30
|
-
definitions := aDefinitions
|
|
31
|
-
!!
|
|
32
|
-
|
|
33
|
-
definitions
|
|
34
|
-
|
|
35
|
-
^definitions
|
|
36
|
-
!! !!
|
|
37
|
-
|
|
38
|
-
!!CypressSnapshot class methodsFor: ''not yet classified''!!
|
|
39
|
-
|
|
40
|
-
definitions: aDefinitions
|
|
41
|
-
|
|
42
|
-
^(self new) definitions: aDefinitions
|
|
43
|
-
!! !!
|
|
44
|
-
|
|
45
|
-
Object subclass: #CypressPackage
|
|
46
|
-
instanceVariableNames: ''name''
|
|
47
|
-
package: ''Cypress-Definitions''!!
|
|
48
|
-
|
|
49
|
-
!!CypressPackage methodsFor: ''not yet classified''!!
|
|
50
|
-
|
|
51
|
-
= other
|
|
52
|
-
^ other species = self species and: [other name sameAs: name]
|
|
53
|
-
!!
|
|
12
|
+
targetClass
|
|
13
|
+
^ DoIt
|
|
14
|
+
! !
|
|
54
15
|
|
|
55
|
-
|
|
56
|
-
^ name
|
|
57
|
-
!!
|
|
16
|
+
!CodeGeneratorTest methodsFor: 'factory'!
|
|
58
17
|
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
18
|
+
compiler
|
|
19
|
+
^ Compiler new
|
|
20
|
+
codeGeneratorClass: self codeGeneratorClass;
|
|
21
|
+
yourself
|
|
22
|
+
! !
|
|
62
23
|
|
|
63
|
-
|
|
64
|
-
| package definitions name |
|
|
65
|
-
package := Package named: self name.
|
|
66
|
-
definitions := OrderedCollection new.
|
|
67
|
-
package sortedClasses do: [:cls |
|
|
68
|
-
definitions add: cls asCypressClassDefinition.
|
|
69
|
-
cls methodDictionary values do: [:method |
|
|
70
|
-
(method category match: ''^\*'') ifFalse: [
|
|
71
|
-
definitions add: method asCypressMethodDefinition ]].
|
|
72
|
-
cls class methodDictionary values do: [:method |
|
|
73
|
-
(method category match: ''^\*'') ifFalse: [
|
|
74
|
-
definitions add: method asCypressMethodDefinition ]]].
|
|
75
|
-
name := package name.
|
|
76
|
-
Smalltalk current classes, (Smalltalk current classes collect: [:each | each class]) do: [:each |
|
|
77
|
-
each methodDictionary values do: [:method |
|
|
78
|
-
method category = (''*'', name) ifTrue: [
|
|
79
|
-
definitions add: method asCypressMethodDefinition ]]].
|
|
80
|
-
^ CypressSnapshot definitions: definitions
|
|
81
|
-
!!
|
|
24
|
+
!CodeGeneratorTest methodsFor: 'initialization'!
|
|
82
25
|
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
26
|
+
setUp
|
|
27
|
+
receiver := self targetClass new
|
|
28
|
+
!
|
|
86
29
|
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
30
|
+
tearDown
|
|
31
|
+
"receiver := nil"
|
|
32
|
+
! !
|
|
90
33
|
|
|
91
|
-
|
|
34
|
+
!CodeGeneratorTest methodsFor: 'testing'!
|
|
92
35
|
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
!!
|
|
36
|
+
should: aString return: anObject
|
|
37
|
+
| method result |
|
|
96
38
|
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
39
|
+
method := self compiler install: aString forClass: self targetClass category: 'tests'.
|
|
40
|
+
result := receiver perform: method selector.
|
|
41
|
+
self targetClass removeCompiledMethod: method.
|
|
42
|
+
self assert: anObject equals: result
|
|
43
|
+
! !
|
|
100
44
|
|
|
101
|
-
|
|
102
|
-
self subclassResponsibility
|
|
103
|
-
!!
|
|
45
|
+
!CodeGeneratorTest methodsFor: 'tests'!
|
|
104
46
|
|
|
105
|
-
|
|
106
|
-
^
|
|
107
|
-
|
|
47
|
+
testAssignment
|
|
48
|
+
self should: 'foo | a | a := true ifTrue: [ 1 ]. ^ a' return: 1.
|
|
49
|
+
self should: 'foo | a | a := false ifTrue: [ 1 ]. ^ a' return: nil.
|
|
108
50
|
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
package: ''Cypress-Definitions''!!
|
|
51
|
+
self should: 'foo | a | ^ a := true ifTrue: [ 1 ]' return: 1
|
|
52
|
+
!
|
|
112
53
|
|
|
113
|
-
|
|
54
|
+
testBlockReturn
|
|
55
|
+
self should: 'foo ^ #(1 2 3) collect: [ :each | true ifTrue: [ each + 1 ] ]' return: #(2 3 4).
|
|
56
|
+
self should: 'foo ^ #(1 2 3) collect: [ :each | false ifFalse: [ each + 1 ] ]' return: #(2 3 4).
|
|
57
|
+
self should: 'foo ^ #(1 2 3) collect: [ :each | each odd ifTrue: [ each + 1 ] ifFalse: [ each - 1 ] ]' return: #(2 1 4).
|
|
58
|
+
!
|
|
114
59
|
|
|
115
|
-
|
|
116
|
-
| base target |
|
|
117
|
-
operations := OrderedCollection new.
|
|
118
|
-
base := CypressDefinitionIndex definitions: baseSnapshot definitions.
|
|
119
|
-
target := CypressDefinitionIndex definitions: targetSnapshot definitions.
|
|
60
|
+
testCascades
|
|
120
61
|
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
base
|
|
124
|
-
definitionLike: t
|
|
125
|
-
ifPresent: [:b | (b isSameRevisionAs: t) ifFalse: [operations add: (CypressModification of: b to: t)]]
|
|
126
|
-
ifAbsent: [operations add: (CypressAddition of: t)]].
|
|
127
|
-
|
|
128
|
-
base definitions do:
|
|
129
|
-
[:b |
|
|
130
|
-
target
|
|
131
|
-
definitionLike: b
|
|
132
|
-
ifPresent: [:t | ]
|
|
133
|
-
ifAbsent: [operations add: (CypressRemoval of: b)]]
|
|
134
|
-
!!
|
|
135
|
-
|
|
136
|
-
operations
|
|
137
|
-
|
|
138
|
-
^operations
|
|
139
|
-
!! !!
|
|
140
|
-
|
|
141
|
-
!!CypressPatch class methodsFor: ''not yet classified''!!
|
|
142
|
-
|
|
143
|
-
fromBase: baseSnapshot toTarget: targetSnapshot
|
|
144
|
-
^ (self new)
|
|
145
|
-
fromBase: baseSnapshot
|
|
146
|
-
toTarget: targetSnapshot
|
|
147
|
-
!! !!
|
|
148
|
-
|
|
149
|
-
Object subclass: #CypressDefinitionIndex
|
|
150
|
-
instanceVariableNames: ''definitionMap''
|
|
151
|
-
package: ''Cypress-Definitions''!!
|
|
152
|
-
|
|
153
|
-
!!CypressDefinitionIndex methodsFor: ''not yet classified''!!
|
|
154
|
-
|
|
155
|
-
add: aDefinition
|
|
156
|
-
^ self definitionMap at: aDefinition description put: aDefinition
|
|
157
|
-
!!
|
|
158
|
-
|
|
159
|
-
addAll: aCollection
|
|
160
|
-
aCollection do: [:ea | self add: ea]
|
|
161
|
-
!!
|
|
162
|
-
|
|
163
|
-
definitionLike: aDefinition ifPresent: foundBlock ifAbsent: errorBlock
|
|
164
|
-
| definition |
|
|
165
|
-
definition := self definitionMap at: aDefinition description ifAbsent: [].
|
|
166
|
-
^ definition
|
|
167
|
-
ifNil: errorBlock
|
|
168
|
-
ifNotNil: [foundBlock value: definition]
|
|
169
|
-
!!
|
|
170
|
-
|
|
171
|
-
definitions
|
|
172
|
-
^self definitionMap values
|
|
173
|
-
!!
|
|
174
|
-
|
|
175
|
-
definitionMap
|
|
176
|
-
definitionMap ifNil: [ definitionMap := Dictionary new ].
|
|
177
|
-
^ definitionMap
|
|
178
|
-
!!
|
|
179
|
-
|
|
180
|
-
remove: aDefinition
|
|
181
|
-
self definitionMap removeKey: aDefinition description ifAbsent: []
|
|
182
|
-
!! !!
|
|
183
|
-
|
|
184
|
-
!!CypressDefinitionIndex class methodsFor: ''not yet classified''!!
|
|
185
|
-
|
|
186
|
-
definitions: aCollection
|
|
187
|
-
^ self new addAll: aCollection
|
|
188
|
-
!! !!
|
|
189
|
-
|
|
190
|
-
Object subclass: #CypressPatchOperation
|
|
191
|
-
instanceVariableNames: ''''
|
|
192
|
-
package: ''Cypress-Definitions''!!
|
|
193
|
-
|
|
194
|
-
CypressDefinition subclass: #CypressClassDefinition
|
|
195
|
-
instanceVariableNames: ''name superclassName category comment instVarNames classInstVarNames''
|
|
196
|
-
package: ''Cypress-Definitions''!!
|
|
197
|
-
|
|
198
|
-
!!CypressClassDefinition methodsFor: ''not yet classified''!!
|
|
199
|
-
|
|
200
|
-
name: aClassName superclassName: aSuperclassName category: aCategory instVarNames: anInstanceVariableNames classInstVarNames: aClassInstanceVariableNames comment: aComment
|
|
201
|
-
|
|
202
|
-
name := aClassName.
|
|
203
|
-
superclassName := aSuperclassName.
|
|
204
|
-
category := aCategory.
|
|
205
|
-
instVarNames := anInstanceVariableNames.
|
|
206
|
-
classInstVarNames := aClassInstanceVariableNames.
|
|
207
|
-
comment := aComment
|
|
208
|
-
!!
|
|
209
|
-
|
|
210
|
-
= aDefinition
|
|
211
|
-
^(super = aDefinition)
|
|
212
|
-
and: [superclassName = aDefinition superclassName
|
|
213
|
-
and: [category = aDefinition category
|
|
214
|
-
and: [instVarNames = aDefinition instVarNames
|
|
215
|
-
and: [classInstVarNames = aDefinition classInstVarNames
|
|
216
|
-
and: [comment = aDefinition comment]]]]]
|
|
217
|
-
!!
|
|
218
|
-
|
|
219
|
-
superclassName
|
|
220
|
-
|
|
221
|
-
^superclassName
|
|
222
|
-
!!
|
|
223
|
-
|
|
224
|
-
name
|
|
225
|
-
|
|
226
|
-
^name
|
|
227
|
-
!!
|
|
228
|
-
|
|
229
|
-
category
|
|
230
|
-
|
|
231
|
-
^category
|
|
232
|
-
!!
|
|
233
|
-
|
|
234
|
-
comment
|
|
235
|
-
|
|
236
|
-
^comment
|
|
237
|
-
!!
|
|
62
|
+
self should: 'foo ^ Array new add: 3; add: 4; yourself' return: #(3 4)
|
|
63
|
+
!
|
|
238
64
|
|
|
239
|
-
|
|
65
|
+
testLiterals
|
|
66
|
+
self should: 'foo ^ 1' return: 1.
|
|
67
|
+
self should: 'foo ^ ''hello''' return: 'hello'.
|
|
68
|
+
self should: 'foo ^ #(1 2 3 4)' return: #(1 2 3 4).
|
|
69
|
+
self should: 'foo ^ {1. [:x | x ] value: 2. 3. [4] value}' return: #(1 2 3 4).
|
|
70
|
+
self should: 'foo ^ true' return: true.
|
|
71
|
+
self should: 'foo ^ false' return: false.
|
|
72
|
+
self should: 'foo ^ #{1->2. 3->4}' return: #{1->2. 3->4}.
|
|
73
|
+
self should: 'foo ^ #hello' return: #hello.
|
|
74
|
+
self should: 'foo ^ -123.456' return: -123.456
|
|
75
|
+
!
|
|
240
76
|
|
|
241
|
-
|
|
242
|
-
|
|
77
|
+
testLocalReturn
|
|
78
|
+
self should: 'foo ^ 1' return: 1.
|
|
79
|
+
self should: 'foo ^ 1 + 1' return: 2.
|
|
80
|
+
self should: 'foo ' return: receiver.
|
|
81
|
+
self should: 'foo self asString' return: receiver.
|
|
82
|
+
self should: 'foo | a b | a := 1. b := 2. ^ a + b' return: 3
|
|
83
|
+
!
|
|
243
84
|
|
|
244
|
-
|
|
85
|
+
testMessageSends
|
|
86
|
+
self should: 'foo ^ 1 asString' return: '1'.
|
|
245
87
|
|
|
246
|
-
^
|
|
247
|
-
|
|
88
|
+
self should: 'foo ^ 1 + 1' return: 2.
|
|
89
|
+
self should: 'foo ^ 1 + 2 * 3' return: 9.
|
|
248
90
|
|
|
249
|
-
|
|
91
|
+
self should: 'foo ^ 1 to: 3' return: #(1 2 3).
|
|
92
|
+
self should: 'foo ^ 1 to: 5 by: 2' return: #(1 3 5)
|
|
93
|
+
!
|
|
250
94
|
|
|
251
|
-
|
|
252
|
-
|
|
95
|
+
testNestedIfTrue
|
|
96
|
+
self should: 'foo ^ true ifTrue: [ false ifFalse: [ 1 ] ]' return: 1.
|
|
97
|
+
self should: 'foo ^ true ifTrue: [ false ifTrue: [ 1 ] ]' return: nil.
|
|
253
98
|
|
|
254
|
-
|
|
99
|
+
self should: 'foo true ifTrue: [ false ifFalse: [ ^ 1 ] ]' return: 1.
|
|
100
|
+
self should: 'foo true ifTrue: [ false ifTrue: [ ^ 1 ] ]' return: receiver.
|
|
101
|
+
!
|
|
255
102
|
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
103
|
+
testNonLocalReturn
|
|
104
|
+
self should: 'foo [ ^ 1 ] value' return: 1.
|
|
105
|
+
self should: 'foo [ ^ 1 + 1 ] value' return: 2.
|
|
106
|
+
self should: 'foo | a b | a := 1. b := 2. [ ^ a + b ] value. self halt' return: 3.
|
|
107
|
+
self should: 'foo [ :x | ^ x + x ] value: 4. ^ 2' return: 8
|
|
108
|
+
!
|
|
262
109
|
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
!! !!
|
|
110
|
+
testifFalse
|
|
111
|
+
self should: 'foo true ifFalse: [ ^ 1 ]' return: receiver.
|
|
112
|
+
self should: 'foo false ifFalse: [ ^ 2 ]' return: 2.
|
|
113
|
+
|
|
114
|
+
self should: 'foo ^ true ifFalse: [ 1 ]' return: nil.
|
|
115
|
+
self should: 'foo ^ false ifFalse: [ 2 ]' return: 2.
|
|
116
|
+
!
|
|
271
117
|
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
118
|
+
testifFalseIfTrue
|
|
119
|
+
self should: 'foo true ifFalse: [ ^ 1 ] ifTrue: [ ^ 2 ]' return: 2.
|
|
120
|
+
self should: 'foo false ifFalse: [ ^ 2 ] ifTrue: [ ^1 ]' return: 2.
|
|
121
|
+
|
|
122
|
+
self should: 'foo ^ true ifFalse: [ 1 ] ifTrue: [ 2 ]' return: 2.
|
|
123
|
+
self should: 'foo ^ false ifFalse: [ 2 ] ifTrue: [ 1 ]' return: 2.
|
|
124
|
+
!
|
|
275
125
|
|
|
276
|
-
|
|
126
|
+
testifNil
|
|
127
|
+
self should: 'foo ^ 1 ifNil: [ 2 ]' return: 1.
|
|
128
|
+
self should: 'foo ^ nil ifNil: [ 2 ]' return: 2.
|
|
277
129
|
|
|
278
|
-
|
|
130
|
+
self should: 'foo 1 ifNil: [ ^ 2 ]' return: receiver.
|
|
131
|
+
self should: 'foo nil ifNil: [ ^ 2 ]' return: 2.
|
|
132
|
+
!
|
|
279
133
|
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
category := aCategory.
|
|
284
|
-
source := aSource.
|
|
285
|
-
!!
|
|
134
|
+
testifNilIfNotNil
|
|
135
|
+
self should: 'foo ^ 1 ifNil: [ 2 ] ifNotNil: [ 3 ]' return: 3.
|
|
136
|
+
self should: 'foo ^ nil ifNil: [ 2 ] ifNotNil: [ 3 ]' return: 2.
|
|
286
137
|
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
and: [ aDefinition category = self category ] ]
|
|
291
|
-
!!
|
|
138
|
+
self should: 'foo 1 ifNil: [ ^ 2 ] ifNotNil: [ ^3 ]' return: 3.
|
|
139
|
+
self should: 'foo nil ifNil: [ ^ 2 ] ifNotNil: [ ^3 ]' return: 2.
|
|
140
|
+
!
|
|
292
141
|
|
|
293
|
-
|
|
142
|
+
testifNotNil
|
|
143
|
+
self should: 'foo ^ 1 ifNotNil: [ 2 ]' return: 2.
|
|
144
|
+
self should: 'foo ^ nil ifNotNil: [ 2 ]' return: nil.
|
|
294
145
|
|
|
295
|
-
^
|
|
296
|
-
|
|
146
|
+
self should: 'foo 1 ifNotNil: [ ^ 2 ]' return: 2.
|
|
147
|
+
self should: 'foo nil ifNotNil: [ ^ 2 ]' return: receiver.
|
|
148
|
+
!
|
|
297
149
|
|
|
298
|
-
|
|
150
|
+
testifTrue
|
|
151
|
+
self should: 'foo false ifTrue: [ ^ 1 ]' return: receiver.
|
|
152
|
+
self should: 'foo true ifTrue: [ ^ 2 ]' return: 2.
|
|
153
|
+
|
|
154
|
+
self should: 'foo ^ false ifTrue: [ 1 ]' return: nil.
|
|
155
|
+
self should: 'foo ^ true ifTrue: [ 2 ]' return: 2.
|
|
156
|
+
!
|
|
299
157
|
|
|
300
|
-
|
|
301
|
-
|
|
158
|
+
testifTrueIfFalse
|
|
159
|
+
self should: 'foo false ifTrue: [ ^ 1 ] ifFalse: [ ^2 ]' return: 2.
|
|
160
|
+
self should: 'foo true ifTrue: [ ^ 1 ] ifFalse: [ ^ 2 ]' return: 1.
|
|
161
|
+
|
|
162
|
+
self should: 'foo ^ false ifTrue: [ 2 ] ifFalse: [ 1 ]' return: 1.
|
|
163
|
+
self should: 'foo ^ true ifTrue: [ 2 ] ifFalse: [ 1 ]' return: 2.
|
|
164
|
+
! !
|
|
302
165
|
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
with: selector
|
|
307
|
-
with: classIsMeta
|
|
308
|
-
!! !!
|
|
166
|
+
CodeGeneratorTest subclass: #InliningCodeGeneratorTest
|
|
167
|
+
instanceVariableNames: ''
|
|
168
|
+
package: 'Compiler-Tests'!
|
|
309
169
|
|
|
310
|
-
|
|
170
|
+
!InliningCodeGeneratorTest methodsFor: 'accessing'!
|
|
311
171
|
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
category: aCategory
|
|
316
|
-
source: aSource
|
|
172
|
+
codeGeneratorClass
|
|
173
|
+
^ InliningCodeGenerator
|
|
174
|
+
! !
|
|
317
175
|
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
selector: aSelector
|
|
322
|
-
category: aCategory
|
|
323
|
-
source: aSource
|
|
324
|
-
!! !!
|
|
176
|
+
TestCase subclass: #ScopeVarTest
|
|
177
|
+
instanceVariableNames: ''
|
|
178
|
+
package: 'Compiler-Tests'!
|
|
325
179
|
|
|
326
|
-
|
|
327
|
-
instanceVariableNames: ''definition''
|
|
328
|
-
package: ''Cypress-Definitions''!!
|
|
180
|
+
!ScopeVarTest methodsFor: 'tests'!
|
|
329
181
|
|
|
330
|
-
|
|
182
|
+
testClassRefVar
|
|
183
|
+
| node |
|
|
184
|
+
node := ClassReferenceNode new
|
|
185
|
+
value: 'Object';
|
|
186
|
+
yourself.
|
|
187
|
+
SemanticAnalyzer new visit: node.
|
|
188
|
+
self assert: node binding isClassRefVar
|
|
189
|
+
!
|
|
331
190
|
|
|
332
|
-
|
|
191
|
+
testInstanceVar
|
|
192
|
+
| node scope |
|
|
193
|
+
node := VariableNode new
|
|
194
|
+
value: 'bzzz';
|
|
195
|
+
yourself.
|
|
196
|
+
scope := MethodLexicalScope new.
|
|
197
|
+
scope addIVar: 'bzzz'.
|
|
198
|
+
self assert: (scope bindingFor: node) isInstanceVar
|
|
199
|
+
!
|
|
333
200
|
|
|
334
|
-
|
|
335
|
-
|
|
201
|
+
testPseudoVar
|
|
202
|
+
| node pseudoVars |
|
|
203
|
+
pseudoVars := #('self' 'super' 'true' 'false' 'nil').
|
|
204
|
+
pseudoVars do: [:each |
|
|
205
|
+
node := VariableNode new
|
|
206
|
+
value: each;
|
|
207
|
+
yourself.
|
|
208
|
+
self assert: (MethodLexicalScope new bindingFor: node) isPseudoVar ]
|
|
209
|
+
!
|
|
336
210
|
|
|
337
|
-
|
|
211
|
+
testTempVar
|
|
212
|
+
| node scope |
|
|
213
|
+
node := VariableNode new
|
|
214
|
+
value: 'bzzz';
|
|
215
|
+
yourself.
|
|
216
|
+
scope := MethodLexicalScope new.
|
|
217
|
+
scope addTemp: 'bzzz'.
|
|
218
|
+
self assert: (scope bindingFor: node) isTempVar
|
|
219
|
+
!
|
|
338
220
|
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
221
|
+
testUnknownVar
|
|
222
|
+
| node |
|
|
223
|
+
node := VariableNode new
|
|
224
|
+
value: 'bzzz';
|
|
225
|
+
yourself.
|
|
226
|
+
self assert: (MethodLexicalScope new bindingFor: node) isNil
|
|
227
|
+
! !
|
|
342
228
|
|
|
343
|
-
|
|
344
|
-
instanceVariableNames: ''
|
|
345
|
-
package: '
|
|
229
|
+
TestCase subclass: #SemanticAnalyzerTest
|
|
230
|
+
instanceVariableNames: 'analyzer'
|
|
231
|
+
package: 'Compiler-Tests'!
|
|
346
232
|
|
|
347
|
-
|
|
233
|
+
!SemanticAnalyzerTest methodsFor: 'running'!
|
|
348
234
|
|
|
349
|
-
|
|
235
|
+
setUp
|
|
236
|
+
analyzer := SemanticAnalyzer on: Object
|
|
237
|
+
! !
|
|
350
238
|
|
|
351
|
-
|
|
352
|
-
modification := target.
|
|
353
|
-
!! !!
|
|
239
|
+
!SemanticAnalyzerTest methodsFor: 'tests'!
|
|
354
240
|
|
|
355
|
-
|
|
241
|
+
testAssignment
|
|
242
|
+
| src ast |
|
|
356
243
|
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
244
|
+
src := 'foo self := 1'.
|
|
245
|
+
ast := smalltalk parse: src.
|
|
246
|
+
self should: [analyzer visit: ast] raise: InvalidAssignmentError
|
|
247
|
+
!
|
|
360
248
|
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
package: ''Cypress-Definitions''!!
|
|
249
|
+
testNonLocalReturn
|
|
250
|
+
| src ast |
|
|
364
251
|
|
|
365
|
-
|
|
252
|
+
src := 'foo | a | a + 1. ^ a'.
|
|
253
|
+
ast := smalltalk parse: src.
|
|
254
|
+
analyzer visit: ast.
|
|
366
255
|
|
|
367
|
-
|
|
256
|
+
self deny: ast scope hasNonLocalReturn
|
|
257
|
+
!
|
|
368
258
|
|
|
369
|
-
|
|
370
|
-
|
|
259
|
+
testNonLocalReturn2
|
|
260
|
+
| src ast |
|
|
371
261
|
|
|
372
|
-
|
|
262
|
+
src := 'foo | a | a + 1. [ [ ^ a] ]'.
|
|
263
|
+
ast := smalltalk parse: src.
|
|
264
|
+
analyzer visit: ast.
|
|
373
265
|
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
!! !!
|
|
266
|
+
self assert: ast scope hasNonLocalReturn
|
|
267
|
+
!
|
|
377
268
|
|
|
378
|
-
|
|
269
|
+
testScope
|
|
270
|
+
| src ast |
|
|
379
271
|
|
|
380
|
-
|
|
272
|
+
src := 'foo | a | a + 1. [ | b | b := a ]'.
|
|
273
|
+
ast := smalltalk parse: src.
|
|
274
|
+
analyzer visit: ast.
|
|
381
275
|
|
|
382
|
-
|
|
383
|
-
|
|
276
|
+
self deny: ast nodes first nodes last scope == ast scope.
|
|
277
|
+
!
|
|
384
278
|
|
|
385
|
-
|
|
279
|
+
testScope2
|
|
280
|
+
| src ast |
|
|
386
281
|
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
superclassName: self superclass name
|
|
391
|
-
category: self category
|
|
392
|
-
instVarNames: self instanceVariableNames
|
|
393
|
-
classInstVarNames: self class instanceVariableNames
|
|
394
|
-
comment: self comment
|
|
395
|
-
!! !!
|
|
282
|
+
src := 'foo | a | a + 1. [ [ | b | b := a ] ]'.
|
|
283
|
+
ast := smalltalk parse: src.
|
|
284
|
+
analyzer visit: ast.
|
|
396
285
|
|
|
397
|
-
|
|
286
|
+
self deny: ast nodes first nodes last nodes first nodes first scope == ast scope.
|
|
287
|
+
!
|
|
398
288
|
|
|
399
|
-
|
|
289
|
+
testScopeLevel
|
|
290
|
+
| src ast |
|
|
400
291
|
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
selector: self selector
|
|
405
|
-
category: self category
|
|
406
|
-
source: self source
|
|
407
|
-
!! !!
|
|
292
|
+
src := 'foo | a | a + 1. [ [ | b | b := a ] ]'.
|
|
293
|
+
ast := smalltalk parse: src.
|
|
294
|
+
analyzer visit: ast.
|
|
408
295
|
|
|
409
|
-
|
|
296
|
+
self assert: ast scope scopeLevel = 1.
|
|
297
|
+
self assert: ast nodes first nodes last nodes first nodes first scope scopeLevel = 3
|
|
298
|
+
!
|
|
410
299
|
|
|
411
|
-
|
|
300
|
+
testUnknownVariables
|
|
301
|
+
| src ast |
|
|
412
302
|
|
|
413
|
-
|
|
414
|
-
|
|
303
|
+
src := 'foo | a | b + a'.
|
|
304
|
+
ast := smalltalk parse: src.
|
|
415
305
|
|
|
416
|
-
|
|
417
|
-
!
|
|
306
|
+
self should: [ analyzer visit: ast ] raise: UnknownVariableError
|
|
307
|
+
!
|
|
418
308
|
|
|
419
|
-
|
|
309
|
+
testUnknownVariablesDefinedInJS
|
|
420
310
|
|
|
421
|
-
|
|
311
|
+
< var someVariable = 1 >.
|
|
422
312
|
|
|
423
|
-
|
|
424
|
-
self cleanUp
|
|
313
|
+
self shouldnt: [ smalltalk parse: 'foo someVariable' ] raise: UnknownVariableError
|
|
425
314
|
!
|
|
426
315
|
|
|
427
|
-
|
|
316
|
+
testUnknownVariablesWithScope
|
|
317
|
+
| src ast |
|
|
428
318
|
|
|
429
|
-
|
|
430
|
-
|
|
319
|
+
src := 'foo | a b | [ c + 1. [ a + 1. d + 1 ]]'.
|
|
320
|
+
ast := smalltalk parse: src.
|
|
321
|
+
|
|
322
|
+
self should: [ analyzer visit: ast ] raise: UnknownVariableError
|
|
431
323
|
!
|
|
432
324
|
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
!ImporterTest methodsFor: 'tests'!
|
|
440
|
-
|
|
441
|
-
testBigChunkString
|
|
442
|
-
"importer does not correctly add extension methods.
|
|
443
|
-
|
|
444
|
-
After loading in AmberProjectImporter, the following import fails...get a MNU from `CypressPackage new species`:
|
|
445
|
-
|
|
446
|
-
AmberProjectImporter
|
|
447
|
-
importSTPackage: 'Cypress-Definitions'
|
|
448
|
-
prefix: 'tests/'.
|
|
325
|
+
testVariableShadowing
|
|
326
|
+
| src ast |
|
|
327
|
+
src := 'foo | a | a + 1'.
|
|
328
|
+
ast := smalltalk parse: src.
|
|
329
|
+
analyzer visit: ast
|
|
330
|
+
!
|
|
449
331
|
|
|
450
|
-
|
|
332
|
+
testVariableShadowing2
|
|
333
|
+
| src ast |
|
|
334
|
+
src := 'foo | a | a + 1. [ | a | a := 2 ]'.
|
|
335
|
+
ast := smalltalk parse: src.
|
|
336
|
+
self should: [analyzer visit: ast] raise: ShadowingVariableError
|
|
337
|
+
!
|
|
451
338
|
|
|
452
|
-
|
|
339
|
+
testVariableShadowing3
|
|
340
|
+
| src ast |
|
|
341
|
+
src := 'foo | a | a + 1. [ | b | b := 2 ]'.
|
|
342
|
+
ast := smalltalk parse: src.
|
|
343
|
+
analyzer visit: ast
|
|
344
|
+
!
|
|
453
345
|
|
|
454
|
-
|
|
455
|
-
|
|
346
|
+
testVariableShadowing4
|
|
347
|
+
| src ast |
|
|
348
|
+
src := 'foo | a | a + 1. [ [ [ | b | b := 2 ] ] ]'.
|
|
349
|
+
ast := smalltalk parse: src.
|
|
350
|
+
analyzer visit: ast
|
|
456
351
|
!
|
|
457
352
|
|
|
458
|
-
|
|
353
|
+
testVariableShadowing5
|
|
354
|
+
| src ast |
|
|
355
|
+
src := 'foo | a | a + 1. [ [ [ | a | a := 2 ] ] ]'.
|
|
356
|
+
ast := smalltalk parse: src.
|
|
357
|
+
self should: [analyzer visit: ast] raise: ShadowingVariableError
|
|
358
|
+
!
|
|
459
359
|
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
self assert: (Object new importerTestMethod = 'success').
|
|
463
|
-
! !
|
|
360
|
+
testVariablesLookup
|
|
361
|
+
| src ast |
|
|
464
362
|
|
|
465
|
-
|
|
363
|
+
src := 'foo | a | a + 1. [ | b | b := a ]'.
|
|
364
|
+
ast := smalltalk parse: src.
|
|
365
|
+
analyzer visit: ast.
|
|
466
366
|
|
|
467
|
-
|
|
367
|
+
"Binding for `a` in the message send"
|
|
368
|
+
self assert: ast nodes first nodes first receiver binding isTempVar.
|
|
369
|
+
self assert: ast nodes first nodes first receiver binding scope == ast scope.
|
|
468
370
|
|
|
469
|
-
|
|
371
|
+
"Binding for `b`"
|
|
372
|
+
self assert: ast nodes first nodes last nodes first nodes first left binding isTempVar.
|
|
373
|
+
self assert: ast nodes first nodes last nodes first nodes first left binding scope == ast nodes first nodes last scope.
|
|
470
374
|
! !
|
|
471
375
|
|