Changeset 185432 in webkit
- Timestamp:
- Jun 10, 2015, 3:32:36 PM (11 years ago)
- Location:
- trunk
- Files:
-
- 3 added
- 7 edited
-
LayoutTests/ChangeLog (modified) (1 diff)
-
LayoutTests/js/Object-getOwnPropertyNames-expected.txt (modified) (1 diff)
-
LayoutTests/js/regexp-flags-expected.txt (added)
-
LayoutTests/js/regexp-flags.html (added)
-
LayoutTests/js/script-tests/Object-getOwnPropertyNames.js (modified) (1 diff)
-
LayoutTests/js/script-tests/regexp-flags.js (added)
-
Source/JavaScriptCore/ChangeLog (modified) (1 diff)
-
Source/JavaScriptCore/runtime/CommonIdentifiers.h (modified) (1 diff)
-
Source/JavaScriptCore/runtime/RegExpPrototype.cpp (modified) (5 diffs)
-
Source/JavaScriptCore/tests/stress/static-getter-in-names.js (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r185430 r185432 1 2015-06-10 Jordan Harband <ljharb@gmail.com> 2 3 Implement RegExp.prototype.flags 4 https://bugs.webkit.org/show_bug.cgi?id=145599 5 6 Reviewed by Geoffrey Garen. 7 8 * js/Object-getOwnPropertyNames-expected.txt: 9 * js/regexp-flags-expected.txt: Added. 10 * js/regexp-flags.html: Added. 11 * js/script-tests/Object-getOwnPropertyNames.js: 12 * js/script-tests/regexp-flags.js: Added. 13 (.get shouldBe): 14 1 15 2015-06-10 Alex Christensen <achristensen@webkit.org> 2 16 -
trunk/LayoutTests/js/Object-getOwnPropertyNames-expected.txt
r185370 r185432 57 57 PASS getSortedOwnPropertyNames(Date.prototype) is ['constructor', 'getDate', 'getDay', 'getFullYear', 'getHours', 'getMilliseconds', 'getMinutes', 'getMonth', 'getSeconds', 'getTime', 'getTimezoneOffset', 'getUTCDate', 'getUTCDay', 'getUTCFullYear', 'getUTCHours', 'getUTCMilliseconds', 'getUTCMinutes', 'getUTCMonth', 'getUTCSeconds', 'getYear', 'setDate', 'setFullYear', 'setHours', 'setMilliseconds', 'setMinutes', 'setMonth', 'setSeconds', 'setTime', 'setUTCDate', 'setUTCFullYear', 'setUTCHours', 'setUTCMilliseconds', 'setUTCMinutes', 'setUTCMonth', 'setUTCSeconds', 'setYear', 'toDateString', 'toGMTString', 'toISOString', 'toJSON', 'toLocaleDateString', 'toLocaleString', 'toLocaleTimeString', 'toString', 'toTimeString', 'toUTCString', 'valueOf'] 58 58 PASS getSortedOwnPropertyNames(RegExp) is ['$&', "$'", '$*', '$+', '$1', '$2', '$3', '$4', '$5', '$6', '$7', '$8', '$9', '$_', '$`', 'input', 'lastMatch', 'lastParen', 'leftContext', 'length', 'multiline', 'name', 'prototype', 'rightContext'] 59 PASS getSortedOwnPropertyNames(RegExp.prototype) is ['compile', 'constructor', 'exec', ' global', 'ignoreCase', 'lastIndex', 'multiline', 'source', 'test', 'toString']59 PASS getSortedOwnPropertyNames(RegExp.prototype) is ['compile', 'constructor', 'exec', 'flags', 'global', 'ignoreCase', 'lastIndex', 'multiline', 'source', 'test', 'toString'] 60 60 PASS getSortedOwnPropertyNames(Error) is ['length', 'name', 'prototype'] 61 61 PASS getSortedOwnPropertyNames(Error.prototype) is ['constructor', 'message', 'name', 'toString'] -
trunk/LayoutTests/js/script-tests/Object-getOwnPropertyNames.js
r185370 r185432 66 66 "Date.prototype": "['constructor', 'getDate', 'getDay', 'getFullYear', 'getHours', 'getMilliseconds', 'getMinutes', 'getMonth', 'getSeconds', 'getTime', 'getTimezoneOffset', 'getUTCDate', 'getUTCDay', 'getUTCFullYear', 'getUTCHours', 'getUTCMilliseconds', 'getUTCMinutes', 'getUTCMonth', 'getUTCSeconds', 'getYear', 'setDate', 'setFullYear', 'setHours', 'setMilliseconds', 'setMinutes', 'setMonth', 'setSeconds', 'setTime', 'setUTCDate', 'setUTCFullYear', 'setUTCHours', 'setUTCMilliseconds', 'setUTCMinutes', 'setUTCMonth', 'setUTCSeconds', 'setYear', 'toDateString', 'toGMTString', 'toISOString', 'toJSON', 'toLocaleDateString', 'toLocaleString', 'toLocaleTimeString', 'toString', 'toTimeString', 'toUTCString', 'valueOf']", 67 67 "RegExp": "['$&', \"$'\", '$*', '$+', '$1', '$2', '$3', '$4', '$5', '$6', '$7', '$8', '$9', '$_', '$`', 'input', 'lastMatch', 'lastParen', 'leftContext', 'length', 'multiline', 'name', 'prototype', 'rightContext']", 68 "RegExp.prototype": "['compile', 'constructor', 'exec', ' global', 'ignoreCase', 'lastIndex', 'multiline', 'source', 'test', 'toString']",68 "RegExp.prototype": "['compile', 'constructor', 'exec', 'flags', 'global', 'ignoreCase', 'lastIndex', 'multiline', 'source', 'test', 'toString']", 69 69 "Error": "['length', 'name', 'prototype']", 70 70 "Error.prototype": "['constructor', 'message', 'name', 'toString']", -
trunk/Source/JavaScriptCore/ChangeLog
r185427 r185432 1 2015-06-10 Jordan Harband <ljharb@gmail.com> 2 3 Implement RegExp.prototype.flags 4 https://bugs.webkit.org/show_bug.cgi?id=145599 5 6 Reviewed by Geoffrey Garen. 7 Per https://people.mozilla.org/~jorendorff/es6-draft.html#sec-get-regexp.prototype.flags 8 9 * runtime/CommonIdentifiers.h: 10 * runtime/RegExpPrototype.cpp: 11 (JSC::flagsString): 12 (JSC::regExpProtoFuncToString): 13 (JSC::regExpProtoGetterFlags): 14 * tests/stress/static-getter-in-names.js: 15 1 16 2015-06-10 Filip Pizlo <fpizlo@apple.com> 2 17 -
trunk/Source/JavaScriptCore/runtime/CommonIdentifiers.h
r185322 r185432 104 104 macro(executionCount) \ 105 105 macro(exitKind) \ 106 macro(flags) \ 106 107 macro(focus) \ 107 108 macro(forEach) \ -
trunk/Source/JavaScriptCore/runtime/RegExpPrototype.cpp
r185370 r185432 48 48 static EncodedJSValue JSC_HOST_CALL regExpProtoGetterMultiline(ExecState*); 49 49 static EncodedJSValue JSC_HOST_CALL regExpProtoGetterSource(ExecState*); 50 static EncodedJSValue JSC_HOST_CALL regExpProtoGetterFlags(ExecState*); 50 51 51 52 } … … 67 68 multiline regExpProtoGetterMultiline DontEnum|Accessor 68 69 source regExpProtoGetterSource DontEnum|Accessor 70 flags regExpProtoGetterFlags DontEnum|Accessor 69 71 @end 70 72 */ … … 136 138 } 137 139 140 static inline String flagsString(ExecState *exec, JSObject* regexp) 141 { 142 char flags[4] = { 0, 0, 0, 0 }; 143 int index = 0; 144 145 JSValue globalValue = regexp->get(exec, exec->propertyNames().global); 146 if (exec->hadException()) 147 return String(); 148 JSValue ignoreCaseValue = regexp->get(exec, exec->propertyNames().ignoreCase); 149 if (exec->hadException()) 150 return String(); 151 JSValue multilineValue = regexp->get(exec, exec->propertyNames().multiline); 152 if (exec->hadException()) 153 return String(); 154 155 if (globalValue.toBoolean(exec)) 156 flags[index++] = 'g'; 157 if (ignoreCaseValue.toBoolean(exec)) 158 flags[index++] = 'i'; 159 if (multilineValue.toBoolean(exec)) 160 flags[index] = 'm'; 161 return String(flags); 162 } 163 138 164 EncodedJSValue JSC_HOST_CALL regExpProtoFuncToString(ExecState* exec) 139 165 { … … 148 174 return JSValue::encode(earlyReturnValue); 149 175 150 char postfix[5] = { '/', 0, 0, 0, 0 }; 151 int index = 1; 152 if (thisObject->get(exec, exec->propertyNames().global).toBoolean(exec)) 153 postfix[index++] = 'g'; 154 if (thisObject->get(exec, exec->propertyNames().ignoreCase).toBoolean(exec)) 155 postfix[index++] = 'i'; 156 if (thisObject->get(exec, exec->propertyNames().multiline).toBoolean(exec)) 157 postfix[index] = 'm'; 158 String source = thisObject->get(exec, exec->propertyNames().source).toString(exec)->value(exec); 176 JSValue sourceValue = thisObject->get(exec, exec->propertyNames().source); 177 if (exec->hadException()) 178 return JSValue::encode(jsUndefined()); 179 String source = sourceValue.toString(exec)->value(exec); 180 if (exec->hadException()) 181 return JSValue::encode(jsUndefined()); 182 183 String flags = flagsString(exec, thisObject); 184 if (exec->hadException()) 185 return JSValue::encode(jsUndefined()); 186 159 187 // If source is empty, use "/(?:)/" to avoid colliding with comment syntax 160 return JSValue::encode(jsMakeNontrivialString(exec, "/", source, postfix));188 return JSValue::encode(jsMakeNontrivialString(exec, "/", source, "/", flags)); 161 189 } 162 190 … … 187 215 return JSValue::encode(jsBoolean(asRegExpObject(thisValue)->regExp()->multiline())); 188 216 } 217 218 EncodedJSValue JSC_HOST_CALL regExpProtoGetterFlags(ExecState* exec) 219 { 220 JSValue thisValue = exec->thisValue(); 221 if (!thisValue.isObject()) 222 return JSValue::encode(throwTypeError(exec)); 223 224 String flagsStr = flagsString(exec, asObject(thisValue)); 225 if (exec->hadException()) 226 return JSValue::encode(jsUndefined()); 227 228 JSValue flags = jsMakeNontrivialString(exec, flagsStr); 229 return JSValue::encode(flags); 230 } 231 189 232 190 233 template <typename CharacterType> -
trunk/Source/JavaScriptCore/tests/stress/static-getter-in-names.js
r185370 r185432 4 4 } 5 5 6 shouldBe(JSON.stringify(Object.getOwnPropertyNames(RegExp.prototype).sort()), '["compile","constructor","exec"," global","ignoreCase","lastIndex","multiline","source","test","toString"]');6 shouldBe(JSON.stringify(Object.getOwnPropertyNames(RegExp.prototype).sort()), '["compile","constructor","exec","flags","global","ignoreCase","lastIndex","multiline","source","test","toString"]'); 7 7 shouldBe(JSON.stringify(Object.getOwnPropertyNames(/Cocoa/).sort()), '["lastIndex"]');
Note:
See TracChangeset
for help on using the changeset viewer.