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
@@ -77,6 +77,10 @@ The default behavior is to allow it, as this is how Amber currently is able to s
|
|
77
77
|
|
78
78
|
!UnknownVariableError methodsFor: 'accessing'!
|
79
79
|
|
80
|
+
messageText
|
81
|
+
^ 'Unknown Variable error: ', self variableName, ' is not defined'
|
82
|
+
!
|
83
|
+
|
80
84
|
variableName
|
81
85
|
^ variableName
|
82
86
|
!
|
data/amber/st/Compiler-IR.st
CHANGED
@@ -60,7 +60,7 @@ withSequence: aSequence do: aBlock
|
|
60
60
|
alias: aNode
|
61
61
|
| variable |
|
62
62
|
|
63
|
-
aNode
|
63
|
+
aNode isImmutable ifTrue: [ ^ self visit: aNode ].
|
64
64
|
|
65
65
|
variable := IRVariable new
|
66
66
|
variable: (AliasVar new name: '$', self nextAlias);
|
@@ -76,6 +76,29 @@ alias: aNode
|
|
76
76
|
^ variable
|
77
77
|
!
|
78
78
|
|
79
|
+
aliasTemporally: aCollection
|
80
|
+
"https://github.com/NicolasPetton/amber/issues/296
|
81
|
+
|
82
|
+
If a node is aliased, all preceding ones are aliased as well.
|
83
|
+
The tree is iterated twice. First we get the aliasing dependency,
|
84
|
+
then the aliasing itself is done"
|
85
|
+
|
86
|
+
| threshold result |
|
87
|
+
threshold := 0.
|
88
|
+
|
89
|
+
aCollection withIndexDo: [ :each :i |
|
90
|
+
each subtreeNeedsAliasing
|
91
|
+
ifTrue: [ threshold := i ]].
|
92
|
+
|
93
|
+
result := OrderedCollection new.
|
94
|
+
aCollection withIndexDo: [ :each :i |
|
95
|
+
result add: (i <= threshold
|
96
|
+
ifTrue: [ self alias: each ]
|
97
|
+
ifFalse: [ self visit: each ])].
|
98
|
+
|
99
|
+
^result
|
100
|
+
!
|
101
|
+
|
79
102
|
visitAssignmentNode: aNode
|
80
103
|
| left right assignment |
|
81
104
|
right := self visit: aNode right.
|
@@ -96,6 +119,7 @@ visitBlockNode: aNode
|
|
96
119
|
aNode scope temps do: [ :each |
|
97
120
|
closure add: (IRTempDeclaration new
|
98
121
|
name: each name;
|
122
|
+
scope: aNode scope;
|
99
123
|
yourself) ].
|
100
124
|
aNode nodes do: [ :each | closure add: (self visit: each) ].
|
101
125
|
^ closure
|
@@ -116,7 +140,7 @@ visitBlockSequenceNode: aNode
|
|
116
140
|
visitCascadeNode: aNode
|
117
141
|
| alias |
|
118
142
|
|
119
|
-
aNode receiver
|
143
|
+
aNode receiver isImmutable ifFalse: [
|
120
144
|
alias := self alias: aNode receiver.
|
121
145
|
aNode nodes do: [ :each |
|
122
146
|
each receiver: (VariableNode new binding: alias variable) ]].
|
@@ -130,14 +154,14 @@ visitCascadeNode: aNode
|
|
130
154
|
visitDynamicArrayNode: aNode
|
131
155
|
| array |
|
132
156
|
array := IRDynamicArray new.
|
133
|
-
aNode nodes do: [
|
157
|
+
(self aliasTemporally: aNode nodes) do: [:each | array add: each].
|
134
158
|
^ array
|
135
159
|
!
|
136
160
|
|
137
161
|
visitDynamicDictionaryNode: aNode
|
138
162
|
| dictionary |
|
139
163
|
dictionary := IRDynamicDictionary new.
|
140
|
-
|
164
|
+
(self aliasTemporally: aNode nodes) do: [:each | dictionary add: each].
|
141
165
|
^ dictionary
|
142
166
|
!
|
143
167
|
|
@@ -151,9 +175,11 @@ visitMethodNode: aNode
|
|
151
175
|
|
152
176
|
self method: (IRMethod new
|
153
177
|
source: self source;
|
178
|
+
theClass: self theClass;
|
154
179
|
arguments: aNode arguments;
|
155
180
|
selector: aNode selector;
|
156
181
|
messageSends: aNode messageSends;
|
182
|
+
superSends: aNode superSends;
|
157
183
|
classReferences: aNode classReferences;
|
158
184
|
scope: aNode scope;
|
159
185
|
yourself).
|
@@ -161,6 +187,7 @@ visitMethodNode: aNode
|
|
161
187
|
aNode scope temps do: [ :each |
|
162
188
|
self method add: (IRTempDeclaration new
|
163
189
|
name: each name;
|
190
|
+
scope: aNode scope;
|
164
191
|
yourself) ].
|
165
192
|
|
166
193
|
aNode nodes do: [ :each | self method add: (self visit: each) ].
|
@@ -185,21 +212,16 @@ visitReturnNode: aNode
|
|
185
212
|
!
|
186
213
|
|
187
214
|
visitSendNode: aNode
|
188
|
-
| send receiver arguments |
|
215
|
+
| send all receiver arguments |
|
189
216
|
send := IRSend new.
|
190
217
|
send
|
191
218
|
selector: aNode selector;
|
192
219
|
index: aNode index.
|
193
220
|
aNode superSend ifTrue: [ send classSend: self theClass superclass ].
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
arguments := aNode arguments collect: [ :each |
|
200
|
-
each shouldBeInlined
|
201
|
-
ifTrue: [ self alias: each ]
|
202
|
-
ifFalse: [ self visit: each ]].
|
221
|
+
|
222
|
+
all := self aliasTemporally: { aNode receiver }, aNode arguments.
|
223
|
+
receiver := all first.
|
224
|
+
arguments := all allButFirst.
|
203
225
|
|
204
226
|
send add: receiver.
|
205
227
|
arguments do: [ :each | send add: each ].
|
@@ -242,6 +264,10 @@ instructions
|
|
242
264
|
^ instructions ifNil: [ instructions := OrderedCollection new ]
|
243
265
|
!
|
244
266
|
|
267
|
+
method
|
268
|
+
^ self parent method
|
269
|
+
!
|
270
|
+
|
245
271
|
parent
|
246
272
|
^ parent
|
247
273
|
!
|
@@ -294,6 +320,10 @@ isLocalReturn
|
|
294
320
|
^ false
|
295
321
|
!
|
296
322
|
|
323
|
+
isMethod
|
324
|
+
^ false
|
325
|
+
!
|
326
|
+
|
297
327
|
isReturn
|
298
328
|
^ false
|
299
329
|
!
|
@@ -372,11 +402,11 @@ scope: aScope
|
|
372
402
|
scope := aScope
|
373
403
|
! !
|
374
404
|
|
375
|
-
IRScopedInstruction subclass: #
|
405
|
+
IRScopedInstruction subclass: #IRClosureInstruction
|
376
406
|
instanceVariableNames: 'arguments'
|
377
407
|
package: 'Compiler-IR'!
|
378
408
|
|
379
|
-
!
|
409
|
+
!IRClosureInstruction methodsFor: 'accessing'!
|
380
410
|
|
381
411
|
arguments
|
382
412
|
^ arguments ifNil: [ #() ]
|
@@ -386,11 +416,28 @@ arguments: aCollection
|
|
386
416
|
arguments := aCollection
|
387
417
|
!
|
388
418
|
|
419
|
+
locals
|
420
|
+
^ self arguments copy
|
421
|
+
addAll: (self tempDeclarations collect: [ :each | each name ]);
|
422
|
+
yourself
|
423
|
+
!
|
424
|
+
|
389
425
|
scope: aScope
|
390
426
|
super scope: aScope.
|
391
427
|
aScope instruction: self
|
392
428
|
!
|
393
429
|
|
430
|
+
tempDeclarations
|
431
|
+
^ self instructions select: [ :each |
|
432
|
+
each isTempDeclaration ]
|
433
|
+
! !
|
434
|
+
|
435
|
+
IRClosureInstruction subclass: #IRClosure
|
436
|
+
instanceVariableNames: ''
|
437
|
+
package: 'Compiler-IR'!
|
438
|
+
|
439
|
+
!IRClosure methodsFor: 'accessing'!
|
440
|
+
|
394
441
|
sequence
|
395
442
|
^ self instructions last
|
396
443
|
! !
|
@@ -407,22 +454,14 @@ accept: aVisitor
|
|
407
454
|
^ aVisitor visitIRClosure: self
|
408
455
|
! !
|
409
456
|
|
410
|
-
|
411
|
-
instanceVariableNames: 'source selector classReferences messageSends
|
457
|
+
IRClosureInstruction subclass: #IRMethod
|
458
|
+
instanceVariableNames: 'theClass source selector classReferences messageSends superSends internalVariables'
|
412
459
|
package: 'Compiler-IR'!
|
413
460
|
!IRMethod commentStamp!
|
414
461
|
I am a method instruction!
|
415
462
|
|
416
463
|
!IRMethod methodsFor: 'accessing'!
|
417
464
|
|
418
|
-
arguments
|
419
|
-
^ arguments
|
420
|
-
!
|
421
|
-
|
422
|
-
arguments: aCollection
|
423
|
-
arguments := aCollection
|
424
|
-
!
|
425
|
-
|
426
465
|
classReferences
|
427
466
|
^ classReferences
|
428
467
|
!
|
@@ -435,6 +474,10 @@ internalVariables
|
|
435
474
|
^ internalVariables ifNil: [ internalVariables := Set new ]
|
436
475
|
!
|
437
476
|
|
477
|
+
isMethod
|
478
|
+
^ true
|
479
|
+
!
|
480
|
+
|
438
481
|
messageSends
|
439
482
|
^ messageSends
|
440
483
|
!
|
@@ -443,9 +486,8 @@ messageSends: aCollection
|
|
443
486
|
messageSends := aCollection
|
444
487
|
!
|
445
488
|
|
446
|
-
|
447
|
-
|
448
|
-
aScope instruction: self
|
489
|
+
method
|
490
|
+
^ self
|
449
491
|
!
|
450
492
|
|
451
493
|
selector
|
@@ -462,6 +504,22 @@ source
|
|
462
504
|
|
463
505
|
source: aString
|
464
506
|
source := aString
|
507
|
+
!
|
508
|
+
|
509
|
+
superSends
|
510
|
+
^ superSends
|
511
|
+
!
|
512
|
+
|
513
|
+
superSends: aCollection
|
514
|
+
superSends := aCollection
|
515
|
+
!
|
516
|
+
|
517
|
+
theClass
|
518
|
+
^ theClass
|
519
|
+
!
|
520
|
+
|
521
|
+
theClass: aClass
|
522
|
+
theClass := aClass
|
465
523
|
! !
|
466
524
|
|
467
525
|
!IRMethod methodsFor: 'visiting'!
|
@@ -543,6 +601,32 @@ accept: aVisitor
|
|
543
601
|
^ aVisitor visitIRNonLocalReturn: self
|
544
602
|
! !
|
545
603
|
|
604
|
+
IRScopedInstruction subclass: #IRTempDeclaration
|
605
|
+
instanceVariableNames: 'name'
|
606
|
+
package: 'Compiler-IR'!
|
607
|
+
|
608
|
+
!IRTempDeclaration methodsFor: 'accessing'!
|
609
|
+
|
610
|
+
name
|
611
|
+
^ name
|
612
|
+
!
|
613
|
+
|
614
|
+
name: aString
|
615
|
+
name := aString
|
616
|
+
! !
|
617
|
+
|
618
|
+
!IRTempDeclaration methodsFor: 'testing'!
|
619
|
+
|
620
|
+
isTempDeclaration
|
621
|
+
^ true
|
622
|
+
! !
|
623
|
+
|
624
|
+
!IRTempDeclaration methodsFor: 'visiting'!
|
625
|
+
|
626
|
+
accept: aVisitor
|
627
|
+
^ aVisitor visitIRTempDeclaration: self
|
628
|
+
! !
|
629
|
+
|
546
630
|
IRInstruction subclass: #IRSend
|
547
631
|
instanceVariableNames: 'selector classSend index'
|
548
632
|
package: 'Compiler-IR'!
|
@@ -567,6 +651,12 @@ index: anInteger
|
|
567
651
|
index := anInteger
|
568
652
|
!
|
569
653
|
|
654
|
+
javascriptSelector
|
655
|
+
^ self classSend
|
656
|
+
ifNil: [ self selector asSelector ]
|
657
|
+
ifNotNil: [ self selector asSuperSelector ]
|
658
|
+
!
|
659
|
+
|
570
660
|
selector
|
571
661
|
^ selector
|
572
662
|
!
|
@@ -613,32 +703,6 @@ accept: aVisitor
|
|
613
703
|
^ aVisitor visitIRBlockSequence: self
|
614
704
|
! !
|
615
705
|
|
616
|
-
IRInstruction subclass: #IRTempDeclaration
|
617
|
-
instanceVariableNames: 'name'
|
618
|
-
package: 'Compiler-IR'!
|
619
|
-
!IRTempDeclaration commentStamp!
|
620
|
-
I am a temporary variable declaration instruction!
|
621
|
-
|
622
|
-
!IRTempDeclaration methodsFor: 'accessing'!
|
623
|
-
|
624
|
-
name
|
625
|
-
^ name
|
626
|
-
!
|
627
|
-
|
628
|
-
name: aString
|
629
|
-
name := aString
|
630
|
-
! !
|
631
|
-
|
632
|
-
!IRTempDeclaration methodsFor: 'visiting'!
|
633
|
-
|
634
|
-
accept: aVisitor
|
635
|
-
^ aVisitor visitIRTempDeclaration: self
|
636
|
-
!
|
637
|
-
|
638
|
-
isTempDeclaration
|
639
|
-
^ true
|
640
|
-
! !
|
641
|
-
|
642
706
|
IRInstruction subclass: #IRValue
|
643
707
|
instanceVariableNames: 'value'
|
644
708
|
package: 'Compiler-IR'!
|
@@ -831,7 +895,12 @@ visitIRAssignment: anIRAssignment
|
|
831
895
|
|
832
896
|
visitIRClosure: anIRClosure
|
833
897
|
self stream
|
834
|
-
nextPutClosureWith: [
|
898
|
+
nextPutClosureWith: [
|
899
|
+
self stream nextPutVars: (anIRClosure tempDeclarations collect: [ :each |
|
900
|
+
each name asVariableName ]).
|
901
|
+
self stream
|
902
|
+
nextPutBlockContextFor: anIRClosure
|
903
|
+
during: [ super visitIRClosure: anIRClosure ] ]
|
835
904
|
arguments: anIRClosure arguments
|
836
905
|
!
|
837
906
|
|
@@ -852,10 +921,14 @@ visitIRDynamicDictionary: anIRDynamicDictionary
|
|
852
921
|
!
|
853
922
|
|
854
923
|
visitIRMethod: anIRMethod
|
924
|
+
|
855
925
|
self stream
|
856
926
|
nextPutMethodDeclaration: anIRMethod
|
857
927
|
with: [ self stream
|
858
928
|
nextPutFunctionWith: [
|
929
|
+
self stream nextPutVars: (anIRMethod tempDeclarations collect: [ :each |
|
930
|
+
each name asVariableName ]).
|
931
|
+
self stream nextPutContextFor: anIRMethod during: [
|
859
932
|
anIRMethod internalVariables notEmpty ifTrue: [
|
860
933
|
self stream nextPutVars: (anIRMethod internalVariables asArray collect: [ :each |
|
861
934
|
each variable alias ]) ].
|
@@ -863,7 +936,7 @@ visitIRMethod: anIRMethod
|
|
863
936
|
ifTrue: [
|
864
937
|
self stream nextPutNonLocalReturnHandlingWith: [
|
865
938
|
super visitIRMethod: anIRMethod ]]
|
866
|
-
ifFalse: [ super visitIRMethod: anIRMethod ]]
|
939
|
+
ifFalse: [ super visitIRMethod: anIRMethod ]]]
|
867
940
|
arguments: anIRMethod arguments ]
|
868
941
|
!
|
869
942
|
|
@@ -878,23 +951,26 @@ visitIRReturn: anIRReturn
|
|
878
951
|
!
|
879
952
|
|
880
953
|
visitIRSend: anIRSend
|
881
|
-
|
882
|
-
|
883
|
-
|
884
|
-
|
885
|
-
|
886
|
-
|
887
|
-
|
888
|
-
|
889
|
-
|
890
|
-
|
891
|
-
|
892
|
-
|
893
|
-
|
894
|
-
|
895
|
-
anIRSend
|
896
|
-
|
897
|
-
|
954
|
+
anIRSend classSend
|
955
|
+
ifNil: [
|
956
|
+
self stream nextPutAll: '_st('.
|
957
|
+
self visit: anIRSend instructions first.
|
958
|
+
self stream nextPutAll: ').', anIRSend selector asSelector, '('.
|
959
|
+
anIRSend instructions allButFirst
|
960
|
+
do: [ :each | self visit: each ]
|
961
|
+
separatedBy: [ self stream nextPutAll: ',' ].
|
962
|
+
self stream nextPutAll: ')' ]
|
963
|
+
ifNotNil: [
|
964
|
+
self stream
|
965
|
+
nextPutAll: anIRSend classSend asJavascript, '.fn.prototype.';
|
966
|
+
nextPutAll: anIRSend selector asSelector, '.apply(';
|
967
|
+
nextPutAll: '_st('.
|
968
|
+
self visit: anIRSend instructions first.
|
969
|
+
self stream nextPutAll: '), ['.
|
970
|
+
anIRSend instructions allButFirst
|
971
|
+
do: [ :each | self visit: each ]
|
972
|
+
separatedBy: [ self stream nextPutAll: ',' ].
|
973
|
+
self stream nextPutAll: '])' ]
|
898
974
|
!
|
899
975
|
|
900
976
|
visitIRSequence: anIRSequence
|
@@ -904,7 +980,9 @@ visitIRSequence: anIRSequence
|
|
904
980
|
!
|
905
981
|
|
906
982
|
visitIRTempDeclaration: anIRTempDeclaration
|
907
|
-
self stream
|
983
|
+
"self stream
|
984
|
+
nextPutAll: 'var ', anIRTempDeclaration name asVariableName, ';';
|
985
|
+
lf"
|
908
986
|
!
|
909
987
|
|
910
988
|
visitIRValue: anIRValue
|
@@ -957,6 +1035,30 @@ nextPutAssignment
|
|
957
1035
|
stream nextPutAll: '='
|
958
1036
|
!
|
959
1037
|
|
1038
|
+
nextPutBlockContextFor: anIRClosure during: aBlock
|
1039
|
+
self
|
1040
|
+
nextPutAll: 'return smalltalk.withContext(function(', anIRClosure scope alias, ') {';
|
1041
|
+
nextPutAll: String cr.
|
1042
|
+
|
1043
|
+
aBlock value.
|
1044
|
+
|
1045
|
+
self
|
1046
|
+
nextPutAll: '}, function(', anIRClosure scope alias, ') {';
|
1047
|
+
nextPutAll: anIRClosure scope alias, '.fillBlock({'.
|
1048
|
+
|
1049
|
+
anIRClosure locals
|
1050
|
+
do: [ :each |
|
1051
|
+
self
|
1052
|
+
nextPutAll: each asVariableName;
|
1053
|
+
nextPutAll: ':';
|
1054
|
+
nextPutAll: each asVariableName]
|
1055
|
+
separatedBy: [ self nextPutAll: ',' ].
|
1056
|
+
|
1057
|
+
self
|
1058
|
+
nextPutAll: '},';
|
1059
|
+
nextPutAll: anIRClosure method scope alias, ')})'
|
1060
|
+
!
|
1061
|
+
|
960
1062
|
nextPutClosureWith: aBlock arguments: anArray
|
961
1063
|
stream nextPutAll: '(function('.
|
962
1064
|
anArray
|
@@ -967,6 +1069,30 @@ nextPutClosureWith: aBlock arguments: anArray
|
|
967
1069
|
stream nextPutAll: '})'
|
968
1070
|
!
|
969
1071
|
|
1072
|
+
nextPutContextFor: aMethod during: aBlock
|
1073
|
+
self
|
1074
|
+
nextPutAll: 'return smalltalk.withContext(function(', aMethod scope alias, ') { ';
|
1075
|
+
nextPutAll: String cr.
|
1076
|
+
aBlock value.
|
1077
|
+
|
1078
|
+
self
|
1079
|
+
nextPutAll: '}, function(', aMethod scope alias, ') {', aMethod scope alias;
|
1080
|
+
nextPutAll: '.fill(self,', aMethod selector asJavascript, ',{'.
|
1081
|
+
|
1082
|
+
aMethod locals
|
1083
|
+
do: [ :each |
|
1084
|
+
self
|
1085
|
+
nextPutAll: each asVariableName;
|
1086
|
+
nextPutAll: ':';
|
1087
|
+
nextPutAll: each asVariableName]
|
1088
|
+
separatedBy: [ self nextPutAll: ',' ].
|
1089
|
+
|
1090
|
+
self
|
1091
|
+
nextPutAll: '}, ';
|
1092
|
+
nextPutAll: aMethod theClass asJavascript;
|
1093
|
+
nextPutAll: ')})'
|
1094
|
+
!
|
1095
|
+
|
970
1096
|
nextPutFunctionWith: aBlock arguments: anArray
|
971
1097
|
stream nextPutAll: 'fn: function('.
|
972
1098
|
anArray
|
@@ -1000,12 +1126,12 @@ nextPutMethodDeclaration: aMethod with: aBlock
|
|
1000
1126
|
stream
|
1001
1127
|
nextPutAll: 'smalltalk.method({'; lf;
|
1002
1128
|
nextPutAll: 'selector: "', aMethod selector, '",'; lf;
|
1003
|
-
nextPutAll: 'source: ', aMethod source asJavascript, ',';lf.
|
1129
|
+
nextPutAll: 'source: ', aMethod source asJavascript, ',';lf.
|
1004
1130
|
aBlock value.
|
1005
1131
|
stream
|
1006
1132
|
nextPutAll: ',', String lf, 'messageSends: ';
|
1007
1133
|
nextPutAll: aMethod messageSends asArray asJavascript, ','; lf;
|
1008
|
-
|
1134
|
+
nextPutAll: 'args: ', (aMethod arguments collect: [ :each | each value ]) asArray asJavascript, ','; lf;
|
1009
1135
|
nextPutAll: 'referencedClasses: ['.
|
1010
1136
|
aMethod classReferences
|
1011
1137
|
do: [:each | stream nextPutAll: each asJavascript]
|
@@ -1040,16 +1166,6 @@ nextPutReturnWith: aBlock
|
|
1040
1166
|
aBlock value
|
1041
1167
|
!
|
1042
1168
|
|
1043
|
-
nextPutSendTo: receiver selector: selector arguments: arguments
|
1044
|
-
stream nextPutAll: 'smalltalk.send('.
|
1045
|
-
receiver emitOn: self.
|
1046
|
-
stream nextPutAll: ',"', selector asSelector, '",['.
|
1047
|
-
arguments
|
1048
|
-
do: [ :each | each emitOn: self ]
|
1049
|
-
separatedBy: [ stream nextPutAll: ',' ].
|
1050
|
-
stream nextPutAll: '])'
|
1051
|
-
!
|
1052
|
-
|
1053
1169
|
nextPutSequenceWith: aBlock
|
1054
1170
|
"stream
|
1055
1171
|
nextPutAll: 'switch(smalltalk.thisContext.pc){'; lf."
|
@@ -1074,6 +1190,8 @@ nextPutVar: aString
|
|
1074
1190
|
!
|
1075
1191
|
|
1076
1192
|
nextPutVars: aCollection
|
1193
|
+
aCollection ifEmpty: [ ^self ].
|
1194
|
+
|
1077
1195
|
stream nextPutAll: 'var '.
|
1078
1196
|
aCollection
|
1079
1197
|
do: [ :each | stream nextPutAll: each ]
|