resin 0.3.1 → 0.4.0
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/bin/amberc +10 -350
- data/amber/js/Benchfib.deploy.js +80 -89
- data/amber/js/Benchfib.js +80 -89
- data/amber/js/Canvas.deploy.js +558 -545
- data/amber/js/Canvas.js +563 -545
- data/amber/js/Compiler-AST.deploy.js +431 -243
- data/amber/js/Compiler-AST.js +487 -244
- data/amber/js/Compiler-Core.deploy.js +201 -1045
- data/amber/js/Compiler-Core.js +208 -1207
- data/amber/js/Compiler-Exceptions.deploy.js +37 -18
- data/amber/js/Compiler-Exceptions.js +42 -18
- data/amber/js/Compiler-IR.deploy.js +1071 -774
- data/amber/js/Compiler-IR.js +1194 -848
- data/amber/js/Compiler-Inlining.deploy.js +395 -373
- data/amber/js/Compiler-Inlining.js +395 -373
- data/amber/js/Compiler-Interpreter.deploy.js +1202 -0
- data/amber/js/Compiler-Interpreter.js +1631 -0
- data/amber/js/Compiler-Semantic.deploy.js +695 -600
- data/amber/js/Compiler-Semantic.js +721 -611
- data/amber/js/Compiler-Tests.deploy.js +699 -376
- data/amber/js/Compiler-Tests.js +834 -381
- data/amber/js/Compiler.deploy.js +8563 -1805
- data/amber/js/Compiler.js +11476 -2633
- data/amber/js/Examples.deploy.js +29 -29
- data/amber/js/Examples.js +29 -29
- data/amber/js/IDE.deploy.js +3292 -2649
- data/amber/js/IDE.js +3318 -2710
- data/amber/js/Importer-Exporter.deploy.js +393 -349
- data/amber/js/Importer-Exporter.js +398 -354
- data/amber/js/Kernel-Announcements.deploy.js +53 -44
- data/amber/js/Kernel-Announcements.js +55 -44
- data/amber/js/Kernel-Classes.deploy.js +566 -368
- data/amber/js/Kernel-Classes.js +660 -402
- data/amber/js/Kernel-Collections.deploy.js +1149 -1098
- data/amber/js/Kernel-Collections.js +1183 -1116
- data/amber/js/Kernel-Exceptions.deploy.js +173 -75
- data/amber/js/Kernel-Exceptions.js +215 -77
- data/amber/js/Kernel-Methods.deploy.js +530 -313
- data/amber/js/Kernel-Methods.js +632 -338
- data/amber/js/Kernel-Objects.deploy.js +1734 -1577
- data/amber/js/Kernel-Objects.js +1867 -1654
- data/amber/js/Kernel-Tests.deploy.js +1416 -973
- data/amber/js/Kernel-Tests.js +1495 -981
- data/amber/js/Kernel-Transcript.deploy.js +23 -24
- data/amber/js/Kernel-Transcript.js +25 -26
- data/amber/js/SUnit-Tests.deploy.js +402 -0
- data/amber/js/SUnit-Tests.js +518 -0
- data/amber/js/SUnit.deploy.js +535 -237
- data/amber/js/SUnit.js +634 -246
- data/amber/js/amber.js +90 -53
- data/amber/js/boot.js +441 -255
- data/amber/js/init.js +1 -3
- data/amber/js/lib/CodeMirror/codemirror.css +3 -0
- data/amber/js/lib/CodeMirror/codemirror.js +104 -55
- data/amber/js/lib/peg-0.7.0.min.js +9 -0
- data/amber/js/parser.js +1504 -802
- data/amber/js/parser.pegjs +170 -165
- data/amber/st/Canvas.st +6 -0
- data/amber/st/Compiler-AST.st +54 -3
- data/amber/st/Compiler-Core.st +6 -551
- data/amber/st/Compiler-Exceptions.st +4 -0
- data/amber/st/Compiler-IR.st +205 -87
- data/amber/st/Compiler-Interpreter.st +597 -0
- data/amber/st/Compiler-Semantic.st +46 -21
- data/amber/st/Compiler-Tests.st +254 -7
- data/amber/st/Compiler.st +3172 -1541
- data/amber/st/IDE.st +57 -93
- data/amber/st/Importer-Exporter.st +4 -7
- data/amber/st/Kernel-Announcements.st +8 -0
- data/amber/st/Kernel-Classes.st +149 -40
- data/amber/st/Kernel-Collections.st +43 -32
- data/amber/st/Kernel-Exceptions.st +70 -1
- data/amber/st/Kernel-Methods.st +165 -27
- data/amber/st/Kernel-Objects.st +215 -140
- data/amber/st/Kernel-Tests.st +195 -10
- data/amber/st/Kernel-Transcript.st +1 -3
- data/amber/st/SUnit-Tests.st +186 -0
- data/amber/st/SUnit.st +186 -14
- data/bin/resin +6 -0
- data/lib/resin/cli.rb +19 -0
- metadata +41 -25
- data/amber/js/lib/peg-0.6.2.min.js +0 -2
- data/bin/resin-compile +0 -6
- data/bin/runresin +0 -12
data/amber/js/Compiler-Tests.js
CHANGED
@@ -1,14 +1,452 @@
|
|
1
1
|
smalltalk.addPackage('Compiler-Tests', {});
|
2
|
+
smalltalk.addClass('AbstractASTInterpreterTest', smalltalk.TestCase, [], 'Compiler-Tests');
|
3
|
+
smalltalk.addMethod(
|
4
|
+
"_analyze_forClass_",
|
5
|
+
smalltalk.method({
|
6
|
+
selector: "analyze:forClass:",
|
7
|
+
category: 'interpreting',
|
8
|
+
fn: function (aNode,aClass){
|
9
|
+
var self=this;
|
10
|
+
return smalltalk.withContext(function($ctx1) {
|
11
|
+
_st(_st((smalltalk.SemanticAnalyzer || SemanticAnalyzer))._on_(aClass))._visit_(aNode);
|
12
|
+
$1=aNode;
|
13
|
+
return $1;
|
14
|
+
}, function($ctx1) {$ctx1.fill(self,"analyze:forClass:",{aNode:aNode,aClass:aClass}, smalltalk.AbstractASTInterpreterTest)})},
|
15
|
+
args: ["aNode", "aClass"],
|
16
|
+
source: "analyze: aNode forClass: aClass\x0a\x09(SemanticAnalyzer on: aClass) visit: aNode.\x0a ^ aNode",
|
17
|
+
messageSends: ["visit:", "on:"],
|
18
|
+
referencedClasses: ["SemanticAnalyzer"]
|
19
|
+
}),
|
20
|
+
smalltalk.AbstractASTInterpreterTest);
|
21
|
+
|
22
|
+
smalltalk.addMethod(
|
23
|
+
"_interpret_",
|
24
|
+
smalltalk.method({
|
25
|
+
selector: "interpret:",
|
26
|
+
category: 'interpreting',
|
27
|
+
fn: function (aString){
|
28
|
+
var self=this;
|
29
|
+
return smalltalk.withContext(function($ctx1) {
|
30
|
+
$1=_st(self)._interpret_withArguments_(aString,_st((smalltalk.Dictionary || Dictionary))._new());
|
31
|
+
return $1;
|
32
|
+
}, function($ctx1) {$ctx1.fill(self,"interpret:",{aString:aString}, smalltalk.AbstractASTInterpreterTest)})},
|
33
|
+
args: ["aString"],
|
34
|
+
source: "interpret: aString\x0a\x09^ self \x0a \x09interpret: aString \x0a withArguments: Dictionary new",
|
35
|
+
messageSends: ["interpret:withArguments:", "new"],
|
36
|
+
referencedClasses: ["Dictionary"]
|
37
|
+
}),
|
38
|
+
smalltalk.AbstractASTInterpreterTest);
|
39
|
+
|
40
|
+
smalltalk.addMethod(
|
41
|
+
"_interpret_receiver_withArguments_",
|
42
|
+
smalltalk.method({
|
43
|
+
selector: "interpret:receiver:withArguments:",
|
44
|
+
category: 'interpreting',
|
45
|
+
fn: function (aString,anObject,aDictionary){
|
46
|
+
var self=this;
|
47
|
+
var ctx;
|
48
|
+
return smalltalk.withContext(function($ctx1) {
|
49
|
+
ctx=_st((smalltalk.AIContext || AIContext))._new();
|
50
|
+
_st(ctx)._receiver_(anObject);
|
51
|
+
_st(aDictionary)._keysAndValuesDo_((function(key,value){
|
52
|
+
return smalltalk.withContext(function($ctx2) {
|
53
|
+
}, function($ctx2) {$ctx2.fillBlock({key:key,value:value},$ctx1)})}));
|
54
|
+
$2=_st(self)._interpreter();
|
55
|
+
_st($2)._context_(ctx);
|
56
|
+
_st($2)._interpret_(_st(_st(_st(self)._parse_forClass_(aString,_st(anObject)._class()))._nodes())._first());
|
57
|
+
$3=_st($2)._result();
|
58
|
+
$1=$3;
|
59
|
+
return $1;
|
60
|
+
}, function($ctx1) {$ctx1.fill(self,"interpret:receiver:withArguments:",{aString:aString,anObject:anObject,aDictionary:aDictionary,ctx:ctx}, smalltalk.AbstractASTInterpreterTest)})},
|
61
|
+
args: ["aString", "anObject", "aDictionary"],
|
62
|
+
source: "interpret: aString receiver: anObject withArguments: aDictionary\x0a\x09\x22The food is a methodNode. Interpret the sequenceNode only\x22\x0a \x0a | ctx |\x0a \x0a ctx := AIContext new.\x0a ctx receiver: anObject.\x0a aDictionary keysAndValuesDo: [ :key :value |\x0a \x09ctx localAt: key put: value ].\x0a \x0a ^ self interpreter\x0a \x09context: ctx;\x0a \x09interpret: (self parse: aString forClass: anObject class) \x0a \x09nodes first;\x0a result",
|
63
|
+
messageSends: ["new", "receiver:", "keysAndValuesDo:", "localAt:put:", "context:", "interpreter", "interpret:", "first", "nodes", "parse:forClass:", "class", "result"],
|
64
|
+
referencedClasses: ["AIContext"]
|
65
|
+
}),
|
66
|
+
smalltalk.AbstractASTInterpreterTest);
|
67
|
+
|
68
|
+
smalltalk.addMethod(
|
69
|
+
"_interpret_withArguments_",
|
70
|
+
smalltalk.method({
|
71
|
+
selector: "interpret:withArguments:",
|
72
|
+
category: 'interpreting',
|
73
|
+
fn: function (aString,aDictionary){
|
74
|
+
var self=this;
|
75
|
+
return smalltalk.withContext(function($ctx1) {
|
76
|
+
$1=_st(self)._interpret_receiver_withArguments_(aString,_st((smalltalk.Object || Object))._new(),aDictionary);
|
77
|
+
return $1;
|
78
|
+
}, function($ctx1) {$ctx1.fill(self,"interpret:withArguments:",{aString:aString,aDictionary:aDictionary}, smalltalk.AbstractASTInterpreterTest)})},
|
79
|
+
args: ["aString", "aDictionary"],
|
80
|
+
source: "interpret: aString withArguments: aDictionary\x0a\x09^ self \x0a \x09interpret: aString \x0a receiver: Object new\x0a withArguments: aDictionary",
|
81
|
+
messageSends: ["interpret:receiver:withArguments:", "new"],
|
82
|
+
referencedClasses: ["Object"]
|
83
|
+
}),
|
84
|
+
smalltalk.AbstractASTInterpreterTest);
|
85
|
+
|
86
|
+
smalltalk.addMethod(
|
87
|
+
"_interpreter",
|
88
|
+
smalltalk.method({
|
89
|
+
selector: "interpreter",
|
90
|
+
category: 'accessing',
|
91
|
+
fn: function (){
|
92
|
+
var self=this;
|
93
|
+
return smalltalk.withContext(function($ctx1) {
|
94
|
+
$1=_st(self)._subclassResponsibility();
|
95
|
+
return $1;
|
96
|
+
}, function($ctx1) {$ctx1.fill(self,"interpreter",{}, smalltalk.AbstractASTInterpreterTest)})},
|
97
|
+
args: [],
|
98
|
+
source: "interpreter\x0a\x09^ self subclassResponsibility",
|
99
|
+
messageSends: ["subclassResponsibility"],
|
100
|
+
referencedClasses: []
|
101
|
+
}),
|
102
|
+
smalltalk.AbstractASTInterpreterTest);
|
103
|
+
|
104
|
+
smalltalk.addMethod(
|
105
|
+
"_parse_",
|
106
|
+
smalltalk.method({
|
107
|
+
selector: "parse:",
|
108
|
+
category: 'parsing',
|
109
|
+
fn: function (aString){
|
110
|
+
var self=this;
|
111
|
+
return smalltalk.withContext(function($ctx1) {
|
112
|
+
$1=_st(_st((smalltalk.Smalltalk || Smalltalk))._current())._parse_(aString);
|
113
|
+
return $1;
|
114
|
+
}, function($ctx1) {$ctx1.fill(self,"parse:",{aString:aString}, smalltalk.AbstractASTInterpreterTest)})},
|
115
|
+
args: ["aString"],
|
116
|
+
source: "parse: aString\x0a\x09^ Smalltalk current parse: aString",
|
117
|
+
messageSends: ["parse:", "current"],
|
118
|
+
referencedClasses: ["Smalltalk"]
|
119
|
+
}),
|
120
|
+
smalltalk.AbstractASTInterpreterTest);
|
121
|
+
|
122
|
+
smalltalk.addMethod(
|
123
|
+
"_parse_forClass_",
|
124
|
+
smalltalk.method({
|
125
|
+
selector: "parse:forClass:",
|
126
|
+
category: 'parsing',
|
127
|
+
fn: function (aString,aClass){
|
128
|
+
var self=this;
|
129
|
+
return smalltalk.withContext(function($ctx1) {
|
130
|
+
$1=_st(self)._analyze_forClass_(_st(self)._parse_(aString),aClass);
|
131
|
+
return $1;
|
132
|
+
}, function($ctx1) {$ctx1.fill(self,"parse:forClass:",{aString:aString,aClass:aClass}, smalltalk.AbstractASTInterpreterTest)})},
|
133
|
+
args: ["aString", "aClass"],
|
134
|
+
source: "parse: aString forClass: aClass\x0a\x09^ self analyze: (self parse: aString) forClass: aClass",
|
135
|
+
messageSends: ["analyze:forClass:", "parse:"],
|
136
|
+
referencedClasses: []
|
137
|
+
}),
|
138
|
+
smalltalk.AbstractASTInterpreterTest);
|
139
|
+
|
140
|
+
|
141
|
+
|
142
|
+
smalltalk.addClass('ASTInterpreterTest', smalltalk.AbstractASTInterpreterTest, [], 'Compiler-Tests');
|
143
|
+
smalltalk.addMethod(
|
144
|
+
"_interpreter",
|
145
|
+
smalltalk.method({
|
146
|
+
selector: "interpreter",
|
147
|
+
category: 'accessing',
|
148
|
+
fn: function (){
|
149
|
+
var self=this;
|
150
|
+
return smalltalk.withContext(function($ctx1) {
|
151
|
+
$1=_st((smalltalk.ASTInterpreter || ASTInterpreter))._new();
|
152
|
+
return $1;
|
153
|
+
}, function($ctx1) {$ctx1.fill(self,"interpreter",{}, smalltalk.ASTInterpreterTest)})},
|
154
|
+
args: [],
|
155
|
+
source: "interpreter\x0a\x09^ ASTInterpreter new",
|
156
|
+
messageSends: ["new"],
|
157
|
+
referencedClasses: ["ASTInterpreter"]
|
158
|
+
}),
|
159
|
+
smalltalk.ASTInterpreterTest);
|
160
|
+
|
161
|
+
smalltalk.addMethod(
|
162
|
+
"_testBinarySend",
|
163
|
+
smalltalk.method({
|
164
|
+
selector: "testBinarySend",
|
165
|
+
category: 'tests',
|
166
|
+
fn: function (){
|
167
|
+
var self=this;
|
168
|
+
return smalltalk.withContext(function($ctx1) {
|
169
|
+
return self}, function($ctx1) {$ctx1.fill(self,"testBinarySend",{}, smalltalk.ASTInterpreterTest)})},
|
170
|
+
args: [],
|
171
|
+
source: "testBinarySend\x0a\x09self assert: (self interpret: 'foo 2+3+4') equals: 9",
|
172
|
+
messageSends: ["assert:equals:", "interpret:"],
|
173
|
+
referencedClasses: []
|
174
|
+
}),
|
175
|
+
smalltalk.ASTInterpreterTest);
|
176
|
+
|
177
|
+
smalltalk.addMethod(
|
178
|
+
"_testBlockLiteral",
|
179
|
+
smalltalk.method({
|
180
|
+
selector: "testBlockLiteral",
|
181
|
+
category: 'tests',
|
182
|
+
fn: function (){
|
183
|
+
var self=this;
|
184
|
+
return smalltalk.withContext(function($ctx1) {
|
185
|
+
_st(self)._assert_equals_(_st(self)._interpret_("foo true ifTrue: [ ^ 1 ] ifFalse: [ 2 ]"),(1));
|
186
|
+
_st(self)._assert_equals_(_st(self)._interpret_("foo ^ false ifTrue: [ 1 ] ifFalse: [ 2 ]"),(2));
|
187
|
+
return self}, function($ctx1) {$ctx1.fill(self,"testBlockLiteral",{}, smalltalk.ASTInterpreterTest)})},
|
188
|
+
args: [],
|
189
|
+
source: "testBlockLiteral\x0a\x09self assert: (self interpret: 'foo ^ true ifTrue: [ 1 ] ifFalse: [ 2 ]') equals: 1.\x0a self assert: (self interpret: 'foo true ifTrue: [ ^ 1 ] ifFalse: [ 2 ]') equals: 1.\x0a self assert: (self interpret: 'foo ^ false ifTrue: [ 1 ] ifFalse: [ 2 ]') equals: 2",
|
190
|
+
messageSends: ["assert:equals:", "interpret:"],
|
191
|
+
referencedClasses: []
|
192
|
+
}),
|
193
|
+
smalltalk.ASTInterpreterTest);
|
194
|
+
|
195
|
+
smalltalk.addMethod(
|
196
|
+
"_testCascade",
|
197
|
+
smalltalk.method({
|
198
|
+
selector: "testCascade",
|
199
|
+
category: 'tests',
|
200
|
+
fn: function (){
|
201
|
+
var self=this;
|
202
|
+
return smalltalk.withContext(function($ctx1) {
|
203
|
+
return self}, function($ctx1) {$ctx1.fill(self,"testCascade",{}, smalltalk.ASTInterpreterTest)})},
|
204
|
+
args: [],
|
205
|
+
source: "testCascade\x0a\x09self assert: (self interpret: 'foo ^ OrderedCollection new add: 2; add: 3; yourself') equals: (OrderedCollection with: 2 with: 3)",
|
206
|
+
messageSends: ["assert:equals:", "interpret:", "with:with:"],
|
207
|
+
referencedClasses: ["OrderedCollection"]
|
208
|
+
}),
|
209
|
+
smalltalk.ASTInterpreterTest);
|
210
|
+
|
211
|
+
smalltalk.addMethod(
|
212
|
+
"_testDynamicArray",
|
213
|
+
smalltalk.method({
|
214
|
+
selector: "testDynamicArray",
|
215
|
+
category: 'tests',
|
216
|
+
fn: function (){
|
217
|
+
var self=this;
|
218
|
+
return smalltalk.withContext(function($ctx1) {
|
219
|
+
return self}, function($ctx1) {$ctx1.fill(self,"testDynamicArray",{}, smalltalk.ASTInterpreterTest)})},
|
220
|
+
args: [],
|
221
|
+
source: "testDynamicArray\x0a\x09self assert: (self interpret: 'foo ^ {1+1. 2+2}') equals: #(2 4)",
|
222
|
+
messageSends: ["assert:equals:", "interpret:"],
|
223
|
+
referencedClasses: []
|
224
|
+
}),
|
225
|
+
smalltalk.ASTInterpreterTest);
|
226
|
+
|
227
|
+
smalltalk.addMethod(
|
228
|
+
"_testDynamicDictionary",
|
229
|
+
smalltalk.method({
|
230
|
+
selector: "testDynamicDictionary",
|
231
|
+
category: 'tests',
|
232
|
+
fn: function (){
|
233
|
+
var self=this;
|
234
|
+
return smalltalk.withContext(function($ctx1) {
|
235
|
+
return self}, function($ctx1) {$ctx1.fill(self,"testDynamicDictionary",{}, smalltalk.ASTInterpreterTest)})},
|
236
|
+
args: [],
|
237
|
+
source: "testDynamicDictionary\x0a\x09self assert: (self interpret: 'foo ^ #{1->1. 2->3}') equals: #{1->1. 2->3}",
|
238
|
+
messageSends: ["assert:equals:", "interpret:", "->"],
|
239
|
+
referencedClasses: []
|
240
|
+
}),
|
241
|
+
smalltalk.ASTInterpreterTest);
|
242
|
+
|
243
|
+
smalltalk.addMethod(
|
244
|
+
"_testInlinedJSStatement",
|
245
|
+
smalltalk.method({
|
246
|
+
selector: "testInlinedJSStatement",
|
247
|
+
category: 'tests',
|
248
|
+
fn: function (){
|
249
|
+
var self=this;
|
250
|
+
return smalltalk.withContext(function($ctx1) {
|
251
|
+
_st(self)._assert_equals_(_st(self)._interpret_withArguments_("foo: anInteger <return 2 + anInteger>",smalltalk.HashedCollection._fromPairs_([_st("anInteger").__minus_gt((3))])),(5));
|
252
|
+
return self}, function($ctx1) {$ctx1.fill(self,"testInlinedJSStatement",{}, smalltalk.ASTInterpreterTest)})},
|
253
|
+
args: [],
|
254
|
+
source: "testInlinedJSStatement\x0a\x09self assert: (self interpret: 'foo <return 2+3>') equals: 5.\x0a \x0a self \x0a \x09assert: (self \x0a \x09\x09interpret: 'foo: anInteger <return 2 + anInteger>' \x0a \x09withArguments: #{ 'anInteger' -> 3}) \x0a\x09\x09equals: 5",
|
255
|
+
messageSends: ["assert:equals:", "interpret:", "interpret:withArguments:", "->"],
|
256
|
+
referencedClasses: []
|
257
|
+
}),
|
258
|
+
smalltalk.ASTInterpreterTest);
|
259
|
+
|
260
|
+
smalltalk.addMethod(
|
261
|
+
"_testInstVarAccess",
|
262
|
+
smalltalk.method({
|
263
|
+
selector: "testInstVarAccess",
|
264
|
+
category: 'tests',
|
265
|
+
fn: function (){
|
266
|
+
var self=this;
|
267
|
+
return smalltalk.withContext(function($ctx1) {
|
268
|
+
return self}, function($ctx1) {$ctx1.fill(self,"testInstVarAccess",{}, smalltalk.ASTInterpreterTest)})},
|
269
|
+
args: [],
|
270
|
+
source: "testInstVarAccess\x0a\x09self \x0a \x09assert: (self \x0a \x09\x09interpret: 'foo ^ x'\x0a \x09receiver: 2@3\x0a \x09withArguments: #{})\x0a equals: 2",
|
271
|
+
messageSends: ["assert:equals:", "interpret:receiver:withArguments:", "@"],
|
272
|
+
referencedClasses: []
|
273
|
+
}),
|
274
|
+
smalltalk.ASTInterpreterTest);
|
275
|
+
|
276
|
+
smalltalk.addMethod(
|
277
|
+
"_testInstVarAssignment",
|
278
|
+
smalltalk.method({
|
279
|
+
selector: "testInstVarAssignment",
|
280
|
+
category: 'tests',
|
281
|
+
fn: function (){
|
282
|
+
var self=this;
|
283
|
+
return smalltalk.withContext(function($ctx1) {
|
284
|
+
return self}, function($ctx1) {$ctx1.fill(self,"testInstVarAssignment",{}, smalltalk.ASTInterpreterTest)})},
|
285
|
+
args: [],
|
286
|
+
source: "testInstVarAssignment\x0a\x09self \x0a \x09assert: (self \x0a \x09\x09interpret: 'foo: anInteger x := anInteger. ^ x'\x0a \x09receiver: Point new\x0a \x09withArguments: #{'anInteger' -> 2})\x0a equals: 2",
|
287
|
+
messageSends: ["assert:equals:", "interpret:receiver:withArguments:", "new", "->"],
|
288
|
+
referencedClasses: ["Point"]
|
289
|
+
}),
|
290
|
+
smalltalk.ASTInterpreterTest);
|
291
|
+
|
292
|
+
smalltalk.addMethod(
|
293
|
+
"_testNonlocalReturn",
|
294
|
+
smalltalk.method({
|
295
|
+
selector: "testNonlocalReturn",
|
296
|
+
category: 'tests',
|
297
|
+
fn: function (){
|
298
|
+
var self=this;
|
299
|
+
return smalltalk.withContext(function($ctx1) {
|
300
|
+
return self}, function($ctx1) {$ctx1.fill(self,"testNonlocalReturn",{}, smalltalk.ASTInterpreterTest)})},
|
301
|
+
args: [],
|
302
|
+
source: "testNonlocalReturn\x0a\x09self assert: (self interpret: 'foo true ifTrue: [ ^ 1 ]. ^2') equals: 1",
|
303
|
+
messageSends: ["assert:equals:", "interpret:"],
|
304
|
+
referencedClasses: []
|
305
|
+
}),
|
306
|
+
smalltalk.ASTInterpreterTest);
|
307
|
+
|
308
|
+
smalltalk.addMethod(
|
309
|
+
"_testReceiver",
|
310
|
+
smalltalk.method({
|
311
|
+
selector: "testReceiver",
|
312
|
+
category: 'tests',
|
313
|
+
fn: function (){
|
314
|
+
var self=this;
|
315
|
+
return smalltalk.withContext(function($ctx1) {
|
316
|
+
return self}, function($ctx1) {$ctx1.fill(self,"testReceiver",{}, smalltalk.ASTInterpreterTest)})},
|
317
|
+
args: [],
|
318
|
+
source: "testReceiver\x0a\x09self \x0a \x09assert: (self \x0a \x09\x09interpret: 'foo ^ self'\x0a \x09receiver: 2@3\x0a \x09withArguments: #{})\x0a equals: 2@3",
|
319
|
+
messageSends: ["assert:equals:", "interpret:receiver:withArguments:", "@"],
|
320
|
+
referencedClasses: []
|
321
|
+
}),
|
322
|
+
smalltalk.ASTInterpreterTest);
|
323
|
+
|
324
|
+
smalltalk.addMethod(
|
325
|
+
"_testTempAssignment",
|
326
|
+
smalltalk.method({
|
327
|
+
selector: "testTempAssignment",
|
328
|
+
category: 'tests',
|
329
|
+
fn: function (){
|
330
|
+
var self=this;
|
331
|
+
return smalltalk.withContext(function($ctx1) {
|
332
|
+
return self}, function($ctx1) {$ctx1.fill(self,"testTempAssignment",{}, smalltalk.ASTInterpreterTest)})},
|
333
|
+
args: [],
|
334
|
+
source: "testTempAssignment\x0a\x09self assert: (self interpret: 'foo | a | a := 2. ^ a') equals: 2",
|
335
|
+
messageSends: ["assert:equals:", "interpret:"],
|
336
|
+
referencedClasses: []
|
337
|
+
}),
|
338
|
+
smalltalk.ASTInterpreterTest);
|
339
|
+
|
340
|
+
|
341
|
+
|
342
|
+
smalltalk.addClass('ASTSteppingInterpreterTest', smalltalk.AbstractASTInterpreterTest, ['interpreter'], 'Compiler-Tests');
|
343
|
+
smalltalk.addMethod(
|
344
|
+
"_interpreter",
|
345
|
+
smalltalk.method({
|
346
|
+
selector: "interpreter",
|
347
|
+
category: 'accessing',
|
348
|
+
fn: function (){
|
349
|
+
var self=this;
|
350
|
+
return smalltalk.withContext(function($ctx1) {
|
351
|
+
$2=self["@interpreter"];
|
352
|
+
if(($receiver = $2) == nil || $receiver == undefined){
|
353
|
+
self["@interpreter"]=_st((smalltalk.ASTSteppingInterpreter || ASTSteppingInterpreter))._new();
|
354
|
+
$1=self["@interpreter"];
|
355
|
+
} else {
|
356
|
+
$1=$2;
|
357
|
+
};
|
358
|
+
return $1;
|
359
|
+
}, function($ctx1) {$ctx1.fill(self,"interpreter",{}, smalltalk.ASTSteppingInterpreterTest)})},
|
360
|
+
args: [],
|
361
|
+
source: "interpreter\x0a\x09^ interpreter ifNil: [ interpreter := ASTSteppingInterpreter new ]",
|
362
|
+
messageSends: ["ifNil:", "new"],
|
363
|
+
referencedClasses: ["ASTSteppingInterpreter"]
|
364
|
+
}),
|
365
|
+
smalltalk.ASTSteppingInterpreterTest);
|
366
|
+
|
367
|
+
smalltalk.addMethod(
|
368
|
+
"_testAtEnd",
|
369
|
+
smalltalk.method({
|
370
|
+
selector: "testAtEnd",
|
371
|
+
category: 'tests',
|
372
|
+
fn: function (){
|
373
|
+
var self=this;
|
374
|
+
return smalltalk.withContext(function($ctx1) {
|
375
|
+
_st(self)._deny_(_st(_st(self)._interpreter())._atEnd());
|
376
|
+
_st(_st(self)._interpreter())._step();
|
377
|
+
_st(self)._deny_(_st(_st(self)._interpreter())._atEnd());
|
378
|
+
_st(_st(self)._interpreter())._step();
|
379
|
+
_st(self)._deny_(_st(_st(self)._interpreter())._atEnd());
|
380
|
+
_st(_st(self)._interpreter())._step();
|
381
|
+
_st(self)._deny_(_st(_st(self)._interpreter())._atEnd());
|
382
|
+
_st(_st(self)._interpreter())._step();
|
383
|
+
_st(self)._assert_(_st(_st(self)._interpreter())._atEnd());
|
384
|
+
return self}, function($ctx1) {$ctx1.fill(self,"testAtEnd",{}, smalltalk.ASTSteppingInterpreterTest)})},
|
385
|
+
args: [],
|
386
|
+
source: "testAtEnd\x0a\x09self interpret: 'foo 1 + 2'.\x0a self deny: self interpreter atEnd.\x0a\x0a self interpreter step.\x0a self deny: self interpreter atEnd.\x0a \x0a self interpreter step.\x0a self deny: self interpreter atEnd.\x0a \x0a self interpreter step.\x0a self deny: self interpreter atEnd.\x0a \x0a self interpreter step.\x0a self assert: self interpreter atEnd",
|
387
|
+
messageSends: ["interpret:", "deny:", "atEnd", "interpreter", "step", "assert:"],
|
388
|
+
referencedClasses: []
|
389
|
+
}),
|
390
|
+
smalltalk.ASTSteppingInterpreterTest);
|
391
|
+
|
392
|
+
smalltalk.addMethod(
|
393
|
+
"_testMessageSend",
|
394
|
+
smalltalk.method({
|
395
|
+
selector: "testMessageSend",
|
396
|
+
category: 'tests',
|
397
|
+
fn: function (){
|
398
|
+
var self=this;
|
399
|
+
return smalltalk.withContext(function($ctx1) {
|
400
|
+
_st(_st(self)._interpreter())._step();
|
401
|
+
_st(_st(self)._interpreter())._step();
|
402
|
+
_st(_st(self)._interpreter())._step();
|
403
|
+
_st(self)._assert_equals_(_st(_st(_st(self)._interpreter())._currentNode())._value(),(1));
|
404
|
+
_st(_st(self)._interpreter())._step();
|
405
|
+
_st(self)._assert_equals_(_st(_st(_st(self)._interpreter())._currentNode())._value(),(2));
|
406
|
+
_st(_st(self)._interpreter())._step();
|
407
|
+
_st(self)._assert_equals_(_st(_st(self)._interpreter())._result(),(3));
|
408
|
+
return self}, function($ctx1) {$ctx1.fill(self,"testMessageSend",{}, smalltalk.ASTSteppingInterpreterTest)})},
|
409
|
+
args: [],
|
410
|
+
source: "testMessageSend\x0a\x09self interpret: 'foo 1 + 2'.\x0a \x0a \x22SequenceNode\x22\x0a self interpreter step.\x0a \x0a \x22SendNode\x22\x0a self interpreter step.\x0a \x0a \x22ValueNode\x22\x0a self interpreter step.\x0a self assert: self interpreter currentNode value equals: 1.\x0a \x0a \x22ValueNode\x22\x0a self interpreter step.\x0a self assert: self interpreter currentNode value equals: 2.\x0a \x0a \x22Result\x22\x0a self interpreter step.\x0a self assert: self interpreter result equals: 3\x0a\x09",
|
411
|
+
messageSends: ["interpret:", "step", "interpreter", "assert:equals:", "value", "currentNode", "result"],
|
412
|
+
referencedClasses: []
|
413
|
+
}),
|
414
|
+
smalltalk.ASTSteppingInterpreterTest);
|
415
|
+
|
416
|
+
smalltalk.addMethod(
|
417
|
+
"_testSimpleStepping",
|
418
|
+
smalltalk.method({
|
419
|
+
selector: "testSimpleStepping",
|
420
|
+
category: 'tests',
|
421
|
+
fn: function (){
|
422
|
+
var self=this;
|
423
|
+
return smalltalk.withContext(function($ctx1) {
|
424
|
+
_st(_st(self)._interpreter())._step();
|
425
|
+
_st(self)._assert_(_st(_st(_st(self)._interpreter())._result())._isNil());
|
426
|
+
_st(_st(self)._interpreter())._step();
|
427
|
+
_st(self)._assert_equals_(_st(_st(self)._interpreter())._result(),(1));
|
428
|
+
return self}, function($ctx1) {$ctx1.fill(self,"testSimpleStepping",{}, smalltalk.ASTSteppingInterpreterTest)})},
|
429
|
+
args: [],
|
430
|
+
source: "testSimpleStepping\x0a\x09self interpret: 'foo 1'.\x0a \x0a \x22SequenceNode\x22\x0a self interpreter step.\x0a \x0a self assert: self interpreter result isNil.\x0a \x0a \x22ValueNode\x22\x0a self interpreter step.\x0a \x0a self assert: self interpreter result equals: 1\x0a \x0a\x09",
|
431
|
+
messageSends: ["interpret:", "step", "interpreter", "assert:", "isNil", "result", "assert:equals:"],
|
432
|
+
referencedClasses: []
|
433
|
+
}),
|
434
|
+
smalltalk.ASTSteppingInterpreterTest);
|
435
|
+
|
436
|
+
|
437
|
+
|
2
438
|
smalltalk.addClass('CodeGeneratorTest', smalltalk.TestCase, ['receiver'], 'Compiler-Tests');
|
3
439
|
smalltalk.addMethod(
|
4
440
|
"_codeGeneratorClass",
|
5
441
|
smalltalk.method({
|
6
442
|
selector: "codeGeneratorClass",
|
7
443
|
category: 'accessing',
|
8
|
-
fn: function ()
|
9
|
-
|
10
|
-
|
11
|
-
|
444
|
+
fn: function (){
|
445
|
+
var self=this;
|
446
|
+
return smalltalk.withContext(function($ctx1) {
|
447
|
+
$1=(smalltalk.CodeGenerator || CodeGenerator);
|
448
|
+
return $1;
|
449
|
+
}, function($ctx1) {$ctx1.fill(self,"codeGeneratorClass",{}, smalltalk.CodeGeneratorTest)})},
|
12
450
|
args: [],
|
13
451
|
source: "codeGeneratorClass\x0a\x09^ CodeGenerator",
|
14
452
|
messageSends: [],
|
@@ -21,15 +459,15 @@ smalltalk.addMethod(
|
|
21
459
|
smalltalk.method({
|
22
460
|
selector: "compiler",
|
23
461
|
category: 'factory',
|
24
|
-
fn: function ()
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
},
|
462
|
+
fn: function (){
|
463
|
+
var self=this;
|
464
|
+
return smalltalk.withContext(function($ctx1) {
|
465
|
+
$2=_st((smalltalk.Compiler || Compiler))._new();
|
466
|
+
_st($2)._codeGeneratorClass_(_st(self)._codeGeneratorClass());
|
467
|
+
$3=_st($2)._yourself();
|
468
|
+
$1=$3;
|
469
|
+
return $1;
|
470
|
+
}, function($ctx1) {$ctx1.fill(self,"compiler",{}, smalltalk.CodeGeneratorTest)})},
|
33
471
|
args: [],
|
34
472
|
source: "compiler\x0a\x09^ Compiler new\x0a\x09\x09codeGeneratorClass: self codeGeneratorClass;\x0a\x09\x09yourself",
|
35
473
|
messageSends: ["codeGeneratorClass:", "codeGeneratorClass", "new", "yourself"],
|
@@ -42,11 +480,10 @@ smalltalk.addMethod(
|
|
42
480
|
smalltalk.method({
|
43
481
|
selector: "setUp",
|
44
482
|
category: 'initialization',
|
45
|
-
fn: function ()
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
},
|
483
|
+
fn: function (){
|
484
|
+
var self=this;
|
485
|
+
return smalltalk.withContext(function($ctx1) {
|
486
|
+
return self}, function($ctx1) {$ctx1.fill(self,"setUp",{}, smalltalk.CodeGeneratorTest)})},
|
50
487
|
args: [],
|
51
488
|
source: "setUp\x0a\x09receiver := self targetClass new",
|
52
489
|
messageSends: ["new", "targetClass"],
|
@@ -59,16 +496,14 @@ smalltalk.addMethod(
|
|
59
496
|
smalltalk.method({
|
60
497
|
selector: "should:return:",
|
61
498
|
category: 'testing',
|
62
|
-
fn: function (aString,
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
return self;
|
71
|
-
},
|
499
|
+
fn: function (aString,anObject){
|
500
|
+
var self=this;
|
501
|
+
var method,result;
|
502
|
+
return smalltalk.withContext(function($ctx1) {
|
503
|
+
result=_st(self["@receiver"])._perform_(_st(method)._selector());
|
504
|
+
_st(_st(self)._targetClass())._removeCompiledMethod_(method);
|
505
|
+
_st(self)._assert_equals_(anObject,result);
|
506
|
+
return self}, function($ctx1) {$ctx1.fill(self,"should:return:",{aString:aString,anObject:anObject,method:method,result:result}, smalltalk.CodeGeneratorTest)})},
|
72
507
|
args: ["aString", "anObject"],
|
73
508
|
source: "should: aString return: anObject\x0a\x09| method result |\x0a\x0a\x09method := self compiler install: aString forClass: self targetClass category: 'tests'.\x0a\x09result := receiver perform: method selector.\x0a\x09self targetClass removeCompiledMethod: method.\x0a\x09self assert: anObject equals: result",
|
74
509
|
messageSends: ["install:forClass:category:", "targetClass", "compiler", "perform:", "selector", "removeCompiledMethod:", "assert:equals:"],
|
@@ -81,10 +516,12 @@ smalltalk.addMethod(
|
|
81
516
|
smalltalk.method({
|
82
517
|
selector: "targetClass",
|
83
518
|
category: 'accessing',
|
84
|
-
fn: function ()
|
85
|
-
|
86
|
-
|
87
|
-
|
519
|
+
fn: function (){
|
520
|
+
var self=this;
|
521
|
+
return smalltalk.withContext(function($ctx1) {
|
522
|
+
$1=(smalltalk.DoIt || DoIt);
|
523
|
+
return $1;
|
524
|
+
}, function($ctx1) {$ctx1.fill(self,"targetClass",{}, smalltalk.CodeGeneratorTest)})},
|
88
525
|
args: [],
|
89
526
|
source: "targetClass\x0a\x09^ DoIt",
|
90
527
|
messageSends: [],
|
@@ -97,10 +534,9 @@ smalltalk.addMethod(
|
|
97
534
|
smalltalk.method({
|
98
535
|
selector: "tearDown",
|
99
536
|
category: 'initialization',
|
100
|
-
fn: function ()
|
101
|
-
|
102
|
-
|
103
|
-
},
|
537
|
+
fn: function (){
|
538
|
+
var self=this;
|
539
|
+
return smalltalk.withContext(function($ctx1) {
|
104
540
|
args: [],
|
105
541
|
source: "tearDown\x0a\x09\x22receiver := nil\x22",
|
106
542
|
messageSends: [],
|
@@ -113,13 +549,12 @@ smalltalk.addMethod(
|
|
113
549
|
smalltalk.method({
|
114
550
|
selector: "testAssignment",
|
115
551
|
category: 'tests',
|
116
|
-
fn: function ()
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
},
|
552
|
+
fn: function (){
|
553
|
+
var self=this;
|
554
|
+
return smalltalk.withContext(function($ctx1) {
|
555
|
+
_st(self)._should_return_("foo | a | a := false ifTrue: [ 1 ]. ^ a",nil);
|
556
|
+
_st(self)._should_return_("foo | a | ^ a := true ifTrue: [ 1 ]",(1));
|
557
|
+
return self}, function($ctx1) {$ctx1.fill(self,"testAssignment",{}, smalltalk.CodeGeneratorTest)})},
|
123
558
|
args: [],
|
124
559
|
source: "testAssignment\x0a\x09self should: 'foo | a | a := true ifTrue: [ 1 ]. ^ a' return: 1.\x0a\x09self should: 'foo | a | a := false ifTrue: [ 1 ]. ^ a' return: nil.\x0a\x0a\x09self should: 'foo | a | ^ a := true ifTrue: [ 1 ]' return: 1 ",
|
125
560
|
messageSends: ["should:return:"],
|
@@ -132,13 +567,12 @@ smalltalk.addMethod(
|
|
132
567
|
smalltalk.method({
|
133
568
|
selector: "testBlockReturn",
|
134
569
|
category: 'tests',
|
135
|
-
fn: function ()
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
},
|
570
|
+
fn: function (){
|
571
|
+
var self=this;
|
572
|
+
return smalltalk.withContext(function($ctx1) {
|
573
|
+
_st(self)._should_return_("foo ^ #(1 2 3) collect: [ :each | false ifFalse: [ each + 1 ] ]",[(2), (3), (4)]);
|
574
|
+
_st(self)._should_return_("foo ^ #(1 2 3) collect: [ :each | each odd ifTrue: [ each + 1 ] ifFalse: [ each - 1 ] ]",[(2), (1), (4)]);
|
575
|
+
return self}, function($ctx1) {$ctx1.fill(self,"testBlockReturn",{}, smalltalk.CodeGeneratorTest)})},
|
142
576
|
args: [],
|
143
577
|
source: "testBlockReturn\x0a\x09self should: 'foo ^ #(1 2 3) collect: [ :each | true ifTrue: [ each + 1 ] ]' return: #(2 3 4).\x0a\x09self should: 'foo ^ #(1 2 3) collect: [ :each | false ifFalse: [ each + 1 ] ]' return: #(2 3 4).\x0a\x09self should: 'foo ^ #(1 2 3) collect: [ :each | each odd ifTrue: [ each + 1 ] ifFalse: [ each - 1 ] ]' return: #(2 1 4).",
|
144
578
|
messageSends: ["should:return:"],
|
@@ -151,11 +585,10 @@ smalltalk.addMethod(
|
|
151
585
|
smalltalk.method({
|
152
586
|
selector: "testCascades",
|
153
587
|
category: 'tests',
|
154
|
-
fn: function ()
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
},
|
588
|
+
fn: function (){
|
589
|
+
var self=this;
|
590
|
+
return smalltalk.withContext(function($ctx1) {
|
591
|
+
return self}, function($ctx1) {$ctx1.fill(self,"testCascades",{}, smalltalk.CodeGeneratorTest)})},
|
159
592
|
args: [],
|
160
593
|
source: "testCascades\x0a\x09\x0a\x09self should: 'foo ^ Array new add: 3; add: 4; yourself' return: #(3 4)",
|
161
594
|
messageSends: ["should:return:"],
|
@@ -163,24 +596,74 @@ referencedClasses: []
|
|
163
596
|
}),
|
164
597
|
smalltalk.CodeGeneratorTest);
|
165
598
|
|
599
|
+
smalltalk.addMethod(
|
600
|
+
"_testDynamicArrayElementsOrdered",
|
601
|
+
smalltalk.method({
|
602
|
+
selector: "testDynamicArrayElementsOrdered",
|
603
|
+
category: 'tests',
|
604
|
+
fn: function (){
|
605
|
+
var self=this;
|
606
|
+
return smalltalk.withContext(function($ctx1) {
|
607
|
+
return self}, function($ctx1) {$ctx1.fill(self,"testDynamicArrayElementsOrdered",{}, smalltalk.CodeGeneratorTest)})},
|
608
|
+
args: [],
|
609
|
+
source: "testDynamicArrayElementsOrdered\x0a\x09self should: 'foo\x0a | x |\x0a x := 1.\x0a ^ { x. true ifTrue: [ x := 2 ] }\x0a' return: #(1 2).\x0a",
|
610
|
+
messageSends: ["should:return:"],
|
611
|
+
referencedClasses: []
|
612
|
+
}),
|
613
|
+
smalltalk.CodeGeneratorTest);
|
614
|
+
|
615
|
+
smalltalk.addMethod(
|
616
|
+
"_testDynamicDictionaryElementsOrdered",
|
617
|
+
smalltalk.method({
|
618
|
+
selector: "testDynamicDictionaryElementsOrdered",
|
619
|
+
category: 'tests',
|
620
|
+
fn: function (){
|
621
|
+
var self=this;
|
622
|
+
return smalltalk.withContext(function($ctx1) {
|
623
|
+
return self}, function($ctx1) {$ctx1.fill(self,"testDynamicDictionaryElementsOrdered",{}, smalltalk.CodeGeneratorTest)})},
|
624
|
+
args: [],
|
625
|
+
source: "testDynamicDictionaryElementsOrdered\x0a\x09self should: 'foo\x0a | x |\x0a x := ''foo''->1.\x0a ^ #{ x. (true ifTrue: [ x := ''bar''->2 ]) }\x0a' return: #{'foo'->1. 'bar'->2}.\x0a",
|
626
|
+
messageSends: ["should:return:", "->"],
|
627
|
+
referencedClasses: []
|
628
|
+
}),
|
629
|
+
smalltalk.CodeGeneratorTest);
|
630
|
+
|
631
|
+
smalltalk.addMethod(
|
632
|
+
"_testInnerTemporalDependentElementsOrdered",
|
633
|
+
smalltalk.method({
|
634
|
+
selector: "testInnerTemporalDependentElementsOrdered",
|
635
|
+
category: 'tests',
|
636
|
+
fn: function (){
|
637
|
+
var self=this;
|
638
|
+
return smalltalk.withContext(function($ctx1) {
|
639
|
+
_st(self)._should_return_("foo\x0a | x |\x0a x := 1.\x0a ^ Array with: 'foo'->x with: 'bar'->(true ifTrue: [ x := 2 ])\x0a",[_st("foo").__minus_gt((1)),_st("bar").__minus_gt((2))]);
|
640
|
+
_st(self)._should_return_("foo\x0a | x |\x0a x := 1.\x0a ^ { 'foo'->x. 'bar'->(true ifTrue: [ x := 2 ]) }\x0a",[_st("foo").__minus_gt((1)),_st("bar").__minus_gt((2))]);
|
641
|
+
_st(self)._should_return_("foo\x0a | x |\x0a x := 1.\x0a ^ #{ 'foo'->x. 'bar'->(true ifTrue: [ x := 2 ]) }\x0a",smalltalk.HashedCollection._fromPairs_([_st("foo").__minus_gt((1)),_st("bar").__minus_gt((2))]));
|
642
|
+
return self}, function($ctx1) {$ctx1.fill(self,"testInnerTemporalDependentElementsOrdered",{}, smalltalk.CodeGeneratorTest)})},
|
643
|
+
args: [],
|
644
|
+
source: "testInnerTemporalDependentElementsOrdered\x0a\x09self should: 'foo\x0a | x |\x0a x := Array.\x0a ^ x with: ''foo''->x with: ''bar''->(true ifTrue: [ x := 2 ])\x0a' return: {'foo'->Array. 'bar'->2}.\x0a\x09self should: 'foo\x0a | x |\x0a x := 1.\x0a ^ Array with: ''foo''->x with: ''bar''->(true ifTrue: [ x := 2 ])\x0a' return: {'foo'->1. 'bar'->2}.\x0a\x09self should: 'foo\x0a | x |\x0a x := 1.\x0a ^ { ''foo''->x. ''bar''->(true ifTrue: [ x := 2 ]) }\x0a' return: {'foo'->1. 'bar'->2}.\x0a\x09self should: 'foo\x0a | x |\x0a x := 1.\x0a ^ #{ ''foo''->x. ''bar''->(true ifTrue: [ x := 2 ]) }\x0a' return: #{'foo'->1. 'bar'->2}.\x0a",
|
645
|
+
messageSends: ["should:return:", "->"],
|
646
|
+
referencedClasses: ["Array"]
|
647
|
+
}),
|
648
|
+
smalltalk.CodeGeneratorTest);
|
649
|
+
|
166
650
|
smalltalk.addMethod(
|
167
651
|
"_testLiterals",
|
168
652
|
smalltalk.method({
|
169
653
|
selector: "testLiterals",
|
170
654
|
category: 'tests',
|
171
|
-
fn: function ()
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
},
|
655
|
+
fn: function (){
|
656
|
+
var self=this;
|
657
|
+
return smalltalk.withContext(function($ctx1) {
|
658
|
+
_st(self)._should_return_("foo ^ 'hello'","hello");
|
659
|
+
_st(self)._should_return_("foo ^ #(1 2 3 4)",[(1), (2), (3), (4)]);
|
660
|
+
_st(self)._should_return_("foo ^ {1. [:x | x ] value: 2. 3. [4] value}",[(1), (2), (3), (4)]);
|
661
|
+
_st(self)._should_return_("foo ^ true",true);
|
662
|
+
_st(self)._should_return_("foo ^ false",false);
|
663
|
+
_st(self)._should_return_("foo ^ #{1->2. 3->4}",smalltalk.HashedCollection._fromPairs_([_st((1)).__minus_gt((2)),_st((3)).__minus_gt((4))]));
|
664
|
+
_st(self)._should_return_("foo ^ #hello",smalltalk.symbolFor("hello"));
|
665
|
+
_st(self)._should_return_("foo ^ -123.456",(-123.456));
|
666
|
+
return self}, function($ctx1) {$ctx1.fill(self,"testLiterals",{}, smalltalk.CodeGeneratorTest)})},
|
184
667
|
args: [],
|
185
668
|
source: "testLiterals\x0a\x09self should: 'foo ^ 1' return: 1.\x0a\x09self should: 'foo ^ ''hello''' return: 'hello'.\x0a\x09self should: 'foo ^ #(1 2 3 4)' return: #(1 2 3 4).\x0a\x09self should: 'foo ^ {1. [:x | x ] value: 2. 3. [4] value}' return: #(1 2 3 4).\x0a\x09self should: 'foo ^ true' return: true.\x0a\x09self should: 'foo ^ false' return: false.\x0a\x09self should: 'foo ^ #{1->2. 3->4}' return: #{1->2. 3->4}.\x0a\x09self should: 'foo ^ #hello' return: #hello.\x0a\x09self should: 'foo ^ -123.456' return: -123.456",
|
186
669
|
messageSends: ["should:return:", "->"],
|
@@ -193,15 +676,14 @@ smalltalk.addMethod(
|
|
193
676
|
smalltalk.method({
|
194
677
|
selector: "testLocalReturn",
|
195
678
|
category: 'tests',
|
196
|
-
fn: function ()
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
},
|
679
|
+
fn: function (){
|
680
|
+
var self=this;
|
681
|
+
return smalltalk.withContext(function($ctx1) {
|
682
|
+
_st(self)._should_return_("foo ^ 1 + 1",(2));
|
683
|
+
_st(self)._should_return_("foo ",self["@receiver"]);
|
684
|
+
_st(self)._should_return_("foo self asString",self["@receiver"]);
|
685
|
+
_st(self)._should_return_("foo | a b | a := 1. b := 2. ^ a + b",(3));
|
686
|
+
return self}, function($ctx1) {$ctx1.fill(self,"testLocalReturn",{}, smalltalk.CodeGeneratorTest)})},
|
205
687
|
args: [],
|
206
688
|
source: "testLocalReturn\x0a\x09self should: 'foo ^ 1' return: 1.\x0a\x09self should: 'foo ^ 1 + 1' return: 2.\x0a\x09self should: 'foo ' return: receiver.\x0a\x09self should: 'foo self asString' return: receiver.\x0a\x09self should: 'foo | a b | a := 1. b := 2. ^ a + b' return: 3",
|
207
689
|
messageSends: ["should:return:"],
|
@@ -214,15 +696,14 @@ smalltalk.addMethod(
|
|
214
696
|
smalltalk.method({
|
215
697
|
selector: "testMessageSends",
|
216
698
|
category: 'tests',
|
217
|
-
fn: function ()
|
218
|
-
|
219
|
-
|
220
|
-
|
221
|
-
|
222
|
-
|
223
|
-
|
224
|
-
|
225
|
-
},
|
699
|
+
fn: function (){
|
700
|
+
var self=this;
|
701
|
+
return smalltalk.withContext(function($ctx1) {
|
702
|
+
_st(self)._should_return_("foo ^ 1 + 1",(2));
|
703
|
+
_st(self)._should_return_("foo ^ 1 + 2 * 3",(9));
|
704
|
+
_st(self)._should_return_("foo ^ 1 to: 3",[(1), (2), (3)]);
|
705
|
+
_st(self)._should_return_("foo ^ 1 to: 5 by: 2",[(1), (3), (5)]);
|
706
|
+
return self}, function($ctx1) {$ctx1.fill(self,"testMessageSends",{}, smalltalk.CodeGeneratorTest)})},
|
226
707
|
args: [],
|
227
708
|
source: "testMessageSends\x0a\x09self should: 'foo ^ 1 asString' return: '1'.\x0a\x0a\x09self should: 'foo ^ 1 + 1' return: 2.\x0a\x09self should: 'foo ^ 1 + 2 * 3' return: 9.\x0a\x0a\x09self should: 'foo ^ 1 to: 3' return: #(1 2 3).\x0a\x09self should: 'foo ^ 1 to: 5 by: 2' return: #(1 3 5)",
|
228
709
|
messageSends: ["should:return:"],
|
@@ -235,14 +716,13 @@ smalltalk.addMethod(
|
|
235
716
|
smalltalk.method({
|
236
717
|
selector: "testNestedIfTrue",
|
237
718
|
category: 'tests',
|
238
|
-
fn: function ()
|
239
|
-
|
240
|
-
|
241
|
-
|
242
|
-
|
243
|
-
|
244
|
-
|
245
|
-
},
|
719
|
+
fn: function (){
|
720
|
+
var self=this;
|
721
|
+
return smalltalk.withContext(function($ctx1) {
|
722
|
+
_st(self)._should_return_("foo ^ true ifTrue: [ false ifTrue: [ 1 ] ]",nil);
|
723
|
+
_st(self)._should_return_("foo true ifTrue: [ false ifFalse: [ ^ 1 ] ]",(1));
|
724
|
+
_st(self)._should_return_("foo true ifTrue: [ false ifTrue: [ ^ 1 ] ]",self["@receiver"]);
|
725
|
+
return self}, function($ctx1) {$ctx1.fill(self,"testNestedIfTrue",{}, smalltalk.CodeGeneratorTest)})},
|
246
726
|
args: [],
|
247
727
|
source: "testNestedIfTrue\x0a\x09self should: 'foo ^ true ifTrue: [ false ifFalse: [ 1 ] ]' return: 1.\x0a\x09self should: 'foo ^ true ifTrue: [ false ifTrue: [ 1 ] ]' return: nil.\x0a\x0a\x09self should: 'foo true ifTrue: [ false ifFalse: [ ^ 1 ] ]' return: 1.\x0a\x09self should: 'foo true ifTrue: [ false ifTrue: [ ^ 1 ] ]' return: receiver.",
|
248
728
|
messageSends: ["should:return:"],
|
@@ -255,14 +735,13 @@ smalltalk.addMethod(
|
|
255
735
|
smalltalk.method({
|
256
736
|
selector: "testNonLocalReturn",
|
257
737
|
category: 'tests',
|
258
|
-
fn: function ()
|
259
|
-
|
260
|
-
|
261
|
-
|
262
|
-
|
263
|
-
|
264
|
-
|
265
|
-
},
|
738
|
+
fn: function (){
|
739
|
+
var self=this;
|
740
|
+
return smalltalk.withContext(function($ctx1) {
|
741
|
+
_st(self)._should_return_("foo [ ^ 1 + 1 ] value",(2));
|
742
|
+
_st(self)._should_return_("foo | a b | a := 1. b := 2. [ ^ a + b ] value. self halt",(3));
|
743
|
+
_st(self)._should_return_("foo [ :x | ^ x + x ] value: 4. ^ 2",(8));
|
744
|
+
return self}, function($ctx1) {$ctx1.fill(self,"testNonLocalReturn",{}, smalltalk.CodeGeneratorTest)})},
|
266
745
|
args: [],
|
267
746
|
source: "testNonLocalReturn\x0a\x09self should: 'foo [ ^ 1 ] value' return: 1.\x0a\x09self should: 'foo [ ^ 1 + 1 ] value' return: 2.\x0a\x09self should: 'foo | a b | a := 1. b := 2. [ ^ a + b ] value. self halt' return: 3.\x0a\x09self should: 'foo [ :x | ^ x + x ] value: 4. ^ 2' return: 8",
|
268
747
|
messageSends: ["should:return:"],
|
@@ -270,19 +749,35 @@ referencedClasses: []
|
|
270
749
|
}),
|
271
750
|
smalltalk.CodeGeneratorTest);
|
272
751
|
|
752
|
+
smalltalk.addMethod(
|
753
|
+
"_testSendReceiverAndArgumentsOrdered",
|
754
|
+
smalltalk.method({
|
755
|
+
selector: "testSendReceiverAndArgumentsOrdered",
|
756
|
+
category: 'tests',
|
757
|
+
fn: function (){
|
758
|
+
var self=this;
|
759
|
+
return smalltalk.withContext(function($ctx1) {
|
760
|
+
_st(self)._should_return_("foo\x0a | x |\x0a x := Array.\x0a ^ x with: x with: (true ifTrue: [ x := 2 ])\x0a",[(smalltalk.Array || Array),(2)]);
|
761
|
+
return self}, function($ctx1) {$ctx1.fill(self,"testSendReceiverAndArgumentsOrdered",{}, smalltalk.CodeGeneratorTest)})},
|
762
|
+
args: [],
|
763
|
+
source: "testSendReceiverAndArgumentsOrdered\x0a\x09self should: 'foo\x0a | x |\x0a x := 1.\x0a ^ Array with: x with: (true ifTrue: [ x := 2 ])\x0a' return: #(1 2).\x0a\x0a\x09self should: 'foo\x0a | x |\x0a x := Array.\x0a ^ x with: x with: (true ifTrue: [ x := 2 ])\x0a' return: {Array. 2}.\x0a",
|
764
|
+
messageSends: ["should:return:"],
|
765
|
+
referencedClasses: ["Array"]
|
766
|
+
}),
|
767
|
+
smalltalk.CodeGeneratorTest);
|
768
|
+
|
273
769
|
smalltalk.addMethod(
|
274
770
|
"_testifFalse",
|
275
771
|
smalltalk.method({
|
276
772
|
selector: "testifFalse",
|
277
773
|
category: 'tests',
|
278
|
-
fn: function ()
|
279
|
-
|
280
|
-
|
281
|
-
|
282
|
-
|
283
|
-
|
284
|
-
|
285
|
-
},
|
774
|
+
fn: function (){
|
775
|
+
var self=this;
|
776
|
+
return smalltalk.withContext(function($ctx1) {
|
777
|
+
_st(self)._should_return_("foo false ifFalse: [ ^ 2 ]",(2));
|
778
|
+
_st(self)._should_return_("foo ^ true ifFalse: [ 1 ]",nil);
|
779
|
+
_st(self)._should_return_("foo ^ false ifFalse: [ 2 ]",(2));
|
780
|
+
return self}, function($ctx1) {$ctx1.fill(self,"testifFalse",{}, smalltalk.CodeGeneratorTest)})},
|
286
781
|
args: [],
|
287
782
|
source: "testifFalse\x0a\x09self should: 'foo true ifFalse: [ ^ 1 ]' return: receiver.\x0a\x09self should: 'foo false ifFalse: [ ^ 2 ]' return: 2.\x0a\x09\x0a\x09self should: 'foo ^ true ifFalse: [ 1 ]' return: nil.\x0a\x09self should: 'foo ^ false ifFalse: [ 2 ]' return: 2.",
|
288
783
|
messageSends: ["should:return:"],
|
@@ -295,14 +790,13 @@ smalltalk.addMethod(
|
|
295
790
|
smalltalk.method({
|
296
791
|
selector: "testifFalseIfTrue",
|
297
792
|
category: 'tests',
|
298
|
-
fn: function ()
|
299
|
-
|
300
|
-
|
301
|
-
|
302
|
-
|
303
|
-
|
304
|
-
|
305
|
-
},
|
793
|
+
fn: function (){
|
794
|
+
var self=this;
|
795
|
+
return smalltalk.withContext(function($ctx1) {
|
796
|
+
_st(self)._should_return_("foo false ifFalse: [ ^ 2 ] ifTrue: [ ^1 ]",(2));
|
797
|
+
_st(self)._should_return_("foo ^ true ifFalse: [ 1 ] ifTrue: [ 2 ]",(2));
|
798
|
+
_st(self)._should_return_("foo ^ false ifFalse: [ 2 ] ifTrue: [ 1 ]",(2));
|
799
|
+
return self}, function($ctx1) {$ctx1.fill(self,"testifFalseIfTrue",{}, smalltalk.CodeGeneratorTest)})},
|
306
800
|
args: [],
|
307
801
|
source: "testifFalseIfTrue\x0a\x09self should: 'foo true ifFalse: [ ^ 1 ] ifTrue: [ ^ 2 ]' return: 2.\x0a\x09self should: 'foo false ifFalse: [ ^ 2 ] ifTrue: [ ^1 ]' return: 2.\x0a\x09\x0a\x09self should: 'foo ^ true ifFalse: [ 1 ] ifTrue: [ 2 ]' return: 2.\x0a\x09self should: 'foo ^ false ifFalse: [ 2 ] ifTrue: [ 1 ]' return: 2.",
|
308
802
|
messageSends: ["should:return:"],
|
@@ -315,14 +809,13 @@ smalltalk.addMethod(
|
|
315
809
|
smalltalk.method({
|
316
810
|
selector: "testifNil",
|
317
811
|
category: 'tests',
|
318
|
-
fn: function ()
|
319
|
-
|
320
|
-
|
321
|
-
|
322
|
-
|
323
|
-
|
324
|
-
|
325
|
-
},
|
812
|
+
fn: function (){
|
813
|
+
var self=this;
|
814
|
+
return smalltalk.withContext(function($ctx1) {
|
815
|
+
_st(self)._should_return_("foo ^ nil ifNil: [ 2 ]",(2));
|
816
|
+
_st(self)._should_return_("foo 1 ifNil: [ ^ 2 ]",self["@receiver"]);
|
817
|
+
_st(self)._should_return_("foo nil ifNil: [ ^ 2 ]",(2));
|
818
|
+
return self}, function($ctx1) {$ctx1.fill(self,"testifNil",{}, smalltalk.CodeGeneratorTest)})},
|
326
819
|
args: [],
|
327
820
|
source: "testifNil\x0a\x09self should: 'foo ^ 1 ifNil: [ 2 ]' return: 1.\x0a\x09self should: 'foo ^ nil ifNil: [ 2 ]' return: 2.\x0a\x0a\x09self should: 'foo 1 ifNil: [ ^ 2 ]' return: receiver.\x0a\x09self should: 'foo nil ifNil: [ ^ 2 ]' return: 2.",
|
328
821
|
messageSends: ["should:return:"],
|
@@ -335,14 +828,13 @@ smalltalk.addMethod(
|
|
335
828
|
smalltalk.method({
|
336
829
|
selector: "testifNilIfNotNil",
|
337
830
|
category: 'tests',
|
338
|
-
fn: function ()
|
339
|
-
|
340
|
-
|
341
|
-
|
342
|
-
|
343
|
-
|
344
|
-
|
345
|
-
},
|
831
|
+
fn: function (){
|
832
|
+
var self=this;
|
833
|
+
return smalltalk.withContext(function($ctx1) {
|
834
|
+
_st(self)._should_return_("foo ^ nil ifNil: [ 2 ] ifNotNil: [ 3 ]",(2));
|
835
|
+
_st(self)._should_return_("foo 1 ifNil: [ ^ 2 ] ifNotNil: [ ^3 ]",(3));
|
836
|
+
_st(self)._should_return_("foo nil ifNil: [ ^ 2 ] ifNotNil: [ ^3 ]",(2));
|
837
|
+
return self}, function($ctx1) {$ctx1.fill(self,"testifNilIfNotNil",{}, smalltalk.CodeGeneratorTest)})},
|
346
838
|
args: [],
|
347
839
|
source: "testifNilIfNotNil\x0a\x09self should: 'foo ^ 1 ifNil: [ 2 ] ifNotNil: [ 3 ]' return: 3.\x0a\x09self should: 'foo ^ nil ifNil: [ 2 ] ifNotNil: [ 3 ]' return: 2.\x0a\x0a\x09self should: 'foo 1 ifNil: [ ^ 2 ] ifNotNil: [ ^3 ]' return: 3.\x0a\x09self should: 'foo nil ifNil: [ ^ 2 ] ifNotNil: [ ^3 ]' return: 2.",
|
348
840
|
messageSends: ["should:return:"],
|
@@ -355,14 +847,13 @@ smalltalk.addMethod(
|
|
355
847
|
smalltalk.method({
|
356
848
|
selector: "testifNotNil",
|
357
849
|
category: 'tests',
|
358
|
-
fn: function ()
|
359
|
-
|
360
|
-
|
361
|
-
|
362
|
-
|
363
|
-
|
364
|
-
|
365
|
-
},
|
850
|
+
fn: function (){
|
851
|
+
var self=this;
|
852
|
+
return smalltalk.withContext(function($ctx1) {
|
853
|
+
_st(self)._should_return_("foo ^ nil ifNotNil: [ 2 ]",nil);
|
854
|
+
_st(self)._should_return_("foo 1 ifNotNil: [ ^ 2 ]",(2));
|
855
|
+
_st(self)._should_return_("foo nil ifNotNil: [ ^ 2 ]",self["@receiver"]);
|
856
|
+
return self}, function($ctx1) {$ctx1.fill(self,"testifNotNil",{}, smalltalk.CodeGeneratorTest)})},
|
366
857
|
args: [],
|
367
858
|
source: "testifNotNil\x0a\x09self should: 'foo ^ 1 ifNotNil: [ 2 ]' return: 2.\x0a\x09self should: 'foo ^ nil ifNotNil: [ 2 ]' return: nil.\x0a\x0a\x09self should: 'foo 1 ifNotNil: [ ^ 2 ]' return: 2.\x0a\x09self should: 'foo nil ifNotNil: [ ^ 2 ]' return: receiver.",
|
368
859
|
messageSends: ["should:return:"],
|
@@ -375,14 +866,13 @@ smalltalk.addMethod(
|
|
375
866
|
smalltalk.method({
|
376
867
|
selector: "testifTrue",
|
377
868
|
category: 'tests',
|
378
|
-
fn: function ()
|
379
|
-
|
380
|
-
|
381
|
-
|
382
|
-
|
383
|
-
|
384
|
-
|
385
|
-
},
|
869
|
+
fn: function (){
|
870
|
+
var self=this;
|
871
|
+
return smalltalk.withContext(function($ctx1) {
|
872
|
+
_st(self)._should_return_("foo true ifTrue: [ ^ 2 ]",(2));
|
873
|
+
_st(self)._should_return_("foo ^ false ifTrue: [ 1 ]",nil);
|
874
|
+
_st(self)._should_return_("foo ^ true ifTrue: [ 2 ]",(2));
|
875
|
+
return self}, function($ctx1) {$ctx1.fill(self,"testifTrue",{}, smalltalk.CodeGeneratorTest)})},
|
386
876
|
args: [],
|
387
877
|
source: "testifTrue\x0a\x09self should: 'foo false ifTrue: [ ^ 1 ]' return: receiver.\x0a\x09self should: 'foo true ifTrue: [ ^ 2 ]' return: 2.\x0a\x09\x0a\x09self should: 'foo ^ false ifTrue: [ 1 ]' return: nil.\x0a\x09self should: 'foo ^ true ifTrue: [ 2 ]' return: 2.",
|
388
878
|
messageSends: ["should:return:"],
|
@@ -395,14 +885,13 @@ smalltalk.addMethod(
|
|
395
885
|
smalltalk.method({
|
396
886
|
selector: "testifTrueIfFalse",
|
397
887
|
category: 'tests',
|
398
|
-
fn: function ()
|
399
|
-
|
400
|
-
|
401
|
-
|
402
|
-
|
403
|
-
|
404
|
-
|
405
|
-
},
|
888
|
+
fn: function (){
|
889
|
+
var self=this;
|
890
|
+
return smalltalk.withContext(function($ctx1) {
|
891
|
+
_st(self)._should_return_("foo true ifTrue: [ ^ 1 ] ifFalse: [ ^ 2 ]",(1));
|
892
|
+
_st(self)._should_return_("foo ^ false ifTrue: [ 2 ] ifFalse: [ 1 ]",(1));
|
893
|
+
_st(self)._should_return_("foo ^ true ifTrue: [ 2 ] ifFalse: [ 1 ]",(2));
|
894
|
+
return self}, function($ctx1) {$ctx1.fill(self,"testifTrueIfFalse",{}, smalltalk.CodeGeneratorTest)})},
|
406
895
|
args: [],
|
407
896
|
source: "testifTrueIfFalse\x0a\x09self should: 'foo false ifTrue: [ ^ 1 ] ifFalse: [ ^2 ]' return: 2.\x0a\x09self should: 'foo true ifTrue: [ ^ 1 ] ifFalse: [ ^ 2 ]' return: 1.\x0a\x09\x0a\x09self should: 'foo ^ false ifTrue: [ 2 ] ifFalse: [ 1 ]' return: 1.\x0a\x09self should: 'foo ^ true ifTrue: [ 2 ] ifFalse: [ 1 ]' return: 2.",
|
408
897
|
messageSends: ["should:return:"],
|
@@ -418,10 +907,12 @@ smalltalk.addMethod(
|
|
418
907
|
smalltalk.method({
|
419
908
|
selector: "codeGeneratorClass",
|
420
909
|
category: 'accessing',
|
421
|
-
fn: function ()
|
422
|
-
|
423
|
-
|
424
|
-
|
910
|
+
fn: function (){
|
911
|
+
var self=this;
|
912
|
+
return smalltalk.withContext(function($ctx1) {
|
913
|
+
$1=(smalltalk.InliningCodeGenerator || InliningCodeGenerator);
|
914
|
+
return $1;
|
915
|
+
}, function($ctx1) {$ctx1.fill(self,"codeGeneratorClass",{}, smalltalk.InliningCodeGeneratorTest)})},
|
425
916
|
args: [],
|
426
917
|
source: "codeGeneratorClass\x0a\x09^ InliningCodeGenerator",
|
427
918
|
messageSends: [],
|
@@ -437,18 +928,17 @@ smalltalk.addMethod(
|
|
437
928
|
smalltalk.method({
|
438
929
|
selector: "testClassRefVar",
|
439
930
|
category: 'tests',
|
440
|
-
fn: function ()
|
441
|
-
|
442
|
-
|
443
|
-
|
444
|
-
|
445
|
-
|
446
|
-
|
447
|
-
|
448
|
-
|
449
|
-
|
450
|
-
|
451
|
-
},
|
931
|
+
fn: function (){
|
932
|
+
var self=this;
|
933
|
+
var node;
|
934
|
+
return smalltalk.withContext(function($ctx1) {
|
935
|
+
$1=_st((smalltalk.ClassReferenceNode || ClassReferenceNode))._new();
|
936
|
+
_st($1)._value_("Object");
|
937
|
+
$2=_st($1)._yourself();
|
938
|
+
node=$2;
|
939
|
+
_st(_st((smalltalk.SemanticAnalyzer || SemanticAnalyzer))._new())._visit_(node);
|
940
|
+
_st(self)._assert_(_st(_st(node)._binding())._isClassRefVar());
|
941
|
+
return self}, function($ctx1) {$ctx1.fill(self,"testClassRefVar",{node:node}, smalltalk.ScopeVarTest)})},
|
452
942
|
args: [],
|
453
943
|
source: "testClassRefVar\x0a\x09| node |\x0a\x09node := ClassReferenceNode new\x0a\x09\x09value: 'Object';\x0a\x09\x09yourself.\x0a\x09SemanticAnalyzer new visit: node.\x0a\x09self assert: node binding isClassRefVar",
|
454
944
|
messageSends: ["value:", "new", "yourself", "visit:", "assert:", "isClassRefVar", "binding"],
|
@@ -461,20 +951,18 @@ smalltalk.addMethod(
|
|
461
951
|
smalltalk.method({
|
462
952
|
selector: "testInstanceVar",
|
463
953
|
category: 'tests',
|
464
|
-
fn: function ()
|
465
|
-
|
466
|
-
|
467
|
-
|
468
|
-
|
469
|
-
|
470
|
-
|
471
|
-
|
472
|
-
|
473
|
-
|
474
|
-
|
475
|
-
|
476
|
-
return self;
|
477
|
-
},
|
954
|
+
fn: function (){
|
955
|
+
var self=this;
|
956
|
+
var node,scope;
|
957
|
+
return smalltalk.withContext(function($ctx1) {
|
958
|
+
$1=_st((smalltalk.VariableNode || VariableNode))._new();
|
959
|
+
_st($1)._value_("bzzz");
|
960
|
+
$2=_st($1)._yourself();
|
961
|
+
node=$2;
|
962
|
+
scope=_st((smalltalk.MethodLexicalScope || MethodLexicalScope))._new();
|
963
|
+
_st(scope)._addIVar_("bzzz");
|
964
|
+
_st(self)._assert_(_st(_st(scope)._bindingFor_(node))._isInstanceVar());
|
965
|
+
return self}, function($ctx1) {$ctx1.fill(self,"testInstanceVar",{node:node,scope:scope}, smalltalk.ScopeVarTest)})},
|
478
966
|
args: [],
|
479
967
|
source: "testInstanceVar\x0a\x09| node scope |\x0a\x09node := VariableNode new\x0a\x09\x09value: 'bzzz';\x0a\x09\x09yourself.\x0a\x09scope := MethodLexicalScope new.\x0a\x09scope addIVar: 'bzzz'.\x0a\x09self assert: (scope bindingFor: node) isInstanceVar",
|
480
968
|
messageSends: ["value:", "new", "yourself", "addIVar:", "assert:", "isInstanceVar", "bindingFor:"],
|
@@ -487,15 +975,20 @@ smalltalk.addMethod(
|
|
487
975
|
smalltalk.method({
|
488
976
|
selector: "testPseudoVar",
|
489
977
|
category: 'tests',
|
490
|
-
fn: function ()
|
491
|
-
|
492
|
-
|
493
|
-
|
494
|
-
|
495
|
-
|
496
|
-
|
497
|
-
|
498
|
-
|
978
|
+
fn: function (){
|
979
|
+
var self=this;
|
980
|
+
var node,pseudoVars;
|
981
|
+
return smalltalk.withContext(function($ctx1) {
|
982
|
+
pseudoVars=["self", "super", "true", "false", "nil"];
|
983
|
+
_st(pseudoVars)._do_((function(each){
|
984
|
+
return smalltalk.withContext(function($ctx2) {
|
985
|
+
_st($1)._value_(each);
|
986
|
+
$2=_st($1)._yourself();
|
987
|
+
node=$2;
|
988
|
+
node;
|
989
|
+
return _st(self)._assert_(_st(_st(_st((smalltalk.MethodLexicalScope || MethodLexicalScope))._new())._bindingFor_(node))._isPseudoVar());
|
990
|
+
}, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1)})}));
|
991
|
+
return self}, function($ctx1) {$ctx1.fill(self,"testPseudoVar",{node:node,pseudoVars:pseudoVars}, smalltalk.ScopeVarTest)})},
|
499
992
|
args: [],
|
500
993
|
source: "testPseudoVar\x0a\x09| node pseudoVars |\x0a\x09pseudoVars := #('self' 'super' 'true' 'false' 'nil').\x0a\x09pseudoVars do: [:each |\x0a\x09\x09node := VariableNode new\x0a\x09\x09value: each;\x0a\x09\x09yourself.\x0a\x09\x09self assert: (MethodLexicalScope new bindingFor: node) isPseudoVar ]",
|
501
994
|
messageSends: ["do:", "value:", "new", "yourself", "assert:", "isPseudoVar", "bindingFor:"],
|
@@ -508,20 +1001,18 @@ smalltalk.addMethod(
|
|
508
1001
|
smalltalk.method({
|
509
1002
|
selector: "testTempVar",
|
510
1003
|
category: 'tests',
|
511
|
-
fn: function ()
|
512
|
-
|
513
|
-
|
514
|
-
|
515
|
-
|
516
|
-
|
517
|
-
|
518
|
-
|
519
|
-
|
520
|
-
|
521
|
-
|
522
|
-
|
523
|
-
return self;
|
524
|
-
},
|
1004
|
+
fn: function (){
|
1005
|
+
var self=this;
|
1006
|
+
var node,scope;
|
1007
|
+
return smalltalk.withContext(function($ctx1) {
|
1008
|
+
$1=_st((smalltalk.VariableNode || VariableNode))._new();
|
1009
|
+
_st($1)._value_("bzzz");
|
1010
|
+
$2=_st($1)._yourself();
|
1011
|
+
node=$2;
|
1012
|
+
scope=_st((smalltalk.MethodLexicalScope || MethodLexicalScope))._new();
|
1013
|
+
_st(scope)._addTemp_("bzzz");
|
1014
|
+
_st(self)._assert_(_st(_st(scope)._bindingFor_(node))._isTempVar());
|
1015
|
+
return self}, function($ctx1) {$ctx1.fill(self,"testTempVar",{node:node,scope:scope}, smalltalk.ScopeVarTest)})},
|
525
1016
|
args: [],
|
526
1017
|
source: "testTempVar\x0a\x09| node scope |\x0a\x09node := VariableNode new\x0a\x09\x09value: 'bzzz';\x0a\x09\x09yourself.\x0a\x09scope := MethodLexicalScope new.\x0a\x09scope addTemp: 'bzzz'.\x0a\x09self assert: (scope bindingFor: node) isTempVar",
|
527
1018
|
messageSends: ["value:", "new", "yourself", "addTemp:", "assert:", "isTempVar", "bindingFor:"],
|
@@ -534,17 +1025,16 @@ smalltalk.addMethod(
|
|
534
1025
|
smalltalk.method({
|
535
1026
|
selector: "testUnknownVar",
|
536
1027
|
category: 'tests',
|
537
|
-
fn: function ()
|
538
|
-
|
539
|
-
|
540
|
-
|
541
|
-
|
542
|
-
|
543
|
-
|
544
|
-
|
545
|
-
|
546
|
-
|
547
|
-
},
|
1028
|
+
fn: function (){
|
1029
|
+
var self=this;
|
1030
|
+
var node;
|
1031
|
+
return smalltalk.withContext(function($ctx1) {
|
1032
|
+
$1=_st((smalltalk.VariableNode || VariableNode))._new();
|
1033
|
+
_st($1)._value_("bzzz");
|
1034
|
+
$2=_st($1)._yourself();
|
1035
|
+
node=$2;
|
1036
|
+
_st(self)._assert_(_st(_st(_st((smalltalk.MethodLexicalScope || MethodLexicalScope))._new())._bindingFor_(node))._isNil());
|
1037
|
+
return self}, function($ctx1) {$ctx1.fill(self,"testUnknownVar",{node:node}, smalltalk.ScopeVarTest)})},
|
548
1038
|
args: [],
|
549
1039
|
source: "testUnknownVar\x0a\x09| node |\x0a\x09node := VariableNode new\x0a\x09\x09value: 'bzzz';\x0a\x09\x09yourself.\x0a\x09self assert: (MethodLexicalScope new bindingFor: node) isNil",
|
550
1040
|
messageSends: ["value:", "new", "yourself", "assert:", "isNil", "bindingFor:"],
|
@@ -560,11 +1050,10 @@ smalltalk.addMethod(
|
|
560
1050
|
smalltalk.method({
|
561
1051
|
selector: "setUp",
|
562
1052
|
category: 'running',
|
563
|
-
fn: function ()
|
564
|
-
|
565
|
-
|
566
|
-
|
567
|
-
},
|
1053
|
+
fn: function (){
|
1054
|
+
var self=this;
|
1055
|
+
return smalltalk.withContext(function($ctx1) {
|
1056
|
+
return self}, function($ctx1) {$ctx1.fill(self,"setUp",{}, smalltalk.SemanticAnalyzerTest)})},
|
568
1057
|
args: [],
|
569
1058
|
source: "setUp\x0a\x09analyzer := SemanticAnalyzer on: Object",
|
570
1059
|
messageSends: ["on:"],
|
@@ -577,15 +1066,15 @@ smalltalk.addMethod(
|
|
577
1066
|
smalltalk.method({
|
578
1067
|
selector: "testAssignment",
|
579
1068
|
category: 'tests',
|
580
|
-
fn: function ()
|
581
|
-
|
582
|
-
|
583
|
-
|
584
|
-
|
585
|
-
|
586
|
-
|
587
|
-
|
588
|
-
},
|
1069
|
+
fn: function (){
|
1070
|
+
var self=this;
|
1071
|
+
var src,ast;
|
1072
|
+
return smalltalk.withContext(function($ctx1) {
|
1073
|
+
ast=_st(smalltalk)._parse_(src);
|
1074
|
+
_st(self)._should_raise_((function(){
|
1075
|
+
return smalltalk.withContext(function($ctx2) {
|
1076
|
+
}, function($ctx2) {$ctx2.fillBlock({},$ctx1)})}),(smalltalk.InvalidAssignmentError || InvalidAssignmentError));
|
1077
|
+
return self}, function($ctx1) {$ctx1.fill(self,"testAssignment",{src:src,ast:ast}, smalltalk.SemanticAnalyzerTest)})},
|
589
1078
|
args: [],
|
590
1079
|
source: "testAssignment\x0a\x09| src ast |\x0a\x0a\x09src := 'foo self := 1'.\x0a\x09ast := smalltalk parse: src.\x0a\x09self should: [analyzer visit: ast] raise: InvalidAssignmentError",
|
591
1080
|
messageSends: ["parse:", "should:raise:", "visit:"],
|
@@ -598,16 +1087,14 @@ smalltalk.addMethod(
|
|
598
1087
|
smalltalk.method({
|
599
1088
|
selector: "testNonLocalReturn",
|
600
1089
|
category: 'tests',
|
601
|
-
fn: function ()
|
602
|
-
|
603
|
-
|
604
|
-
|
605
|
-
|
606
|
-
|
607
|
-
|
608
|
-
|
609
|
-
return self;
|
610
|
-
},
|
1090
|
+
fn: function (){
|
1091
|
+
var self=this;
|
1092
|
+
var src,ast;
|
1093
|
+
return smalltalk.withContext(function($ctx1) {
|
1094
|
+
ast=_st(smalltalk)._parse_(src);
|
1095
|
+
_st(self["@analyzer"])._visit_(ast);
|
1096
|
+
_st(self)._deny_(_st(_st(ast)._scope())._hasNonLocalReturn());
|
1097
|
+
return self}, function($ctx1) {$ctx1.fill(self,"testNonLocalReturn",{src:src,ast:ast}, smalltalk.SemanticAnalyzerTest)})},
|
611
1098
|
args: [],
|
612
1099
|
source: "testNonLocalReturn\x0a\x09| src ast |\x0a\x0a\x09src := 'foo | a | a + 1. ^ a'.\x0a\x09ast := smalltalk parse: src.\x0a\x09analyzer visit: ast.\x0a\x0a\x09self deny: ast scope hasNonLocalReturn",
|
613
1100
|
messageSends: ["parse:", "visit:", "deny:", "hasNonLocalReturn", "scope"],
|
@@ -620,16 +1107,14 @@ smalltalk.addMethod(
|
|
620
1107
|
smalltalk.method({
|
621
1108
|
selector: "testNonLocalReturn2",
|
622
1109
|
category: 'tests',
|
623
|
-
fn: function ()
|
624
|
-
|
625
|
-
|
626
|
-
|
627
|
-
|
628
|
-
|
629
|
-
|
630
|
-
|
631
|
-
return self;
|
632
|
-
},
|
1110
|
+
fn: function (){
|
1111
|
+
var self=this;
|
1112
|
+
var src,ast;
|
1113
|
+
return smalltalk.withContext(function($ctx1) {
|
1114
|
+
ast=_st(smalltalk)._parse_(src);
|
1115
|
+
_st(self["@analyzer"])._visit_(ast);
|
1116
|
+
_st(self)._assert_(_st(_st(ast)._scope())._hasNonLocalReturn());
|
1117
|
+
return self}, function($ctx1) {$ctx1.fill(self,"testNonLocalReturn2",{src:src,ast:ast}, smalltalk.SemanticAnalyzerTest)})},
|
633
1118
|
args: [],
|
634
1119
|
source: "testNonLocalReturn2\x0a\x09| src ast |\x0a\x0a\x09src := 'foo | a | a + 1. [ [ ^ a] ]'.\x0a\x09ast := smalltalk parse: src.\x0a\x09analyzer visit: ast.\x0a\x0a\x09self assert: ast scope hasNonLocalReturn",
|
635
1120
|
messageSends: ["parse:", "visit:", "assert:", "hasNonLocalReturn", "scope"],
|
@@ -642,16 +1127,14 @@ smalltalk.addMethod(
|
|
642
1127
|
smalltalk.method({
|
643
1128
|
selector: "testScope",
|
644
1129
|
category: 'tests',
|
645
|
-
fn: function ()
|
646
|
-
|
647
|
-
|
648
|
-
|
649
|
-
|
650
|
-
|
651
|
-
|
652
|
-
|
653
|
-
return self;
|
654
|
-
},
|
1130
|
+
fn: function (){
|
1131
|
+
var self=this;
|
1132
|
+
var src,ast;
|
1133
|
+
return smalltalk.withContext(function($ctx1) {
|
1134
|
+
ast=_st(smalltalk)._parse_(src);
|
1135
|
+
_st(self["@analyzer"])._visit_(ast);
|
1136
|
+
_st(self)._deny_(_st(_st(_st(_st(_st(_st(ast)._nodes())._first())._nodes())._last())._scope()).__eq_eq(_st(ast)._scope()));
|
1137
|
+
return self}, function($ctx1) {$ctx1.fill(self,"testScope",{src:src,ast:ast}, smalltalk.SemanticAnalyzerTest)})},
|
655
1138
|
args: [],
|
656
1139
|
source: "testScope\x0a\x09| src ast |\x0a\x0a\x09src := 'foo | a | a + 1. [ | b | b := a ]'.\x0a\x09ast := smalltalk parse: src.\x0a\x09analyzer visit: ast.\x0a\x0a\x09self deny: ast nodes first nodes last scope == ast scope.",
|
657
1140
|
messageSends: ["parse:", "visit:", "deny:", "==", "scope", "last", "nodes", "first"],
|
@@ -664,16 +1147,14 @@ smalltalk.addMethod(
|
|
664
1147
|
smalltalk.method({
|
665
1148
|
selector: "testScope2",
|
666
1149
|
category: 'tests',
|
667
|
-
fn: function ()
|
668
|
-
|
669
|
-
|
670
|
-
|
671
|
-
|
672
|
-
|
673
|
-
|
674
|
-
|
675
|
-
return self;
|
676
|
-
},
|
1150
|
+
fn: function (){
|
1151
|
+
var self=this;
|
1152
|
+
var src,ast;
|
1153
|
+
return smalltalk.withContext(function($ctx1) {
|
1154
|
+
ast=_st(smalltalk)._parse_(src);
|
1155
|
+
_st(self["@analyzer"])._visit_(ast);
|
1156
|
+
_st(self)._deny_(_st(_st(_st(_st(_st(_st(_st(_st(_st(_st(ast)._nodes())._first())._nodes())._last())._nodes())._first())._nodes())._first())._scope()).__eq_eq(_st(ast)._scope()));
|
1157
|
+
return self}, function($ctx1) {$ctx1.fill(self,"testScope2",{src:src,ast:ast}, smalltalk.SemanticAnalyzerTest)})},
|
677
1158
|
args: [],
|
678
1159
|
source: "testScope2\x0a\x09| src ast |\x0a\x0a\x09src := 'foo | a | a + 1. [ [ | b | b := a ] ]'.\x0a\x09ast := smalltalk parse: src.\x0a\x09analyzer visit: ast.\x0a\x0a\x09self deny: ast nodes first nodes last nodes first nodes first scope == ast scope.",
|
679
1160
|
messageSends: ["parse:", "visit:", "deny:", "==", "scope", "first", "nodes", "last"],
|
@@ -686,17 +1167,15 @@ smalltalk.addMethod(
|
|
686
1167
|
smalltalk.method({
|
687
1168
|
selector: "testScopeLevel",
|
688
1169
|
category: 'tests',
|
689
|
-
fn: function ()
|
690
|
-
|
691
|
-
|
692
|
-
|
693
|
-
|
694
|
-
|
695
|
-
|
696
|
-
|
697
|
-
|
698
|
-
return self;
|
699
|
-
},
|
1170
|
+
fn: function (){
|
1171
|
+
var self=this;
|
1172
|
+
var src,ast;
|
1173
|
+
return smalltalk.withContext(function($ctx1) {
|
1174
|
+
ast=_st(smalltalk)._parse_(src);
|
1175
|
+
_st(self["@analyzer"])._visit_(ast);
|
1176
|
+
_st(self)._assert_(_st(_st(_st(ast)._scope())._scopeLevel()).__eq((1)));
|
1177
|
+
_st(self)._assert_(_st(_st(_st(_st(_st(_st(_st(_st(_st(_st(_st(ast)._nodes())._first())._nodes())._last())._nodes())._first())._nodes())._first())._scope())._scopeLevel()).__eq((3)));
|
1178
|
+
return self}, function($ctx1) {$ctx1.fill(self,"testScopeLevel",{src:src,ast:ast}, smalltalk.SemanticAnalyzerTest)})},
|
700
1179
|
args: [],
|
701
1180
|
source: "testScopeLevel\x0a\x09| src ast |\x0a\x0a\x09src := 'foo | a | a + 1. [ [ | b | b := a ] ]'.\x0a\x09ast := smalltalk parse: src.\x0a\x09analyzer visit: ast.\x0a\x0a\x09self assert: ast scope scopeLevel = 1.\x0a\x09self assert: ast nodes first nodes last nodes first nodes first scope scopeLevel = 3",
|
702
1181
|
messageSends: ["parse:", "visit:", "assert:", "=", "scopeLevel", "scope", "first", "nodes", "last"],
|
@@ -709,15 +1188,15 @@ smalltalk.addMethod(
|
|
709
1188
|
smalltalk.method({
|
710
1189
|
selector: "testUnknownVariables",
|
711
1190
|
category: 'tests',
|
712
|
-
fn: function ()
|
713
|
-
|
714
|
-
|
715
|
-
|
716
|
-
|
717
|
-
|
718
|
-
|
719
|
-
|
720
|
-
},
|
1191
|
+
fn: function (){
|
1192
|
+
var self=this;
|
1193
|
+
var src,ast;
|
1194
|
+
return smalltalk.withContext(function($ctx1) {
|
1195
|
+
ast=_st(smalltalk)._parse_(src);
|
1196
|
+
_st(self)._should_raise_((function(){
|
1197
|
+
return smalltalk.withContext(function($ctx2) {
|
1198
|
+
}, function($ctx2) {$ctx2.fillBlock({},$ctx1)})}),(smalltalk.UnknownVariableError || UnknownVariableError));
|
1199
|
+
return self}, function($ctx1) {$ctx1.fill(self,"testUnknownVariables",{src:src,ast:ast}, smalltalk.SemanticAnalyzerTest)})},
|
721
1200
|
args: [],
|
722
1201
|
source: "testUnknownVariables\x0a\x09| src ast |\x0a\x0a\x09src := 'foo | a | b + a'.\x0a\x09ast := smalltalk parse: src.\x0a\x0a\x09self should: [ analyzer visit: ast ] raise: UnknownVariableError",
|
723
1202
|
messageSends: ["parse:", "should:raise:", "visit:"],
|
@@ -725,38 +1204,20 @@ referencedClasses: ["UnknownVariableError"]
|
|
725
1204
|
}),
|
726
1205
|
smalltalk.SemanticAnalyzerTest);
|
727
1206
|
|
728
|
-
smalltalk.addMethod(
|
729
|
-
"_testUnknownVariablesDefinedInJS",
|
730
|
-
smalltalk.method({
|
731
|
-
selector: "testUnknownVariablesDefinedInJS",
|
732
|
-
category: 'tests',
|
733
|
-
fn: function () {
|
734
|
-
var self = this;
|
735
|
-
var someVariable = 1;
|
736
|
-
smalltalk.send(self, "_shouldnt_raise_", [function () {return smalltalk.send(smalltalk, "_parse_", ["foo someVariable"]);}, smalltalk.UnknownVariableError || UnknownVariableError]);
|
737
|
-
return self;
|
738
|
-
},
|
739
|
-
args: [],
|
740
|
-
source: "testUnknownVariablesDefinedInJS\x0a\x0a\x09< var someVariable = 1 >.\x0a\x0a\x09self shouldnt: [ smalltalk parse: 'foo someVariable' ] raise: UnknownVariableError",
|
741
|
-
messageSends: ["shouldnt:raise:", "parse:"],
|
742
|
-
referencedClasses: ["UnknownVariableError"]
|
743
|
-
}),
|
744
|
-
smalltalk.SemanticAnalyzerTest);
|
745
|
-
|
746
1207
|
smalltalk.addMethod(
|
747
1208
|
"_testUnknownVariablesWithScope",
|
748
1209
|
smalltalk.method({
|
749
1210
|
selector: "testUnknownVariablesWithScope",
|
750
1211
|
category: 'tests',
|
751
|
-
fn: function ()
|
752
|
-
|
753
|
-
|
754
|
-
|
755
|
-
|
756
|
-
|
757
|
-
|
758
|
-
|
759
|
-
},
|
1212
|
+
fn: function (){
|
1213
|
+
var self=this;
|
1214
|
+
var src,ast;
|
1215
|
+
return smalltalk.withContext(function($ctx1) {
|
1216
|
+
ast=_st(smalltalk)._parse_(src);
|
1217
|
+
_st(self)._should_raise_((function(){
|
1218
|
+
return smalltalk.withContext(function($ctx2) {
|
1219
|
+
}, function($ctx2) {$ctx2.fillBlock({},$ctx1)})}),(smalltalk.UnknownVariableError || UnknownVariableError));
|
1220
|
+
return self}, function($ctx1) {$ctx1.fill(self,"testUnknownVariablesWithScope",{src:src,ast:ast}, smalltalk.SemanticAnalyzerTest)})},
|
760
1221
|
args: [],
|
761
1222
|
source: "testUnknownVariablesWithScope\x0a\x09| src ast |\x0a\x0a\x09src := 'foo | a b | [ c + 1. [ a + 1. d + 1 ]]'.\x0a\x09ast := smalltalk parse: src.\x0a\x09\x0a\x09self should: [ analyzer visit: ast ] raise: UnknownVariableError",
|
762
1223
|
messageSends: ["parse:", "should:raise:", "visit:"],
|
@@ -769,15 +1230,13 @@ smalltalk.addMethod(
|
|
769
1230
|
smalltalk.method({
|
770
1231
|
selector: "testVariableShadowing",
|
771
1232
|
category: 'tests',
|
772
|
-
fn: function ()
|
773
|
-
|
774
|
-
|
775
|
-
|
776
|
-
|
777
|
-
|
778
|
-
|
779
|
-
return self;
|
780
|
-
},
|
1233
|
+
fn: function (){
|
1234
|
+
var self=this;
|
1235
|
+
var src,ast;
|
1236
|
+
return smalltalk.withContext(function($ctx1) {
|
1237
|
+
ast=_st(smalltalk)._parse_(src);
|
1238
|
+
_st(self["@analyzer"])._visit_(ast);
|
1239
|
+
return self}, function($ctx1) {$ctx1.fill(self,"testVariableShadowing",{src:src,ast:ast}, smalltalk.SemanticAnalyzerTest)})},
|
781
1240
|
args: [],
|
782
1241
|
source: "testVariableShadowing\x0a\x09| src ast |\x0a\x09src := 'foo | a | a + 1'.\x0a\x09ast := smalltalk parse: src.\x0a\x09analyzer visit: ast",
|
783
1242
|
messageSends: ["parse:", "visit:"],
|
@@ -790,15 +1249,15 @@ smalltalk.addMethod(
|
|
790
1249
|
smalltalk.method({
|
791
1250
|
selector: "testVariableShadowing2",
|
792
1251
|
category: 'tests',
|
793
|
-
fn: function ()
|
794
|
-
|
795
|
-
|
796
|
-
|
797
|
-
|
798
|
-
|
799
|
-
|
800
|
-
|
801
|
-
},
|
1252
|
+
fn: function (){
|
1253
|
+
var self=this;
|
1254
|
+
var src,ast;
|
1255
|
+
return smalltalk.withContext(function($ctx1) {
|
1256
|
+
ast=_st(smalltalk)._parse_(src);
|
1257
|
+
_st(self)._should_raise_((function(){
|
1258
|
+
return smalltalk.withContext(function($ctx2) {
|
1259
|
+
}, function($ctx2) {$ctx2.fillBlock({},$ctx1)})}),(smalltalk.ShadowingVariableError || ShadowingVariableError));
|
1260
|
+
return self}, function($ctx1) {$ctx1.fill(self,"testVariableShadowing2",{src:src,ast:ast}, smalltalk.SemanticAnalyzerTest)})},
|
802
1261
|
args: [],
|
803
1262
|
source: "testVariableShadowing2\x0a\x09| src ast |\x0a\x09src := 'foo | a | a + 1. [ | a | a := 2 ]'.\x0a\x09ast := smalltalk parse: src.\x0a\x09self should: [analyzer visit: ast] raise: ShadowingVariableError",
|
804
1263
|
messageSends: ["parse:", "should:raise:", "visit:"],
|
@@ -811,15 +1270,13 @@ smalltalk.addMethod(
|
|
811
1270
|
smalltalk.method({
|
812
1271
|
selector: "testVariableShadowing3",
|
813
1272
|
category: 'tests',
|
814
|
-
fn: function ()
|
815
|
-
|
816
|
-
|
817
|
-
|
818
|
-
|
819
|
-
|
820
|
-
|
821
|
-
return self;
|
822
|
-
},
|
1273
|
+
fn: function (){
|
1274
|
+
var self=this;
|
1275
|
+
var src,ast;
|
1276
|
+
return smalltalk.withContext(function($ctx1) {
|
1277
|
+
ast=_st(smalltalk)._parse_(src);
|
1278
|
+
_st(self["@analyzer"])._visit_(ast);
|
1279
|
+
return self}, function($ctx1) {$ctx1.fill(self,"testVariableShadowing3",{src:src,ast:ast}, smalltalk.SemanticAnalyzerTest)})},
|
823
1280
|
args: [],
|
824
1281
|
source: "testVariableShadowing3\x0a\x09| src ast |\x0a\x09src := 'foo | a | a + 1. [ | b | b := 2 ]'.\x0a\x09ast := smalltalk parse: src.\x0a\x09analyzer visit: ast",
|
825
1282
|
messageSends: ["parse:", "visit:"],
|
@@ -832,15 +1289,13 @@ smalltalk.addMethod(
|
|
832
1289
|
smalltalk.method({
|
833
1290
|
selector: "testVariableShadowing4",
|
834
1291
|
category: 'tests',
|
835
|
-
fn: function ()
|
836
|
-
|
837
|
-
|
838
|
-
|
839
|
-
|
840
|
-
|
841
|
-
|
842
|
-
return self;
|
843
|
-
},
|
1292
|
+
fn: function (){
|
1293
|
+
var self=this;
|
1294
|
+
var src,ast;
|
1295
|
+
return smalltalk.withContext(function($ctx1) {
|
1296
|
+
ast=_st(smalltalk)._parse_(src);
|
1297
|
+
_st(self["@analyzer"])._visit_(ast);
|
1298
|
+
return self}, function($ctx1) {$ctx1.fill(self,"testVariableShadowing4",{src:src,ast:ast}, smalltalk.SemanticAnalyzerTest)})},
|
844
1299
|
args: [],
|
845
1300
|
source: "testVariableShadowing4\x0a\x09| src ast |\x0a\x09src := 'foo | a | a + 1. [ [ [ | b | b := 2 ] ] ]'.\x0a\x09ast := smalltalk parse: src.\x0a\x09analyzer visit: ast",
|
846
1301
|
messageSends: ["parse:", "visit:"],
|
@@ -853,15 +1308,15 @@ smalltalk.addMethod(
|
|
853
1308
|
smalltalk.method({
|
854
1309
|
selector: "testVariableShadowing5",
|
855
1310
|
category: 'tests',
|
856
|
-
fn: function ()
|
857
|
-
|
858
|
-
|
859
|
-
|
860
|
-
|
861
|
-
|
862
|
-
|
863
|
-
|
864
|
-
},
|
1311
|
+
fn: function (){
|
1312
|
+
var self=this;
|
1313
|
+
var src,ast;
|
1314
|
+
return smalltalk.withContext(function($ctx1) {
|
1315
|
+
ast=_st(smalltalk)._parse_(src);
|
1316
|
+
_st(self)._should_raise_((function(){
|
1317
|
+
return smalltalk.withContext(function($ctx2) {
|
1318
|
+
}, function($ctx2) {$ctx2.fillBlock({},$ctx1)})}),(smalltalk.ShadowingVariableError || ShadowingVariableError));
|
1319
|
+
return self}, function($ctx1) {$ctx1.fill(self,"testVariableShadowing5",{src:src,ast:ast}, smalltalk.SemanticAnalyzerTest)})},
|
865
1320
|
args: [],
|
866
1321
|
source: "testVariableShadowing5\x0a\x09| src ast |\x0a\x09src := 'foo | a | a + 1. [ [ [ | a | a := 2 ] ] ]'.\x0a\x09ast := smalltalk parse: src.\x0a\x09self should: [analyzer visit: ast] raise: ShadowingVariableError",
|
867
1322
|
messageSends: ["parse:", "should:raise:", "visit:"],
|
@@ -874,19 +1329,17 @@ smalltalk.addMethod(
|
|
874
1329
|
smalltalk.method({
|
875
1330
|
selector: "testVariablesLookup",
|
876
1331
|
category: 'tests',
|
877
|
-
fn: function ()
|
878
|
-
|
879
|
-
|
880
|
-
|
881
|
-
|
882
|
-
|
883
|
-
|
884
|
-
|
885
|
-
|
886
|
-
|
887
|
-
|
888
|
-
return self;
|
889
|
-
},
|
1332
|
+
fn: function (){
|
1333
|
+
var self=this;
|
1334
|
+
var src,ast;
|
1335
|
+
return smalltalk.withContext(function($ctx1) {
|
1336
|
+
ast=_st(smalltalk)._parse_(src);
|
1337
|
+
_st(self["@analyzer"])._visit_(ast);
|
1338
|
+
_st(self)._assert_(_st(_st(_st(_st(_st(_st(_st(ast)._nodes())._first())._nodes())._first())._receiver())._binding())._isTempVar());
|
1339
|
+
_st(self)._assert_(_st(_st(_st(_st(_st(_st(_st(_st(ast)._nodes())._first())._nodes())._first())._receiver())._binding())._scope()).__eq_eq(_st(ast)._scope()));
|
1340
|
+
_st(self)._assert_(_st(_st(_st(_st(_st(_st(_st(_st(_st(_st(_st(ast)._nodes())._first())._nodes())._last())._nodes())._first())._nodes())._first())._left())._binding())._isTempVar());
|
1341
|
+
_st(self)._assert_(_st(_st(_st(_st(_st(_st(_st(_st(_st(_st(_st(_st(ast)._nodes())._first())._nodes())._last())._nodes())._first())._nodes())._first())._left())._binding())._scope()).__eq_eq(_st(_st(_st(_st(_st(ast)._nodes())._first())._nodes())._last())._scope()));
|
1342
|
+
return self}, function($ctx1) {$ctx1.fill(self,"testVariablesLookup",{src:src,ast:ast}, smalltalk.SemanticAnalyzerTest)})},
|
890
1343
|
args: [],
|
891
1344
|
source: "testVariablesLookup\x0a\x09| src ast |\x0a\x0a\x09src := 'foo | a | a + 1. [ | b | b := a ]'.\x0a\x09ast := smalltalk parse: src.\x0a\x09analyzer visit: ast.\x0a\x0a\x09\x22Binding for `a` in the message send\x22\x0a\x09self assert: ast nodes first nodes first receiver binding isTempVar.\x0a\x09self assert: ast nodes first nodes first receiver binding scope == ast scope.\x0a\x0a\x09\x22Binding for `b`\x22\x0a\x09self assert: ast nodes first nodes last nodes first nodes first left binding isTempVar.\x0a\x09self assert: ast nodes first nodes last nodes first nodes first left binding scope == ast nodes first nodes last scope.",
|
892
1345
|
messageSends: ["parse:", "visit:", "assert:", "isTempVar", "binding", "receiver", "first", "nodes", "==", "scope", "left", "last"],
|