[pypy-commit] lang-js default: renamed js property flags
stepahn
noreply at buildbot.pypy.org
Fri Dec 28 11:32:30 CET 2012
Author: Stephan <stephan at stzal.com>
Branch:
Changeset: r132:274f4936c68e
Date: 2011-10-04 13:06 +0200
http://bitbucket.org/pypy/lang-js/changeset/274f4936c68e/
Log: renamed js property flags
diff --git a/js/interpreter.py b/js/interpreter.py
--- a/js/interpreter.py
+++ b/js/interpreter.py
@@ -8,7 +8,7 @@
w_Undefined, W_NewBuiltin, W_IntNumber, w_Null, create_object, W_Boolean,\
W_FloatNumber, W_String, W_Builtin, W_Array, w_Null, newbool,\
isnull_or_undefined, W_PrimitiveObject, W_ListObject, W_BaseNumber,\
- DE, DD, RO, IT
+ DONT_DELETE, DONT_ENUM, READ_ONLY, INTERNAL
from js.execution import ThrowException, JsTypeError
from js.jscode import JsCode
@@ -321,7 +321,7 @@
def Call(self, ctx, args=[], this=None):
if len(args) >= 1:
propname = args[0].ToString(ctx)
- if propname in this.propdict and not this.propdict[propname].flags & DE:
+ if propname in this.propdict and not this.propdict[propname].flags & DONT_ENUM:
return newbool(True)
return newbool(False)
@@ -721,7 +721,7 @@
class Interpreter(object):
"""Creates a js interpreter"""
def __init__(self):
- allon = DE | DD | RO
+ allon = DONT_ENUM | DONT_DELETE | READ_ONLY
from js.jsexecution_context import make_global_context
ctx = make_global_context()
w_Global = ctx.to_context_object()
@@ -807,13 +807,13 @@
'__proto__': w_FncPrototype,
'length' : W_IntNumber(1),
})
- w_Number.propdict['prototype'].flags |= RO
- w_Number.Put(ctx, 'MAX_VALUE', W_FloatNumber(1.7976931348623157e308), flags = RO|DD)
- w_Number.Put(ctx, 'MIN_VALUE', W_FloatNumber(0), flags = RO|DD)
- w_Number.Put(ctx, 'NaN', W_FloatNumber(NAN), flags = RO|DD)
+ w_Number.propdict['prototype'].flags |= READ_ONLY
+ w_Number.Put(ctx, 'MAX_VALUE', W_FloatNumber(1.7976931348623157e308), flags = READ_ONLY | DONT_DELETE)
+ w_Number.Put(ctx, 'MIN_VALUE', W_FloatNumber(0), flags = READ_ONLY | DONT_DELETE)
+ w_Number.Put(ctx, 'NaN', W_FloatNumber(NAN), flags = READ_ONLY | DONT_DELETE)
# ^^^ this is exactly in test case suite
- w_Number.Put(ctx, 'POSITIVE_INFINITY', W_FloatNumber(INFINITY), flags = RO|DD)
- w_Number.Put(ctx, 'NEGATIVE_INFINITY', W_FloatNumber(-INFINITY), flags = RO|DD)
+ w_Number.Put(ctx, 'POSITIVE_INFINITY', W_FloatNumber(INFINITY), flags = READ_ONLY | DONT_DELETE)
+ w_Number.Put(ctx, 'NEGATIVE_INFINITY', W_FloatNumber(-INFINITY), flags = READ_ONLY | DONT_DELETE)
w_Global.Put(ctx, 'Number', w_Number)
@@ -908,9 +908,9 @@
w_Global.Put(ctx, 'Date', w_Date)
- w_Global.Put(ctx, 'NaN', W_FloatNumber(NAN), flags = DE|DD)
- w_Global.Put(ctx, 'Infinity', W_FloatNumber(INFINITY), flags = DE|DD)
- w_Global.Put(ctx, 'undefined', w_Undefined, flags = DE|DD)
+ w_Global.Put(ctx, 'NaN', W_FloatNumber(NAN), flags = DONT_ENUM | DONT_DELETE)
+ w_Global.Put(ctx, 'Infinity', W_FloatNumber(INFINITY), flags = DONT_ENUM | DONT_DELETE)
+ w_Global.Put(ctx, 'undefined', w_Undefined, flags = DONT_ENUM | DONT_DELETE)
w_Global.Put(ctx, 'eval', W_Eval(ctx))
w_Global.Put(ctx, 'parseInt', W_ParseInt(ctx))
w_Global.Put(ctx, 'parseFloat', W_ParseFloat(ctx))
diff --git a/js/jsobj.py b/js/jsobj.py
--- a/js/jsobj.py
+++ b/js/jsobj.py
@@ -138,8 +138,7 @@
def Delete(self, name):
try:
- from jsobj import DD
- if self.context.get_property_flags(name) & DD:
+ if self.context.get_property_flags(name) & DONT_DELETE:
return False
self.context.delete_identifier(name)
except KeyError:
@@ -153,7 +152,7 @@
self.Prototype = Prototype
if Prototype is None:
Prototype = w_Undefined
- self.propdict['prototype'] = Property('prototype', Prototype, flags = DE|DD)
+ self.propdict['prototype'] = Property('prototype', Prototype, flags = DONT_ENUM | DONT_DELETE)
self.Class = Class
self.callfunc = callfunc
if callfunc is not None:
@@ -166,6 +165,7 @@
def Call(self, ctx, args=[], this=None):
if self.callfunc is None: # XXX Not sure if I should raise it here
raise JsTypeError('not a function')
+
# TODO
if this:
from js.jsobj import W_Root
@@ -236,7 +236,7 @@
def Delete(self, P):
if P in self.propdict:
- if self.propdict[P].flags & DD:
+ if self.propdict[P].flags & DONT_DELETE:
return False
del self.propdict[P]
return True
@@ -311,7 +311,7 @@
W_PrimitiveObject.__init__(self, ctx, Prototype, Class, Value, callfunc)
if self.length != -1:
- self.Put(ctx, 'length', W_IntNumber(self.length), flags = DE|DD|RO)
+ self.Put(ctx, 'length', W_IntNumber(self.length), flags = DONT_ENUM|DONT_DELETE|READ_ONLY)
def Call(self, ctx, args=[], this = None):
@@ -369,7 +369,7 @@
def __init__(self, ctx=None, Prototype=None, Class='Array',
Value=w_Undefined, callfunc=None):
W_ListObject.__init__(self, ctx, Prototype, Class, Value, callfunc)
- self.Put(ctx, 'length', W_IntNumber(0), flags = DD)
+ self.Put(ctx, 'length', W_IntNumber(0), flags = DONT_DELETE)
self.length = r_uint(0)
def set_length(self, newlength):
@@ -448,7 +448,7 @@
def ToObject(self, ctx):
o = create_object(ctx, 'String', Value=self)
- o.Put(ctx, 'length', W_IntNumber(len(self.strval)), flags = RO|DD|DE)
+ o.Put(ctx, 'length', W_IntNumber(len(self.strval)), flags = READ_ONLY | DONT_DELETE | DONT_ENUM)
return o
def ToString(self, ctx=None):
@@ -624,7 +624,7 @@
proto = ctx.get_global().Get(ctx, prototypename).Get(ctx, 'prototype')
obj = W_Object(ctx, callfunc = callfunc,Prototype=proto,
Class = proto.Class, Value = Value)
- obj.Put(ctx, '__proto__', proto, DE|DD|RO)
+ obj.Put(ctx, '__proto__', proto, DONT_ENUM | DONT_DELETE | READ_ONLY)
return obj
def isnull_or_undefined(obj):
diff --git a/js/opcodes.py b/js/opcodes.py
--- a/js/opcodes.py
+++ b/js/opcodes.py
@@ -176,7 +176,7 @@
callfunc=self.funcobj)
w_func.Put(ctx, 'length', W_IntNumber(len(self.funcobj.params)))
w_obj = create_object(ctx, 'Object')
- w_obj.Put(ctx, 'constructor', w_func, flags = jsobj.DE)
+ w_obj.Put(ctx, 'constructor', w_func, flags = jsobj.DONT_ENUM)
w_func.Put(ctx, 'prototype', w_obj)
ctx.append(w_func)
@@ -468,7 +468,7 @@
w_func = W_Object(ctx=ctx, Prototype=proto, Class='Function', callfunc=self.funcobj)
w_func.Put(ctx, 'length', W_IntNumber(len(self.funcobj.params)))
w_obj = create_object(ctx, 'Object')
- w_obj.Put(ctx, 'constructor', w_func, flags = jsobj.DE)
+ w_obj.Put(ctx, 'constructor', w_func, flags = jsobj.DONT_ENUM)
w_func.Put(ctx, 'prototype', w_obj)
if self.funcobj.name is not None:
ctx.put(self.funcobj.name, w_func)
@@ -594,7 +594,7 @@
_stack_change = 0
def eval(self, ctx):
obj = ctx.pop().ToObject(ctx)
- props = [prop.value for prop in obj.propdict.values() if not prop.flags & jsobj.DE]
+ props = [prop.value for prop in obj.propdict.values() if not prop.flags & jsobj.DONT_ENUM]
ctx.append(W_Iterator(props))
class JUMP_IF_ITERATOR_EMPTY(BaseJump):
More information about the pypy-commit
mailing list