resin 0.2.1 → 0.2.2
Sign up to get free protection for your applications and to get access to all the features.
- data/README.markdown +2 -0
- data/amber/bin/nodecompile.js +3 -3
- data/amber/css/amber.css +47 -23
- data/amber/images/off.amber.png +0 -0
- data/amber/images/offHover.amber.png +0 -0
- data/amber/images/sprite.amber.png +0 -0
- data/amber/images/tinylogo.amber.png +0 -0
- data/amber/js/Benchfib.deploy.js +34 -34
- data/amber/js/Benchfib.js +49 -49
- data/amber/js/Canvas.deploy.js +937 -937
- data/amber/js/Canvas.js +1622 -1622
- data/amber/js/Compiler-Tests.deploy.js +97 -0
- data/amber/js/Compiler-Tests.js +137 -0
- data/amber/js/Compiler.deploy.js +1030 -924
- data/amber/js/Compiler.js +1613 -1467
- data/amber/js/Documentation.deploy.js +417 -417
- data/amber/js/Documentation.js +728 -728
- data/amber/js/Examples.deploy.js +24 -13
- data/amber/js/Examples.js +36 -19
- data/amber/js/IDE.deploy.js +1583 -1527
- data/amber/js/IDE.js +2586 -2510
- data/amber/js/Kernel-Announcements.deploy.js +19 -19
- data/amber/js/Kernel-Announcements.js +28 -28
- data/amber/js/Kernel-Classes.deploy.js +332 -229
- data/amber/js/Kernel-Classes.js +532 -384
- data/amber/js/Kernel-Collections.deploy.js +1516 -1712
- data/amber/js/Kernel-Collections.js +2436 -2712
- data/amber/js/Kernel-Exceptions.deploy.js +85 -62
- data/amber/js/Kernel-Exceptions.js +131 -98
- data/amber/js/Kernel-Methods.deploy.js +326 -378
- data/amber/js/Kernel-Methods.js +473 -525
- data/amber/js/Kernel-Objects.deploy.js +1777 -2428
- data/amber/js/Kernel-Objects.js +2599 -3426
- data/amber/js/Kernel-Tests.deploy.js +871 -772
- data/amber/js/Kernel-Tests.js +1207 -1083
- data/amber/js/Kernel-Transcript.deploy.js +57 -57
- data/amber/js/Kernel-Transcript.js +94 -94
- data/amber/js/SUnit.deploy.js +116 -116
- data/amber/js/SUnit.js +211 -211
- data/amber/js/amber.js +10 -11
- data/amber/js/boot.js +132 -156
- data/amber/js/init.js +2 -2
- data/amber/js/parser.js +2095 -3014
- data/amber/js/parser.pegjs +1 -1
- data/amber/st/Benchfib.st +22 -22
- data/amber/st/Canvas.st +471 -471
- data/amber/st/Compiler-Tests.st +471 -0
- data/amber/st/Compiler.st +858 -794
- data/amber/st/Examples.st +22 -5
- data/amber/st/IDE.st +1326 -1291
- data/amber/st/Kernel-Announcements.st +2 -2
- data/amber/st/Kernel-Classes.st +148 -90
- data/amber/st/Kernel-Collections.st +950 -1061
- data/amber/st/Kernel-Exceptions.st +33 -25
- data/amber/st/Kernel-Methods.st +151 -151
- data/amber/st/Kernel-Objects.st +891 -1036
- data/amber/st/Kernel-Tests.st +622 -544
- data/amber/st/Kernel-Transcript.st +38 -38
- data/amber/st/SUnit.st +53 -53
- metadata +27 -20
data/amber/js/amber.js
CHANGED
@@ -95,7 +95,7 @@ amber = (function() {
|
|
95
95
|
|
96
96
|
var additionalFiles = spec.packages || spec.files;
|
97
97
|
if (additionalFiles) {
|
98
|
-
loadPackages(additionalFiles, spec.prefix);
|
98
|
+
loadPackages(additionalFiles, spec.prefix, spec.packageHome);
|
99
99
|
}
|
100
100
|
|
101
101
|
// Be sure to setup & initialize smalltalk classes
|
@@ -103,29 +103,32 @@ amber = (function() {
|
|
103
103
|
initializeSmalltalk();
|
104
104
|
};
|
105
105
|
|
106
|
-
function loadPackages(names, prefix){
|
106
|
+
function loadPackages(names, prefix, urlHome){
|
107
107
|
var name, url;
|
108
108
|
var prefix = prefix || 'js';
|
109
|
+
var urlHome = urlHome || home;
|
109
110
|
|
110
111
|
for (var i=0; i < names.length; i++) {
|
111
112
|
name = names[i].split(/\.js$/)[0];
|
112
|
-
addJSToLoad(name + '.js', prefix);
|
113
|
+
addJSToLoad(name + '.js', prefix, urlHome);
|
113
114
|
}
|
114
115
|
};
|
115
116
|
|
116
|
-
function addJSToLoad(name, prefix) {
|
117
|
-
|
117
|
+
function addJSToLoad(name, prefix, urlHome) {
|
118
|
+
var urlHome = urlHome || home;
|
119
|
+
jsToLoad.push(buildJSURL(name, prefix, urlHome));
|
118
120
|
};
|
119
121
|
|
120
|
-
function buildJSURL(name, prefix) {
|
122
|
+
function buildJSURL(name, prefix, urlHome) {
|
121
123
|
var prefix = prefix || 'js';
|
122
124
|
var name = name;
|
125
|
+
var urlHome = urlHome || home;
|
123
126
|
|
124
127
|
if (!deploy) {
|
125
128
|
name = name + nocache;
|
126
129
|
}
|
127
130
|
|
128
|
-
return
|
131
|
+
return urlHome + prefix + '/' + name;
|
129
132
|
};
|
130
133
|
|
131
134
|
function loadCSS(name, prefix) {
|
@@ -165,10 +168,6 @@ amber = (function() {
|
|
165
168
|
// This will be called after JS files have been loaded
|
166
169
|
function initializeSmalltalk() {
|
167
170
|
window.smalltalkReady = function() {
|
168
|
-
if (deploy) {
|
169
|
-
smalltalk.setDeploymentMode();
|
170
|
-
}
|
171
|
-
|
172
171
|
if (spec.ready) {
|
173
172
|
spec.ready();
|
174
173
|
}
|
data/amber/js/boot.js
CHANGED
@@ -45,22 +45,21 @@ if (typeof console === "undefined") {
|
|
45
45
|
};
|
46
46
|
}
|
47
47
|
|
48
|
-
|
49
48
|
/* Smalltalk constructors definition */
|
50
49
|
|
51
50
|
function SmalltalkObject(){}
|
52
|
-
function SmalltalkBehavior(){}
|
51
|
+
function SmalltalkBehavior(){}
|
53
52
|
function SmalltalkClass(){}
|
54
|
-
function SmalltalkPackage(){}
|
53
|
+
function SmalltalkPackage(){}
|
55
54
|
function SmalltalkMetaclass(){
|
56
55
|
this.meta = true;
|
57
|
-
}
|
58
|
-
function SmalltalkMethod(){}
|
59
|
-
function SmalltalkNil(){}
|
56
|
+
}
|
57
|
+
function SmalltalkMethod(){}
|
58
|
+
function SmalltalkNil(){}
|
60
59
|
|
61
60
|
function SmalltalkSymbol(string){
|
62
61
|
this.value = string;
|
63
|
-
}
|
62
|
+
}
|
64
63
|
|
65
64
|
function Smalltalk(){
|
66
65
|
|
@@ -107,8 +106,8 @@ function Smalltalk(){
|
|
107
106
|
/* Smalltalk package creation. To add a Package, use smalltalk.addPackage() */
|
108
107
|
|
109
108
|
function pkg(spec) {
|
110
|
-
var that
|
111
|
-
that.pkgName
|
109
|
+
var that = new SmalltalkPackage();
|
110
|
+
that.pkgName = spec.pkgName;
|
112
111
|
that.properties = spec.properties || {};
|
113
112
|
return that;
|
114
113
|
};
|
@@ -120,28 +119,36 @@ function Smalltalk(){
|
|
120
119
|
|
121
120
|
function klass(spec) {
|
122
121
|
var spec = spec || {};
|
123
|
-
var
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
that.
|
129
|
-
|
130
|
-
that.klass.className = that.className + ' class';
|
122
|
+
var meta = metaclass();
|
123
|
+
var that = setupClass(meta.instanceClass, spec);
|
124
|
+
that.className = spec.className;
|
125
|
+
meta.className = spec.className + ' class';
|
126
|
+
if(spec.superclass) {
|
127
|
+
that.superclass = spec.superclass;
|
128
|
+
meta.superclass = spec.superclass.klass;
|
131
129
|
}
|
132
|
-
|
130
|
+
return that;
|
131
|
+
}
|
132
|
+
|
133
|
+
function metaclass() {
|
134
|
+
var meta = setupClass(new SmalltalkMetaclass(), {});
|
135
|
+
meta.instanceClass = new meta.fn;
|
136
|
+
return meta;
|
137
|
+
}
|
138
|
+
|
139
|
+
function setupClass(that, spec) {
|
133
140
|
that.fn = spec.fn || function(){};
|
134
|
-
that.superclass = spec.superclass;
|
135
141
|
that.iVarNames = spec.iVarNames || [];
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
}
|
142
|
+
Object.defineProperty(that, "toString", {
|
143
|
+
value: function() { return 'Smalltalk ' + this.className; },
|
144
|
+
configurable: true // no writable - in par with ES6 methods
|
145
|
+
});
|
140
146
|
that.pkg = spec.pkg;
|
141
|
-
that.fn.prototype
|
142
|
-
|
143
|
-
|
144
|
-
|
147
|
+
Object.defineProperties(that.fn.prototype, {
|
148
|
+
methods: { value: {}, enumerable: false, configurable: true, writable: true },
|
149
|
+
inheritedMethods: { value: {}, enumerable: false, configurable: true, writable: true },
|
150
|
+
klass: { value: that, enumerable: false, configurable: true, writable: true }
|
151
|
+
});
|
145
152
|
return that;
|
146
153
|
};
|
147
154
|
|
@@ -158,36 +165,44 @@ function Smalltalk(){
|
|
158
165
|
that.messageSends = spec.messageSends || [];
|
159
166
|
that.referencedClasses = spec.referencedClasses || [];
|
160
167
|
that.fn = spec.fn;
|
161
|
-
return that
|
168
|
+
return that;
|
162
169
|
};
|
163
170
|
|
164
171
|
/* Initialize a class in its class hierarchy. Handle both class and
|
165
172
|
metaclasses. */
|
166
|
-
|
173
|
+
|
167
174
|
st.init = function(klass) {
|
175
|
+
st.initSubTree(klass);
|
176
|
+
if(klass.klass && !klass.meta) {
|
177
|
+
st.initSubTree(klass.klass);
|
178
|
+
}
|
179
|
+
};
|
180
|
+
|
181
|
+
st.initSubTree = function(klass) {
|
168
182
|
var subclasses = st.subclasses(klass);
|
169
|
-
var methods;
|
183
|
+
var methods, proto = klass.fn.prototype;
|
170
184
|
|
171
185
|
if(klass.superclass && klass.superclass !== nil) {
|
172
186
|
methods = st.methods(klass.superclass);
|
173
187
|
|
174
188
|
//Methods linking
|
175
|
-
for(var i
|
176
|
-
|
177
|
-
|
178
|
-
|
189
|
+
for(var keys=Object.keys(methods),i=0,l=keys.length; i<l; ++i) {
|
190
|
+
var k = keys[i]
|
191
|
+
if(!proto.methods[k]) {
|
192
|
+
proto.inheritedMethods[k] = methods[k];
|
193
|
+
Object.defineProperty(proto, methods[k].jsSelector, {
|
194
|
+
value: methods[k].fn, configurable: true // no writable - in par with ES6 methods
|
195
|
+
});
|
179
196
|
}
|
180
197
|
}
|
181
198
|
}
|
182
199
|
|
183
200
|
for(var i=0;i<subclasses.length;i++) {
|
184
|
-
st.
|
185
|
-
}
|
186
|
-
if(klass.klass && !klass.meta) {
|
187
|
-
st.init(klass.klass);
|
201
|
+
st.initSubTree(subclasses[i]);
|
188
202
|
}
|
189
203
|
};
|
190
204
|
|
205
|
+
|
191
206
|
/* Answer all registered Packages as Array */
|
192
207
|
|
193
208
|
st.packages.all = function() {
|
@@ -202,42 +217,49 @@ function Smalltalk(){
|
|
202
217
|
/* Answer all registered Smalltalk classes */
|
203
218
|
|
204
219
|
st.classes = function() {
|
205
|
-
var classes = [];
|
206
|
-
for(var i
|
207
|
-
|
208
|
-
|
220
|
+
var classes = [], names = Object.keys(st), l = names.length;
|
221
|
+
for (var i=0; i<l; ++i) {
|
222
|
+
var name = names[i];
|
223
|
+
if (name.search(/^[A-Z]/) !== -1) {
|
224
|
+
classes.push(st[name]);
|
209
225
|
}
|
210
226
|
}
|
211
|
-
return classes
|
227
|
+
return classes;
|
212
228
|
};
|
213
229
|
|
230
|
+
|
214
231
|
/* Answer all methods (included inherited ones) of klass. */
|
215
232
|
|
216
233
|
st.methods = function(klass) {
|
217
234
|
var methods = {};
|
218
|
-
|
219
|
-
|
235
|
+
var copyFrom = klass.fn.prototype.methods;
|
236
|
+
for(var i=0, k=Object.keys(copyFrom), l=k.length; i<l; ++i) {
|
237
|
+
methods[k[i]] = copyFrom[k[i]];
|
220
238
|
}
|
221
|
-
|
222
|
-
|
239
|
+
copyFrom = klass.fn.prototype.inheritedMethods;
|
240
|
+
for(var i=0, k=Object.keys(copyFrom), l=k.length; i<l; ++i) {
|
241
|
+
methods[k[i]] = copyFrom[k[i]];
|
223
242
|
}
|
224
243
|
return methods;
|
225
|
-
}
|
244
|
+
};
|
245
|
+
|
226
246
|
|
227
247
|
/* Answer the direct subclasses of klass. */
|
228
248
|
|
229
249
|
st.subclasses = function(klass) {
|
230
250
|
var subclasses = [];
|
231
251
|
var classes = st.classes();
|
232
|
-
for(var i
|
233
|
-
|
234
|
-
|
235
|
-
if(classes[i].klass && classes[i].klass.superclass === klass) {
|
236
|
-
subclasses.push(classes[i].klass);
|
237
|
-
}
|
252
|
+
for(var i=0, l=classes.length; i<l; ++i) {
|
253
|
+
var c = classes[i]
|
254
|
+
if(c.fn) {
|
238
255
|
//Classes
|
239
|
-
if(
|
240
|
-
subclasses.push(
|
256
|
+
if(c.superclass === klass) {
|
257
|
+
subclasses.push(c);
|
258
|
+
}
|
259
|
+
c = c.klass;
|
260
|
+
//Metaclasses
|
261
|
+
if(c && c.superclass === klass) {
|
262
|
+
subclasses.push(c);
|
241
263
|
}
|
242
264
|
}
|
243
265
|
}
|
@@ -257,10 +279,10 @@ function Smalltalk(){
|
|
257
279
|
});
|
258
280
|
};
|
259
281
|
|
260
|
-
|
261
|
-
|
262
|
-
|
263
|
-
|
282
|
+
/* Create an alias for an existing class */
|
283
|
+
st.alias = function(klass, alias) {
|
284
|
+
st[alias] = klass;
|
285
|
+
}
|
264
286
|
|
265
287
|
/* Add a package to the smalltalk.packages object, creating a new one if needed.
|
266
288
|
If pkgName is null or empty we return nil, which is an allowed package for a class.
|
@@ -290,7 +312,7 @@ function Smalltalk(){
|
|
290
312
|
st[className].superclass = superclass;
|
291
313
|
st[className].iVarNames = iVarNames;
|
292
314
|
st[className].pkg = pkg || st[className].pkg;
|
293
|
-
} else {
|
315
|
+
} else {
|
294
316
|
st[className] = klass({
|
295
317
|
className: className,
|
296
318
|
superclass: superclass,
|
@@ -303,31 +325,17 @@ function Smalltalk(){
|
|
303
325
|
/* Add a method to a class */
|
304
326
|
|
305
327
|
st.addMethod = function(jsSelector, method, klass) {
|
306
|
-
klass.fn.prototype
|
328
|
+
Object.defineProperty(klass.fn.prototype, jsSelector, {
|
329
|
+
value: method.fn, configurable: true // not writable - in par with ES6 methods
|
330
|
+
});
|
307
331
|
klass.fn.prototype.methods[method.selector] = method;
|
308
332
|
method.methodClass = klass;
|
309
333
|
method.jsSelector = jsSelector;
|
310
334
|
};
|
311
335
|
|
312
|
-
/* Handles Smalltalk message send. Automatically converts undefined to the nil object.
|
313
|
-
If the receiver does not understand the selector, call its #doesNotUnderstand: method */
|
314
|
-
|
315
|
-
sendWithoutContext = function(receiver, selector, args, klass) {
|
316
|
-
if(receiver === undefined || receiver === null) {
|
317
|
-
receiver = nil;
|
318
|
-
}
|
319
|
-
if(!klass && receiver.klass && receiver[selector]) {
|
320
|
-
return receiver[selector].apply(receiver, args);
|
321
|
-
} else if(klass && klass.fn.prototype[selector]) {
|
322
|
-
return klass.fn.prototype[selector].apply(receiver, args)
|
323
|
-
}
|
324
|
-
return messageNotUnderstood(receiver, selector, args);
|
325
|
-
};
|
326
|
-
|
327
|
-
|
328
336
|
/* Handles unhandled errors during message sends */
|
329
337
|
|
330
|
-
|
338
|
+
st.send = function(receiver, selector, args, klass) {
|
331
339
|
if(st.thisContext) {
|
332
340
|
return withContextSend(receiver, selector, args, klass);
|
333
341
|
} else {
|
@@ -344,25 +352,20 @@ function Smalltalk(){
|
|
344
352
|
}
|
345
353
|
};
|
346
354
|
|
347
|
-
|
348
|
-
|
349
|
-
|
350
|
-
var call, context;
|
351
|
-
if(receiver === undefined || receiver === null) {
|
355
|
+
function withContextSend(receiver, selector, args, klass) {
|
356
|
+
var call, imp;
|
357
|
+
if(receiver == null) {
|
352
358
|
receiver = nil;
|
353
359
|
}
|
354
|
-
|
355
|
-
|
356
|
-
|
357
|
-
|
358
|
-
return call;
|
359
|
-
} else if(klass && klass.fn.prototype[selector]) {
|
360
|
-
context = pushContext(receiver, selector, args);
|
361
|
-
call = klass.fn.prototype[selector].apply(receiver, args);
|
360
|
+
imp = klass ? klass.fn.prototype[selector] : receiver.klass && receiver[selector];
|
361
|
+
if(imp) {
|
362
|
+
var context = pushContext(receiver, selector, args);
|
363
|
+
call = imp.apply(receiver, args);
|
362
364
|
popContext(context);
|
363
365
|
return call;
|
366
|
+
} else {
|
367
|
+
return messageNotUnderstood(receiver, selector, args);
|
364
368
|
}
|
365
|
-
return messageNotUnderstood(receiver, selector, args);
|
366
369
|
};
|
367
370
|
|
368
371
|
/* Handles Smalltalk errors. Triggers the registered ErrorHandler
|
@@ -371,7 +374,7 @@ function Smalltalk(){
|
|
371
374
|
function handleError(error) {
|
372
375
|
st.thisContext = undefined;
|
373
376
|
smalltalk.ErrorHandler._current()._handleError_(error);
|
374
|
-
}
|
377
|
+
};
|
375
378
|
|
376
379
|
/* Handles #dnu: *and* JavaScript method calls.
|
377
380
|
if the receiver has no klass, we consider it a JS object (outside of the
|
@@ -424,9 +427,9 @@ function Smalltalk(){
|
|
424
427
|
};
|
425
428
|
|
426
429
|
|
427
|
-
/* Reuse old
|
430
|
+
/* Reuse one old context stored in oldContext */
|
428
431
|
|
429
|
-
st.
|
432
|
+
st.oldContext = null;
|
430
433
|
|
431
434
|
|
432
435
|
/* Handle thisContext pseudo variable */
|
@@ -434,23 +437,28 @@ function Smalltalk(){
|
|
434
437
|
st.getThisContext = function() {
|
435
438
|
if(st.thisContext) {
|
436
439
|
return st.thisContext.copy();
|
437
|
-
} else {
|
440
|
+
}/* else { // this is the default
|
438
441
|
return undefined;
|
439
|
-
}
|
440
|
-
}
|
442
|
+
}*/
|
443
|
+
};
|
441
444
|
|
442
|
-
pushContext
|
443
|
-
|
444
|
-
|
445
|
-
|
446
|
-
return st.thisContext = new SmalltalkMethodContext(receiver, selector, temps);
|
445
|
+
function pushContext(receiver, selector, temps) {
|
446
|
+
var c = st.oldContext, tc = st.thisContext;
|
447
|
+
if (!c) {
|
448
|
+
return st.thisContext = new SmalltalkMethodContext(receiver, selector, temps, tc);
|
447
449
|
}
|
450
|
+
st.oldContext = null;
|
451
|
+
c.homeContext = tc;
|
452
|
+
c.receiver = receiver;
|
453
|
+
c.selector = selector;
|
454
|
+
c.temps = temps || {};
|
455
|
+
return st.thisContext = c;
|
448
456
|
};
|
449
457
|
|
450
|
-
popContext
|
451
|
-
|
452
|
-
|
453
|
-
|
458
|
+
function popContext(context) {
|
459
|
+
st.thisContext = context.homeContext;
|
460
|
+
context.homeContext = undefined;
|
461
|
+
st.oldContext = context;
|
454
462
|
};
|
455
463
|
|
456
464
|
/* Convert a string to a valid smalltalk selector.
|
@@ -502,57 +510,25 @@ function Smalltalk(){
|
|
502
510
|
}
|
503
511
|
return object;
|
504
512
|
};
|
505
|
-
|
506
|
-
/* Toggle deployment mode (no context will be handled during message send */
|
507
|
-
st.setDeploymentMode = function() {
|
508
|
-
st.send = sendWithoutContext;
|
509
|
-
};
|
510
|
-
|
511
|
-
st.setDevelopmentMode = function() {
|
512
|
-
st.send = sendWithContext;
|
513
|
-
}
|
514
|
-
|
515
|
-
/* Set development mode by default */
|
516
|
-
st.setDevelopmentMode();
|
517
|
-
}
|
513
|
+
};
|
518
514
|
|
519
515
|
function SmalltalkMethodContext(receiver, selector, temps, home) {
|
520
|
-
|
521
|
-
|
522
|
-
|
523
|
-
|
524
|
-
|
525
|
-
|
526
|
-
that.copy = function() {
|
527
|
-
var home = that.homeContext;
|
528
|
-
if(home) {home = home.copy()}
|
529
|
-
return new SmalltalkMethodContext(
|
530
|
-
that.receiver,
|
531
|
-
that.selector,
|
532
|
-
that.temps,
|
533
|
-
home
|
534
|
-
);
|
535
|
-
}
|
536
|
-
|
537
|
-
that.newContext = function(receiver, selector, temps) {
|
538
|
-
var c = smalltalk.oldContexts.pop();
|
539
|
-
if(c) {
|
540
|
-
c.homeContext = that;
|
541
|
-
c.receiver = receiver;
|
542
|
-
c.selector = selector;
|
543
|
-
c.temps = temps || {};
|
544
|
-
} else {
|
545
|
-
c = new SmalltalkMethodContext(receiver, selector, temps, that);
|
546
|
-
}
|
547
|
-
return c;
|
548
|
-
}
|
516
|
+
this.receiver = receiver;
|
517
|
+
this.selector = selector;
|
518
|
+
this.temps = temps || {};
|
519
|
+
this.homeContext = home;
|
520
|
+
};
|
549
521
|
|
550
|
-
|
551
|
-
|
552
|
-
|
553
|
-
|
554
|
-
|
555
|
-
|
522
|
+
SmalltalkMethodContext.prototype.copy = function() {
|
523
|
+
var home = this.homeContext;
|
524
|
+
if(home) {home = home.copy()}
|
525
|
+
return new SmalltalkMethodContext(
|
526
|
+
this.receiver,
|
527
|
+
this.selector,
|
528
|
+
this.temps,
|
529
|
+
home
|
530
|
+
);
|
531
|
+
};
|
556
532
|
|
557
533
|
/* Global Smalltalk objects. */
|
558
534
|
|