mirror of
https://github.com/servo/servo.git
synced 2025-07-25 08:10:21 +01:00
Mark @@iterator as nonenumerable
This commit is contained in:
parent
c5d6bb604d
commit
1c717bc086
5 changed files with 15 additions and 48 deletions
|
@ -1633,6 +1633,7 @@ class MethodDefiner(PropertyDefiner):
|
|||
self.regular = [{"name": m.identifier.name,
|
||||
"methodInfo": not m.isStatic(),
|
||||
"length": methodLength(m),
|
||||
"flags": "JSPROP_ENUMERATE",
|
||||
"condition": PropertyDefiner.getControllingCondition(m, descriptor)}
|
||||
for m in methods]
|
||||
|
||||
|
@ -1642,6 +1643,7 @@ class MethodDefiner(PropertyDefiner):
|
|||
"methodInfo": False,
|
||||
"selfHostedName": "ArrayValues",
|
||||
"length": 0,
|
||||
"flags": "0", # Not enumerable, per spec.
|
||||
"condition": "Condition::Satisfied"})
|
||||
|
||||
# Generate the keys/values/entries aliases for value iterables.
|
||||
|
@ -1656,6 +1658,7 @@ class MethodDefiner(PropertyDefiner):
|
|||
"methodInfo": False,
|
||||
"selfHostedName": "ArrayKeys",
|
||||
"length": 0,
|
||||
"flags": "JSPROP_ENUMERATE",
|
||||
"condition": PropertyDefiner.getControllingCondition(m,
|
||||
descriptor)
|
||||
})
|
||||
|
@ -1664,6 +1667,7 @@ class MethodDefiner(PropertyDefiner):
|
|||
"methodInfo": False,
|
||||
"selfHostedName": "ArrayValues",
|
||||
"length": 0,
|
||||
"flags": "JSPROP_ENUMERATE",
|
||||
"condition": PropertyDefiner.getControllingCondition(m,
|
||||
descriptor)
|
||||
})
|
||||
|
@ -1672,6 +1676,7 @@ class MethodDefiner(PropertyDefiner):
|
|||
"methodInfo": False,
|
||||
"selfHostedName": "ArrayEntries",
|
||||
"length": 0,
|
||||
"flags": "JSPROP_ENUMERATE",
|
||||
"condition": PropertyDefiner.getControllingCondition(m,
|
||||
descriptor)
|
||||
})
|
||||
|
@ -1680,6 +1685,7 @@ class MethodDefiner(PropertyDefiner):
|
|||
"methodInfo": False,
|
||||
"selfHostedName": "ArrayForEach",
|
||||
"length": 1,
|
||||
"flags": "JSPROP_ENUMERATE",
|
||||
"condition": PropertyDefiner.getControllingCondition(m,
|
||||
descriptor)
|
||||
})
|
||||
|
@ -1692,6 +1698,7 @@ class MethodDefiner(PropertyDefiner):
|
|||
"name": "toString",
|
||||
"nativeName": stringifier.identifier.name,
|
||||
"length": 0,
|
||||
"flags": "JSPROP_ENUMERATE",
|
||||
"condition": PropertyDefiner.getControllingCondition(stringifier, descriptor)
|
||||
})
|
||||
self.unforgeable = unforgeable
|
||||
|
@ -1703,13 +1710,10 @@ class MethodDefiner(PropertyDefiner):
|
|||
def condition(m, d):
|
||||
return m["condition"]
|
||||
|
||||
flags = "JSPROP_ENUMERATE"
|
||||
if self.unforgeable:
|
||||
flags += " | JSPROP_PERMANENT | JSPROP_READONLY"
|
||||
|
||||
def specData(m):
|
||||
# TODO: Use something like JS_FNSPEC
|
||||
# https://github.com/servo/servo/issues/6391
|
||||
flags = m["flags"]
|
||||
if self.unforgeable:
|
||||
flags += " | JSPROP_PERMANENT | JSPROP_READONLY"
|
||||
if "selfHostedName" in m:
|
||||
selfHostedName = '%s as *const u8 as *const libc::c_char' % str_to_const_array(m["selfHostedName"])
|
||||
assert not m.get("methodInfo", True)
|
||||
|
@ -3071,12 +3075,14 @@ assert!((*cache)[PrototypeList::Constructor::%(id)s as usize].is_null());
|
|||
symbolJSID=symbolJSID))
|
||||
defineFn = "JS_DefinePropertyById2"
|
||||
prop = "iteratorId.handle()"
|
||||
enumFlags = "0" # Not enumerable, per spec.
|
||||
elif alias.startswith("@@"):
|
||||
raise TypeError("Can't handle any well-known Symbol other than @@iterator")
|
||||
else:
|
||||
getSymbolJSID = None
|
||||
defineFn = "JS_DefineProperty"
|
||||
prop = '"%s"' % alias
|
||||
enumFlags = "JSPROP_ENUMERATE"
|
||||
return CGList([
|
||||
getSymbolJSID,
|
||||
# XXX If we ever create non-enumerable properties that can
|
||||
|
@ -3085,10 +3091,11 @@ assert!((*cache)[PrototypeList::Constructor::%(id)s as usize].is_null());
|
|||
CGGeneric(fill(
|
||||
"""
|
||||
assert!(${defineFn}(*cx, prototype.handle(), ${prop}, aliasedVal.handle(),
|
||||
JSPROP_ENUMERATE as u32));
|
||||
${enumFlags} as u32));
|
||||
""",
|
||||
defineFn=defineFn,
|
||||
prop=prop))
|
||||
prop=prop,
|
||||
enumFlags=enumFlags))
|
||||
], "\n")
|
||||
|
||||
def defineAliasesFor(m):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue