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.
Files changed (84) hide show
  1. data/amber/bin/amberc +10 -350
  2. data/amber/js/Benchfib.deploy.js +80 -89
  3. data/amber/js/Benchfib.js +80 -89
  4. data/amber/js/Canvas.deploy.js +558 -545
  5. data/amber/js/Canvas.js +563 -545
  6. data/amber/js/Compiler-AST.deploy.js +431 -243
  7. data/amber/js/Compiler-AST.js +487 -244
  8. data/amber/js/Compiler-Core.deploy.js +201 -1045
  9. data/amber/js/Compiler-Core.js +208 -1207
  10. data/amber/js/Compiler-Exceptions.deploy.js +37 -18
  11. data/amber/js/Compiler-Exceptions.js +42 -18
  12. data/amber/js/Compiler-IR.deploy.js +1071 -774
  13. data/amber/js/Compiler-IR.js +1194 -848
  14. data/amber/js/Compiler-Inlining.deploy.js +395 -373
  15. data/amber/js/Compiler-Inlining.js +395 -373
  16. data/amber/js/Compiler-Interpreter.deploy.js +1202 -0
  17. data/amber/js/Compiler-Interpreter.js +1631 -0
  18. data/amber/js/Compiler-Semantic.deploy.js +695 -600
  19. data/amber/js/Compiler-Semantic.js +721 -611
  20. data/amber/js/Compiler-Tests.deploy.js +699 -376
  21. data/amber/js/Compiler-Tests.js +834 -381
  22. data/amber/js/Compiler.deploy.js +8563 -1805
  23. data/amber/js/Compiler.js +11476 -2633
  24. data/amber/js/Examples.deploy.js +29 -29
  25. data/amber/js/Examples.js +29 -29
  26. data/amber/js/IDE.deploy.js +3292 -2649
  27. data/amber/js/IDE.js +3318 -2710
  28. data/amber/js/Importer-Exporter.deploy.js +393 -349
  29. data/amber/js/Importer-Exporter.js +398 -354
  30. data/amber/js/Kernel-Announcements.deploy.js +53 -44
  31. data/amber/js/Kernel-Announcements.js +55 -44
  32. data/amber/js/Kernel-Classes.deploy.js +566 -368
  33. data/amber/js/Kernel-Classes.js +660 -402
  34. data/amber/js/Kernel-Collections.deploy.js +1149 -1098
  35. data/amber/js/Kernel-Collections.js +1183 -1116
  36. data/amber/js/Kernel-Exceptions.deploy.js +173 -75
  37. data/amber/js/Kernel-Exceptions.js +215 -77
  38. data/amber/js/Kernel-Methods.deploy.js +530 -313
  39. data/amber/js/Kernel-Methods.js +632 -338
  40. data/amber/js/Kernel-Objects.deploy.js +1734 -1577
  41. data/amber/js/Kernel-Objects.js +1867 -1654
  42. data/amber/js/Kernel-Tests.deploy.js +1416 -973
  43. data/amber/js/Kernel-Tests.js +1495 -981
  44. data/amber/js/Kernel-Transcript.deploy.js +23 -24
  45. data/amber/js/Kernel-Transcript.js +25 -26
  46. data/amber/js/SUnit-Tests.deploy.js +402 -0
  47. data/amber/js/SUnit-Tests.js +518 -0
  48. data/amber/js/SUnit.deploy.js +535 -237
  49. data/amber/js/SUnit.js +634 -246
  50. data/amber/js/amber.js +90 -53
  51. data/amber/js/boot.js +441 -255
  52. data/amber/js/init.js +1 -3
  53. data/amber/js/lib/CodeMirror/codemirror.css +3 -0
  54. data/amber/js/lib/CodeMirror/codemirror.js +104 -55
  55. data/amber/js/lib/peg-0.7.0.min.js +9 -0
  56. data/amber/js/parser.js +1504 -802
  57. data/amber/js/parser.pegjs +170 -165
  58. data/amber/st/Canvas.st +6 -0
  59. data/amber/st/Compiler-AST.st +54 -3
  60. data/amber/st/Compiler-Core.st +6 -551
  61. data/amber/st/Compiler-Exceptions.st +4 -0
  62. data/amber/st/Compiler-IR.st +205 -87
  63. data/amber/st/Compiler-Interpreter.st +597 -0
  64. data/amber/st/Compiler-Semantic.st +46 -21
  65. data/amber/st/Compiler-Tests.st +254 -7
  66. data/amber/st/Compiler.st +3172 -1541
  67. data/amber/st/IDE.st +57 -93
  68. data/amber/st/Importer-Exporter.st +4 -7
  69. data/amber/st/Kernel-Announcements.st +8 -0
  70. data/amber/st/Kernel-Classes.st +149 -40
  71. data/amber/st/Kernel-Collections.st +43 -32
  72. data/amber/st/Kernel-Exceptions.st +70 -1
  73. data/amber/st/Kernel-Methods.st +165 -27
  74. data/amber/st/Kernel-Objects.st +215 -140
  75. data/amber/st/Kernel-Tests.st +195 -10
  76. data/amber/st/Kernel-Transcript.st +1 -3
  77. data/amber/st/SUnit-Tests.st +186 -0
  78. data/amber/st/SUnit.st +186 -14
  79. data/bin/resin +6 -0
  80. data/lib/resin/cli.rb +19 -0
  81. metadata +41 -25
  82. data/amber/js/lib/peg-0.6.2.min.js +0 -2
  83. data/bin/resin-compile +0 -6
  84. data/bin/runresin +0 -12
