[pypy-svn] r55199 - in pypy/branch/js-refactoring/pypy/lang/js: . bench
santagada at codespeak.net
santagada at codespeak.net
Sun May 25 06:20:52 CEST 2008
Author: santagada
Date: Sun May 25 06:20:50 2008
New Revision: 55199
Modified:
pypy/branch/js-refactoring/pypy/lang/js/astbuilder.py
pypy/branch/js-refactoring/pypy/lang/js/bench/TODO.txt
pypy/branch/js-refactoring/pypy/lang/js/interpreter.py
pypy/branch/js-refactoring/pypy/lang/js/jsobj.py
Log:
fixes for Boolean objects, a nasty property 'de' propagation error, some intmask/float mistakes, a adition to benchmarks
Modified: pypy/branch/js-refactoring/pypy/lang/js/astbuilder.py
==============================================================================
--- pypy/branch/js-refactoring/pypy/lang/js/astbuilder.py (original)
+++ pypy/branch/js-refactoring/pypy/lang/js/astbuilder.py Sun May 25 06:20:50 2008
@@ -1,3 +1,4 @@
+from pypy.rlib.rarithmetic import intmask, ovfcheck
from pypy.rlib.parsing.tree import RPythonVisitor, Symbol, Nonterminal
from pypy.lang.js import operations
from pypy.rlib.parsing.parsing import ParseError
@@ -86,10 +87,10 @@
def visit_DECIMALLITERAL(self, node):
pos = self.get_pos(node)
try:
- int(node.additional_info)
- except ValueError:
+ ovfcheck(int(node.additional_info))
+ except (ValueError, OverflowError):
return operations.FloatNumber(pos, float(node.additional_info))
- return operations.IntNumber(pos, int(node.additional_info))
+ return operations.IntNumber(pos, intmask(node.additional_info))
def visit_HEXINTEGERLITERAL(self, node):
pos = self.get_pos(node)
Modified: pypy/branch/js-refactoring/pypy/lang/js/bench/TODO.txt
==============================================================================
--- pypy/branch/js-refactoring/pypy/lang/js/bench/TODO.txt (original)
+++ pypy/branch/js-refactoring/pypy/lang/js/bench/TODO.txt Sun May 25 06:20:50 2008
@@ -1,5 +1,8 @@
All benchmarks are from The Computer Language Benchmarks Game, licensed under the revised BSD License
+Maybe we should also take a look at those benchmarks:
+ http://trac.webkit.org/projects/webkit/wiki/JavaScript%20and%20DOM%20Benchmarks
+
Parameters for the benchmarks:
ackermann 9,10,11
Modified: pypy/branch/js-refactoring/pypy/lang/js/interpreter.py
==============================================================================
--- pypy/branch/js-refactoring/pypy/lang/js/interpreter.py (original)
+++ pypy/branch/js-refactoring/pypy/lang/js/interpreter.py Sun May 25 06:20:50 2008
@@ -87,7 +87,7 @@
return W_String('')
def Construct(self, ctx, args=[]):
- if len(args) >= 1 and not isnull_or_undefined(args[0]):
+ if len(args) >= 1:
Value = W_String(args[0].ToString(ctx))
return create_object(ctx, 'String', Value = Value)
return create_object(ctx, 'String', Value = W_String(''))
@@ -461,19 +461,20 @@
})
w_Boolean = W_BooleanObject('Boolean', w_FncPrototype)
- w_Boolean.Put('constructor', w_FncPrototype)
+ w_Boolean.Put('constructor', w_FncPrototype, dd=True, ro=True, de=True)
+ w_Boolean.Put('length', W_IntNumber(1), dd=True, ro=True, de=True)
w_BoolPrototype = create_object(ctx, 'Object', Value=W_Boolean(False))
w_BoolPrototype.Class = 'Boolean'
put_values(w_BoolPrototype, {
'constructor': w_FncPrototype,
- '__proto__': w_BoolPrototype,
+ '__proto__': w_ObjPrototype,
'toString': W_BooleanValueToString(ctx),
- 'valueOf': get_value_of('Boolean', ctx)
+ 'valueOf': get_value_of('Boolean', ctx),
})
- w_Boolean.Put('prototype', w_BoolPrototype)
+ w_Boolean.Put('prototype', w_BoolPrototype, dd=True, ro=True, de=True)
w_Global.Put('Boolean', w_Boolean)
Modified: pypy/branch/js-refactoring/pypy/lang/js/jsobj.py
==============================================================================
--- pypy/branch/js-refactoring/pypy/lang/js/jsobj.py (original)
+++ pypy/branch/js-refactoring/pypy/lang/js/jsobj.py Sun May 25 06:20:50 2008
@@ -33,7 +33,7 @@
# return self
def ToBoolean(self):
- return False
+ raise NotImplementedError()
def ToPrimitive(self, ctx, hint=""):
return self
@@ -86,7 +86,7 @@
def ToBoolean(self):
return False
- def ToString(self, ctx = None):
+ def ToString(self, ctx):
return "undefined"
def type(self):
@@ -188,7 +188,7 @@
P.value = V
except KeyError:
self.propdict[P] = Property(P, V,
- dd = dd, ro = ro, it = it)
+ dd = dd, ro = ro, de = de, it = it)
def HasProperty(self, P):
if P in self.propdict: return True
@@ -223,6 +223,9 @@
ToPrimitive = DefaultValue
+ def ToBoolean(self):
+ return True
+
def ToString(self, ctx):
try:
res = self.ToPrimitive(ctx, 'String')
@@ -390,7 +393,10 @@
return self.strval
def ToBoolean(self):
- return bool(self.strval)
+ if len(self.strval) == 0:
+ return False
+ else:
+ return True
def type(self):
return 'string'
@@ -426,6 +432,7 @@
self.intval = intmask(intval)
def ToString(self, ctx=None):
+ # XXX incomplete, this doesn't follow the 9.8.1 recommendation
return str(self.intval)
def ToBoolean(self):
@@ -454,6 +461,7 @@
self.floatval = floatval
def ToString(self, ctx = None):
+ # XXX incomplete, this doesn't follow the 9.8.1 recommendation
if isnan(self.floatval):
return 'NaN'
if isinf(self.floatval):
@@ -477,7 +485,7 @@
def ToInt32(self):
if isnan(self.floatval) or isinf(self.floatval):
return 0
- return int(self.floatval)
+ return intmask(self.floatval)
def ToUInt32(self):
if isnan(self.floatval) or isinf(self.floatval):
More information about the Pypy-commit
mailing list