| Index: frog/corejs.dart
|
| ===================================================================
|
| --- frog/corejs.dart (revision 4175)
|
| +++ frog/corejs.dart (working copy)
|
| @@ -28,6 +28,7 @@
|
| bool _generatedDynamicSetMetadata = false;
|
| bool _generatedInherits = false;
|
| bool _generatedDefProp = false;
|
| + bool _generatedBind = false;
|
|
|
|
|
| Map<String, String> _usedOperators;
|
| @@ -128,6 +129,12 @@
|
| writer.writeln(_DEF_PROP_FUNCTION);
|
| }
|
|
|
| + void ensureBind() {
|
| + if (_generatedBind) return;
|
| + _generatedBind = true;
|
| + writer.writeln(_BIND_CODE);
|
| + }
|
| +
|
| void generate(CodeWriter w) {
|
| // Write any stuff we had queued up, then replace our writer with the one
|
| // in WorldGenerator so anything we discover that we need later on will be
|
| @@ -429,11 +436,11 @@
|
| }
|
| return this[i];
|
| });
|
| -$defProp(Array.prototype, '$index', function(i) {
|
| - return this[i];
|
| +$defProp(Array.prototype, '$index', function(i) {
|
| + return this[i];
|
| });
|
| -$defProp(String.prototype, '$index', function(i) {
|
| - return this[i];
|
| +$defProp(String.prototype, '$index', function(i) {
|
| + return this[i];
|
| });""";
|
|
|
| final String _CHECKED_INDEX_OPERATORS = @"""
|
| @@ -532,3 +539,24 @@
|
| var $globalThis = this;
|
| var $globals = null;
|
| var $globalState = null;""";
|
| +
|
| +
|
| +/** Snippet that initializes Function.prototype.bind. */
|
| +final String _BIND_CODE = @"""
|
| +Function.prototype.bind = Function.prototype.bind ||
|
| + function(thisObj, args) {
|
| + var func = this;
|
| + if (typeof args !== 'undefined') {
|
| + var boundArgs = Array.prototype.slice.call(arguments, 3);
|
| + return function() {
|
| + // Prepend the bound arguments to the current arguments.
|
| + var newArgs = Array.prototype.slice.call(arguments);
|
| + Array.prototype.unshift.apply(newArgs, boundArgs);
|
| + return func.apply(thisObj, newArgs);
|
| + };
|
| + } else {
|
| + return function() {
|
| + return func.apply(thisObj, arguments);
|
| + };
|
| + }
|
| + };""";
|
|
|