Author: Stephan <step...@stzal.com> Branch: Changeset: r305:8b3a4555d227 Date: 2012-12-11 12:17 +0100 http://bitbucket.org/pypy/lang-js/changeset/8b3a4555d227/
Log: use parse int in W_String.ToNumber () diff --git a/js/builtins_global.py b/js/builtins_global.py --- a/js/builtins_global.py +++ b/js/builtins_global.py @@ -110,11 +110,16 @@ # 15.1.2.2 @w_return def parse_int(this, args): - NUMERALS = u'0123456789abcdefghijklmnopqrstuvwxyz' string = get_arg(args, 0) radix = get_arg(args, 1) - input_string = string.to_string() + return _parse_int(string.to_string(), radix.ToInt32()) + + +def _parse_int(string, radix): + assert isinstance(string, unicode) + NUMERALS = u'0123456789abcdefghijklmnopqrstuvwxyz' + input_string = string s = _strip(input_string) sign = 1 @@ -123,7 +128,7 @@ if s.startswith(u'-') or s.startswith(u'+'): s = s[1:] - r = radix.ToInt32() + r = radix strip_prefix = True if r != 0: diff --git a/js/jsobj.py b/js/jsobj.py --- a/js/jsobj.py +++ b/js/jsobj.py @@ -1061,19 +1061,21 @@ return float(num_lit) + from builtins_global import _parse_int + match_data = hex_rexp.match(s) if match_data is not None: hex_lit = match_data.group(1) assert hex_lit is not None assert hex_lit.startswith('0x') is False assert hex_lit.startswith('0X') is False - return int(hex_lit, 16) + return float(_parse_int(unicode(hex_lit), 16)) match_data = oct_rexp.match(s) if match_data is not None: oct_lit = match_data.group(1) assert oct_lit is not None - return int(oct_lit, 8) + return float(_parse_int(unicode(oct_lit), 8)) return NAN _______________________________________________ pypy-commit mailing list pypy-commit@python.org http://mail.python.org/mailman/listinfo/pypy-commit