Author: Stephan <step...@stzal.com> Branch: Changeset: r265:83a0fa75c418 Date: 2012-06-22 11:42 +0200 http://bitbucket.org/pypy/lang-js/changeset/83a0fa75c418/
Log: added object_space diff --git a/js/builtins.py b/js/builtins.py --- a/js/builtins.py +++ b/js/builtins.py @@ -18,7 +18,7 @@ from js.object_space import object_space jsfunc = JsNativeFunction(function, name) - obj = object_space.new_obj(W__Function, jsfunc, formal_parameter_list = params) + obj = object_space.new_func(jsfunc, formal_parameter_list = params) return obj # 15 @@ -33,7 +33,7 @@ from js.object_space import object_space jsfunc = JsIntimateFunction(func, name) - w_func = object_space.new_obj(W__Function, jsfunc, formal_parameter_list = params) + w_func = object_space.new_func(jsfunc, formal_parameter_list = params) put_property(obj, name, w_func, writable = writable, configurable = configurable, enumerable = enumerable) # 15 @@ -46,7 +46,7 @@ # 15.2.4 Properties of the Object Prototype Object from js.jsobj import W_BasicObject - w_ObjectPrototype = object_space.new_obj_with_proto(W_BasicObject, w_Null) + w_ObjectPrototype = W_BasicObject() object_space.proto_object = w_ObjectPrototype # 15.3.2 @@ -60,13 +60,19 @@ from js.functions import JsNativeFunction empty_func = JsNativeFunction(function_builtins.empty, u'Empty') - w_FunctionPrototype = object_space.new_obj_with_proto(W__Function, w_ObjectPrototype, empty_func, formal_parameter_list = []) + w_FunctionPrototype = W__Function(empty_func, formal_parameter_list = []) + object_space.assign_proto(w_FunctionPrototype, object_space.proto_object) object_space.proto_function = w_FunctionPrototype + # 15.3.3 + object_space.assign_proto(w_Function, object_space.proto_function) + # 15.2 Object Objects # 15.2.3 Properties of the Object Constructor from js.jsobj import W_ObjectConstructor - w_Object = object_space.new_obj_with_proto(W_ObjectConstructor, object_space.proto_function) + w_Object = W_ObjectConstructor() + object_space.assign_proto(w_Object, object_space.proto_function) + put_property(w_Object, u'length', _w(1)) put_property(global_object, u'Object', w_Object) diff --git a/js/builtins_array.py b/js/builtins_array.py --- a/js/builtins_array.py +++ b/js/builtins_array.py @@ -7,10 +7,12 @@ from js.object_space import object_space w_Array = W_ArrayConstructor() + object_space.assign_proto(w_Array, object_space.proto_function) put_property(global_object, u'Array', w_Array) # 15.4.4 - w_ArrayPrototype = object_space.new_obj_with_proto(W__Array, object_space.proto_object) + w_ArrayPrototype = W__Array() + object_space.assign_proto(w_ArrayPrototype, object_space.proto_object) object_space.proto_array = w_ArrayPrototype # 15.4.3.1 diff --git a/js/builtins_boolean.py b/js/builtins_boolean.py --- a/js/builtins_boolean.py +++ b/js/builtins_boolean.py @@ -9,13 +9,15 @@ # 15.6.2 from js.jsobj import W_BooleanConstructor w_Boolean = W_BooleanConstructor() + object_space.assign_proto(w_Boolean, object_space.proto_function) put_property(global_object, u'Boolean', w_Boolean) # 15.6.3 put_property(w_Boolean, u'length', _w(1), writable = False, enumerable = False, configurable = False) # 15.6.4 - w_BooleanPrototype = object_space.new_obj_with_proto(W_BooleanObject, object_space.proto_object, _w(False)) + w_BooleanPrototype = W_BooleanObject(_w(False)) + object_space.assign_proto(w_BooleanPrototype, object_space.proto_object) # 15.6.3.1 object_space.proto_boolean = w_BooleanPrototype diff --git a/js/builtins_date.py b/js/builtins_date.py --- a/js/builtins_date.py +++ b/js/builtins_date.py @@ -12,7 +12,9 @@ ##Date # 15.9.5 - w_DatePrototype = object_space.new_obj_with_proto(W_DateObject, object_space.proto_object, w_NAN) + w_DatePrototype = W_DateObject(w_NAN) + object_space.assign_proto(w_DatePrototype, object_space.proto_object) + object_space.proto_date = w_DatePrototype def putf(name, func): @@ -81,6 +83,7 @@ # 15.9.3 w_Date = W_DateConstructor() + object_space.assign_proto(w_Date, object_space.proto_function) put_property(global_object, u'Date', w_Date) put_property(w_Date, u'prototype', w_DatePrototype, writable = False, enumerable = False, configurable = False) diff --git a/js/builtins_math.py b/js/builtins_math.py --- a/js/builtins_math.py +++ b/js/builtins_math.py @@ -7,8 +7,10 @@ def setup(global_object): from js.builtins import put_native_function, put_property from js.jsobj import W_Math + from js.object_space import object_space # 15.8 w_Math = W_Math() + object_space.assign_proto(w_Math) put_property(global_object, u'Math', w_Math) put_native_function(w_Math, u'abs', js_abs, params = [u'x']) diff --git a/js/builtins_number.py b/js/builtins_number.py --- a/js/builtins_number.py +++ b/js/builtins_number.py @@ -4,18 +4,20 @@ def setup(global_object): from js.builtins import put_property, put_native_function + from js.object_space import object_space # 15.7.2 from js.jsobj import W_NumberConstructor w_Number = W_NumberConstructor() + object_space.assign_proto(w_Number, object_space.proto_function) put_property(global_object, u'Number', w_Number) # 15.7.3 put_property(w_Number, u'length', _w(1), writable = False, enumerable = False, configurable = False) # 15.7.4 - from js.object_space import object_space - w_NumberPrototype = object_space.new_obj_with_proto(W_NumericObject, object_space.proto_object, _w(0)) + w_NumberPrototype = W_NumericObject(_w(0)) + object_space.assign_proto(W_NumericObject, object_space.proto_object) object_space.proto_number = w_NumberPrototype # 15.7.4.1 diff --git a/js/builtins_string.py b/js/builtins_string.py --- a/js/builtins_string.py +++ b/js/builtins_string.py @@ -5,20 +5,21 @@ def setup(global_object): from js.builtins import put_native_function, put_property + from js.object_space import object_space #String # 15.5.1 from js.jsobj import W_StringConstructor w_String = W_StringConstructor() + object_space.assign_proto(w_String, object_space.proto_function) put_property(w_String, u'length', _w(1), writable = False, enumerable = False, configurable = False) - put_property(global_object, u'String', w_String) # 15.5.4 from js.jsobj import W_StringObject - from js.object_space import object_space - w_StringPrototype = object_space.new_obj_with_proto(W_StringObject, object_space.proto_object, _w(u'')) + w_StringPrototype = W_StringObject(_w(u'')) + object_space.assign_proto(w_StringPrototype, object_space.proto_object) # 15.5.3.1 object_space.proto_string = w_StringPrototype @@ -115,10 +116,7 @@ #15.5.4.5 def char_code_at(this, args): - pos = w_Undefined - - if len(args) > 0: - pos = args[0] + pos = get_arg(args, 0) this.check_object_coercible() string = this.to_string() diff --git a/js/interpreter.py b/js/interpreter.py --- a/js/interpreter.py +++ b/js/interpreter.py @@ -21,6 +21,10 @@ from js.builtins import setup_builtins setup_builtins(self.global_object) self.setup_interpreter_builtins() + from js.object_space import object_space + object_space.global_object = self.global_object + object_space.assign_proto(self.global_object) + def setup_interpreter_builtins(self): global_object = self.global_object @@ -72,7 +76,6 @@ ctx = GlobalExecutionContext(c, self.global_object) object_space.global_context = ctx - object_space.global_object = self.global_object result = c.run(ctx) return result.value diff --git a/js/jsobj.py b/js/jsobj.py --- a/js/jsobj.py +++ b/js/jsobj.py @@ -661,11 +661,12 @@ proto = self.get(u'prototype') if isinstance(proto, W_BasicObject): - obj = object_space.new_obj_with_proto(W__Object, proto) + obj = object_space.new_obj() + object_space.assign_proto(obj, proto) else: # would love to test this # but I fail to find a case that falls into this - obj = object_space.new_obj(W__Object) + obj = object_space.new_obj() result = self.Call(args, this=obj) if isinstance(result, W__Object): @@ -713,7 +714,7 @@ assert isnull_or_undefined(value) from js.object_space import object_space - obj = object_space.new_obj(W__Object) + obj = object_space.new_obj() return obj # TODO @@ -758,7 +759,7 @@ scope = object_space.get_global_environment() strict = func.strict params = func.params() - w_func = object_space.new_obj(W__Function, func, formal_parameter_list = params, scope = scope, strict = strict) + w_func = object_space.new_func(func, formal_parameter_list = params, scope = scope, strict = strict) return w_func # TODO @@ -787,7 +788,7 @@ class W_StringConstructor(W_BasicFunction): def Call(self, args = [], this = None, calling_context = None): from js.builtins import get_arg - arg0 = get_arg(args, 0) + arg0 = get_arg(args, 0, _w(u"")) strval = arg0.to_string() return W_String(strval) @@ -845,7 +846,7 @@ value = _w(int(time.time() * 1000)) from js.object_space import object_space - obj = object_space.new_obj(W_DateObject, value) + obj = object_space.new_date(value) return obj # 15.7.2.1 @@ -872,7 +873,7 @@ # 15. put_property(self, u'length', _w(_len), writable = False, enumerable = False, configurable = False) # 16. - proto_obj = object_space.new_obj(W__Object) + proto_obj = object_space.new_obj() # 17. put_property(proto_obj, u'constructor', self, writable = True, enumerable = False, configurable = True) # 18. @@ -941,7 +942,7 @@ put_property(self, u'length', _w(_len), writable = True, enumerable = False, configurable = True) from js.object_space import object_space - _map = object_space.new_obj(W__Object) + _map = object_space.new_obj() mapped_names = [] indx = _len - 1 while indx >= 0: @@ -991,15 +992,15 @@ length = _len.ToUInt32() if length != _len.ToNumber(): raise JsRangeError() - array = object_space.new_obj(W__Array, length) + array = object_space.new_array(_w(length)) else: length = 1 - array = object_space.new_obj(W__Array, length) + array = object_space.new_array(_w(length)) array.put(u'0', _len) return array else: - array = object_space.new_obj(W__Array) + array = object_space.new_array() for index, obj in enumerate(args): array.put(unicode(str(index)), obj) return array @@ -1007,13 +1008,240 @@ def Construct(self, args=[]): return self.Call(args) + +# 15.8 +class W_Math(W__Object): + _class_ = 'Math' + +class W_Boolean(W_Primitive): + _type_ = 'boolean' + + def __init__(self, boolval): + W_Primitive.__init__(self) + self._boolval_ = bool(boolval) + + def __str__(self): + return 'W_Bool(%s)' % (str(self._boolval_), ) + + def ToObject(self): + from js.object_space import object_space + return object_space.new_bool(self) + + def to_string(self): + if self._boolval_ == True: + return u'true' + return u'false' + + def ToNumber(self): + if self._boolval_ == True: + return 1.0 + return 0.0 + + def to_boolean(self): + return self._boolval_ + +class W_String(W_Primitive): + _type_ = 'string' + + def __init__(self, strval): + assert isinstance(strval, unicode) + W_Primitive.__init__(self) + self._strval_ = strval + + def __eq__(self, other): + other_string = other.to_string() + return self.to_string() == other_string + + def __str__(self): + return u'W_String("%s")' % (self._strval_) + + def ToObject(self): + from js.object_space import object_space + return object_space.new_string(self) + + def to_string(self): + return self._strval_ + + def to_boolean(self): + if len(self._strval_) == 0: + return False + else: + return True + + def ToNumber(self): + u_strval = self._strval_ + assert isinstance(u_strval, unicode) + import re + if u_strval == u'': + return 0.0 + if re.match('^\s*$', u_strval): + return 0.0 + + strval = str(u_strval) + + try: + return float(strval) + except ValueError: + try: + return float(int(strval, 16)) + except ValueError: + try: + return float(int(strval, 8)) + except ValueError: + return NAN + except OverflowError: + return INFINITY + except OverflowError: + return INFINITY + except OverflowError: + return INFINITY + +class W_Number(W_Primitive): + """ Base class for numbers, both known to be floats + and those known to be integers + """ + _type_ = 'number' + + # 9.9 + def ToObject(self): + from js.object_space import object_space + obj = object_space.new_number(self) + return obj + + def to_boolean(self): + num = self.ToNumber() + if isnan(num): + return False + return bool(num) + + def __eq__(self, other): + if isinstance(other, W_Number): + return self.ToNumber() == other.ToNumber() + else: + return False + +class W_IntNumber(W_Number): + """ Number known to be an integer + """ + def __init__(self, intval): + W_Number.__init__(self) + self._intval_ = intmask(intval) + + def __str__(self): + return 'W_IntNumber(%s)' % (self._intval_,) + + def ToInteger(self): + return self._intval_ + + def ToNumber(self): + # XXX + return float(self._intval_) + + def to_string(self): + # XXX incomplete, this doesn't follow the 9.8.1 recommendation + return unicode(str(self.ToInteger())) + +def r_int32(n): + return intmask(rffi.cast(rffi.INT, n)) + +def r_uint32(n): + return intmask(rffi.cast(rffi.UINT, n)) + +class W_FloatNumber(W_Number): + """ Number known to be a float + """ + def __init__(self, floatval): + assert isinstance(floatval, float) + W_Number.__init__(self) + self._floatval_ = float(floatval) + + def __str__(self): + return 'W_FloatNumber(%s)' % (self._floatval_,) + + def to_string(self): + # XXX incomplete, this doesn't follow the 9.8.1 recommendation + if isnan(self._floatval_): + return u'NaN' + if isinf(self._floatval_): + if self._floatval_ > 0: + return u'Infinity' + else: + return u'-Infinity' + + if self._floatval_ == 0: + return u'0' + + res = u'' + try: + res = unicode(formatd(self._floatval_, 'g', 10)) + except OverflowError: + raise + + if len(res) > 3 and (res[-3] == '+' or res[-3] == '-') and res[-2] == '0': + cut = len(res) - 2 + assert cut >= 0 + res = res[:cut] + res[-1] + return res + + def ToNumber(self): + return self._floatval_ + + def ToInteger(self): + if isnan(self._floatval_): + return 0 + + if self._floatval_ == 0 or isinf(self._floatval_): + return self._floatval_ + + return intmask(int(self._floatval_)) + + +def isnull_or_undefined(obj): + if obj is w_Null or obj is w_Undefined: + return True + return False + +w_True = W_Boolean(True) +w_False = W_Boolean(False) + +def newbool(val): + if val: + return w_True + return w_False + +class W_List(W_Root): + def __init__(self, values): + self.values = values + + def to_list(self): + return self.values + + def __str__(self): + return 'W_List(%s)' % ( unicode([unicode(v) for v in self.values]) ) + +class W_Iterator(W_Root): + def __init__(self, elements_w): + self.elements_w = elements_w + + def next(self): + if self.elements_w: + return self.elements_w.pop() + + def empty(self): + return len(self.elements_w) == 0 + + def to_string(self): + return u'<Iterator>' + +w_0 = W_IntNumber(0) class W__Array(W_BasicObject): _class_ = 'Array' - def __init__(self, length = 0): + def __init__(self, length = w_0): + assert isinstance(length, W_Root) W_BasicObject.__init__(self) - desc = PropertyDescriptor(value = _w(length), writable = True, enumerable = False, configurable = False) + desc = PropertyDescriptor(value = length, writable = True, enumerable = False, configurable = False) W_BasicObject.define_own_property(self, u'length', desc) # 15.4.5.1 @@ -1111,230 +1339,6 @@ except ValueError: return False -# 15.8 -class W_Math(W__Object): - _class_ = 'Math' - -class W_Boolean(W_Primitive): - _type_ = 'boolean' - - def __init__(self, boolval): - W_Primitive.__init__(self) - self._boolval_ = bool(boolval) - - def __str__(self): - return 'W_Bool(%s)' % (str(self._boolval_), ) - - def ToObject(self): - from js.object_space import object_space - return object_space.new_obj(W_BooleanObject, self) - - def to_string(self): - if self._boolval_ == True: - return u'true' - return u'false' - - def ToNumber(self): - if self._boolval_ == True: - return 1.0 - return 0.0 - - def to_boolean(self): - return self._boolval_ - -class W_String(W_Primitive): - _type_ = 'string' - - def __init__(self, strval): - assert isinstance(strval, unicode) - W_Primitive.__init__(self) - self._strval_ = strval - - def __eq__(self, other): - other_string = other.to_string() - return self.to_string() == other_string - - def __str__(self): - return u'W_String("%s")' % (self._strval_) - - def ToObject(self): - from js.object_space import object_space - return object_space.new_obj(W_StringObject, self) - - def to_string(self): - return self._strval_ - - def to_boolean(self): - if len(self._strval_) == 0: - return False - else: - return True - - def ToNumber(self): - u_strval = self._strval_ - assert isinstance(u_strval, unicode) - - if u_strval == u'': - return 0.0 - if u_strval.strip(' ') == u'': - return 0.0 - - strval = str(u_strval) - - try: - return float(strval) - except ValueError: - try: - return float(int(strval, 16)) - except ValueError: - try: - return float(int(strval, 8)) - except ValueError: - return NAN - except OverflowError: - return INFINITY - except OverflowError: - return INFINITY - except OverflowError: - return INFINITY - -class W_Number(W_Primitive): - """ Base class for numbers, both known to be floats - and those known to be integers - """ - _type_ = 'number' - - # 9.9 - def ToObject(self): - from js.object_space import object_space - obj = object_space.new_obj(W_NumericObject, self) - return obj - - def to_boolean(self): - num = self.ToNumber() - if isnan(num): - return False - return bool(num) - - def __eq__(self, other): - if isinstance(other, W_Number): - return self.ToNumber() == other.ToNumber() - else: - return False - -class W_IntNumber(W_Number): - """ Number known to be an integer - """ - def __init__(self, intval): - W_Number.__init__(self) - self._intval_ = intmask(intval) - - def __str__(self): - return 'W_IntNumber(%s)' % (self._intval_,) - - def ToInteger(self): - return self._intval_ - - def ToNumber(self): - # XXX - return float(self._intval_) - - def to_string(self): - # XXX incomplete, this doesn't follow the 9.8.1 recommendation - return unicode(str(self.ToInteger())) - -def r_int32(n): - return intmask(rffi.cast(rffi.INT, n)) - -def r_uint32(n): - return intmask(rffi.cast(rffi.UINT, n)) - -class W_FloatNumber(W_Number): - """ Number known to be a float - """ - def __init__(self, floatval): - assert isinstance(floatval, float) - W_Number.__init__(self) - self._floatval_ = float(floatval) - - def __str__(self): - return 'W_FloatNumber(%s)' % (self._floatval_,) - - def to_string(self): - # XXX incomplete, this doesn't follow the 9.8.1 recommendation - if isnan(self._floatval_): - return u'NaN' - if isinf(self._floatval_): - if self._floatval_ > 0: - return u'Infinity' - else: - return u'-Infinity' - - if self._floatval_ == 0: - return u'0' - - res = u'' - try: - res = unicode(formatd(self._floatval_, 'g', 10)) - except OverflowError: - raise - - if len(res) > 3 and (res[-3] == '+' or res[-3] == '-') and res[-2] == '0': - cut = len(res) - 2 - assert cut >= 0 - res = res[:cut] + res[-1] - return res - - def ToNumber(self): - return self._floatval_ - - def ToInteger(self): - if isnan(self._floatval_): - return 0 - - if self._floatval_ == 0 or isinf(self._floatval_): - return self._floatval_ - - return intmask(int(self._floatval_)) - - -def isnull_or_undefined(obj): - if obj is w_Null or obj is w_Undefined: - return True - return False - -w_True = W_Boolean(True) -w_False = W_Boolean(False) - -def newbool(val): - if val: - return w_True - return w_False - -class W_List(W_Root): - def __init__(self, values): - self.values = values - - def to_list(self): - return self.values - - def __str__(self): - return 'W_List(%s)' % ( unicode([unicode(v) for v in self.values]) ) - -class W_Iterator(W_Root): - def __init__(self, elements_w): - self.elements_w = elements_w - - def next(self): - if self.elements_w: - return self.elements_w.pop() - - def empty(self): - return len(self.elements_w) == 0 - - def to_string(self): - return u'<Iterator>' - from pypy.rlib.objectmodel import specialize @specialize.argtype(0) def _w(value): @@ -1352,7 +1356,7 @@ return W_String(unicode(value)) elif isinstance(value, list): from js.object_space import object_space - a = object_space.new_obj(W__Array) + a = object_space.new_array() for index, item in enumerate(value): put_property(a, unicode(index), _w(item), writable = True, enumerable = True, configurable = True) return a diff --git a/js/object_space.py b/js/object_space.py --- a/js/object_space.py +++ b/js/object_space.py @@ -1,34 +1,63 @@ +from js.jsobj import _w, W_BasicObject, W__Object, W_BasicFunction, W__Function, W_DateObject, W_BooleanObject, W_StringObject, W_NumericObject, W__Array + class ObjectSpace(object): - def get_global_object(self): - return self.global_object - def get_global_environment(self): return self.global_context.variable_environment() - def new_obj_with_proto(self, cls, proto, *args, **kwargs): - obj = cls(*args, **kwargs) - obj._prototype_ = proto + def assign_proto(self, obj, proto = None): + if proto is not None: + obj._prototype_ = proto + return obj + + if isinstance(obj, W_BasicFunction): + obj._prototype_ = self.proto_function + elif isinstance(obj, W_BooleanObject): + obj._prototype_ = self.proto_boolean + elif isinstance(obj, W_NumericObject): + obj._prototype_ = self.proto_number + elif isinstance(obj, W_StringObject): + obj._prototype_ = self.proto_string + elif isinstance(obj, W__Array): + obj._prototype_ = self.proto_array + elif isinstance(obj, W_DateObject): + obj._prototype_ = self.proto_date + else: + obj._prototype_ = self.proto_object return obj - def new_obj(self, cls, *args, **kwargs): - from js.jsobj import W_BasicFunction, W_BooleanObject, W_StringObject, W_NumericObject, W_DateObject, W__Array - obj = cls(*args, **kwargs) + def new_obj(self): + obj = W__Object() + self.assign_proto(obj) + return obj - if issubclass(cls, W_BasicFunction): - obj._prototype_ = self.proto_function - elif issubclass(cls, W_BooleanObject): - obj._prototype_ = self.proto_boolean - elif issubclass(cls, W_StringObject): - obj._prototype_ = self.proto_string - elif issubclass(cls, W_NumericObject): - obj._prototype_ = self.proto_number - elif issubclass(cls, W_DateObject): - obj._prototype_ = self.proto_date - elif issubclass(cls, W__Array): - obj._prototype_ = self.proto_array - else: - obj._prototype_ = self.proto_object + def new_func(self, function_body, formal_parameter_list=[], scope=None, strict=False): + obj = W__Function(function_body, formal_parameter_list, scope, strict) + self.assign_proto(obj) + return obj + def new_date(self, value): + obj = W_DateObject(value) + self.assign_proto(obj) + return obj + + def new_array(self, length = _w(0)): + obj = W__Array(length) + self.assign_proto(obj) + return obj + + def new_bool(self, value): + obj = W_BooleanObject(value) + self.assign_proto(obj) + return obj + + def new_string(self, value): + obj = W_StringObject(value) + self.assign_proto(obj) + return obj + + def new_number(self, value): + obj = W_NumericObject(value) + self.assign_proto(obj) return obj object_space = ObjectSpace() diff --git a/js/opcodes.py b/js/opcodes.py --- a/js/opcodes.py +++ b/js/opcodes.py @@ -142,9 +142,8 @@ self.counter = counter def eval(self, ctx): - from js.jsobj import W__Array from js.object_space import object_space - array = object_space.new_obj(W__Array) + array = object_space.new_array() list_w = ctx.stack_pop_n(self.counter) # [:] # pop_n returns a non-resizable list for index, el in enumerate(list_w): @@ -179,13 +178,13 @@ # 13.2 Creating Function Objects def eval(self, ctx): - from js.jsobj import W__Object from js.object_space import object_space + func = self.funcobj scope = ctx.lexical_environment() params = func.params() strict = func.strict - w_func = object_space.new_obj(W__Function, func, formal_parameter_list = params, scope = scope, strict = strict) + w_func = object_space.new_func(func, formal_parameter_list = params, scope = scope, strict = strict) ctx.stack_append(w_func) @@ -199,7 +198,7 @@ def eval(self, ctx): from js.object_space import object_space - w_obj = object_space.new_obj(W__Object) + w_obj = object_space.new_obj() for _ in range(self.counter): name = ctx.stack_pop().to_string() w_elem = ctx.stack_pop() diff --git a/js/operations.py b/js/operations.py --- a/js/operations.py +++ b/js/operations.py @@ -655,8 +655,8 @@ bytecode.emit('LOAD_STRINGCONSTANT', strval) def string_unquote(self, string): - #s = decode_unicode_escape(string) - s = string + s = decode_unicode_escape(string) + #s = string if s.startswith('"'): assert s.endswith('"') else: @@ -664,7 +664,7 @@ assert s.endswith("'") s = s[:-1] s = s[1:] - s = u''.join(s.split(u'\\')) + #s = u''.join(s.split(u'\\')) return unicode(s) def decode_unicode_escape(string): _______________________________________________ pypy-commit mailing list pypy-commit@python.org http://mail.python.org/mailman/listinfo/pypy-commit