Skip to content

Commit

Permalink
do not replace String.prototype.match.
Browse files Browse the repository at this point in the history
  • Loading branch information
tokuhirom committed Aug 29, 2012
1 parent 1d07f60 commit e741449
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
9 changes: 5 additions & 4 deletions src/runtime.js
Expand Up @@ -55,11 +55,12 @@
}

// TODO: optimize
var origStringPrototypeMatch = String.prototype.match;
var lastMatch = [];
String.prototype.match = function () {
lastMatch = origStringPrototypeMatch.apply(this, Array.prototype.slice.call(arguments));
return lastMatch;
global.Kuma.Runtime = {
match: function (str, re) {
lastMatch = str.match(re);
return lastMatch;
}
};

var glob_cache;
Expand Down
2 changes: 1 addition & 1 deletion src/translator.js
Expand Up @@ -474,7 +474,7 @@
return ret;
}).call(this);
case Parser.NODE_REGEXP_MATCH:
return "((" + this._translate(ast[ND_DATAS][0]) + ").match(" + this._translate(ast[ND_DATAS][1]) + "))";
return "(Kuma.Runtime.match((" + this._translate(ast[ND_DATAS][0]) + "),(" + this._translate(ast[ND_DATAS][1]) + ")))";
case Parser.NODE_REGEXP_NOT_MATCH:
return "(!((" + this._translate(ast[ND_DATAS][0]) + ").match(" + this._translate(ast[ND_DATAS][1]) + ")))";
case Parser.NODE_DOTDOTDOT:
Expand Down

0 comments on commit e741449

Please sign in to comment.