@@ -68,15 +68,11 @@ identityHash
68
68
  !
69
69
 
70
70
  instVarAt: aSymbol
71
- | varname |
72
- varname := aSymbol asString.
73
- <return self['@'+varname]>
71
+ <return self['@'+aSymbol._asString()]>
74
72
  !
75
73
 
76
74
  instVarAt: aSymbol put: anObject
77
- | varname |
78
- varname := aSymbol asString.
79
- <self['@' + varname] = anObject>
75
+ <self['@' + aSymbol._asString()] = anObject>
80
76
  !
81
77
 
82
78
  size
@@ -84,7 +80,7 @@ size
84
80
  !
85
81
 
86
82
  value
87
- ^ self
83
+ <return self.valueOf()>
88
84
  !
89
85
 
90
86
  yourself
@@ -133,6 +129,12 @@ asJavascript
133
129
 
134
130
  asString
135
131
  ^self printString
132
+ !
133
+
134
+ test
135
+ | a |
136
+ a := 1.
137
+ self halt
136
138
  ! !
137
139
 
138
140
  !Object methodsFor: 'copying'!
@@ -205,8 +207,7 @@ throw: anObject
205
207
  !
206
208
 
207
209
  try: aBlock catch: anotherBlock
208
- <try{result = aBlock()} catch(e) {result = anotherBlock(e)};
209
- return result;>
210
+ <try{return aBlock()} catch(e) {return anotherBlock(e)}>
210
211
  ! !
211
212
 
212
213
  !Object methodsFor: 'initialization'!
@@ -229,9 +230,7 @@ perform: aSymbol
229
230
  !
230
231
 
231
232
  perform: aSymbol withArguments: aCollection
232
- | selector |
233
- selector := aSymbol asSelector.
234
- <return smalltalk.send(self, selector, aCollection)>
233
+ <return smalltalk.send(self, aSymbol._asSelector(), aCollection)>
235
234
  ! !
236
235
 
237
236
  !Object methodsFor: 'printing'!
@@ -284,6 +283,10 @@ ifNotNil: aBlock ifNil: anotherBlock
284
283
  ^aBlock value
285
284
  !
286
285
 
286
+ isBoolean
287
+ ^ false
288
+ !
289
+
287
290
  isClass
288
291
  ^false
289
292
  !
@@ -348,8 +351,12 @@ Boolean instances are weither `true` or `false`.!
348
351
  !Boolean methodsFor: 'comparing'!
349
352
 
350
353
  = aBoolean
