inline RegExpFlags toFlags(ExecState* exec, JSValue flags) { VM& vm = exec->vm(); auto scope = DECLARE_THROW_SCOPE(vm); if (flags.isUndefined()) return NoFlags; JSString* flagsString = flags.toStringOrNull(exec); ASSERT(!!scope.exception() == !flagsString); if (UNLIKELY(!flagsString)) return InvalidFlags; RegExpFlags result = regExpFlags(flagsString->value(exec)); RETURN_IF_EXCEPTION(scope, InvalidFlags); if (result == InvalidFlags) throwSyntaxError(exec, scope, ASCIILiteral("Invalid flags supplied to RegExp constructor.")); return result; }