amber-rails 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +2 -0
- data/.rvmrc +4 -0
- data/CHANGELOG.md +3 -0
- data/Gemfile +2 -0
- data/Gemfile.lock +96 -0
- data/LICENSE +7 -0
- data/README.md +13 -0
- data/Rakefile +15 -0
- data/amber-rails.gemspec +21 -0
- data/app/assets/.DS_Store +0 -0
- data/app/assets/javascripts/.DS_Store +0 -0
- data/app/assets/javascripts/codemirror/codemirror.js +2144 -0
- data/app/assets/javascripts/codemirror/overlay.js +51 -0
- data/app/assets/javascripts/codemirror/runmode.js +27 -0
- data/app/assets/javascripts/codemirror/smalltalk/index.html +56 -0
- data/app/assets/javascripts/codemirror/smalltalk/smalltalk.js +134 -0
- data/app/assets/javascripts/html5.js +35 -0
- data/app/assets/javascripts/jquery.js +8981 -0
- data/app/assets/javascripts/jquery.textarea.js +267 -0
- data/app/assets/javascripts/jquery.tmpl.js +503 -0
- data/app/assets/javascripts/jquery.ui.js +272 -0
- data/app/assets/javascripts/json2.js +481 -0
- data/app/assets/javascripts/jtalk-development.js.coffee +4 -0
- data/app/assets/javascripts/jtalk-todos.js.coffee +4 -0
- data/app/assets/javascripts/jtalk.js.coffee +16 -0
- data/app/assets/javascripts/jtalk_core/boot.js +466 -0
- data/app/assets/javascripts/jtalk_core/st/.DS_Store +0 -0
- data/app/assets/javascripts/jtalk_core/st/Benchfib.js +159 -0
- data/app/assets/javascripts/jtalk_core/st/Canvas.js +1479 -0
- data/app/assets/javascripts/jtalk_core/st/Compiler.js +1587 -0
- data/app/assets/javascripts/jtalk_core/st/Examples.js +863 -0
- data/app/assets/javascripts/jtalk_core/st/HTML5.js +54 -0
- data/app/assets/javascripts/jtalk_core/st/IDE.js +3457 -0
- data/app/assets/javascripts/jtalk_core/st/JQuery.js +898 -0
- data/app/assets/javascripts/jtalk_core/st/Kernel.js +6761 -0
- data/app/assets/javascripts/jtalk_core/st/Parser.js +1655 -0
- data/app/assets/javascripts/jtalk_core/st/SUnit.js +1059 -0
- data/app/assets/stylesheets/codemirror.css +67 -0
- data/app/assets/stylesheets/codemirror_jtalk.css +21 -0
- data/app/assets/stylesheets/jtalk.css +369 -0
- data/app/assets/stylesheets/sunit.css +65 -0
- data/config/routes.rb +10 -0
- data/examples/todos/.gitignore +5 -0
- data/examples/todos/.rvmrc +4 -0
- data/examples/todos/Gemfile +12 -0
- data/examples/todos/Gemfile.lock +126 -0
- data/examples/todos/README +261 -0
- data/examples/todos/Rakefile +15 -0
- data/examples/todos/app/assets/images/rails.png +0 -0
- data/examples/todos/app/assets/javascripts/application.js.coffee +5 -0
- data/examples/todos/app/assets/javascripts/jtalk/Examples.deploy.js +863 -0
- data/examples/todos/app/assets/javascripts/jtalk/Examples.js +863 -0
- data/examples/todos/app/assets/smalltalk/Examples.st +397 -0
- data/examples/todos/app/assets/stylesheets/application.css +8 -0
- data/examples/todos/app/assets/stylesheets/jtalk-todos.css +154 -0
- data/examples/todos/app/controllers/application_controller.rb +3 -0
- data/examples/todos/app/controllers/todos_controller.rb +5 -0
- data/examples/todos/app/helpers/application_helper.rb +2 -0
- data/examples/todos/app/models/.gitkeep +0 -0
- data/examples/todos/app/views/todos/index.html.haml +16 -0
- data/examples/todos/config.ru +4 -0
- data/examples/todos/config/application.rb +31 -0
- data/examples/todos/config/boot.rb +6 -0
- data/examples/todos/config/database.yml +25 -0
- data/examples/todos/config/environment.rb +5 -0
- data/examples/todos/config/environments/development.rb +27 -0
- data/examples/todos/config/environments/production.rb +60 -0
- data/examples/todos/config/environments/test.rb +42 -0
- data/examples/todos/config/initializers/backtrace_silencers.rb +7 -0
- data/examples/todos/config/initializers/inflections.rb +10 -0
- data/examples/todos/config/initializers/mime_types.rb +5 -0
- data/examples/todos/config/initializers/secret_token.rb +7 -0
- data/examples/todos/config/initializers/session_store.rb +8 -0
- data/examples/todos/config/initializers/wrap_parameters.rb +14 -0
- data/examples/todos/config/locales/en.yml +5 -0
- data/examples/todos/config/routes.rb +3 -0
- data/examples/todos/log/.gitkeep +0 -0
- data/examples/todos/public/404.html +26 -0
- data/examples/todos/public/422.html +26 -0
- data/examples/todos/public/500.html +26 -0
- data/examples/todos/public/favicon.ico +0 -0
- data/examples/todos/public/robots.txt +5 -0
- data/examples/todos/script/rails +6 -0
- data/examples/todos/vendor/assets/stylesheets/.gitkeep +0 -0
- data/examples/todos/vendor/plugins/.gitkeep +0 -0
- data/lib/amber-rails.rb +1 -0
- data/lib/amber/rails.rb +30 -0
- data/lib/amber/rails/engine.rb +12 -0
- data/lib/amber/rails/version.rb +5 -0
- metadata +167 -0
@@ -0,0 +1,16 @@
|
|
1
|
+
#= require jquery
|
2
|
+
#= require jquery.ui
|
3
|
+
#= require jquery.textarea
|
4
|
+
#= require jtalk_core/boot
|
5
|
+
#= require jtalk_core/st/Kernel
|
6
|
+
#= require jtalk_core/st/Canvas
|
7
|
+
#= require jtalk_core/st/JQuery
|
8
|
+
#= require jtalk_core/st/Parser
|
9
|
+
#= require jtalk_core/st/Compiler
|
10
|
+
#= require jtalk_core/st/Examples
|
11
|
+
#= require jtalk_core/st/Benchfib
|
12
|
+
|
13
|
+
$ ->
|
14
|
+
smalltalk.init smalltalk.Object
|
15
|
+
smalltalk.classes()._do_ (each) ->
|
16
|
+
each._initialize()
|
@@ -0,0 +1,466 @@
|
|
1
|
+
/* ====================================================================
|
2
|
+
|
|
3
|
+
| Jtalk Smalltalk
|
4
|
+
| http://jtalk-project.org
|
5
|
+
|
|
6
|
+
======================================================================
|
7
|
+
|
8
|
+
======================================================================
|
9
|
+
|
|
10
|
+
| Copyright (c) 2010-2011
|
11
|
+
| Nicolas Petton <petton.nicolas@gmail.com>
|
12
|
+
|
|
13
|
+
| Jtalk is released under the MIT license
|
14
|
+
|
|
15
|
+
| Permission is hereby granted, free of charge, to any person obtaining
|
16
|
+
| a copy of this software and associated documentation files (the
|
17
|
+
| 'Software'), to deal in the Software without restriction, including
|
18
|
+
| without limitation the rights to use, copy, modify, merge, publish,
|
19
|
+
| distribute, sublicense, and/or sell copies of the Software, and to
|
20
|
+
| permit persons to whom the Software is furnished to do so, subject to
|
21
|
+
| the following conditions:
|
22
|
+
|
|
23
|
+
| The above copyright notice and this permission notice shall be
|
24
|
+
| included in all copies or substantial portions of the Software.
|
25
|
+
|
|
26
|
+
| THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
|
27
|
+
| EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
28
|
+
| MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
29
|
+
| IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
30
|
+
| CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
31
|
+
| TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
32
|
+
| SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
33
|
+
|
|
34
|
+
==================================================================== */
|
35
|
+
|
36
|
+
/* Smalltalk constructors definition */
|
37
|
+
|
38
|
+
function SmalltalkObject(){};
|
39
|
+
function SmalltalkBehavior(){};
|
40
|
+
function SmalltalkClass(){};
|
41
|
+
function SmalltalkMetaclass(){
|
42
|
+
this.meta = true;
|
43
|
+
};
|
44
|
+
function SmalltalkMethod(){};
|
45
|
+
function SmalltalkNil(){};
|
46
|
+
|
47
|
+
function Smalltalk(){
|
48
|
+
|
49
|
+
var st = this;
|
50
|
+
|
51
|
+
/* Smalltalk class creation. A class is an instance of an automatically
|
52
|
+
created metaclass object. Newly created classes (not their metaclass)
|
53
|
+
should be added to the smalltalk object, see smalltalk.addClass().
|
54
|
+
Superclass linking is *not* handled here, see smalltalk.init() */
|
55
|
+
|
56
|
+
function klass(spec) {
|
57
|
+
var spec = spec || {};
|
58
|
+
var that;
|
59
|
+
if(spec.meta) {
|
60
|
+
that = new SmalltalkMetaclass();
|
61
|
+
} else {
|
62
|
+
that = new (klass({meta: true})).fn;
|
63
|
+
that.klass.instanceClass = that;
|
64
|
+
that.className = spec.className;
|
65
|
+
that.klass.className = that.className + ' class';
|
66
|
+
}
|
67
|
+
|
68
|
+
that.fn = spec.fn || function(){};
|
69
|
+
that.superclass = spec.superclass;
|
70
|
+
that.iVarNames = spec.iVarNames || [];
|
71
|
+
if(that.superclass) {
|
72
|
+
that.klass.superclass = that.superclass.klass;
|
73
|
+
}
|
74
|
+
that.category = spec.category || "";
|
75
|
+
that.fn.prototype.methods = {};
|
76
|
+
that.fn.prototype.inheritedMethods = {};
|
77
|
+
that.fn.prototype.klass = that;
|
78
|
+
|
79
|
+
return that;
|
80
|
+
};
|
81
|
+
|
82
|
+
/* Smalltalk method object. To add a method to a class,
|
83
|
+
use smalltalk.addMethod() */
|
84
|
+
|
85
|
+
st.method = function(spec) {
|
86
|
+
var that = new SmalltalkMethod();
|
87
|
+
that.selector = spec.selector;
|
88
|
+
that.jsSelector = spec.jsSelector;
|
89
|
+
that.category = spec.category;
|
90
|
+
that.source = spec.source;
|
91
|
+
that.messageSends = spec.messageSends || [];
|
92
|
+
that.referencedClasses = spec.referencedClasses || [];
|
93
|
+
that.fn = spec.fn;
|
94
|
+
return that
|
95
|
+
};
|
96
|
+
|
97
|
+
/* Initialize a class in its class hierarchy. Handle both class and
|
98
|
+
metaclasses. */
|
99
|
+
|
100
|
+
st.init = function(klass) {
|
101
|
+
var subclasses = st.subclasses(klass);
|
102
|
+
var methods;
|
103
|
+
|
104
|
+
if(klass.superclass && klass.superclass !== nil) {
|
105
|
+
methods = st.methods(klass.superclass);
|
106
|
+
|
107
|
+
//Methods linking
|
108
|
+
for(var i in methods) {
|
109
|
+
if(!klass.fn.prototype.methods[i]) {
|
110
|
+
klass.fn.prototype.inheritedMethods[i] = methods[i];
|
111
|
+
klass.fn.prototype[methods[i].jsSelector] = methods[i].fn;
|
112
|
+
}
|
113
|
+
}
|
114
|
+
}
|
115
|
+
|
116
|
+
for(var i=0;i<subclasses.length;i++) {
|
117
|
+
st.init(subclasses[i]);
|
118
|
+
}
|
119
|
+
if(klass.klass && !klass.meta) {
|
120
|
+
st.init(klass.klass);
|
121
|
+
}
|
122
|
+
};
|
123
|
+
|
124
|
+
/* Answer all registered Smalltalk classes */
|
125
|
+
|
126
|
+
st.classes = function() {
|
127
|
+
var classes = [];
|
128
|
+
for(var i in st) {
|
129
|
+
if(i.search(/^[A-Z]/g) != -1) {
|
130
|
+
classes.push(st[i]);
|
131
|
+
}
|
132
|
+
|
133
|
+
}
|
134
|
+
return classes
|
135
|
+
};
|
136
|
+
|
137
|
+
/* Answer all methods (included inherited ones) of klass. */
|
138
|
+
|
139
|
+
st.methods = function(klass) {
|
140
|
+
var methods = {};
|
141
|
+
for(var i in klass.fn.prototype.methods) {
|
142
|
+
methods[i] = klass.fn.prototype.methods[i]
|
143
|
+
}
|
144
|
+
for(var i in klass.fn.prototype.inheritedMethods) {
|
145
|
+
methods[i] = klass.fn.prototype.inheritedMethods[i]
|
146
|
+
}
|
147
|
+
return methods;
|
148
|
+
}
|
149
|
+
|
150
|
+
/* Answer the direct subclasses of klass. */
|
151
|
+
|
152
|
+
st.subclasses = function(klass) {
|
153
|
+
var subclasses = [];
|
154
|
+
var classes = st.classes();
|
155
|
+
for(var i in classes) {
|
156
|
+
if(classes[i].fn) {
|
157
|
+
//Metaclasses
|
158
|
+
if(classes[i].klass && classes[i].klass.superclass === klass) {
|
159
|
+
subclasses.push(classes[i].klass);
|
160
|
+
}
|
161
|
+
//Classes
|
162
|
+
if(classes[i].superclass === klass) {
|
163
|
+
subclasses.push(classes[i]);
|
164
|
+
}
|
165
|
+
}
|
166
|
+
}
|
167
|
+
return subclasses;
|
168
|
+
};
|
169
|
+
|
170
|
+
/* Create a new class wrapping a JavaScript constructor, and add it to the
|
171
|
+
global smalltalk object. */
|
172
|
+
|
173
|
+
st.mapClassName = function(className, category, fn, superclass) {
|
174
|
+
st[className] = klass({
|
175
|
+
className: className,
|
176
|
+
category: category,
|
177
|
+
superclass: superclass,
|
178
|
+
fn: fn
|
179
|
+
});
|
180
|
+
};
|
181
|
+
|
182
|
+
/* Add a class to the smalltalk object, creating a new one if needed. */
|
183
|
+
|
184
|
+
st.addClass = function(className, superclass, iVarNames, category) {
|
185
|
+
if(st[className]) {
|
186
|
+
st[className].superclass = superclass;
|
187
|
+
st[className].iVarNames = iVarNames;
|
188
|
+
st[className].category = category || st[className].category;
|
189
|
+
} else {
|
190
|
+
st[className] = klass({
|
191
|
+
className: className,
|
192
|
+
iVarNames: iVarNames,
|
193
|
+
superclass: superclass
|
194
|
+
});
|
195
|
+
st[className].category = category || '';
|
196
|
+
}
|
197
|
+
};
|
198
|
+
|
199
|
+
/* Add a method to a class */
|
200
|
+
|
201
|
+
st.addMethod = function(jsSelector, method, klass) {
|
202
|
+
klass.fn.prototype[jsSelector] = method.fn;
|
203
|
+
klass.fn.prototype.methods[method.selector] = method;
|
204
|
+
method.methodClass = klass;
|
205
|
+
method.jsSelector = jsSelector;
|
206
|
+
};
|
207
|
+
|
208
|
+
/* Handles Smalltalk message send. Automatically converts undefined to the nil object.
|
209
|
+
If the receiver does not understand the selector, call its #doesNotUnderstand: method */
|
210
|
+
|
211
|
+
sendWithoutContext = function(receiver, selector, args, klass) {
|
212
|
+
if(typeof receiver === "undefined") {
|
213
|
+
receiver = nil;
|
214
|
+
}
|
215
|
+
if(!klass && receiver.klass && receiver[selector]) {
|
216
|
+
return receiver[selector].apply(receiver, args);
|
217
|
+
} else if(klass && klass.fn.prototype[selector]) {
|
218
|
+
return klass.fn.prototype[selector].apply(receiver, args)
|
219
|
+
}
|
220
|
+
return messageNotUnderstood(receiver, selector, args);
|
221
|
+
};
|
222
|
+
|
223
|
+
|
224
|
+
/* Handles unhandled errors during message sends */
|
225
|
+
|
226
|
+
sendWithContext = function(receiver, selector, args, klass) {
|
227
|
+
if(thisContext) {
|
228
|
+
return withContextSend(receiver, selector, args, klass);
|
229
|
+
} else {
|
230
|
+
try {return withContextSend(receiver, selector, args, klass)}
|
231
|
+
catch(error) {
|
232
|
+
// Reset the context stack in any case
|
233
|
+
thisContext = undefined;
|
234
|
+
if(error.smalltalkError) {
|
235
|
+
handleError(error);
|
236
|
+
} else {
|
237
|
+
throw(error);
|
238
|
+
}
|
239
|
+
}
|
240
|
+
}
|
241
|
+
};
|
242
|
+
|
243
|
+
/* Same as sendWithoutContext but creates a methodContext. */
|
244
|
+
|
245
|
+
withContextSend = function(receiver, selector, args, klass) {
|
246
|
+
var call, context;
|
247
|
+
if(typeof receiver === "undefined") {
|
248
|
+
receiver = nil;
|
249
|
+
}
|
250
|
+
if(!klass && receiver.klass && receiver[selector]) {
|
251
|
+
context = pushContext(receiver, selector, args);
|
252
|
+
call = receiver[selector].apply(receiver, args);
|
253
|
+
popContext(context);
|
254
|
+
return call;
|
255
|
+
} else if(klass && klass.fn.prototype[selector]) {
|
256
|
+
context = pushContext(receiver, selector, args);
|
257
|
+
call = klass.fn.prototype[selector].apply(receiver, args);
|
258
|
+
popContext(context);
|
259
|
+
return call;
|
260
|
+
}
|
261
|
+
return messageNotUnderstood(receiver, selector, args);
|
262
|
+
};
|
263
|
+
|
264
|
+
/* Handles Smalltalk errors. Triggers the registered ErrorHandler
|
265
|
+
(See the Smalltalk class ErrorHandler and its subclasses */
|
266
|
+
|
267
|
+
function handleError(error) {
|
268
|
+
thisContext = undefined;
|
269
|
+
smalltalk.ErrorHandler._current()._handleError_(error);
|
270
|
+
}
|
271
|
+
|
272
|
+
/* Handles #dnu: *and* JavaScript method calls.
|
273
|
+
if the receiver has no klass, we consider it a JS object (outside of the
|
274
|
+
Jtalk system). Else assume that the receiver understands #doesNotUnderstand: */
|
275
|
+
|
276
|
+
function messageNotUnderstood(receiver, selector, args) {
|
277
|
+
/* Handles JS method calls. */
|
278
|
+
if(receiver.klass === undefined || receiver.allowJavaScriptCalls) {
|
279
|
+
return callJavaScriptMethod(receiver, selector, args);
|
280
|
+
}
|
281
|
+
|
282
|
+
/* Handles not understood messages. Also see the Jtalk counter-part
|
283
|
+
Object>>doesNotUnderstand: */
|
284
|
+
|
285
|
+
return receiver._doesNotUnderstand_(
|
286
|
+
st.Message._new()
|
287
|
+
._selector_(st.convertSelector(selector))
|
288
|
+
._arguments_(args)
|
289
|
+
);
|
290
|
+
};
|
291
|
+
|
292
|
+
function callJavaScriptMethod(receiver, selector, args) {
|
293
|
+
/* Call a method of a JS object, or answer a property.
|
294
|
+
|
295
|
+
Converts keyword-based selectors by using the first
|
296
|
+
keyword only, but keeping all message arguments.
|
297
|
+
|
298
|
+
Example:
|
299
|
+
"self do: aBlock with: anObject" -> "self.do(aBlock, anObject)" */
|
300
|
+
|
301
|
+
var jsSelector = selector
|
302
|
+
.replace(/^_/, '')
|
303
|
+
.replace(/_.*/g, '');
|
304
|
+
var jsProperty = receiver[jsSelector];
|
305
|
+
if(typeof jsProperty === "function") {
|
306
|
+
return jsProperty.apply(receiver, args);
|
307
|
+
} else if(jsProperty !== undefined) {
|
308
|
+
if(args[0]) {
|
309
|
+
receiver[jsSelector] = args[0];
|
310
|
+
return nil;
|
311
|
+
} else {
|
312
|
+
return jsProperty
|
313
|
+
}
|
314
|
+
}
|
315
|
+
smalltalk.Error._signal_(receiver + ' is not a Jtalk object and "' + jsSelector + '" is undefined')
|
316
|
+
};
|
317
|
+
|
318
|
+
|
319
|
+
/* Handle thisContext pseudo variable */
|
320
|
+
|
321
|
+
pushContext = function(receiver, selector, temps) {
|
322
|
+
if(thisContext) {
|
323
|
+
return thisContext = thisContext.newContext({receiver: receiver, selector: selector, temps: temps});
|
324
|
+
} else {
|
325
|
+
return thisContext = new SmalltalkMethodContext({receiver: receiver, selector: selector, temps: temps});
|
326
|
+
}
|
327
|
+
};
|
328
|
+
|
329
|
+
popContext = function(context) {
|
330
|
+
if(context) {
|
331
|
+
context.removeYourself();
|
332
|
+
}
|
333
|
+
};
|
334
|
+
|
335
|
+
/* Convert a string to a valid smalltalk selector.
|
336
|
+
if you modify the following functions, also change String>>asSelector
|
337
|
+
accordingly */
|
338
|
+
|
339
|
+
st.convertSelector = function(selector) {
|
340
|
+
if(selector.match(/__/)) {
|
341
|
+
return convertBinarySelector(selector);
|
342
|
+
} else {
|
343
|
+
return convertKeywordSelector(selector);
|
344
|
+
}
|
345
|
+
};
|
346
|
+
|
347
|
+
function convertKeywordSelector(selector) {
|
348
|
+
return selector.replace(/^_/, '').replace(/_/g, ':');
|
349
|
+
};
|
350
|
+
|
351
|
+
function convertBinarySelector(selector) {
|
352
|
+
return selector
|
353
|
+
.replace(/^_/, '')
|
354
|
+
.replace(/_plus/, '+')
|
355
|
+
.replace(/_minus/, '-')
|
356
|
+
.replace(/_star/, '*')
|
357
|
+
.replace(/_slash/, '/')
|
358
|
+
.replace(/_gt/, '>')
|
359
|
+
.replace(/_lt/, '<')
|
360
|
+
.replace(/_eq/, '=')
|
361
|
+
.replace(/_comma/, ',')
|
362
|
+
.replace(/_at/, '@')
|
363
|
+
};
|
364
|
+
|
365
|
+
/* Converts a JavaScript object to valid Smalltalk Object */
|
366
|
+
st.readJSObject = function(js) {
|
367
|
+
var object = js;
|
368
|
+
var readObject = (js.constructor === Object);
|
369
|
+
var readArray = (js.constructor === Array);
|
370
|
+
|
371
|
+
if(readObject) {
|
372
|
+
object = smalltalk.Dictionary._new();
|
373
|
+
}
|
374
|
+
for(var i in js) {
|
375
|
+
if(readObject) {
|
376
|
+
object._at_put_(i, st.readJSObject(js[i]));
|
377
|
+
}
|
378
|
+
if(readArray) {
|
379
|
+
object[i] = st.readJSObject(js[i]);
|
380
|
+
}
|
381
|
+
}
|
382
|
+
return object;
|
383
|
+
};
|
384
|
+
|
385
|
+
/* Toggle deployment mode (no context will be handled during message send */
|
386
|
+
st.setDeploymentMode = function() {
|
387
|
+
st.send = sendWithoutContext;
|
388
|
+
};
|
389
|
+
|
390
|
+
st.setDevelopmentMode = function() {
|
391
|
+
st.send = sendWithContext;
|
392
|
+
}
|
393
|
+
|
394
|
+
/* Set development mode by default */
|
395
|
+
st.setDevelopmentMode();
|
396
|
+
}
|
397
|
+
|
398
|
+
function SmalltalkMethodContext(spec) {
|
399
|
+
var that = this;
|
400
|
+
spec = spec || {};
|
401
|
+
that.homeContext = spec.homeContext;
|
402
|
+
that.selector = spec.selector;
|
403
|
+
that.receiver = spec.receiver;
|
404
|
+
that.temps = spec.temps || {};
|
405
|
+
|
406
|
+
that.newContext = function(spec) {
|
407
|
+
spec = spec || {};
|
408
|
+
return new SmalltalkMethodContext({homeContext: that, receiver: spec.receiver, selector: spec.selector, temps: spec.temps});
|
409
|
+
}
|
410
|
+
|
411
|
+
that.removeYourself = function() {
|
412
|
+
thisContext = that.homeContext;
|
413
|
+
}
|
414
|
+
}
|
415
|
+
|
416
|
+
/* Global Smalltalk objects. nil and thisContext shouldn't be globals. */
|
417
|
+
|
418
|
+
var nil = new SmalltalkNil();
|
419
|
+
var smalltalk = new Smalltalk();
|
420
|
+
var thisContext = undefined;
|
421
|
+
|
422
|
+
|
423
|
+
/* Utilities */
|
424
|
+
|
425
|
+
Array.prototype.remove = function(s){
|
426
|
+
var index = this.indexOf(s);
|
427
|
+
if(this.indexOf(s) != -1)this.splice(index, 1);
|
428
|
+
}
|
429
|
+
|
430
|
+
if(this.jQuery) {
|
431
|
+
this.jQuery.allowJavaScriptCalls = true;
|
432
|
+
}
|
433
|
+
|
434
|
+
/****************************************************************************************/
|
435
|
+
|
436
|
+
|
437
|
+
/* Base classes mapping. If you edit this part, do not forget to set the superclass of the
|
438
|
+
object metaclass to Class after the definition of Object */
|
439
|
+
|
440
|
+
smalltalk.mapClassName("Object", "Kernel", SmalltalkObject);
|
441
|
+
smalltalk.mapClassName("Smalltalk", "Kernel", Smalltalk, smalltalk.Object);
|
442
|
+
smalltalk.mapClassName("Behavior", "Kernel", SmalltalkBehavior, smalltalk.Object);
|
443
|
+
smalltalk.mapClassName("Class", "Kernel", SmalltalkClass, smalltalk.Behavior);
|
444
|
+
smalltalk.mapClassName("Metaclass", "Kernel", SmalltalkMetaclass, smalltalk.Behavior);
|
445
|
+
smalltalk.mapClassName("CompiledMethod", "Kernel", SmalltalkMethod, smalltalk.Object);
|
446
|
+
|
447
|
+
smalltalk.Object.klass.superclass = smalltalk.Class
|
448
|
+
|
449
|
+
smalltalk.mapClassName("Number", "Kernel", Number, smalltalk.Object);
|
450
|
+
smalltalk.mapClassName("BlockClosure", "Kernel", Function, smalltalk.Object);
|
451
|
+
smalltalk.mapClassName("Boolean", "Kernel", Boolean, smalltalk.Object);
|
452
|
+
smalltalk.mapClassName("Date", "Kernel", Date, smalltalk.Object);
|
453
|
+
smalltalk.mapClassName("UndefinedObject", "Kernel", SmalltalkNil, smalltalk.Object);
|
454
|
+
|
455
|
+
smalltalk.mapClassName("Collection", "Kernel", null, smalltalk.Object);
|
456
|
+
smalltalk.mapClassName("SequenceableCollection", "Kernel", null, smalltalk.Collection);
|
457
|
+
smalltalk.mapClassName("String", "Kernel", String, smalltalk.SequenceableCollection);
|
458
|
+
smalltalk.mapClassName("Array", "Kernel", Array, smalltalk.SequenceableCollection);
|
459
|
+
smalltalk.mapClassName("RegularExpression", "Kernel", RegExp, smalltalk.String);
|
460
|
+
|
461
|
+
smalltalk.mapClassName("Error", "Kernel", Error, smalltalk.Object);
|
462
|
+
smalltalk.mapClassName("MethodContext", "Kernel", SmalltalkMethodContext, smalltalk.Object);
|
463
|
+
|
464
|
+
if(this.CanvasRenderingContext2D) {
|
465
|
+
smalltalk.mapClassName("CanvasRenderingContext", "Canvas", CanvasRenderingContext2D, smalltalk.Object);
|
466
|
+
}
|