351
- aBoolean class = self class ifFalse: [^false].
352
- <return Boolean(self == true) == aBoolean>
354
+ <
355
+ if(!! aBoolean._isBoolean || !! aBoolean._isBoolean()) {
356
+ return false;
357
+ }
358
+ return Boolean(self == true) == aBoolean
359
+ >
353
360
  !
354
361
 
355
362
  == aBoolean
@@ -442,6 +449,12 @@ printString
442
449
  <return self.toString()>
443
450
  ! !
444
451
 
452
+ !Boolean methodsFor: 'testing'!
453
+
454
+ isBoolean
455
+ ^ true
456
+ ! !
457
+
445
458
  Object subclass: #Date
446
459
  instanceVariableNames: ''
447
460
  package: 'Kernel-Objects'!
@@ -656,15 +669,11 @@ __Note:__ For keyword-based messages, only the first keyword is kept: `window fo
656
669
  !JSObjectProxy methodsFor: 'accessing'!
657
670
 
658
671
  at: aSymbol
659
- | attr |
660
- attr := aSymbol asString.
661
- <return self['@jsObject'][attr]>
672
+ <return self['@jsObject'][aSymbol._asString()]>
662
673
  !
663
674
 
664
675
  at: aSymbol put: anObject
665
- | attr |
666
- attr := aSymbol asString.
667
- <self['@jsObject'][attr] = anObject>
676
+ <self['@jsObject'][aSymbol._asString()] = anObject>
668
677
  !
669
678
 
670
679
  jsObject
@@ -675,16 +684,38 @@ jsObject: aJSObject
675
684
  jsObject := aJSObject
676
685
  ! !
677
686
 
687
+ !JSObjectProxy methodsFor: 'enumerating'!
688
+
689
+ keysAndValuesDo: aBlock
690
+ <
691
+ var o = self['@jsObject'];
692
+ for(var i in o) {
693
+ aBlock(i, o[i]);
694
+ }
695
+ >
696
+ ! !
697
+
678
698
  !JSObjectProxy methodsFor: 'proxy'!
679
699
 
700
+ addObjectVariablesTo: aDictionary
701
+ <
702
+ for(var i in self['@jsObject']) {
703
+ aDictionary._at_put_(i, self['@jsObject'][i]);
704
+ }
705
+ >
706
+ !
707
+
680
708
  doesNotUnderstand: aMessage
681
- | obj selector jsSelector arguments |
682
- obj := self jsObject.
683
- selector := aMessage selector.
684
- jsSelector := selector asJavaScriptSelector.
685
- arguments := aMessage arguments.
686
- <if(obj[jsSelector] !!= undefined) {return smalltalk.send(obj, jsSelector, arguments)}>.
687
- super doesNotUnderstand: aMessage
709
+
710
+ ^ (self canForwardMessage: aMessage)
711
+ ifTrue: [ self forwardMessage: aMessage ]
712
+ ifFalse: [ ^ super doesNotUnderstand: aMessage ]
713
+ !
714
+
715
+ forwardMessage: aMessage
716
+ <
717
+ return smalltalk.send(self._jsObject(), aMessage._selector()._asJavaScriptSelector(), aMessage._arguments());
718
+ >
688
719
  !
689
720
 
690
721
  inspectOn: anInspector
@@ -692,9 +723,7 @@ inspectOn: anInspector
692
723
  variables := Dictionary new.
693
724
  variables at: '#self' put: self jsObject.
694
725
  anInspector setLabel: self printString.
695
- <for(var i in self['@jsObject']) {
696
- variables._at_put_(i, self['@jsObject'][i]);
697
- }>.
726
+ self addObjectVariablesTo: variables.
698
727
  anInspector setVariables: variables
699
728
  !
700
729
 
@@ -702,6 +731,19 @@ printString
702
731
  ^self jsObject toString
703
732
  ! !
704
733
 
734
+ !JSObjectProxy methodsFor: 'testing'!
735
+
736
+ canForwardMessage: aMessage
737
+ <
738
+ var jsSelector = aMessage._selector()._asJavaScriptSelector();
739
+ if(jsSelector in self._jsObject()) {
740
+ return true
741
+ } else {
742
+ return false;
743
+ }
744
+ >
745
+ ! !
746
+
705
747
  !JSObjectProxy class methodsFor: 'instance creation'!
706
748
 
707
749
  on: aJSObject
@@ -760,8 +802,12 @@ identityHash
760
802
  <return self % aNumber>
761
803
  !
762
804
 
805
+ \\ aNumber
806
+ <return self % aNumber>
807
+ !
808
+
763
809
  abs
764
- ^ <Math.abs(self);>
810
+ <return Math.abs(self);>
765
811
  !
766
812
 
767
813
  max: aNumber
@@ -797,8 +843,12 @@ squared
797
843
  !
798
844
 
799
845
  = aNumber
800
- aNumber isNumber ifFalse: [^false].
801
- <return Number(self) == aNumber>
846
+ <
847
+ if(!! aNumber._isNumber || !! aNumber._isNumber()) {
848
+ return false;
849
+ }
850
+ return Number(self) == aNumber
851
+ >
802
852
  !
803
853
 
804
854
  > aNumber
@@ -877,13 +927,13 @@ to: stop by: step
877
927
  !
878
928
 
879
929
  truncated
880
- |result|
881
-
882
- self >= 0
883
- ifTrue: [<result = Math.floor(self);>]
884
- ifFalse: [<result = (Math.floor(self * (-1)) * (-1));>].
885
-
886
- ^ result
930
+ <
931
+ if(self >>= 0) {
932
+ return Math.floor(self);
933
+ } else {
934
+ return Math.floor(self * (-1)) * (-1);
935
+ };
936
+ >
887
937
  !
888
938
 
889
939
  | aNumber
@@ -903,8 +953,7 @@ deepCopy
903
953
  !Number methodsFor: 'enumerating'!
904
954
 
905
955
  timesRepeat: aBlock
906
- | integer count |
907
- integer := self truncated.
956
+ | count |
908
957
  count := 1.
909
958
  [count > self] whileFalse: [
910
959
  aBlock value.
@@ -974,16 +1023,6 @@ positive
974
1023
  ^ self >= 0
975
1024
  ! !
976
1025
 
977
- !Number methodsFor: 'timeouts/intervals'!
978
-
979
- clearInterval
980
- <clearInterval(Number(self))>
981
- !
982
-
983
- clearTimeout
984
- <clearTimeout(Number(self))>
985
- ! !
986
-
987
1026
  !Number class methodsFor: 'instance creation'!
988
1027
 
989
1028
  pi
@@ -997,7 +1036,7 @@ Object subclass: #Organizer
997
1036
  !Organizer methodsFor: 'accessing'!
998
1037
 
999
1038
  addElement: anObject
1000
- <self.addElement(anObject)>
1039
+ <self.elements.addElement(anObject)>
1001
1040
  !
1002
1041
 
1003
1042
  elements
@@ -1005,7 +1044,7 @@ elements
1005
1044
  !
1006
1045
 
1007
1046
  removeElement: anObject
1008
- <self.removeElement(anObject)>
1047
+ <self.elements.removeElement(anObject)>
1009
1048
  ! !
1010
1049
 
1011
1050
  Object subclass: #Package
@@ -1071,17 +1110,6 @@ organization
1071
1110
 
1072
1111
  properties
1073
1112
  ^Smalltalk current readJSObject: (self basicAt: 'properties')
1074
- !
1075
-
1076
- properties: aDict
1077
- "We store it as a javascript object."
1078
-
1079
- | object |
1080
- <object = {};>.
1081
- aDict keysAndValuesDo: [:key :value |
1082
- <object[key] = value>.
1083
- ].
1084
- <return self.properties = object>
1085
1113
  ! !
1086
1114
 
1087
1115
  !Package methodsFor: 'classes'!
@@ -1090,6 +1118,12 @@ classes
1090
1118
  ^ self organization elements
1091
1119
  !
1092
1120
 
1121
+ setupClasses
1122
+ self classes
1123
+ do: [ :each | ClassBuilder new setupClass: each ];
1124
+ do: [ :each | each initialize ]
1125
+ !
1126
+
1093
1127
  sortedClasses
1094
1128
  "Answer all classes in the receiver, sorted by superclass/subclasses and by class name for common subclasses (Issue #143)."
1095
1129
 
@@ -1135,8 +1169,29 @@ propertyAt: key put: value
1135
1169
 
1136
1170
  Package class instanceVariableNames: 'defaultCommitPathJs defaultCommitPathSt'!
1137
1171
 
1172
+ !Package class methodsFor: 'accessing'!
1173
+
1174
+ named: aPackageName
1175
+
1176
+ ^Smalltalk current packageAt: aPackageName
1177
+ !
1178
+
1179
+ named: aPackageName ifAbsent: aBlock
1180
+
1181
+ ^Smalltalk current packageAt: aPackageName ifAbsent: aBlock
1182
+ ! !
1183
+
1138
1184
  !Package class methodsFor: 'commit paths'!
1139
1185
 
1186
+ commitPathsFromLoader
1187
+ <
1188
+ var cp = smalltalk['@@commitPath'];
1189
+ if (!!cp) return;
1190
+ if (cp.js) self._defaultCommitPathJs_(cp.js);
1191
+ if (cp.st) self._defaultCommitPathSt_(cp.st);
1192
+ >
1193
+ !
1194
+
1140
1195
  defaultCommitPathJs
1141
1196
  ^ defaultCommitPathJs ifNil: [ defaultCommitPathJs := 'js']
1142
1197
  !
@@ -1158,39 +1213,24 @@ resetCommitPaths
1158
1213
  defaultCommitPathSt := nil.
1159
1214
  ! !
1160
1215
 
1161
- !Package class methodsFor: 'loading-storing'!
1216
+ !Package class methodsFor: 'initialization'!
1162
1217
 
1163
- commitToLocalStorage: aPackageName
1164
- | key sourceCode |
1165
- key := 'smalltalk.packages.' , aPackageName.
1166
- sourceCode := Exporter new exportPackage: aPackageName.
1167
- <localStorage[key] = escape(sourceCode)>
1168
- !
1218
+ initialize
1219
+ super initialize.
1220
+ self commitPathsFromLoader
1221
+ ! !
1222
+
1223
+ !Package class methodsFor: 'loading-storing'!
1169
1224
 
1170
1225
  fetch: aPackageName
1171
1226
  self fetch: aPackageName prefix: self defaultCommitPathJs, '/'
1172
1227
  !
1173
1228
 
1174
1229
  fetch: aPackageName prefix: aPrefix
1175
- jQuery getScript: (aPrefix , aPackageName , '.js') onSuccess: [ Package init: aPackageName ]
1176
- !
1177
-
1178
- init: aPackageName
1179
- (smalltalk classes select: [ :each | <each.pkg.pkgName == aPackageName> ])
1180
- do: [ :each | <smalltalk.init(each)> ];
1181
- do: [ :each | each initialize ]
1182
- ! !
1183
-
1184
- !Package class methodsFor: 'not yet classified'!
1185
-
1186
- named: aPackageName
1187
-
1188
- ^Smalltalk current packageAt: aPackageName
1189
- !
1190
-
1191
- named: aPackageName ifAbsent: aBlock
1192
-
1193
- ^Smalltalk current packageAt: aPackageName ifAbsent: aBlock
1230
+ jQuery
1231
+ getScript: (aPrefix , aPackageName , '.js')
1232
+ onSuccess: [
1233
+ (Package named: aPackageName) setupClasses ]
1194
1234
  ! !
1195
1235
 
1196
1236
  !Package class methodsFor: 'sorting'!
@@ -1390,31 +1430,12 @@ at: aSymbol
1390
1430
  <return self[aSymbol._asString()]>
1391
1431
  !
1392
1432
 
1393
- basicParse: aString
1394
- <return smalltalk.parser.parse(aString)>
1395
- !
1396
-
1397
1433
  parse: aString
1398
1434
  | result |
1399
1435
  self try: [result := self basicParse: aString] catch: [:ex | (self parseError: ex parsing: aString) signal].
1400
1436
  ^result
1401
1437
  !
1402
1438
 
1403
- parseError: anException parsing: aString
1404
- | row col message lines badLine code |
1405
- <row = anException.line;
1406
- col = anException.column;
1407
- message = anException.message;>.
1408
- lines := aString lines.
1409
- badLine := lines at: row.
1410
- badLine := (badLine copyFrom: 1 to: col - 1), ' ===>', (badLine copyFrom: col to: badLine size).
1411
- lines at: row put: badLine.
1412
- code := String streamContents: [:s |
1413
- lines withIndexDo: [:l :i |
1414
- s nextPutAll: i asString, ': ', l, String lf]].
1415
- ^ ParseError new messageText: ('Parse error on line ' , row , ' column ' , col , ' : ' , message , ' Below is code with line numbers and ===> marker inserted:' , String lf, code)
1416
- !
1417
-
1418
1439
  readJSObject: anObject
1419
1440
  <return self.readJSObject(anObject)>
1420
1441
  !
@@ -1422,12 +1443,6 @@ readJSObject: anObject
1422
1443
  reservedWords
1423
1444
  "JavaScript reserved words"
1424
1445
  <return self.reservedWords>
1425
- !
1426
-
1427
- send: aSelector to: anObject arguments: aCollection
1428
- | selector |
1429
- selector := aSelector asString asSelector.
1430
- <return self.send(anObject, selector, aCollection)>
1431
1446
  ! !
1432
1447
 
1433
1448
  !Smalltalk methodsFor: 'classes'!
@@ -1436,6 +1451,12 @@ classes
1436
1451
  <return self.classes()>
1437
1452
  !
1438
1453
 
1454
+ deleteClass: aClass
1455
+ "Deletes a class by deleting its binding only. Use #removeClass instead"
1456
+
1457
+ <self.removeClass(aClass)>
1458
+ !
1459
+
1439
1460
  removeClass: aClass
1440
1461
  aClass isMetaclass ifTrue: [self error: aClass asString, ' is a Metaclass and cannot be removed!!'].
1441
1462
 
@@ -1453,8 +1474,35 @@ removeClass: aClass
1453
1474
  yourself)
1454
1475
  ! !
1455
1476
 
1477
+ !Smalltalk methodsFor: 'error handling'!
1478
+
1479
+ asSmalltalkException: anObject
1480
+ "A JavaScript exception may be thrown.
1481
+ We then need to convert it back to a Smalltalk object"
1482
+
1483
+ ^ ((self isSmalltalkObject: anObject) and: [ anObject isKindOf: Error ])
1484
+ ifTrue: [ anObject ]
1485
+ ifFalse: [ JavaScriptException on: anObject ]
1486
+ !
1487
+
1488
+ parseError: anException parsing: aString
1489
+ ^ ParseError new messageText: 'Parse error on line ', (anException basicAt: 'line') ,' column ' , (anException basicAt: 'column') ,' : Unexpected character ', (anException basicAt: 'found')
1490
+ ! !
1491
+
1456
1492
  !Smalltalk methodsFor: 'packages'!
1457
1493
 
1494
+ createPackage: packageName
1495
+ "Create and bind a new package with given name and return it."
1496
+ <return smalltalk.addPackage(packageName)>
1497
+ !
1498
+
1499
+ deletePackage: packageName
1500
+ "Deletes a package by deleting its binding, but does not check if it contains classes etc.
1501
+ To remove a package, use #removePackage instead."
1502
+
1503
+ <delete smalltalk.packages[packageName]>
1504
+ !
1505
+
1458
1506
  packageAt: packageName
1459
1507
  <return self.packages[packageName]>
1460
1508
  !
@@ -1489,41 +1537,32 @@ renamePackage: packageName to: newName
1489
1537
  | pkg |
1490
1538
  pkg := self packageAt: packageName ifAbsent: [self error: 'Missing package: ', packageName].
1491
1539
  (self packageAt: newName) ifNotNil: [self error: 'Already exists a package called: ', newName].
1492
- <smalltalk.packages[newName] = smalltalk.packages[packageName]>.
1540
+ (self basicAt: 'packages') at: newName put: pkg.
1493
1541
  pkg name: newName.
1494
1542
  self deletePackage: packageName.
1495
1543
  ! !
1496
1544
 
1497
1545
  !Smalltalk methodsFor: 'private'!
1498
1546
 
1499
- createPackage: packageName
1500
- "Create and bind a new package with given name and return it."
1501
-
1502
- <return smalltalk.addPackage(packageName, nil)>
1547
+ basicParse: aString
1548
+ <return smalltalk.parser.parse(aString)>
1503
1549
  !
1504
1550
 
1505
1551
  createPackage: packageName properties: aDict
1506
- "Create and bind a new package with given name and return it."
1507
-
1508
- | object |
1509
- <object = {};>.
1510
- aDict keysAndValuesDo: [:key :value |
1511
- <object[key] = value>.
1512
- ].
1513
- <return smalltalk.addPackage(packageName, object)>
1514
- !
1515
-
1516
- deleteClass: aClass
1517
- "Deletes a class by deleting its binding only. Use #removeClass instead"
1552
+ "Needed to import .st files: they begin with this call."
1553
+ self deprecatedAPI.
1518
1554
 
1519
- <self.removeClass(aClass)>
1520
- !
1555
+ aDict isEmpty ifFalse: [ self error: 'createPackage:properties: called with nonempty properties' ].
1556
+ ^ self createPackage: packageName
1557
+ ! !
1521
1558
 
1522
- deletePackage: packageName
1523
- "Deletes a package by deleting its binding, but does not check if it contains classes etc.
1524
- To remove a package, use #removePackage instead."
1559
+ !Smalltalk methodsFor: 'testing'!
1525
1560
 
1526
- <delete smalltalk.packages[packageName]>
1561
+ isSmalltalkObject: anObject
1562
+ "Consider anObject a Smalltalk object if it has a 'klass' property.
1563
+ Note that this may be unaccurate"
1564
+
1565
+ <return typeof anObject.klass !!== 'undefined'>
1527
1566
  ! !
1528
1567
 
1529
1568
  Smalltalk class instanceVariableNames: 'current'!
@@ -1534,6 +1573,42 @@ current
1534
1573
  <return smalltalk>
1535
1574
  ! !
1536
1575
 
1576
+ Object subclass: #Timeout
1577
+ instanceVariableNames: 'rawTimeout'
1578
+ package: 'Kernel-Objects'!
1579
+ !Timeout commentStamp!
1580
+ I am wrapping the returns from set{Timeout,Interval}.
1581
+
1582
+ Number suffices in browsers, but node.js returns an object.!
1583
+
1584
+ !Timeout methodsFor: 'accessing'!
1585
+
1586
+ rawTimeout: anObject
1587
+ rawTimeout := anObject
1588
+ ! !
1589
+
1590
+ !Timeout methodsFor: 'timeout/interval'!
1591
+
1592
+ clearInterval
1593
+ <
1594
+ var interval = self["@rawTimeout"];
1595
+ clearInterval(interval);
1596
+ >
1597
+ !
1598
+
1599
+ clearTimeout
1600
+ <
1601
+ var timeout = self["@rawTimeout"];
1602
+ clearTimeout(timeout);
1603
+ >
1604
+ ! !
1605
+
1606
+ !Timeout class methodsFor: 'instance creation'!
1607
+
1608
+ on: anObject
1609
+ ^self new rawTimeout: anObject; yourself
1610
+ ! !
1611
+
1537
1612
  Object subclass: #UndefinedObject
1538
1613
  instanceVariableNames: ''
1539
1614
  package: 'Kernel-Objects'!
@@ -1556,7 +1631,7 @@ subclass: aString instanceVariableNames: aString2 category: aString3
1556
1631
 
1557
1632
  subclass: aString instanceVariableNames: aString2 package: aString3
1558
1633
  ^ClassBuilder new
1559
- superclass: self subclass: aString instanceVariableNames: aString2 package: aString3
1634
+ superclass: self subclass: aString asString instanceVariableNames: aString2 package: aString3
1560
1635
  ! !
1561
1636
 
1562
1637
  !UndefinedObject methodsFor: 'converting'!