From e7414497a749838075b9d66b78b62327ff39cade Mon Sep 17 00:00:00 2001 From: tokuhirom Date: Wed, 29 Aug 2012 18:01:44 +0900 Subject: [PATCH] do not replace String.prototype.match. --- src/runtime.js | 9 +++++---- src/translator.js | 2 +- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/src/runtime.js b/src/runtime.js index af6d504..9af05cd 100644 --- a/src/runtime.js +++ b/src/runtime.js @@ -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; diff --git a/src/translator.js b/src/translator.js index df3a54f..f8c9b6c 100644 --- a/src/translator.js +++ b/src/translator.js @@ -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: