lib: drop unnecessary new and const

CoreLibraryReviewExempt: no API changes
TEST=no behavior changes
Change-Id: Ibef80bbfb000026042e562014b672258a5f1860d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/419761
Reviewed-by: Lasse Nielsen <lrn@google.com>
Reviewed-by: Liam Appelbe <liama@google.com>
Commit-Queue: Kevin Moore <kevmoo@google.com>
This commit is contained in:
Kevin Moore
2025-04-02 09:28:41 -07:00
committed by Commit Queue
parent b18df098e7
commit dc7e9dac2e
88 changed files with 1347 additions and 1441 deletions
+4 -4
View File
@@ -189,7 +189,7 @@ void _requestPackagesMap(Uri? packageConfig) {
assert(msg.length >= 2);
assert(msg[1] == null);
_packageConfig = Uri.parse(msg[0]);
final pmap = new Map<String, Uri>();
final pmap = Map<String, Uri>();
_packageMap = pmap;
for (var i = 2; i < msg.length; i += 2) {
// TODO(iposva): Complain about duplicate entries.
@@ -335,7 +335,7 @@ _findPackagesConfiguration(bool traceLoading, Uri base) {
// of
// - .packages (preferred)
// - .dart_tool/package_config.json
var currentDir = new File.fromUri(base).parent;
var currentDir = File.fromUri(base).parent;
while (true) {
final dirUri = currentDir.uri;
@@ -497,7 +497,7 @@ void _Init(
_setupHooks();
// _workingDirectory must be set first.
_workingDirectory = new Uri.directory(workingDirectory);
_workingDirectory = Uri.directory(workingDirectory);
// setup _rootScript.
if (rootScript != null) {
@@ -521,7 +521,7 @@ void _setWorkingDirectory(String cwd) {
if (_traceLoading) {
_log('Setting working directory: $cwd');
}
_workingDirectory = new Uri.directory(cwd);
_workingDirectory = Uri.directory(cwd);
if (_traceLoading) {
_log('Working directory URI: $_workingDirectory');
}
@@ -53,7 +53,7 @@ class _Directory {
class _AsyncDirectoryListerOps {
@patch
factory _AsyncDirectoryListerOps(int pointer) =>
new _AsyncDirectoryListerOpsImpl(pointer);
_AsyncDirectoryListerOpsImpl(pointer);
}
base class _AsyncDirectoryListerOpsImpl extends NativeFieldWrapperClass1
@@ -61,7 +61,7 @@ base class _AsyncDirectoryListerOpsImpl extends NativeFieldWrapperClass1
_AsyncDirectoryListerOpsImpl._();
factory _AsyncDirectoryListerOpsImpl(int pointer) =>
new _AsyncDirectoryListerOpsImpl._().._setPointer(pointer);
_AsyncDirectoryListerOpsImpl._().._setPointer(pointer);
@pragma("vm:external-name", "Directory_SetAsyncDirectoryListerPointer")
external void _setPointer(int pointer);
@@ -79,13 +79,13 @@ Uri _uriBaseClosure() {
}
var result = _Directory._current(_Namespace._namespace);
if (result is OSError) {
throw new FileSystemException._fromOSError(
throw FileSystemException._fromOSError(
result,
"Getting current working directory failed",
"",
);
}
return new Uri.directory(result as String);
return Uri.directory(result as String);
}
@pragma("vm:entry-point", "call")
+21 -25
View File
@@ -91,7 +91,7 @@ class _File {
class _RandomAccessFileOps {
@patch
factory _RandomAccessFileOps(int pointer) =>
new _RandomAccessFileOpsImpl(pointer);
_RandomAccessFileOpsImpl(pointer);
}
@pragma("vm:entry-point")
@@ -100,7 +100,7 @@ base class _RandomAccessFileOpsImpl extends NativeFieldWrapperClass1
_RandomAccessFileOpsImpl._();
factory _RandomAccessFileOpsImpl(int pointer) =>
new _RandomAccessFileOpsImpl._().._setPointer(pointer);
_RandomAccessFileOpsImpl._().._setPointer(pointer);
@pragma("vm:external-name", "File_SetPointer")
external void _setPointer(int pointer);
@@ -156,7 +156,7 @@ abstract class _FileSystemWatcher {
_WatcherPath? _watcherPath;
final StreamController<FileSystemEvent> _broadcastController =
new StreamController<FileSystemEvent>.broadcast();
StreamController<FileSystemEvent>.broadcast();
/// Subscription on the stream returned by [_watchPath].
///
@@ -171,26 +171,22 @@ abstract class _FileSystemWatcher {
bool recursive,
) {
if (Platform.isLinux || Platform.isAndroid) {
return new _InotifyFileSystemWatcher(path, events, recursive)._stream;
return _InotifyFileSystemWatcher(path, events, recursive)._stream;
}
if (Platform.isWindows) {
return new _Win32FileSystemWatcher(path, events, recursive)._stream;
return _Win32FileSystemWatcher(path, events, recursive)._stream;
}
if (Platform.isMacOS) {
return new _FSEventStreamFileSystemWatcher(
path,
events,
recursive,
)._stream;
return _FSEventStreamFileSystemWatcher(path, events, recursive)._stream;
}
throw new FileSystemException(
throw FileSystemException(
"File system watching is not supported on this platform",
);
}
_FileSystemWatcher._(this._path, this._events, this._recursive) {
if (!isSupported) {
throw new FileSystemException(
throw FileSystemException(
"File system watching is not supported on this platform",
_path,
);
@@ -236,7 +232,7 @@ abstract class _FileSystemWatcher {
return;
}
if (!_idMap.containsKey(pathId)) {
_idMap[pathId] = new _WatcherPath(pathId, _path, _events);
_idMap[pathId] = _WatcherPath(pathId, _path, _events);
}
_watcherPath = _idMap[pathId];
_watcherPath!.count++;
@@ -324,9 +320,9 @@ abstract class _FileSystemWatcher {
void rewriteMove(event, isDir) {
if (event[3]) {
add(event[4], new FileSystemCreateEvent(getPath(event), isDir));
add(event[4], FileSystemCreateEvent(getPath(event), isDir));
} else {
add(event[4], new FileSystemDeleteEvent(getPath(event), false));
add(event[4], FileSystemDeleteEvent(getPath(event), false));
}
}
@@ -344,13 +340,13 @@ abstract class _FileSystemWatcher {
bool isDir = getIsDir(event);
var path = getPath(event);
if ((event[0] & FileSystemEvent.create) != 0) {
add(event[4], new FileSystemCreateEvent(path, isDir));
add(event[4], FileSystemCreateEvent(path, isDir));
}
if ((event[0] & FileSystemEvent.modify) != 0) {
add(event[4], new FileSystemModifyEvent(path, isDir, true));
add(event[4], FileSystemModifyEvent(path, isDir, true));
}
if ((event[0] & FileSystemEvent._modifyAttributes) != 0) {
add(event[4], new FileSystemModifyEvent(path, isDir, false));
add(event[4], FileSystemModifyEvent(path, isDir, false));
}
if ((event[0] & FileSystemEvent.move) != 0) {
int link = event[1];
@@ -359,7 +355,7 @@ abstract class _FileSystemWatcher {
if (pair[pathId].containsKey(link)) {
add(
event[4],
new FileSystemMoveEvent(
FileSystemMoveEvent(
getPath(pair[pathId][link]),
isDir,
path,
@@ -374,10 +370,10 @@ abstract class _FileSystemWatcher {
}
}
if ((event[0] & FileSystemEvent.delete) != 0) {
add(event[4], new FileSystemDeleteEvent(path, false));
add(event[4], FileSystemDeleteEvent(path, false));
}
if ((event[0] & FileSystemEvent._deleteSelf) != 0) {
add(event[4], new FileSystemDeleteEvent(path, false));
add(event[4], FileSystemDeleteEvent(path, false));
// Signal done event.
stops.add([event[4], null]);
}
@@ -479,7 +475,7 @@ class _InotifyFileSystemWatcher extends _FileSystemWatcher {
Stream<FileSystemEvent> _pathWatched() {
var pathId = _watcherPath!.pathId;
if (!_idMap.containsKey(pathId)) {
_idMap[pathId] = new StreamController<FileSystemEvent>.broadcast();
_idMap[pathId] = StreamController<FileSystemEvent>.broadcast();
}
return _idMap[pathId]!.stream;
}
@@ -501,7 +497,7 @@ class _Win32FileSystemWatcher extends _FileSystemWatcher {
Stream<FileSystemEvent> _pathWatched() {
var pathId = _watcherPath!.pathId;
_controller = new StreamController<FileSystemEvent>();
_controller = StreamController<FileSystemEvent>();
_subscription = _FileSystemWatcher._listenOnSocket(
pathId,
0,
@@ -533,7 +529,7 @@ class _FSEventStreamFileSystemWatcher extends _FileSystemWatcher {
Stream<FileSystemEvent> _pathWatched() {
var pathId = _watcherPath!.pathId;
var socketId = _FileSystemWatcher._getSocketId(0, pathId);
_controller = new StreamController<FileSystemEvent>();
_controller = StreamController<FileSystemEvent>();
_subscription = _FileSystemWatcher._listenOnSocket(
socketId,
0,
@@ -556,5 +552,5 @@ class _FSEventStreamFileSystemWatcher extends _FileSystemWatcher {
@pragma("vm:entry-point", "call")
Uint8List _makeUint8ListView(Uint8List source, int offsetInBytes, int length) {
return new Uint8List.view(source.buffer, offsetInBytes, length);
return Uint8List.view(source.buffer, offsetInBytes, length);
}
+2 -2
View File
@@ -66,7 +66,7 @@ class RawZLibFilter {
int strategy,
List<int>? dictionary,
bool raw,
) => new _ZLibDeflateFilter(
) => _ZLibDeflateFilter(
gzip,
level,
windowBits,
@@ -81,5 +81,5 @@ class RawZLibFilter {
int windowBits,
List<int>? dictionary,
bool raw,
) => new _ZLibInflateFilter(gzip, windowBits, dictionary, raw);
) => _ZLibInflateFilter(gzip, windowBits, dictionary, raw);
}
@@ -17,7 +17,7 @@ class _IOService {
assert(data.length == 2);
_forwardResponse(data[0] as int, data[1]);
}, 'IO Service');
static HashMap<int, Completer> _messageMap = new HashMap<int, Completer>();
static HashMap<int, Completer> _messageMap = HashMap<int, Completer>();
static int _id = 0;
@patch
@@ -26,7 +26,7 @@ class _IOService {
do {
id = _getNextId();
} while (_messageMap.containsKey(id));
final Completer completer = new Completer();
final Completer completer = Completer();
try {
if (_messageMap.isEmpty) {
// This is the first outgoing request after being in an idle state,
@@ -20,14 +20,14 @@ base class _NamespaceImpl extends NativeFieldWrapperClass1
// embedder with the platform-specific namespace information.
static _NamespaceImpl? _cachedNamespace = null;
static void _setupNamespace(var namespace) {
_cachedNamespace = _create(new _NamespaceImpl._(), namespace);
_cachedNamespace = _create(_NamespaceImpl._(), namespace);
}
static _NamespaceImpl get _namespace {
if (_cachedNamespace == null) {
// The embedder has not supplied a namespace before one is needed, so
// instead use a safe-ish default value.
_cachedNamespace = _create(new _NamespaceImpl._(), _getDefault());
_cachedNamespace = _create(_NamespaceImpl._(), _getDefault());
}
return _cachedNamespace!;
}
+1 -1
View File
@@ -60,7 +60,7 @@ class _Platform {
path.startsWith('file:')) {
return Uri.parse(path);
} else {
return Uri.base.resolveUri(new Uri.file(path));
return Uri.base.resolveUri(Uri.file(path));
}
});
}
+29 -33
View File
@@ -30,7 +30,7 @@ class Process {
bool runInShell = false,
ProcessStartMode mode = ProcessStartMode.normal,
}) {
_ProcessImpl process = new _ProcessImpl(
_ProcessImpl process = _ProcessImpl(
executable,
arguments,
workingDirectory,
@@ -96,12 +96,12 @@ class Process {
}
}
List<_SignalController?> _signalControllers = new List.filled(32, null);
List<_SignalController?> _signalControllers = List.filled(32, null);
class _SignalController {
final ProcessSignal signal;
final _controller = new StreamController<ProcessSignal>.broadcast();
final _controller = StreamController<ProcessSignal>.broadcast();
var _id;
_SignalController(this.signal) {
@@ -115,13 +115,11 @@ class _SignalController {
void _listen() {
var id = _setSignalHandler(signal.signalNumber);
if (id is! int) {
_controller.addError(
new SignalException("Failed to listen for $signal", id),
);
_controller.addError(SignalException("Failed to listen for $signal", id));
return;
}
_id = id;
var socket = new _RawSocket(new _NativeSocket.watchSignal(id));
var socket = _RawSocket(_NativeSocket.watchSignal(id));
socket.listen((event) {
if (event == RawSocketEvent.read) {
var bytes = socket.read()!;
@@ -176,16 +174,14 @@ class _ProcessUtils {
(signal != ProcessSignal.sigusr1 &&
signal != ProcessSignal.sigusr2 &&
signal != ProcessSignal.sigwinch))) {
throw new SignalException(
"Listening for signal $signal is not supported",
);
throw SignalException("Listening for signal $signal is not supported");
}
return _watchSignalInternal(signal);
}
static Stream<ProcessSignal> _watchSignalInternal(ProcessSignal signal) {
if (_signalControllers[signal.signalNumber] == null) {
_signalControllers[signal.signalNumber] = new _SignalController(signal);
_signalControllers[signal.signalNumber] = _SignalController(signal);
}
return _signalControllers[signal.signalNumber]!.stream;
}
@@ -299,14 +295,14 @@ base class _ProcessImpl extends _ProcessImplNativeWrapper implements _Process {
if (_modeHasStdio(_mode)) {
// stdin going to process.
_stdin = new _StdSink(new _Socket._writePipe().._owner = this);
_stdin = _StdSink(_Socket._writePipe().._owner = this);
// stdout coming from process.
_stdout = new _StdStream(new _Socket._readPipe().._owner = this);
_stdout = _StdStream(_Socket._readPipe().._owner = this);
// stderr coming from process.
_stderr = new _StdStream(new _Socket._readPipe().._owner = this);
_stderr = _StdStream(_Socket._readPipe().._owner = this);
}
if (_modeIsAttached(_mode)) {
_exitHandler = new _Socket._readPipe();
_exitHandler = _Socket._readPipe();
}
}
@@ -346,7 +342,7 @@ base class _ProcessImpl extends _ProcessImplNativeWrapper implements _Process {
shellArguments.add(arg);
}
} else {
var commandLine = new StringBuffer();
var commandLine = StringBuffer();
executable = executable.replaceAll("'", "'\"'\"'");
commandLine.write("'$executable'");
shellArguments.add("-c");
@@ -373,7 +369,7 @@ base class _ProcessImpl extends _ProcessImplNativeWrapper implements _Process {
// Replace any number of '\' followed by '"' with
// twice as many '\' followed by '\"'.
var backslash = '\\'.codeUnitAt(0);
var sb = new StringBuffer();
var sb = StringBuffer();
var nextPos = 0;
var quotePos = argument.indexOf('"', nextPos);
while (quotePos != -1) {
@@ -396,7 +392,7 @@ base class _ProcessImpl extends _ProcessImplNativeWrapper implements _Process {
// Add '"' at the beginning and end and replace all '\' at
// the end with two '\'.
sb = new StringBuffer('"');
sb = StringBuffer('"');
sb.write(result);
nextPos = argument.length - 1;
while (argument.codeUnitAt(nextPos) == backslash) {
@@ -418,15 +414,15 @@ base class _ProcessImpl extends _ProcessImplNativeWrapper implements _Process {
}
Future<Process> _start() {
var completer = new Completer<Process>();
var completer = Completer<Process>();
var stackTrace = StackTrace.current;
if (_modeIsAttached(_mode)) {
_exitCode = new Completer<int>();
_exitCode = Completer<int>();
}
// TODO(ager): Make the actual process starting really async instead of
// simulating it with a timer.
Timer.run(() {
var status = new _ProcessStartStatus();
var status = _ProcessStartStatus();
bool success = _startNative(
_Namespace._namespace,
_path,
@@ -442,7 +438,7 @@ base class _ProcessImpl extends _ProcessImplNativeWrapper implements _Process {
);
if (!success) {
completer.completeError(
new ProcessException(
ProcessException(
_path,
_arguments,
status._errorMessage!,
@@ -454,14 +450,14 @@ base class _ProcessImpl extends _ProcessImplNativeWrapper implements _Process {
}
_started = true;
final resourceInfo = new _SpawnedProcessResourceInfo(this);
final resourceInfo = _SpawnedProcessResourceInfo(this);
// Setup an exit handler to handle internal cleanup and possible
// callback when a process terminates.
if (_modeIsAttached(_mode)) {
int exitDataRead = 0;
final int EXIT_DATA_SIZE = 8;
List<int> exitDataBuffer = new List<int>.filled(EXIT_DATA_SIZE, 0);
List<int> exitDataBuffer = List<int>.filled(EXIT_DATA_SIZE, 0);
_exitHandler.listen((data) {
int exitCode(List<int> ints) {
var code = _intFromBytes(ints, 0);
@@ -501,8 +497,8 @@ base class _ProcessImpl extends _ProcessImplNativeWrapper implements _Process {
Encoding? stdoutEncoding,
Encoding? stderrEncoding,
) {
var status = new _ProcessStartStatus();
_exitCode = new Completer<int>();
var status = _ProcessStartStatus();
_exitCode = Completer<int>();
bool success = _startNative(
_Namespace._namespace,
_path,
@@ -517,7 +513,7 @@ base class _ProcessImpl extends _ProcessImplNativeWrapper implements _Process {
status,
);
if (!success) {
throw new ProcessException(
throw ProcessException(
_path,
_arguments,
status._errorMessage!,
@@ -525,7 +521,7 @@ base class _ProcessImpl extends _ProcessImplNativeWrapper implements _Process {
);
}
final resourceInfo = new _SpawnedProcessResourceInfo(this);
final resourceInfo = _SpawnedProcessResourceInfo(this);
var result = _wait(
_stdinNativeSocket,
@@ -541,7 +537,7 @@ base class _ProcessImpl extends _ProcessImplNativeWrapper implements _Process {
resourceInfo.stopped();
return new ProcessResult(
return ProcessResult(
result[0],
result[1],
getOutput(result[2], stdoutEncoding),
@@ -641,14 +637,14 @@ Future<ProcessResult> _runNonInteractiveProcess(
if (encoding == null) {
return stream
.fold<BytesBuilder>(
new BytesBuilder(),
BytesBuilder(),
(builder, data) => builder..add(data),
)
.then((builder) => builder.takeBytes());
} else {
return stream
.transform(encoding.decoder)
.fold<StringBuffer>(new StringBuffer(), (buf, data) {
.fold<StringBuffer>(StringBuffer(), (buf, data) {
buf.write(data);
return buf;
})
@@ -660,7 +656,7 @@ Future<ProcessResult> _runNonInteractiveProcess(
Future stderr = foldStream(p.stderr, stderrEncoding);
return Future.wait([p.exitCode, stdout, stderr]).then((result) {
return new ProcessResult(pid, result[0], result[1], result[2]);
return ProcessResult(pid, result[0], result[1], result[2]);
});
});
}
@@ -675,7 +671,7 @@ ProcessResult _runNonInteractiveProcessSync(
Encoding? stdoutEncoding,
Encoding? stderrEncoding,
) {
var process = new _ProcessImpl(
var process = _ProcessImpl(
executable,
arguments,
workingDirectory,
@@ -7,14 +7,13 @@ part of "common_patch.dart";
@patch
class SecureSocket {
@patch
factory SecureSocket._(RawSecureSocket rawSocket) =>
new _SecureSocket(rawSocket);
factory SecureSocket._(RawSecureSocket rawSocket) => _SecureSocket(rawSocket);
}
@patch
class _SecureFilter {
@patch
factory _SecureFilter._() => new _SecureFilterImpl._();
factory _SecureFilter._() => _SecureFilterImpl._();
}
@patch
@@ -22,7 +21,7 @@ class _SecureFilter {
class X509Certificate {
@patch
@pragma("vm:entry-point")
factory X509Certificate._() => new _X509CertificateImpl._();
factory X509Certificate._() => _X509CertificateImpl._();
}
class _SecureSocket extends _Socket implements SecureSocket {
@@ -38,14 +37,14 @@ class _SecureSocket extends _Socket implements SecureSocket {
X509Certificate? get peerCertificate {
if (_raw == null) {
throw new StateError("peerCertificate called on destroyed SecureSocket");
throw StateError("peerCertificate called on destroyed SecureSocket");
}
return _raw!.peerCertificate;
}
String? get selectedProtocol {
if (_raw == null) {
throw new StateError("selectedProtocol called on destroyed SecureSocket");
throw StateError("selectedProtocol called on destroyed SecureSocket");
}
return _raw!.selectedProtocol;
}
@@ -74,7 +73,7 @@ base class _SecureFilterImpl extends NativeFieldWrapperClass1
_SecureFilterImpl._() {
buffers = <_ExternalBuffer>[
for (int i = 0; i < _RawSecureSocket.bufferCount; ++i)
new _ExternalBuffer(
_ExternalBuffer(
_RawSecureSocket._isBufferEncrypted(i) ? ENCRYPTED_SIZE : SIZE,
),
];
@@ -158,9 +157,9 @@ base class _SecureFilterImpl extends NativeFieldWrapperClass1
}
}
void rehandshake() => throw new UnimplementedError();
void rehandshake() => throw UnimplementedError();
int processBuffer(int bufferIndex) => throw new UnimplementedError();
int processBuffer(int bufferIndex) => throw UnimplementedError();
@pragma("vm:external-name", "SecureSocket_GetSelectedProtocol")
external String? selectedProtocol();
@@ -203,7 +202,7 @@ base class _SecureFilterImpl extends NativeFieldWrapperClass1
class SecurityContext {
@patch
factory SecurityContext({bool withTrustedRoots = false}) {
return new _SecurityContext(withTrustedRoots);
return _SecurityContext(withTrustedRoots);
}
@patch
@@ -245,10 +244,10 @@ base class _SecurityContext extends NativeFieldWrapperClass1
@pragma("vm:external-name", "SecurityContext_Allocate")
external void _createNativeContext();
static final SecurityContext defaultContext = new _SecurityContext(true);
static final SecurityContext defaultContext = _SecurityContext(true);
void usePrivateKey(String file, {String? password}) {
List<int> bytes = (new File(file)).readAsBytesSync();
List<int> bytes = (File(file)).readAsBytesSync();
usePrivateKeyBytes(bytes, password: password);
}
@@ -256,7 +255,7 @@ base class _SecurityContext extends NativeFieldWrapperClass1
external void usePrivateKeyBytes(List<int> keyBytes, {String? password});
void setTrustedCertificates(String file, {String? password}) {
List<int> bytes = (new File(file)).readAsBytesSync();
List<int> bytes = (File(file)).readAsBytesSync();
setTrustedCertificatesBytes(bytes, password: password);
}
@@ -267,7 +266,7 @@ base class _SecurityContext extends NativeFieldWrapperClass1
});
void useCertificateChain(String file, {String? password}) {
List<int> bytes = (new File(file)).readAsBytesSync();
List<int> bytes = (File(file)).readAsBytesSync();
useCertificateChainBytes(bytes, password: password);
}
@@ -278,7 +277,7 @@ base class _SecurityContext extends NativeFieldWrapperClass1
});
void setClientAuthorities(String file, {String? password}) {
List<int> bytes = (new File(file)).readAsBytesSync();
List<int> bytes = (File(file)).readAsBytesSync();
setClientAuthoritiesBytes(bytes, password: password);
}
@@ -334,14 +333,11 @@ base class _X509CertificateImpl extends NativeFieldWrapperClass1
@pragma("vm:external-name", "X509_Issuer")
external String get issuer;
DateTime get startValidity {
return new DateTime.fromMillisecondsSinceEpoch(
_startValidity(),
isUtc: true,
);
return DateTime.fromMillisecondsSinceEpoch(_startValidity(), isUtc: true);
}
DateTime get endValidity {
return new DateTime.fromMillisecondsSinceEpoch(_endValidity(), isUtc: true);
return DateTime.fromMillisecondsSinceEpoch(_endValidity(), isUtc: true);
}
@pragma("vm:external-name", "X509_StartValidity")
+60 -62
View File
@@ -141,7 +141,7 @@ void _throwOnBadPort(int port) {
// TODO(40614): Remove once non-nullability is sound.
ArgumentError.checkNotNull(port, "port");
if ((port < 0) || (port > 0xFFFF)) {
throw new ArgumentError("Invalid port $port");
throw ArgumentError("Invalid port $port");
}
}
@@ -149,7 +149,7 @@ void _throwOnBadTtl(int ttl) {
// TODO(40614): Remove once non-nullability is sound.
ArgumentError.checkNotNull(ttl, "ttl");
if (ttl < 1 || ttl > 255) {
throw new ArgumentError('Invalid ttl $ttl');
throw ArgumentError('Invalid ttl $ttl');
}
}
@@ -178,7 +178,7 @@ class _InternetAddress implements InternetAddress {
String get host => _host ?? address;
Uint8List get rawAddress => new Uint8List.fromList(_in_addr);
Uint8List get rawAddress => Uint8List.fromList(_in_addr);
bool get isLoopback {
switch (type) {
@@ -194,7 +194,7 @@ class _InternetAddress implements InternetAddress {
case InternetAddressType.unix:
return false;
}
throw new UnsupportedError("Unexpected address type $type");
throw UnsupportedError("Unexpected address type $type");
}
bool get isLinkLocal {
@@ -210,7 +210,7 @@ class _InternetAddress implements InternetAddress {
case InternetAddressType.unix:
return false;
}
throw new UnsupportedError("Unexpected address type $type");
throw UnsupportedError("Unexpected address type $type");
}
bool get isMulticast {
@@ -226,7 +226,7 @@ class _InternetAddress implements InternetAddress {
case InternetAddressType.unix:
return false;
}
throw new UnsupportedError("Unexpected address type $type");
throw UnsupportedError("Unexpected address type $type");
}
Future<InternetAddress> reverse() {
@@ -528,10 +528,8 @@ base class _NativeSocket extends _NativeSocketNativeWrapper
static const int normalTokenBatchSize = 8;
static const int listeningTokenBatchSize = 2;
static const Duration _retryDuration = const Duration(milliseconds: 250);
static const Duration _retryDurationLoopback = const Duration(
milliseconds: 25,
);
static const Duration _retryDuration = Duration(milliseconds: 250);
static const Duration _retryDurationLoopback = Duration(milliseconds: 25);
// Socket close state
bool isClosed = false;
@@ -539,7 +537,7 @@ base class _NativeSocket extends _NativeSocketNativeWrapper
bool isClosedRead = false;
bool closedReadEventSent = false;
bool isClosedWrite = false;
Completer closeCompleter = new Completer.sync();
Completer closeCompleter = Completer.sync();
// Handlers and receive port for socket events from the event handler.
void Function()? readEventHandler;
@@ -633,7 +631,7 @@ base class _NativeSocket extends _NativeSocketNativeWrapper
throw createError(response, "Failed listing interfaces");
} else {
var map = (response as List).skip(1).fold(
new Map<String, NetworkInterface>(),
Map<String, NetworkInterface>(),
(map, result) {
List<Object?> resultList = result as List<Object?>;
var type = InternetAddressType._from(resultList[0] as int);
@@ -647,7 +645,7 @@ base class _NativeSocket extends _NativeSocketNativeWrapper
);
if (!includeLinkLocal && address.isLinkLocal) return map;
if (!includeLoopback && address.isLoopback) return map;
map.putIfAbsent(name, () => new _NetworkInterface(name, index));
map.putIfAbsent(name, () => _NetworkInterface(name, index));
(map[name] as _NetworkInterface).addresses.add(address);
return map;
},
@@ -665,7 +663,7 @@ base class _NativeSocket extends _NativeSocketNativeWrapper
if (!checkLinkLocalAddress(host)) {
// The only well defined usage is link-local address. Checks Section 4 of https://tools.ietf.org/html/rfc6874.
// If it is not a valid link-local address and contains escape character, throw an exception.
throw new FormatException(
throw FormatException(
'${host} is not a valid link-local address but contains %. Scope id should be used as part of link-local address.',
host,
index,
@@ -811,7 +809,7 @@ base class _NativeSocket extends _NativeSocketNativeWrapper
}
source = sourceAddress;
} else if (sourceAddress is String) {
source = new _InternetAddress.fromString(sourceAddress);
source = _InternetAddress.fromString(sourceAddress);
} else {
throw ArgumentError.value(
sourceAddress,
@@ -823,7 +821,7 @@ base class _NativeSocket extends _NativeSocketNativeWrapper
final stackTrace = StackTrace.current;
return new Future.value(host).then<ConnectionTask<_NativeSocket>>((host) {
return Future.value(host).then<ConnectionTask<_NativeSocket>>((host) {
if (host is String) {
// Attempt to interpret the host as a numeric address
// (e.g. "127.0.0.1"). This will prevent [InternetAddress.lookup] from
@@ -868,7 +866,7 @@ base class _NativeSocket extends _NativeSocketNativeWrapper
StackTrace callerStackTrace,
) {
// Completer for result.
final result = new Completer<_NativeSocket>();
final result = Completer<_NativeSocket>();
// Error, set if an error occurs.
// Keeps first error if multiple errors occur.
var error = null;
@@ -1012,7 +1010,7 @@ base class _NativeSocket extends _NativeSocketNativeWrapper
return;
}
final address = pendingLookedUp.removeFirst();
final socket = new _NativeSocket.normal(address);
final socket = _NativeSocket.normal(address);
// Will contain values of various types representing the result
// of trying to create a connection.
// A value of `true` means success, everything else means failure.
@@ -1049,7 +1047,7 @@ base class _NativeSocket extends _NativeSocketNativeWrapper
// succeed or fail later.
final duration =
address.isLoopback ? _retryDurationLoopback : _retryDuration;
timer = new Timer(duration, connectNext);
timer = Timer(duration, connectNext);
connecting.add(socket);
// Setup handlers for receiving the first write event which
// indicate that the socket is fully connected.
@@ -1136,7 +1134,7 @@ base class _NativeSocket extends _NativeSocketNativeWrapper
);
connectNext();
return new ConnectionTask<_NativeSocket>._(result.future, onCancel);
return ConnectionTask<_NativeSocket>._(result.future, onCancel);
}
static Future<_NativeSocket> connect(
@@ -1196,7 +1194,7 @@ base class _NativeSocket extends _NativeSocketNativeWrapper
}
final address = await _resolveHost(host);
var socket = new _NativeSocket.listen(address);
var socket = _NativeSocket.listen(address);
var result;
if (address.type == InternetAddressType.unix) {
var path = address.address;
@@ -1220,7 +1218,7 @@ base class _NativeSocket extends _NativeSocketNativeWrapper
);
}
if (result is OSError) {
throw new SocketException(
throw SocketException(
"Failed to create server socket",
osError: result,
address: address,
@@ -1244,7 +1242,7 @@ base class _NativeSocket extends _NativeSocketNativeWrapper
final address = await _resolveHost(host);
var socket = new _NativeSocket.datagram(address);
var socket = _NativeSocket.datagram(address);
var result = socket.nativeCreateBindDatagram(
address._in_addr,
port,
@@ -1253,7 +1251,7 @@ base class _NativeSocket extends _NativeSocketNativeWrapper
ttl,
);
if (result is OSError) {
throw new SocketException(
throw SocketException(
"Failed to create datagram socket",
osError: result,
address: address,
@@ -1295,8 +1293,8 @@ base class _NativeSocket extends _NativeSocketNativeWrapper
bool get isTcp => (typeFlags & typeTcpSocket) != 0;
bool get isUdp => (typeFlags & typeUdpSocket) != 0;
String get _serviceTypePath => throw new UnimplementedError();
String get _serviceTypeName => throw new UnimplementedError();
String get _serviceTypePath => throw UnimplementedError();
String get _serviceTypeName => throw UnimplementedError();
Uint8List? read(int? count) {
if (count != null && count <= 0) {
@@ -1431,14 +1429,14 @@ base class _NativeSocket extends _NativeSocketNativeWrapper
offset = _fixOffset(offset);
if (bytes == null) {
if (offset > buffer.length) {
throw new RangeError.value(offset);
throw RangeError.value(offset);
}
bytes = buffer.length - offset;
}
if (offset < 0) throw new RangeError.value(offset);
if (bytes < 0) throw new RangeError.value(bytes);
if (offset < 0) throw RangeError.value(offset);
if (bytes < 0) throw RangeError.value(bytes);
if ((offset + bytes) > buffer.length) {
throw new RangeError.value(offset + bytes);
throw RangeError.value(offset + bytes);
}
if (isClosing || isClosed) return 0;
if (bytes == 0) return 0;
@@ -1526,14 +1524,14 @@ base class _NativeSocket extends _NativeSocketNativeWrapper
int? bytes,
List<SocketControlMessage> controlMessages,
) {
if (offset < 0) throw new RangeError.value(offset);
if (offset < 0) throw RangeError.value(offset);
if (bytes != null) {
if (bytes < 0) throw new RangeError.value(bytes);
if (bytes < 0) throw RangeError.value(bytes);
} else {
bytes = buffer.length - offset;
}
if ((offset + bytes) > buffer.length) {
throw new RangeError.value(offset + bytes);
throw RangeError.value(offset + bytes);
}
if (isClosing || isClosed) return 0;
try {
@@ -1577,7 +1575,7 @@ base class _NativeSocket extends _NativeSocketNativeWrapper
connections--;
tokens++;
returnTokens(listeningTokenBatchSize);
var socket = new _NativeSocket.normal(address);
var socket = _NativeSocket.normal(address);
if (nativeAccept(socket) != true) return null;
socket.localPort = localPort;
return socket;
@@ -1606,7 +1604,7 @@ base class _NativeSocket extends _NativeSocketNativeWrapper
if (isClosing || isClosed) throw const SocketException.closed();
var result = nativeGetRemotePeer();
var addr = result[0] as List<Object?>;
var type = new InternetAddressType._from(addr[0] as int);
var type = InternetAddressType._from(addr[0] as int);
if (type == InternetAddressType.unix) {
return _InternetAddress.fromString(
addr[1] as String,
@@ -1835,7 +1833,7 @@ base class _NativeSocket extends _NativeSocketNativeWrapper
close();
break;
default:
throw new ArgumentError(direction);
throw ArgumentError(direction);
}
}
}
@@ -1875,7 +1873,7 @@ base class _NativeSocket extends _NativeSocketNativeWrapper
void connectToEventHandler() {
assert(!isClosed);
if (eventPort == null) {
eventPort = new RawReceivePort(multiplex, 'Socket Event Handler');
eventPort = RawReceivePort(multiplex, 'Socket Event Handler');
}
}
@@ -1988,7 +1986,7 @@ base class _NativeSocket extends _NativeSocketNativeWrapper
}
}
// No IPv4 address found on the interface.
throw new SocketException(
throw SocketException(
"The network interface does not have an address "
"of the same family as the multicast address",
);
@@ -2152,14 +2150,14 @@ class _RawServerSocket extends Stream<RawSocket>
bool shared,
) {
_throwOnBadPort(port);
if (backlog < 0) throw new ArgumentError("Invalid backlog $backlog");
if (backlog < 0) throw ArgumentError("Invalid backlog $backlog");
return _NativeSocket.bind(
address,
port,
backlog,
v6Only,
shared,
).then((socket) => new _RawServerSocket(socket, v6Only));
).then((socket) => _RawServerSocket(socket, v6Only));
}
_RawServerSocket(this._socket, this._v6Only);
@@ -2171,11 +2169,11 @@ class _RawServerSocket extends Stream<RawSocket>
bool? cancelOnError,
}) {
if (_controller != null) {
throw new StateError("Stream was already listened to");
throw StateError("Stream was already listened to");
}
var zone = Zone.current;
final controller =
_controller = new StreamController(
_controller = StreamController(
sync: true,
onListen: _onSubscriptionStateChange,
onCancel: _onSubscriptionStateChange,
@@ -2255,7 +2253,7 @@ class _RawServerSocket extends Stream<RawSocket>
class _RawSocket extends Stream<RawSocketEvent>
implements RawSocket, _RawSocketBase {
final _NativeSocket _socket;
final _controller = new StreamController<RawSocketEvent>(sync: true);
final _controller = StreamController<RawSocketEvent>(sync: true);
bool _readEventsEnabled = true;
bool _writeEventsEnabled = true;
@@ -2345,17 +2343,17 @@ class _RawSocket extends Stream<RawSocketEvent>
}
factory _RawSocket._writePipe() {
var native = new _NativeSocket.pipe();
var native = _NativeSocket.pipe();
native.isClosedRead = true;
native.closedReadEventSent = true;
return new _RawSocket(native);
return _RawSocket(native);
}
factory _RawSocket._readPipe(int? fd) {
var native = new _NativeSocket.pipe();
var native = _NativeSocket.pipe();
native.isClosedWrite = true;
if (fd != null) _getStdioHandle(native, fd);
var result = new _RawSocket(native);
var result = _RawSocket(native);
if (fd != null) {
var socketType = _StdIOUtils._nativeSocketType(result._socket);
result._isMacOSTerminalInput =
@@ -2515,7 +2513,7 @@ class _ServerSocket extends Stream<Socket> implements ServerSocket {
backlog,
v6Only,
shared,
).then((socket) => new _ServerSocket(socket));
).then((socket) => _ServerSocket(socket));
}
_ServerSocket(this._socket);
@@ -2527,7 +2525,7 @@ class _ServerSocket extends Stream<Socket> implements ServerSocket {
bool? cancelOnError,
}) {
return _socket
.map<Socket>((rawSocket) => new _Socket(rawSocket))
.map<Socket>((rawSocket) => _Socket(rawSocket))
.listen(
onData,
onError: onError,
@@ -2564,7 +2562,7 @@ class Socket {
sourceAddress: sourceAddress,
sourcePort: sourcePort,
timeout: timeout,
).then((socket) => new _Socket(socket));
).then((socket) => _Socket(socket));
}
@patch
@@ -2581,9 +2579,9 @@ class Socket {
sourcePort: sourcePort,
).then((rawTask) {
Future<Socket> socket = rawTask.socket.then(
(rawSocket) => new _Socket(rawSocket),
(rawSocket) => _Socket(rawSocket),
);
return new ConnectionTask<Socket>._(socket, rawTask._onCancel);
return ConnectionTask<Socket>._(socket, rawTask._onCancel);
});
}
}
@@ -2600,7 +2598,7 @@ class _SocketStreamConsumer implements StreamConsumer<List<int>> {
Future<Socket> addStream(Stream<List<int>> stream) {
socket._ensureRawSocketSubscription();
final completer = streamCompleter = new Completer<Socket>();
final completer = streamCompleter = Completer<Socket>();
if (socket._raw != null) {
subscription = stream.listen(
(data) {
@@ -2640,7 +2638,7 @@ class _SocketStreamConsumer implements StreamConsumer<List<int>> {
Future<Socket> close() {
socket._consumerDone();
return new Future.value(socket);
return Future.value(socket);
}
bool get _previousWriteHasCompleted {
@@ -2710,7 +2708,7 @@ class _SocketStreamConsumer implements StreamConsumer<List<int>> {
class _Socket extends Stream<Uint8List> implements Socket {
RawSocket? _raw; // Set to null when the raw socket is closed.
bool _closed = false; // Set to true when the raw socket is closed.
final _controller = new StreamController<Uint8List>(sync: true);
final _controller = StreamController<Uint8List>(sync: true);
bool _controllerClosed = false;
late _SocketStreamConsumer _consumer;
late IOSink _sink;
@@ -2723,8 +2721,8 @@ class _Socket extends Stream<Uint8List> implements Socket {
..onCancel = _onSubscriptionStateChange
..onPause = _onPauseStateChange
..onResume = _onPauseStateChange;
_consumer = new _SocketStreamConsumer(this);
_sink = new IOSink(_consumer);
_consumer = _SocketStreamConsumer(this);
_sink = IOSink(_consumer);
// Disable read events until there is a subscription.
raw.readEventsEnabled = false;
@@ -2734,11 +2732,11 @@ class _Socket extends Stream<Uint8List> implements Socket {
}
factory _Socket._writePipe() {
return new _Socket(new _RawSocket._writePipe());
return _Socket(_RawSocket._writePipe());
}
factory _Socket._readPipe([int? fd]) {
return new _Socket(new _RawSocket._readPipe(fd));
return _Socket(_RawSocket._readPipe(fd));
}
// Note: this code seems a bit suspicious because _raw can be _RawSocket and
@@ -2783,7 +2781,7 @@ class _Socket extends Stream<Uint8List> implements Socket {
/// Throws an [UnsupportedError] because errors cannot be transmitted over a
/// [Socket].
void addError(Object error, [StackTrace? stackTrace]) {
throw new UnsupportedError("Cannot send errors on sockets");
throw UnsupportedError("Cannot send errors on sockets");
}
Future addStream(Stream<List<int>> stream) {
@@ -2992,7 +2990,7 @@ class _RawDatagramSocket extends Stream<RawSocketEvent>
_RawDatagramSocket(this._socket) {
var zone = Zone.current;
_controller = new StreamController<RawSocketEvent>(
_controller = StreamController<RawSocketEvent>(
sync: true,
onListen: _onSubscriptionStateChange,
onCancel: _onSubscriptionStateChange,
@@ -3160,7 +3158,7 @@ Datagram _makeDatagram(
int port,
int type,
) {
return new Datagram(
return Datagram(
data,
_InternetAddress(InternetAddressType._from(type), address, null, in_addr),
port,
+18 -28
View File
@@ -21,11 +21,11 @@ class _StdIOUtils {
case _stdioHandleTypePipe:
case _stdioHandleTypeSocket:
case _stdioHandleTypeOther:
return new Stdin._(new _Socket._readPipe(fd), fd);
return Stdin._(_Socket._readPipe(fd), fd);
case _stdioHandleTypeFile:
return new Stdin._(new _FileStream.forStdin(), fd);
return Stdin._(_FileStream.forStdin(), fd);
}
throw new UnsupportedError("Unexpected handle type $type");
throw UnsupportedError("Unexpected handle type $type");
}
@patch
@@ -38,7 +38,7 @@ class _StdIOUtils {
type,
);
}
return new Stdout._(new IOSink(new _StdConsumer(fd)), fd);
return Stdout._(IOSink(_StdConsumer(fd)), fd);
}
@patch
@@ -50,7 +50,7 @@ class _StdIOUtils {
static int _nativeSocketType(_NativeSocket nativeSocket) {
var result = _getSocketType(nativeSocket);
if (result is OSError) {
throw new FileSystemException("Error retrieving socket type", "", result);
throw FileSystemException("Error retrieving socket type", "", result);
}
return result;
}
@@ -66,7 +66,7 @@ class Stdin {
int readByteSync() {
var result = _readByte(_fd);
if (result is OSError) {
throw new StdinException("Error reading byte from stdin", result);
throw StdinException("Error reading byte from stdin", result);
}
return result;
}
@@ -75,7 +75,7 @@ class Stdin {
bool get echoMode {
var result = _echoMode(_fd);
if (result is OSError) {
throw new StdinException("Error getting terminal echo mode", result);
throw StdinException("Error getting terminal echo mode", result);
}
return result;
}
@@ -83,13 +83,11 @@ class Stdin {
@patch
void set echoMode(bool enabled) {
if (!_EmbedderConfig._maySetEchoMode) {
throw new UnsupportedError(
"This embedder disallows setting Stdin.echoMode",
);
throw UnsupportedError("This embedder disallows setting Stdin.echoMode");
}
var result = _setEchoMode(_fd, enabled);
if (result is OSError) {
throw new StdinException("Error setting terminal echo mode", result);
throw StdinException("Error setting terminal echo mode", result);
}
}
@@ -97,10 +95,7 @@ class Stdin {
bool get echoNewlineMode {
var result = _echoNewlineMode(_fd);
if (result is OSError) {
throw new StdinException(
"Error getting terminal echo newline mode",
result,
);
throw StdinException("Error getting terminal echo newline mode", result);
}
return result;
}
@@ -108,16 +103,13 @@ class Stdin {
@patch
void set echoNewlineMode(bool enabled) {
if (!_EmbedderConfig._maySetEchoNewlineMode) {
throw new UnsupportedError(
throw UnsupportedError(
"This embedder disallows setting Stdin.echoNewlineMode",
);
}
var result = _setEchoNewlineMode(_fd, enabled);
if (result is OSError) {
throw new StdinException(
"Error setting terminal echo newline mode",
result,
);
throw StdinException("Error setting terminal echo newline mode", result);
}
}
@@ -125,7 +117,7 @@ class Stdin {
bool get lineMode {
var result = _lineMode(_fd);
if (result is OSError) {
throw new StdinException("Error getting terminal line mode", result);
throw StdinException("Error getting terminal line mode", result);
}
return result;
}
@@ -133,13 +125,11 @@ class Stdin {
@patch
void set lineMode(bool enabled) {
if (!_EmbedderConfig._maySetLineMode) {
throw new UnsupportedError(
"This embedder disallows setting Stdin.lineMode",
);
throw UnsupportedError("This embedder disallows setting Stdin.lineMode");
}
var result = _setLineMode(_fd, enabled);
if (result is OSError) {
throw new StdinException("Error setting terminal line mode", result);
throw StdinException("Error setting terminal line mode", result);
}
}
@@ -147,7 +137,7 @@ class Stdin {
bool get supportsAnsiEscapes {
var result = _supportsAnsiEscapes(_fd);
if (result is OSError) {
throw new StdinException("Error determining ANSI support", result);
throw StdinException("Error determining ANSI support", result);
}
return result;
}
@@ -182,7 +172,7 @@ class Stdout {
static List _terminalSize(int fd) {
var size = _getTerminalSize(fd);
if (size is! List) {
throw new StdoutException("Could not get terminal size", size);
throw StdoutException("Could not get terminal size", size);
}
return size;
}
@@ -194,7 +184,7 @@ class Stdout {
static bool _supportsAnsiEscapes(int fd) {
var result = _getAnsiSupported(fd);
if (result is! bool) {
throw new StdoutException("Error determining ANSI support", result);
throw StdoutException("Error determining ANSI support", result);
}
return result;
}
+13 -13
View File
@@ -19,7 +19,7 @@ class _RawSynchronousSocket implements RawSynchronousSocket {
static RawSynchronousSocket connectSync(host, int port) {
_throwOnBadPort(port);
return new _RawSynchronousSocket(
return _RawSynchronousSocket(
_NativeSynchronousSocket.connectSync(host, port),
);
}
@@ -65,7 +65,7 @@ base class _NativeSynchronousSocket
static _NativeSynchronousSocket connectSync(host, int port) {
if (host == null) {
throw new ArgumentError("Parameter host cannot be null");
throw ArgumentError("Parameter host cannot be null");
}
late List<_InternetAddress> addresses;
var error = null;
@@ -89,7 +89,7 @@ base class _NativeSynchronousSocket
throw error;
}
var address = it.current;
var socket = new _NativeSynchronousSocket();
var socket = _NativeSynchronousSocket();
socket.localAddress = address;
var result = socket._nativeCreateConnectSync(address._in_addr, port);
if (result is OSError) {
@@ -178,14 +178,14 @@ base class _NativeSynchronousSocket
int? port,
]) {
if (error is OSError) {
return new SocketException(
return SocketException(
message,
osError: error,
address: address,
port: port,
);
} else {
return new SocketException(message, address: address, port: port);
return SocketException(message, address: address, port: port);
}
}
@@ -199,7 +199,7 @@ base class _NativeSynchronousSocket
}
return <_InternetAddress>[
for (int i = 0; i < response.length; ++i)
new _InternetAddress(
_InternetAddress(
InternetAddressType._from(response[i][0]),
response[i][1],
host,
@@ -214,7 +214,7 @@ base class _NativeSynchronousSocket
ArgumentError.checkNotNull(start, "start");
_checkAvailable();
if (isClosedRead) {
throw new SocketException("Socket is closed for reading");
throw SocketException("Socket is closed for reading");
}
end = RangeError.checkValidRange(start, end, buffer.length);
if (end == start) {
@@ -222,7 +222,7 @@ base class _NativeSynchronousSocket
}
var result = _nativeReadInto(buffer, start, end - start);
if (result is OSError) {
throw new SocketException("readIntoSync failed", osError: result);
throw SocketException("readIntoSync failed", osError: result);
}
return result;
}
@@ -230,11 +230,11 @@ base class _NativeSynchronousSocket
List<int>? readSync(int len) {
_checkAvailable();
if (isClosedRead) {
throw new SocketException("Socket is closed for reading");
throw SocketException("Socket is closed for reading");
}
if ((len != null) && (len < 0)) {
throw new ArgumentError("Illegal length $len");
throw ArgumentError("Illegal length $len");
}
if (len == 0) {
return null;
@@ -261,7 +261,7 @@ base class _NativeSynchronousSocket
closeSync();
break;
default:
throw new ArgumentError(direction);
throw ArgumentError(direction);
}
}
@@ -295,7 +295,7 @@ base class _NativeSynchronousSocket
ArgumentError.checkNotNull(start, "start");
_checkAvailable();
if (isClosedWrite) {
throw new SocketException("Socket is closed for writing");
throw SocketException("Socket is closed for writing");
}
end = RangeError.checkValidRange(start, end, buffer.length);
if (end == start) {
@@ -312,7 +312,7 @@ base class _NativeSynchronousSocket
end - (start - bufferAndStart.start),
);
if (result is OSError) {
throw new SocketException("writeFromSync failed", osError: result);
throw SocketException("writeFromSync failed", osError: result);
}
}
+19 -19
View File
@@ -13,65 +13,65 @@ part 'resident_compiler_utils.dart';
part 'vmservice_server.dart';
// The TCP ip/port that dds listens on.
@pragma('vm:entry-point', !const bool.fromEnvironment('dart.vm.product'))
@pragma('vm:entry-point', !bool.fromEnvironment('dart.vm.product'))
int _ddsPort = 0;
@pragma('vm:entry-point', !const bool.fromEnvironment('dart.vm.product'))
@pragma('vm:entry-point', !bool.fromEnvironment('dart.vm.product'))
String _ddsIP = '';
// The TCP ip/port that the HTTP server listens on.
@pragma('vm:entry-point', !const bool.fromEnvironment('dart.vm.product'))
@pragma('vm:entry-point', !bool.fromEnvironment('dart.vm.product'))
int _port = 0;
@pragma('vm:entry-point', !const bool.fromEnvironment('dart.vm.product'))
@pragma('vm:entry-point', !bool.fromEnvironment('dart.vm.product'))
String _ip = '';
// Should the HTTP server auto start?
@pragma('vm:entry-point', !const bool.fromEnvironment('dart.vm.product'))
@pragma('vm:entry-point', !bool.fromEnvironment('dart.vm.product'))
bool _autoStart = false;
// Should the HTTP server require an auth code?
@pragma('vm:entry-point', !const bool.fromEnvironment('dart.vm.product'))
@pragma('vm:entry-point', !bool.fromEnvironment('dart.vm.product'))
bool _authCodesDisabled = false;
// Should the HTTP server run in devmode?
@pragma('vm:entry-point', !const bool.fromEnvironment('dart.vm.product'))
@pragma('vm:entry-point', !bool.fromEnvironment('dart.vm.product'))
bool _originCheckDisabled = false;
// Location of file to output VM service connection info.
@pragma('vm:entry-point', !const bool.fromEnvironment('dart.vm.product'))
@pragma('vm:entry-point', !bool.fromEnvironment('dart.vm.product'))
String? _serviceInfoFilename;
@pragma('vm:entry-point', !const bool.fromEnvironment('dart.vm.product'))
@pragma('vm:entry-point', !bool.fromEnvironment('dart.vm.product'))
bool _isWindows = false;
@pragma('vm:entry-point', !const bool.fromEnvironment('dart.vm.product'))
@pragma('vm:entry-point', !bool.fromEnvironment('dart.vm.product'))
bool _isFuchsia = false;
@pragma('vm:entry-point', !const bool.fromEnvironment('dart.vm.product'))
@pragma('vm:entry-point', !bool.fromEnvironment('dart.vm.product'))
Stream<ProcessSignal> Function(ProcessSignal signal)? _signalWatch;
@pragma('vm:entry-point', !const bool.fromEnvironment('dart.vm.product'))
@pragma('vm:entry-point', !bool.fromEnvironment('dart.vm.product'))
StreamSubscription<ProcessSignal>? _signalSubscription;
@pragma('vm:entry-point', !const bool.fromEnvironment('dart.vm.product'))
@pragma('vm:entry-point', !bool.fromEnvironment('dart.vm.product'))
bool _serveDevtools = true;
@pragma('vm:entry-point', !const bool.fromEnvironment('dart.vm.product'))
@pragma('vm:entry-point', !bool.fromEnvironment('dart.vm.product'))
bool _enableServicePortFallback = false;
@pragma('vm:entry-point', !const bool.fromEnvironment('dart.vm.product'))
@pragma('vm:entry-point', !bool.fromEnvironment('dart.vm.product'))
bool _waitForDdsToAdvertiseService = false;
@pragma('vm:entry-point', !const bool.fromEnvironment('dart.vm.product'))
@pragma('vm:entry-point', !bool.fromEnvironment('dart.vm.product'))
bool _serveObservatory = false;
@pragma('vm:entry-point', !const bool.fromEnvironment('dart.vm.product'))
@pragma('vm:entry-point', !bool.fromEnvironment('dart.vm.product'))
bool _printDtd = false;
File? _residentCompilerInfoFile = null;
@pragma('vm:entry-point', !const bool.fromEnvironment('dart.vm.product'))
@pragma('vm:entry-point', !bool.fromEnvironment('dart.vm.product'))
void _populateResidentCompilerInfoFile(
/// If either `--resident-compiler-info-file` or `--resident-server-info-file`
/// was supplied on the command line, the CLI argument should be forwarded as
@@ -270,7 +270,7 @@ void _registerSignalHandler() {
).listen((_) => _toggleWebServer());
}
@pragma('vm:entry-point', !const bool.fromEnvironment('dart.vm.product'))
@pragma('vm:entry-point', !bool.fromEnvironment('dart.vm.product'))
void main() {
// Set embedder hooks.
VMServiceEmbedderHooks.cleanup = cleanupCallback;
+10 -12
View File
@@ -19,7 +19,7 @@ abstract class _Array<E> extends FixedLengthListBase<E> {
@pragma("vm:prefer-inline")
_List _slice(int start, int count, bool needsTypeArgument) {
if (count <= 64) {
final result = needsTypeArgument ? new _List<E>(count) : new _List(count);
final result = needsTypeArgument ? _List<E>(count) : _List(count);
for (int i = 0; i < result.length; i++) {
result[i] = this[start + i];
}
@@ -44,7 +44,7 @@ abstract class _Array<E> extends FixedLengthListBase<E> {
@pragma("vm:prefer-inline")
Iterator<E> get iterator {
return new _ArrayIterator<E>(this);
return _ArrayIterator<E>(this);
}
E get first {
@@ -68,12 +68,12 @@ abstract class _Array<E> extends FixedLengthListBase<E> {
if (length > 0) {
_List result = _slice(0, length, !growable);
if (growable) {
return new _GrowableList<E>._withData(result).._setLength(length);
return _GrowableList<E>._withData(result).._setLength(length);
}
return unsafeCast<_List<E>>(result);
}
// _GrowableList._withData must not be called with empty list.
return growable ? <E>[] : new _List<E>(0);
return growable ? <E>[] : _List<E>(0);
}
}
@@ -195,10 +195,10 @@ class _List<E> extends _Array<E> {
// List interface.
void setRange(int start, int end, Iterable<E> iterable, [int skipCount = 0]) {
if (start < 0 || start > this.length) {
throw new RangeError.range(start, 0, this.length);
throw RangeError.range(start, 0, this.length);
}
if (end < start || end > this.length) {
throw new RangeError.range(end, start, this.length);
throw RangeError.range(end, start, this.length);
}
int length = end - start;
if (length == 0) return;
@@ -224,7 +224,7 @@ class _List<E> extends _Array<E> {
void setAll(int index, Iterable<E> iterable) {
if (index < 0 || index > this.length) {
throw new RangeError.range(index, 0, this.length, "index");
throw RangeError.range(index, 0, this.length, "index");
}
List<E> iterableAsList;
if (identical(this, iterable)) {
@@ -241,7 +241,7 @@ class _List<E> extends _Array<E> {
}
int length = iterableAsList.length;
if (index + length > this.length) {
throw new RangeError.range(index + length, 0, this.length);
throw RangeError.range(index + length, 0, this.length);
}
Lists.copy(iterableAsList, 0, this, index, length);
}
@@ -251,7 +251,7 @@ class _List<E> extends _Array<E> {
final int actualEnd = RangeError.checkValidRange(start, end, listLength);
int length = actualEnd - start;
if (length == 0) return <E>[];
var result = new _GrowableList<E>._withData(_slice(start, length, false));
var result = _GrowableList<E>._withData(_slice(start, length, false));
result._setLength(length);
return result;
}
@@ -261,9 +261,7 @@ class _List<E> extends _Array<E> {
@pragma("vm:entry-point")
class _ImmutableList<E> extends _Array<E> with UnmodifiableListMixin<E> {
factory _ImmutableList._uninstantiable() {
throw new UnsupportedError(
"ImmutableArray can only be allocated by the VM",
);
throw UnsupportedError("ImmutableArray can only be allocated by the VM");
}
@pragma("vm:external-name", "ImmutableList_from")
+2 -2
View File
@@ -141,7 +141,7 @@ class _AsyncStarStreamController<T> {
controller.close();
}
_AsyncStarStreamController() : controller = new StreamController(sync: true) {
_AsyncStarStreamController() : controller = StreamController(sync: true) {
controller.onListen = this.onListen;
controller.onResume = this.onResume;
controller.onCancel = this.onCancel;
@@ -164,7 +164,7 @@ class _AsyncStarStreamController<T> {
return null;
}
if (cancellationFuture == null) {
cancellationFuture = new _Future();
cancellationFuture = _Future();
// Only resume the generator if it is suspended at a yield.
// Cancellation does not affect an async generator that is
// suspended at an await.
+16 -16
View File
@@ -28,8 +28,8 @@ dynamic _parseJson(
String source,
Object? Function(Object? key, Object? value)? reviver,
) {
_JsonListener listener = new _JsonListener(reviver);
var parser = new _JsonStringParser(listener);
_JsonListener listener = _JsonListener(reviver);
var parser = _JsonStringParser(listener);
parser.chunk = source;
parser.chunkEnd = source.length;
parser.parse(0);
@@ -42,7 +42,7 @@ class Utf8Decoder {
@patch
Converter<List<int>, T> fuse<T>(Converter<String, T> next) {
if (next is JsonDecoder) {
return new _JsonUtf8Decoder(
return _JsonUtf8Decoder(
(next as JsonDecoder)._reviver,
this._allowMalformed,
)
@@ -66,7 +66,7 @@ class _JsonUtf8Decoder extends Converter<List<int>, Object?> {
}
ByteConversionSink startChunkedConversion(Sink<Object?> sink) {
return new _JsonUtf8DecoderSink(_reviver, sink, _allowMalformed);
return _JsonUtf8DecoderSink(_reviver, sink, _allowMalformed);
}
}
@@ -206,7 +206,7 @@ class _NumberBuffer {
Uint8List list;
int length = 0;
_NumberBuffer(int initialCapacity)
: list = new Uint8List(_initialCapacity(initialCapacity));
: list = Uint8List(_initialCapacity(initialCapacity));
int get capacity => list.length;
@@ -229,13 +229,13 @@ class _NumberBuffer {
void ensureCapacity(int newCapacity) {
Uint8List list = this.list;
if (newCapacity <= list.length) return;
Uint8List newList = new Uint8List(newCapacity);
Uint8List newList = Uint8List(newCapacity);
newList.setRange(0, list.length, list, 0);
this.list = newList;
}
String getString() {
String result = new String.fromCharCodes(list, 0, length);
String result = String.fromCharCodes(list, 0, length);
return result;
}
@@ -1251,7 +1251,7 @@ mixin _ChunkedJsonParser<T> on _JsonParserWithListener {
int beginChunkNumber(int state, int start) {
int end = chunkEnd;
int length = end - start;
var buffer = new _NumberBuffer(length);
var buffer = _NumberBuffer(length);
copyCharsToList(start, end, buffer.list, 0);
buffer.length = length;
this.buffer = buffer;
@@ -1460,7 +1460,7 @@ mixin _ChunkedJsonParser<T> on _JsonParserWithListener {
message = "Unexpected character";
if (position == chunkEnd) message = "Unexpected end of input";
}
throw new FormatException(message, chunk, position);
throw FormatException(message, chunk, position);
}
}
@@ -1486,7 +1486,7 @@ class _JsonStringParser extends _JsonParserWithListener
}
void beginString() {
this.buffer = new StringBuffer();
this.buffer = StringBuffer();
}
void addSliceToString(int start, int end) {
@@ -1521,7 +1521,7 @@ class _JsonStringParser extends _JsonParserWithListener
class JsonDecoder {
@patch
StringConversionSink startChunkedConversion(Sink<Object?> sink) {
return new _JsonStringDecoderSink(this._reviver, sink);
return _JsonStringDecoderSink(this._reviver, sink);
}
}
@@ -1542,7 +1542,7 @@ class _JsonStringDecoderSink extends StringConversionSinkBase {
static _JsonStringParser _createParser(
Object? Function(Object? key, Object? value)? reviver,
) {
return new _JsonStringParser(new _JsonListener(reviver));
return _JsonStringParser(_JsonListener(reviver));
}
void addSlice(String chunk, int start, int end, bool isLast) {
@@ -1564,7 +1564,7 @@ class _JsonStringDecoderSink extends StringConversionSinkBase {
}
ByteConversionSink asUtf8Sink(bool allowMalformed) {
return new _JsonUtf8DecoderSink(_reviver, _sink, allowMalformed);
return _JsonUtf8DecoderSink(_reviver, _sink, allowMalformed);
}
}
@@ -1580,7 +1580,7 @@ class _JsonUtf8Parser extends _JsonParserWithListener
int chunkEnd = 0;
_JsonUtf8Parser(_JsonListener listener, bool allowMalformed)
: decoder = new _Utf8Decoder(allowMalformed),
: decoder = _Utf8Decoder(allowMalformed),
super(listener) {
// Starts out checking for an optional BOM (KWD_BOM, count = 0).
partialState =
@@ -1621,7 +1621,7 @@ class _JsonUtf8Parser extends _JsonParserWithListener
void beginString() {
decoder.reset();
this.buffer = new StringBuffer();
this.buffer = StringBuffer();
}
void addSliceToString(int start, int end) {
@@ -1671,7 +1671,7 @@ class _JsonUtf8DecoderSink extends ByteConversionSink {
Object? Function(Object? key, Object? value)? reviver,
bool allowMalformed,
) {
return new _JsonUtf8Parser(new _JsonListener(reviver), allowMalformed);
return _JsonUtf8Parser(_JsonListener(reviver), allowMalformed);
}
void addSlice(List<int> chunk, int start, int end, bool isLast) {
+9 -9
View File
@@ -38,11 +38,11 @@ void log(
StackTrace? stackTrace,
}) {
if (message is! String) {
throw new ArgumentError.value(message, "message", "Must be a String");
throw ArgumentError.value(message, "message", "Must be a String");
}
time ??= new DateTime.now();
time ??= DateTime.now();
if (time is! DateTime) {
throw new ArgumentError.value(time, "time", "Must be a DateTime");
throw ArgumentError.value(time, "time", "Must be a DateTime");
}
if (sequenceNumber == null) {
sequenceNumber = _nextSequenceNumber++;
@@ -92,7 +92,7 @@ external ServiceExtensionHandler? _lookupExtension(String method);
external _registerExtension(String method, ServiceExtensionHandler handler);
// This code is only invoked when there is no other Dart code on the stack.
@pragma("vm:entry-point", !const bool.fromEnvironment("dart.vm.product"))
@pragma("vm:entry-point", !bool.fromEnvironment("dart.vm.product"))
_runExtension(
ServiceExtensionHandler handler,
String method,
@@ -111,7 +111,7 @@ _runExtension(
response = handler(method, parameters);
} catch (e, st) {
var errorDetails = (st == null) ? '$e' : '$e\n$st';
response = new ServiceExtensionResponse.error(
response = ServiceExtensionResponse.error(
ServiceExtensionResponse.extensionError,
errorDetails,
);
@@ -119,7 +119,7 @@ _runExtension(
return;
}
if (response is! Future) {
response = new ServiceExtensionResponse.error(
response = ServiceExtensionResponse.error(
ServiceExtensionResponse.extensionError,
"Extension handler must return a Future",
);
@@ -130,7 +130,7 @@ _runExtension(
.catchError((e, st) {
// Catch any errors eagerly and wrap them in a ServiceExtensionResponse.
var errorDetails = (st == null) ? '$e' : '$e\n$st';
return new ServiceExtensionResponse.error(
return ServiceExtensionResponse.error(
ServiceExtensionResponse.extensionError,
errorDetails,
);
@@ -139,7 +139,7 @@ _runExtension(
// Post the valid response or the wrapped error after verifying that
// the response is a ServiceExtensionResponse.
if (response is! ServiceExtensionResponse) {
response = new ServiceExtensionResponse.error(
response = ServiceExtensionResponse.error(
ServiceExtensionResponse.extensionError,
"Extension handler must complete to a ServiceExtensionResponse",
);
@@ -169,7 +169,7 @@ _postResponse(
return;
}
assert(id != null);
StringBuffer sb = new StringBuffer();
StringBuffer sb = StringBuffer();
sb.write('{"jsonrpc":"2.0",');
if (response.isError()) {
if (trace_service) {
+15 -15
View File
@@ -139,29 +139,29 @@ final class _Double implements double {
}
double _addFromInteger(int other) {
return new _Double.fromInteger(other)._add(this);
return _Double.fromInteger(other)._add(this);
}
double _subFromInteger(int other) {
return new _Double.fromInteger(other)._sub(this);
return _Double.fromInteger(other)._sub(this);
}
@pragma("vm:recognized", "asm-intrinsic")
@pragma("vm:exact-result-type", "dart:core#_Double")
double _mulFromInteger(int other) {
return new _Double.fromInteger(other)._mul(this);
return _Double.fromInteger(other)._mul(this);
}
int _truncDivFromInteger(int other) {
return (new _Double.fromInteger(other) / this).truncate();
return (_Double.fromInteger(other) / this).truncate();
}
double _moduloFromInteger(int other) {
return new _Double.fromInteger(other)._modulo(this);
return _Double.fromInteger(other)._modulo(this);
}
double _remainderFromInteger(int other) {
return new _Double.fromInteger(other)._remainder(this);
return _Double.fromInteger(other)._remainder(this);
}
@pragma("vm:external-name", "Double_greaterThanFromInteger")
@@ -223,13 +223,13 @@ final class _Double implements double {
num clamp(num lowerLimit, num upperLimit) {
// TODO: Remove these null checks once all code is opted into strong nonnullable mode.
if (lowerLimit == null) {
throw new ArgumentError.notNull("lowerLimit");
throw ArgumentError.notNull("lowerLimit");
}
if (upperLimit == null) {
throw new ArgumentError.notNull("upperLimit");
throw ArgumentError.notNull("upperLimit");
}
if (lowerLimit.compareTo(upperLimit) > 0) {
throw new ArgumentError(lowerLimit);
throw ArgumentError(lowerLimit);
}
if (lowerLimit.isNaN) return lowerLimit;
if (this.compareTo(lowerLimit) < 0) return lowerLimit;
@@ -249,7 +249,7 @@ final class _Double implements double {
static const int CACHE_LENGTH = 1 << (CACHE_SIZE_LOG2 + 1);
static const int CACHE_MASK = CACHE_LENGTH - 1;
// Each key (double) followed by its toString result.
static final List _cache = new List.filled(CACHE_LENGTH, null);
static final List _cache = List.filled(CACHE_LENGTH, null);
static int _cacheEvictIndex = 0;
@pragma("vm:external-name", "Double_toString")
@@ -280,12 +280,12 @@ final class _Double implements double {
// TODO: Remove these null checks once all code is opted into strong nonnullable mode.
if (fractionDigits == null) {
throw new ArgumentError.notNull("fractionDigits");
throw ArgumentError.notNull("fractionDigits");
}
// Step 2.
if (fractionDigits < 0 || fractionDigits > 20) {
throw new RangeError.range(fractionDigits, 0, 20, "fractionDigits");
throw RangeError.range(fractionDigits, 0, 20, "fractionDigits");
}
// Step 3.
@@ -317,7 +317,7 @@ final class _Double implements double {
// Step 7.
if (fractionDigits != null) {
if (fractionDigits < 0 || fractionDigits > 20) {
throw new RangeError.range(fractionDigits, 0, 20, "fractionDigits");
throw RangeError.range(fractionDigits, 0, 20, "fractionDigits");
}
}
@@ -339,7 +339,7 @@ final class _Double implements double {
// See ECMAScript-262, 15.7.4.7 for details.
if (precision == null) {
throw new ArgumentError.notNull("precision");
throw ArgumentError.notNull("precision");
}
// The EcmaScript specification checks for NaN and Infinity before looking
// at the fractionDigits. In Dart we are consistent with toStringAsFixed and
@@ -347,7 +347,7 @@ final class _Double implements double {
// Step 8.
if (precision < 1 || precision > 21) {
throw new RangeError.range(precision, 1, 21, "precision");
throw RangeError.range(precision, 1, 21, "precision");
}
if (isNaN) return "NaN";
+1 -1
View File
@@ -109,7 +109,7 @@ class double {
static double parse(String source) {
var result = _parse(source);
if (result == null) {
throw new FormatException("Invalid double", source);
throw FormatException("Invalid double", source);
}
return result;
}
+11 -11
View File
@@ -141,7 +141,7 @@ class _InternalError {
@pragma("vm:entry-point")
class UnsupportedError {
static Never _throwNew(String msg) {
throw new UnsupportedError(msg);
throw UnsupportedError(msg);
}
}
@@ -150,7 +150,7 @@ class UnsupportedError {
class StateError {
@pragma("vm:entry-point")
static Never _throwNew(String msg) {
throw new StateError(msg);
throw StateError(msg);
}
}
@@ -168,7 +168,7 @@ class NoSuchMethodError {
NoSuchMethodError._withInvocation(this._receiver, this._invocation);
static Never _throwNewInvocation(Object? receiver, Invocation invocation) {
throw new NoSuchMethodError.withInvocation(receiver, invocation);
throw NoSuchMethodError.withInvocation(receiver, invocation);
}
// The compiler emits a call to _throwNew when it cannot resolve a static
@@ -184,7 +184,7 @@ class NoSuchMethodError {
List? arguments,
List? argumentNames,
) {
throw new NoSuchMethodError._withType(
throw NoSuchMethodError._withType(
receiver,
memberName,
invocationType,
@@ -200,11 +200,11 @@ class NoSuchMethodError {
List arguments,
List argumentNames,
) {
Map<Symbol, dynamic> namedArguments = new Map<Symbol, dynamic>();
Map<Symbol, dynamic> namedArguments = Map<Symbol, dynamic>();
int numPositionalArguments = arguments.length - argumentNames.length;
for (int i = 0; i < argumentNames.length; i++) {
final argValue = arguments[numPositionalArguments + i];
namedArguments[new Symbol(argumentNames[i])] = argValue;
namedArguments[Symbol(argumentNames[i])] = argValue;
}
return namedArguments;
}
@@ -222,8 +222,8 @@ class NoSuchMethodError {
Object? typeArguments,
List? arguments,
List? argumentNames,
) : this._invocation = new _InvocationMirror._withType(
new Symbol(memberName),
) : this._invocation = _InvocationMirror._withType(
Symbol(memberName),
invocationType,
_InvocationMirror._unpackTypeArguments(
typeArguments,
@@ -262,7 +262,7 @@ class NoSuchMethodError {
StringBuffer? typeArgumentsBuf = null;
final typeArguments = localInvocation.typeArguments;
if ((typeArguments != null) && (typeArguments.length > 0)) {
final argsBuf = new StringBuffer();
final argsBuf = StringBuffer();
argsBuf.write("<");
for (int i = 0; i < typeArguments.length; i++) {
if (i > 0) {
@@ -273,7 +273,7 @@ class NoSuchMethodError {
argsBuf.write(">");
typeArgumentsBuf = argsBuf;
}
StringBuffer argumentsBuf = new StringBuffer();
StringBuffer argumentsBuf = StringBuffer();
var positionalArguments = localInvocation.positionalArguments;
int argumentCount = 0;
if (positionalArguments != null) {
@@ -320,7 +320,7 @@ class NoSuchMethodError {
])[kind];
}
StringBuffer msgBuf = new StringBuffer("NoSuchMethodError: ");
StringBuffer msgBuf = StringBuffer("NoSuchMethodError: ");
bool isTypeCall = false;
switch (level) {
case _InvocationMirror._DYNAMIC:
+4 -4
View File
@@ -20,11 +20,11 @@ class Expando<T extends Object> {
@patch
Expando([String? name])
: name = name,
_data = new List<_WeakProperty?>.filled(_minSize, null),
_data = List<_WeakProperty?>.filled(_minSize, null),
_used = 0;
static const _minSize = 8;
static final _deletedEntry = new _WeakProperty();
static final _deletedEntry = _WeakProperty();
@patch
T? operator [](Object object) {
@@ -93,7 +93,7 @@ class Expando<T extends Object> {
}
if (_used < _limit) {
var ephemeron = new _WeakProperty();
var ephemeron = _WeakProperty();
ephemeron.key = object;
ephemeron.value = value;
_data[idx] = ephemeron;
@@ -130,7 +130,7 @@ class Expando<T extends Object> {
// Reset the mappings to empty so that we can just add the existing
// valid entries.
_data = new List<_WeakProperty?>.filled(new_size, null);
_data = List<_WeakProperty?>.filled(new_size, null);
_used = 0;
for (var i = 0; i < old_data.length; i++) {
+26 -26
View File
@@ -8,7 +8,7 @@ part of "core_patch.dart";
class _GrowableList<T> extends ListBase<T> {
void insert(int index, T element) {
if ((index < 0) || (index > length)) {
throw new RangeError.range(index, 0, length);
throw RangeError.range(index, 0, length);
}
int oldLength = this.length;
add(element);
@@ -41,7 +41,7 @@ class _GrowableList<T> extends ListBase<T> {
void insertAll(int index, Iterable<T> iterable) {
if (index < 0 || index > length) {
throw new RangeError.range(index, 0, length);
throw RangeError.range(index, 0, length);
}
// TODO(floitsch): we can probably detect more cases.
if (iterable is! List && iterable is! Set && iterable is! SubListIterable) {
@@ -84,11 +84,11 @@ class _GrowableList<T> extends ListBase<T> {
final int actualEnd = RangeError.checkValidRange(start, end, this.length);
int length = actualEnd - start;
if (length == 0) return <T>[];
final list = new _List(length);
final list = _List(length);
for (int i = 0; i < length; i++) {
list[i] = this[start + i];
}
final result = new _GrowableList<T>._withData(list);
final result = _GrowableList<T>._withData(list);
result._setLength(length);
return result;
}
@@ -96,7 +96,7 @@ class _GrowableList<T> extends ListBase<T> {
@pragma('dyn-module:language-impl:callable')
factory _GrowableList(int length) {
var data = _allocateData(length);
var result = new _GrowableList<T>._withData(data);
var result = _GrowableList<T>._withData(data);
if (length > 0) {
result._setLength(length);
}
@@ -105,7 +105,7 @@ class _GrowableList<T> extends ListBase<T> {
factory _GrowableList.withCapacity(int capacity) {
var data = _allocateData(capacity);
return new _GrowableList<T>._withData(data);
return _GrowableList<T>._withData(data);
}
// Specialization of List.empty constructor for growable == true.
@@ -314,7 +314,7 @@ class _GrowableList<T> extends ListBase<T> {
}
if (isVMList) {
if (identical(iterable, this)) {
throw new ConcurrentModificationError(this);
throw ConcurrentModificationError(this);
}
this._setLength(newLen);
final ListBase<T> iterableAsList = iterable as ListBase<T>;
@@ -332,7 +332,7 @@ class _GrowableList<T> extends ListBase<T> {
this._setLength(newLen);
this[len] = it.current;
if (!it.moveNext()) return;
if (this.length != newLen) throw new ConcurrentModificationError(this);
if (this.length != newLen) throw ConcurrentModificationError(this);
len = newLen;
}
_growToNextCapacity();
@@ -364,7 +364,7 @@ class _GrowableList<T> extends ListBase<T> {
}
// Shared array used as backing for new empty growable arrays.
static final _List _emptyList = new _List(0);
static final _List _emptyList = _List(0);
static _List _allocateData(int capacity) {
if (capacity == 0) {
@@ -423,7 +423,7 @@ class _GrowableList<T> extends ListBase<T> {
int initialLength = length;
for (int i = 0; i < length; i++) {
f(this[i]);
if (length != initialLength) throw new ConcurrentModificationError(this);
if (length != initialLength) throw ConcurrentModificationError(this);
}
}
@@ -458,7 +458,7 @@ class _GrowableList<T> extends ListBase<T> {
}
// Not all elements are strings, so allocate a new backing array.
final list = new _List(length);
final list = _List(length);
for (int copyIndex = 0; copyIndex < i; copyIndex++) {
list[copyIndex] = this[copyIndex];
}
@@ -485,7 +485,7 @@ class _GrowableList<T> extends ListBase<T> {
}
String _joinWithSeparator(String separator) {
StringBuffer buffer = new StringBuffer();
StringBuffer buffer = StringBuffer();
buffer.write(this[0]);
for (int i = 1; i < this.length; i++) {
buffer.write(separator);
@@ -512,7 +512,7 @@ class _GrowableList<T> extends ListBase<T> {
@pragma("vm:prefer-inline")
Iterator<T> get iterator {
return new ListIterator<T>(this);
return ListIterator<T>(this);
}
List<T> toList({bool growable = true}) {
@@ -527,18 +527,18 @@ class _GrowableList<T> extends ListBase<T> {
final length = this.length;
if (growable) {
if (length > 0) {
final data = new _List(_adjustedCapacity(length));
final data = _List(_adjustedCapacity(length));
for (int i = 0; i < length; i++) {
data[i] = this[i];
}
final result = new _GrowableList<T>._withData(data);
final result = _GrowableList<T>._withData(data);
result._setLength(length);
return result;
}
return <T>[];
} else {
if (length > 0) {
final list = new _List<T>(length);
final list = _List<T>(length);
for (int i = 0; i < length; i++) {
list[i] = this[i];
}
@@ -549,14 +549,14 @@ class _GrowableList<T> extends ListBase<T> {
}
Set<T> toSet() {
return new Set<T>.of(this);
return Set<T>.of(this);
}
// Factory constructing a mutable List from a parser generated List literal.
// [elements] contains elements that are already type checked.
@pragma("vm:entry-point", "call")
factory _GrowableList._literal(_List elements) {
final result = new _GrowableList<T>._withData(elements);
final result = _GrowableList<T>._withData(elements);
result._setLength(elements.length);
return result;
}
@@ -567,7 +567,7 @@ class _GrowableList<T> extends ListBase<T> {
factory _GrowableList._literal1(T e0) {
_List elements = _List(1);
elements[0] = e0;
final result = new _GrowableList<T>._withData(elements);
final result = _GrowableList<T>._withData(elements);
result._setLength(1);
return result;
}
@@ -577,7 +577,7 @@ class _GrowableList<T> extends ListBase<T> {
_List elements = _List(2);
elements[0] = e0;
elements[1] = e1;
final result = new _GrowableList<T>._withData(elements);
final result = _GrowableList<T>._withData(elements);
result._setLength(2);
return result;
}
@@ -588,7 +588,7 @@ class _GrowableList<T> extends ListBase<T> {
elements[0] = e0;
elements[1] = e1;
elements[2] = e2;
final result = new _GrowableList<T>._withData(elements);
final result = _GrowableList<T>._withData(elements);
result._setLength(3);
return result;
}
@@ -600,7 +600,7 @@ class _GrowableList<T> extends ListBase<T> {
elements[1] = e1;
elements[2] = e2;
elements[3] = e3;
final result = new _GrowableList<T>._withData(elements);
final result = _GrowableList<T>._withData(elements);
result._setLength(4);
return result;
}
@@ -613,7 +613,7 @@ class _GrowableList<T> extends ListBase<T> {
elements[2] = e2;
elements[3] = e3;
elements[4] = e4;
final result = new _GrowableList<T>._withData(elements);
final result = _GrowableList<T>._withData(elements);
result._setLength(5);
return result;
}
@@ -627,7 +627,7 @@ class _GrowableList<T> extends ListBase<T> {
elements[3] = e3;
elements[4] = e4;
elements[5] = e5;
final result = new _GrowableList<T>._withData(elements);
final result = _GrowableList<T>._withData(elements);
result._setLength(6);
return result;
}
@@ -642,7 +642,7 @@ class _GrowableList<T> extends ListBase<T> {
elements[4] = e4;
elements[5] = e5;
elements[6] = e6;
final result = new _GrowableList<T>._withData(elements);
final result = _GrowableList<T>._withData(elements);
result._setLength(7);
return result;
}
@@ -667,7 +667,7 @@ class _GrowableList<T> extends ListBase<T> {
elements[5] = e5;
elements[6] = e6;
elements[7] = e7;
final result = new _GrowableList<T>._withData(elements);
final result = _GrowableList<T>._withData(elements);
result._setLength(8);
return result;
}
+16 -16
View File
@@ -264,10 +264,10 @@ abstract final class _IntegerImplementation implements int {
num clamp(num lowerLimit, num upperLimit) {
// TODO: Remove these null checks once all code is opted into strong nonnullable mode.
if (lowerLimit == null) {
throw new ArgumentError.notNull("lowerLimit");
throw ArgumentError.notNull("lowerLimit");
}
if (upperLimit == null) {
throw new ArgumentError.notNull("upperLimit");
throw ArgumentError.notNull("upperLimit");
}
// Special case for integers.
if (lowerLimit is int && upperLimit is int && lowerLimit <= upperLimit) {
@@ -277,7 +277,7 @@ abstract final class _IntegerImplementation implements int {
}
// Generic case involving doubles, and invalid integer ranges.
if (lowerLimit.compareTo(upperLimit) > 0) {
throw new ArgumentError(lowerLimit);
throw ArgumentError(lowerLimit);
}
if (lowerLimit.isNaN) return lowerLimit;
// Note that we don't need to care for -0.0 for the lower limit.
@@ -293,7 +293,7 @@ abstract final class _IntegerImplementation implements int {
@pragma("vm:recognized", "other")
@pragma("vm:exact-result-type", _Double)
double toDouble() {
return new _Double.fromInteger(this);
return _Double.fromInteger(this);
}
String toStringAsFixed(int fractionDigits) {
@@ -312,7 +312,7 @@ abstract final class _IntegerImplementation implements int {
String toRadixString(int radix) {
if (radix < 2 || 36 < radix) {
throw new RangeError.range(radix, 2, 36, "radix");
throw RangeError.range(radix, 2, 36, "radix");
}
if (radix & (radix - 1) == 0) {
return _toPow2String(radix);
@@ -395,13 +395,13 @@ abstract final class _IntegerImplementation implements int {
int modPow(int e, int m) {
// TODO: Remove these null checks once all code is opted into strong nonnullable mode.
if (e == null) {
throw new ArgumentError.notNull("exponent");
throw ArgumentError.notNull("exponent");
}
if (m == null) {
throw new ArgumentError.notNull("modulus");
throw ArgumentError.notNull("modulus");
}
if (e < 0) throw new RangeError.range(e, 0, null, "exponent");
if (m <= 0) throw new RangeError.range(m, 1, null, "modulus");
if (e < 0) throw RangeError.range(e, 0, null, "exponent");
if (m <= 0) throw RangeError.range(m, 1, null, "modulus");
if (e == 0) return 1;
// This is floor(sqrt(2^63)).
@@ -486,7 +486,7 @@ abstract final class _IntegerImplementation implements int {
} while (u != 0);
if (!inv) return v << s;
if (v != 1) {
throw new Exception("Not coprime");
throw Exception("Not coprime");
}
if (d < 0) {
d += x;
@@ -502,15 +502,15 @@ abstract final class _IntegerImplementation implements int {
int modInverse(int m) {
// TODO: Remove these null checks once all code is opted into strong nonnullable mode.
if (m == null) {
throw new ArgumentError.notNull("modulus");
throw ArgumentError.notNull("modulus");
}
if (m <= 0) throw new RangeError.range(m, 1, null, "modulus");
if (m <= 0) throw RangeError.range(m, 1, null, "modulus");
if (m == 1) return 0;
int t = this;
if ((t < 0) || (t >= m)) t %= m;
if (t == 1) return 1;
if ((t == 0) || (t.isEven && m.isEven)) {
throw new Exception("Not coprime");
throw Exception("Not coprime");
}
return _binaryGcd(m, t, true);
}
@@ -519,7 +519,7 @@ abstract final class _IntegerImplementation implements int {
int gcd(int other) {
// TODO: Remove these null checks once all code is opted into strong nonnullable mode.
if (other == null) {
throw new ArgumentError.notNull("other");
throw ArgumentError.notNull("other");
}
int x = this.abs();
int y = other.abs();
@@ -558,7 +558,7 @@ final class _Smi extends _IntegerImplementation {
* Get the digits of `n`, with `0 <= n < 100`, as
* `_digitTable[n * 2]` and `_digitTable[n * 2 + 1]`.
*/
static const _digitTable = const [
static const _digitTable = [
0x30, 0x30, 0x30, 0x31, 0x30, 0x32, 0x30, 0x33, //
0x30, 0x34, 0x30, 0x35, 0x30, 0x36, 0x30, 0x37, //
0x30, 0x38, 0x30, 0x39, 0x31, 0x30, 0x31, 0x31, //
@@ -589,7 +589,7 @@ final class _Smi extends _IntegerImplementation {
/**
* Result of int.toString for -99, -98, ..., 98, 99.
*/
static const _smallLookupTable = const [
static const _smallLookupTable = [
"-99", "-98", "-97", "-96", "-95", "-94", "-93", "-92", "-91", "-90", //
"-89", "-88", "-87", "-86", "-85", "-84", "-83", "-82", "-81", "-80", //
"-79", "-78", "-77", "-76", "-75", "-74", "-73", "-72", "-71", "-70", //
+5 -5
View File
@@ -206,22 +206,22 @@ bool isSentinel(dynamic value) => throw UnsupportedError('isSentinel');
class LateError {
@pragma("vm:entry-point")
static Never _throwFieldAlreadyInitialized(String fieldName) {
throw new LateError.fieldAI(fieldName);
throw LateError.fieldAI(fieldName);
}
@pragma("vm:entry-point")
static Never _throwLocalNotInitialized(String localName) {
throw new LateError.localNI(localName);
throw LateError.localNI(localName);
}
@pragma("vm:entry-point")
static Never _throwLocalAlreadyInitialized(String localName) {
throw new LateError.localAI(localName);
throw LateError.localAI(localName);
}
@pragma("vm:entry-point")
static Never _throwLocalAssignedDuringInitialization(String localName) {
throw new LateError.localADI(localName);
throw LateError.localADI(localName);
}
}
@@ -234,7 +234,7 @@ void checkValidWeakTarget(object, name) {
(object is Pointer) ||
(object is Struct) ||
(object is Union)) {
throw new ArgumentError.value(
throw ArgumentError.value(
object,
name,
"Cannot be a string, number, boolean, record, null, Pointer, Struct or Union",
@@ -73,16 +73,14 @@ class _InvocationMirror implements Invocation {
}
if (funcName.startsWith("get:")) {
_type |= _GETTER;
_memberName = new internal.Symbol.unvalidated(funcName.substring(4));
_memberName = internal.Symbol.unvalidated(funcName.substring(4));
} else if (funcName.startsWith("set:")) {
_type |= _SETTER;
_memberName = new internal.Symbol.unvalidated(
funcName.substring(4) + "=",
);
_memberName = internal.Symbol.unvalidated(funcName.substring(4) + "=");
} else {
_type |=
_isSuperInvocation ? (_SUPER << _LEVEL_SHIFT) | _METHOD : _METHOD;
_memberName = new internal.Symbol.unvalidated(funcName);
_memberName = internal.Symbol.unvalidated(funcName);
}
}
@@ -130,7 +128,7 @@ class _InvocationMirror implements Invocation {
// Exclude receiver and type args in the returned list.
var receiverIndex = _typeArgsLen > 0 ? 1 : 0;
var args = _arguments!;
_positionalArguments = new _ImmutableList._from(
_positionalArguments = _ImmutableList._from(
args,
receiverIndex + 1,
numPositionalArguments,
@@ -151,15 +149,15 @@ class _InvocationMirror implements Invocation {
return _namedArguments = const {};
}
var receiverIndex = _typeArgsLen > 0 ? 1 : 0;
final namedArguments = new Map<Symbol, Object?>();
final namedArguments = Map<Symbol, Object?>();
for (var i = 0; i < numNamedArguments; i++) {
var namedEntryIndex = _FIRST_NAMED_ENTRY + 2 * i;
var pos = argsDescriptor[namedEntryIndex + 1] as int;
var arg_name = argsDescriptor[namedEntryIndex] as String;
var arg_value = _arguments![receiverIndex + pos];
namedArguments[new internal.Symbol.unvalidated(arg_name)] = arg_value;
namedArguments[internal.Symbol.unvalidated(arg_name)] = arg_value;
}
_namedArguments = new Map.unmodifiable(namedArguments);
_namedArguments = Map.unmodifiable(namedArguments);
}
return _namedArguments!;
}
@@ -218,7 +216,7 @@ class _InvocationMirror implements Invocation {
bool isSuperInvocation, [
int type = _UNINITIALIZED,
]) {
return new _InvocationMirror(
return _InvocationMirror(
functionName,
argumentsDescriptor,
arguments,
@@ -240,7 +238,7 @@ class _InvocationMirror implements Invocation {
int? type,
int delayedTypeArgumentsLen,
) {
return new _InvocationMirror(
return _InvocationMirror(
functionName,
argumentsDescriptor,
arguments,
+30 -31
View File
@@ -16,12 +16,11 @@ part "timer_impl.dart";
@patch
class ReceivePort {
@patch
factory ReceivePort([String debugName = '']) =>
new _ReceivePortImpl(debugName);
factory ReceivePort([String debugName = '']) => _ReceivePortImpl(debugName);
@patch
factory ReceivePort.fromRawReceivePort(RawReceivePort rawPort) {
return new _ReceivePortImpl.fromRawReceivePort(rawPort);
return _ReceivePortImpl.fromRawReceivePort(rawPort);
}
}
@@ -29,7 +28,7 @@ class ReceivePort {
@pragma("vm:entry-point")
class Capability {
@patch
factory Capability() => new _Capability();
factory Capability() => _Capability();
}
@pragma("vm:entry-point")
@@ -62,7 +61,7 @@ class RawReceivePort {
*/
@patch
factory RawReceivePort([Function? handler, String debugName = '']) {
_RawReceivePort result = new _RawReceivePort(debugName);
_RawReceivePort result = _RawReceivePort(debugName);
result.handler = handler;
return result;
}
@@ -70,10 +69,10 @@ class RawReceivePort {
final class _ReceivePortImpl extends Stream implements ReceivePort {
_ReceivePortImpl([String debugName = ''])
: this.fromRawReceivePort(new RawReceivePort(null, debugName));
: this.fromRawReceivePort(RawReceivePort(null, debugName));
_ReceivePortImpl.fromRawReceivePort(this._rawPort)
: _controller = new StreamController(sync: true) {
: _controller = StreamController(sync: true) {
_controller.onCancel = close;
_rawPort.handler = _controller.add;
}
@@ -341,7 +340,7 @@ final class Isolate {
static Uri? get packageConfigSync {
var hook = VMLibraryHooks.packageConfigUriSync;
if (hook == null) {
throw new UnsupportedError("Isolate.packageConfig");
throw UnsupportedError("Isolate.packageConfig");
}
return hook();
}
@@ -355,7 +354,7 @@ final class Isolate {
static Uri? resolvePackageUriSync(Uri packageUri) {
var hook = VMLibraryHooks.resolvePackageUriSync;
if (hook == null) {
throw new UnsupportedError("Isolate.resolvePackageUriSync");
throw UnsupportedError("Isolate.resolvePackageUriSync");
}
return hook(packageUri);
}
@@ -383,7 +382,7 @@ final class Isolate {
if (script == null) {
// We do not have enough information to support spawning the new
// isolate.
throw new UnsupportedError("Isolate.spawn");
throw UnsupportedError("Isolate.spawn");
}
if (script.isScheme("package")) {
if (Isolate._packageSupported()) {
@@ -393,7 +392,7 @@ final class Isolate {
}
}
final RawReceivePort readyPort = new RawReceivePort(
final RawReceivePort readyPort = RawReceivePort(
null,
'Isolate.spawn ready',
);
@@ -413,7 +412,7 @@ final class Isolate {
return await _spawnCommon(readyPort);
} catch (e, st) {
readyPort.close();
return await new Future<Isolate>.error(e, st);
return await Future<Isolate>.error(e, st);
}
}
@@ -448,20 +447,20 @@ final class Isolate {
String? debugName,
}) async {
if (environment != null) {
throw new UnimplementedError("environment");
throw UnimplementedError("environment");
}
// Verify that no mutually exclusive arguments have been passed.
if (automaticPackageResolution) {
if (packageRoot != null) {
throw new ArgumentError(
throw ArgumentError(
"Cannot simultaneously request "
"automaticPackageResolution and specify a "
"packageRoot.",
);
}
if (packageConfig != null) {
throw new ArgumentError(
throw ArgumentError(
"Cannot simultaneously request "
"automaticPackageResolution and specify a "
"packageConfig.",
@@ -469,7 +468,7 @@ final class Isolate {
}
} else {
if ((packageRoot != null) && (packageConfig != null)) {
throw new ArgumentError(
throw ArgumentError(
"Cannot simultaneously specify a "
"packageRoot and a packageConfig.",
);
@@ -497,7 +496,7 @@ final class Isolate {
// The VM will invoke [_startIsolate] and not `main`.
final packageConfigString = packageConfig?.toString();
final RawReceivePort readyPort = new RawReceivePort(
final RawReceivePort readyPort = RawReceivePort(
null,
'Isolate.spawnUri ready',
);
@@ -526,14 +525,14 @@ final class Isolate {
}
static Future<Isolate> _spawnCommon(RawReceivePort readyPort) {
final completer = new Completer<Isolate>.sync();
final completer = Completer<Isolate>.sync();
readyPort.handler = (readyMessage) {
readyPort.close();
if (readyMessage is List && readyMessage.length == 2) {
SendPort controlPort = readyMessage[0];
List capabilities = readyMessage[1];
completer.complete(
new Isolate(
Isolate(
controlPort,
pauseCapability: capabilities[0],
terminateCapability: capabilities[1],
@@ -542,12 +541,12 @@ final class Isolate {
} else if (readyMessage is String) {
// We encountered an error while starting the new isolate.
completer.completeError(
new IsolateSpawnException('Unable to spawn isolate: ${readyMessage}'),
IsolateSpawnException('Unable to spawn isolate: ${readyMessage}'),
);
} else {
// This shouldn't happen.
completer.completeError(
new IsolateSpawnException(
IsolateSpawnException(
"Internal error: unexpected format for ready message: "
"'${readyMessage}'",
),
@@ -599,7 +598,7 @@ final class Isolate {
// _sendOOB expects a fixed length array and hence we create a fixed
// length array and assign values to it instead of using [ ... ].
var msg =
new List<Object?>.filled(4, null)
List<Object?>.filled(4, null)
..[0] =
0 // Make room for OOB message type.
..[1] = _PAUSE
@@ -611,7 +610,7 @@ final class Isolate {
@patch
void resume(Capability resumeCapability) {
var msg =
new List<Object?>.filled(4, null)
List<Object?>.filled(4, null)
..[0] =
0 // Make room for OOB message type.
..[1] = _RESUME
@@ -623,7 +622,7 @@ final class Isolate {
@patch
void addOnExitListener(SendPort responsePort, {Object? response}) {
var msg =
new List<Object?>.filled(4, null)
List<Object?>.filled(4, null)
..[0] =
0 // Make room for OOB message type.
..[1] = _ADD_EXIT
@@ -635,7 +634,7 @@ final class Isolate {
@patch
void removeOnExitListener(SendPort responsePort) {
var msg =
new List<Object?>.filled(3, null)
List<Object?>.filled(3, null)
..[0] =
0 // Make room for OOB message type.
..[1] = _DEL_EXIT
@@ -646,7 +645,7 @@ final class Isolate {
@patch
void setErrorsFatal(bool errorsAreFatal) {
var msg =
new List<Object?>.filled(4, null)
List<Object?>.filled(4, null)
..[0] =
0 // Make room for OOB message type.
..[1] = _ERROR_FATAL
@@ -658,7 +657,7 @@ final class Isolate {
@patch
void kill({int priority = beforeNextEvent}) {
var msg =
new List<Object?>.filled(4, null)
List<Object?>.filled(4, null)
..[0] =
0 // Make room for OOB message type.
..[1] = _KILL
@@ -674,7 +673,7 @@ final class Isolate {
int priority = immediate,
}) {
var msg =
new List<Object?>.filled(5, null)
List<Object?>.filled(5, null)
..[0] =
0 // Make room for OOM message type.
..[1] = _PING
@@ -687,7 +686,7 @@ final class Isolate {
@patch
void addErrorListener(SendPort port) {
var msg =
new List<Object?>.filled(3, null)
List<Object?>.filled(3, null)
..[0] =
0 // Make room for OOB message type.
..[1] = _ADD_ERROR
@@ -698,7 +697,7 @@ final class Isolate {
@patch
void removeErrorListener(SendPort port) {
var msg =
new List<Object?>.filled(3, null)
List<Object?>.filled(3, null)
..[0] =
0 // Make room for OOB message type.
..[1] = _DEL_ERROR
@@ -708,7 +707,7 @@ final class Isolate {
static Isolate _getCurrentIsolate() {
List portAndCapabilities = _getPortAndCapabilitiesOfCurrentIsolate();
return new Isolate(
return Isolate(
portAndCapabilities[0],
pauseCapability: portAndCapabilities[1],
terminateCapability: portAndCapabilities[2],
+6 -6
View File
@@ -20,7 +20,7 @@ class _LibraryPrefix {
@pragma("vm:external-name", "LibraryPrefix_issueLoad")
external static void _issueLoad(Object unit);
static final _loads = new Map<Object, Completer<void>>();
static final _loads = Map<Object, Completer<void>>();
}
class _DeferredNotLoadedError extends Error implements NoSuchMethodError {
@@ -46,7 +46,7 @@ void _completeLoads(Object unit, String? errorMessage, bool transientError) {
Completer<void>? load = _LibraryPrefix._loads[unit];
if (load == null) {
// Embedder loaded even though prefix.loadLibrary() wasn't called.
_LibraryPrefix._loads[unit] = load = new Completer<void>();
_LibraryPrefix._loads[unit] = load = Completer<void>();
}
if (errorMessage == null) {
load.complete(null);
@@ -54,7 +54,7 @@ void _completeLoads(Object unit, String? errorMessage, bool transientError) {
if (transientError) {
_LibraryPrefix._loads.remove(unit);
}
load.completeError(new DeferredLoadException(errorMessage));
load.completeError(DeferredLoadException(errorMessage));
}
}
@@ -69,7 +69,7 @@ Future<void> _loadLibrary(_LibraryPrefix prefix) async {
if (unit != 1) {
Completer<void>? load = _LibraryPrefix._loads[unit];
if (load == null) {
_LibraryPrefix._loads[unit] = load = new Completer<void>();
_LibraryPrefix._loads[unit] = load = Completer<void>();
_LibraryPrefix._issueLoad(unit);
}
await load.future;
@@ -78,7 +78,7 @@ Future<void> _loadLibrary(_LibraryPrefix prefix) async {
// Ensure the prefix's future does not complete until the next Turn even
// when loading is a no-op or synchronous. Helps applications avoid writing
// code that only works when loading isn't really deferred.
await new Future<void>(() {
await Future<void>(() {
prefix._setLoaded();
});
}
@@ -87,6 +87,6 @@ Future<void> _loadLibrary(_LibraryPrefix prefix) async {
@pragma("vm:never-inline") // Don't duplicate prefix checking code.
void _checkLoaded(_LibraryPrefix prefix) {
if (!prefix._isLoaded()) {
throw new _DeferredNotLoadedError(prefix);
throw _DeferredNotLoadedError(prefix);
}
}
+3 -3
View File
@@ -178,7 +178,7 @@ class Random {
factory Random([int? seed]) {
var state = _Random._setupSeed((seed == null) ? _Random._nextSeed() : seed);
// Crank a couple of times to distribute the seed bits a bit further.
return new _Random._withState(state)
return _Random._withState(state)
.._nextState()
.._nextState()
.._nextState()
@@ -207,7 +207,7 @@ class _Random implements Random {
int nextInt(int max) {
const limit = 0x3FFFFFFF;
if ((max <= 0) || ((max > limit) && (max > _POW2_32))) {
throw new RangeError.range(
throw RangeError.range(
max,
1,
_POW2_32,
@@ -245,7 +245,7 @@ class _Random implements Random {
static const _POW2_27_D = 1.0 * (1 << 27);
// Use a singleton Random object to get a new seed if no seed was passed.
static final _prng = new _Random._withState(_initialSeed());
static final _prng = _Random._withState(_initialSeed());
// Thomas Wang 64-bit mix.
// http://www.concentric.net/~Ttwang/tech/inthash.htm
+56 -59
View File
@@ -15,12 +15,12 @@ class _InternalMirrorError extends Error {
String _n(Symbol symbol) => internal.Symbol.getName(symbol as internal.Symbol);
Symbol _s(String name) {
return new internal.Symbol.unvalidated(name);
return internal.Symbol.unvalidated(name);
}
Symbol? _sOpt(String? name) {
if (name == null) return null;
return new internal.Symbol.unvalidated(name);
return internal.Symbol.unvalidated(name);
}
Symbol _computeQualifiedName(DeclarationMirror? owner, Symbol simpleName) {
@@ -32,7 +32,7 @@ String _makeSignatureString(
TypeMirror returnType,
List<ParameterMirror> parameters,
) {
StringBuffer buf = new StringBuffer();
StringBuffer buf = StringBuffer();
buf.write('(');
bool found_optional_positional = false;
bool found_optional_named = false;
@@ -78,25 +78,25 @@ List<InstanceMirror> _wrapMetadata(List reflectees) {
for (var reflectee in reflectees) {
mirrors.add(reflect(reflectee));
}
return new UnmodifiableListView<InstanceMirror>(mirrors);
return UnmodifiableListView<InstanceMirror>(mirrors);
}
@pragma("vm:external-name", "TypeMirror_subtypeTest")
external bool _subtypeTest(Type a, Type b);
class _MirrorSystem extends MirrorSystem {
final TypeMirror dynamicType = new _SpecialTypeMirror._('dynamic');
final TypeMirror voidType = new _SpecialTypeMirror._('void');
final TypeMirror neverType = new _SpecialTypeMirror._('Never');
final TypeMirror dynamicType = _SpecialTypeMirror._('dynamic');
final TypeMirror voidType = _SpecialTypeMirror._('void');
final TypeMirror neverType = _SpecialTypeMirror._('Never');
var _libraries;
Map<Uri, LibraryMirror> get libraries {
if ((_libraries == null) || _dirty) {
_libraries = new Map<Uri, LibraryMirror>();
_libraries = Map<Uri, LibraryMirror>();
for (LibraryMirror lib in _computeLibraries()) {
_libraries[lib.uri] = lib;
}
_libraries = new UnmodifiableMapView<Uri, LibraryMirror>(_libraries);
_libraries = UnmodifiableMapView<Uri, LibraryMirror>(_libraries);
_dirty = false;
}
return _libraries;
@@ -147,7 +147,7 @@ class _IsolateMirror extends Mirror implements IsolateMirror {
var result = _loadUri(uri.toString());
if (result == null) {
// Censored library.
throw new Exception("Cannot load $uri");
throw Exception("Cannot load $uri");
}
return result;
}
@@ -195,8 +195,8 @@ class _SyntheticAccessor implements MethodMirror {
TypeMirror get returnType => _target.type;
List<ParameterMirror> get parameters {
if (isGetter) return const <ParameterMirror>[];
return new UnmodifiableListView<ParameterMirror>(<ParameterMirror>[
new _SyntheticSetterParameter(this, this._target),
return UnmodifiableListView<ParameterMirror>(<ParameterMirror>[
_SyntheticSetterParameter(this, this._target),
]);
}
@@ -247,9 +247,9 @@ abstract class _ObjectMirror extends Mirror implements ObjectMirror {
int numPositionalArguments = positionalArguments.length;
int numNamedArguments = namedArguments.length;
int numArguments = numPositionalArguments + numNamedArguments;
List arguments = new List<dynamic>.filled(numArguments, null);
List arguments = List<dynamic>.filled(numArguments, null);
arguments.setRange(0, numPositionalArguments, positionalArguments);
List names = new List<dynamic>.filled(numNamedArguments, null);
List names = List<dynamic>.filled(numNamedArguments, null);
int argumentIndex = numPositionalArguments;
int nameIndex = 0;
if (numNamedArguments > 0) {
@@ -343,10 +343,10 @@ class _InstanceMirror extends _ObjectMirror implements InstanceMirror {
int numPositionalArguments = positionalArguments.length + 1; // Receiver.
int numNamedArguments = namedArguments.length;
int numArguments = numPositionalArguments + numNamedArguments;
List arguments = new List<dynamic>.filled(numArguments, null);
List arguments = List<dynamic>.filled(numArguments, null);
arguments[0] = _reflectee; // Receiver.
arguments.setRange(1, numPositionalArguments, positionalArguments);
List names = new List<dynamic>.filled(numNamedArguments, null);
List names = List<dynamic>.filled(numNamedArguments, null);
int argumentIndex = numPositionalArguments;
int nameIndex = 0;
if (numNamedArguments > 0) {
@@ -433,9 +433,7 @@ class _ClassMirror extends _ObjectMirror implements ClassMirror, _TypeMirror {
bool get hasReflectedType => !_isGenericDeclaration;
Type get reflectedType {
if (!hasReflectedType) {
throw new UnsupportedError(
"Declarations of generics have no reflected type",
);
throw UnsupportedError("Declarations of generics have no reflected type");
}
return _reflectedType;
}
@@ -510,7 +508,7 @@ class _ClassMirror extends _ObjectMirror implements ClassMirror, _TypeMirror {
for (var interfaceType in interfaceTypes) {
interfaceMirrors.add(reflectType(interfaceType) as ClassMirror);
}
return _superinterfaces = new UnmodifiableListView<ClassMirror>(
return _superinterfaces = UnmodifiableListView<ClassMirror>(
interfaceMirrors,
);
}
@@ -550,7 +548,7 @@ class _ClassMirror extends _ObjectMirror implements ClassMirror, _TypeMirror {
var m = _cachedStaticMembers;
if (m != null) m;
var result = new Map<Symbol, MethodMirror>();
var result = Map<Symbol, MethodMirror>();
var library = this.owner as LibraryMirror;
declarations.values.forEach((decl) {
if (decl is MethodMirror && decl.isStatic && !decl.isConstructor) {
@@ -558,7 +556,7 @@ class _ClassMirror extends _ObjectMirror implements ClassMirror, _TypeMirror {
}
if (decl is VariableMirror && decl.isStatic) {
var getterName = decl.simpleName;
result[getterName] = new _SyntheticAccessor(
result[getterName] = _SyntheticAccessor(
this,
getterName,
true,
@@ -568,7 +566,7 @@ class _ClassMirror extends _ObjectMirror implements ClassMirror, _TypeMirror {
);
if (!decl.isFinal) {
var setterName = _asSetter(decl.simpleName, library);
result[setterName] = new _SyntheticAccessor(
result[setterName] = _SyntheticAccessor(
this,
setterName,
false,
@@ -579,7 +577,7 @@ class _ClassMirror extends _ObjectMirror implements ClassMirror, _TypeMirror {
}
}
});
return _cachedStaticMembers = new UnmodifiableMapView<Symbol, MethodMirror>(
return _cachedStaticMembers = UnmodifiableMapView<Symbol, MethodMirror>(
result,
);
}
@@ -589,7 +587,7 @@ class _ClassMirror extends _ObjectMirror implements ClassMirror, _TypeMirror {
var m = _cachedInstanceMembers;
if (m != null) return m;
var result = new Map<Symbol, MethodMirror>();
var result = Map<Symbol, MethodMirror>();
var library = this.owner as LibraryMirror;
var sup = superclass;
if (sup != null) {
@@ -604,7 +602,7 @@ class _ClassMirror extends _ObjectMirror implements ClassMirror, _TypeMirror {
}
if (decl is VariableMirror && !decl.isStatic) {
var getterName = decl.simpleName;
result[getterName] = new _SyntheticAccessor(
result[getterName] = _SyntheticAccessor(
this,
getterName,
true,
@@ -614,7 +612,7 @@ class _ClassMirror extends _ObjectMirror implements ClassMirror, _TypeMirror {
);
if (!decl.isFinal) {
var setterName = _asSetter(decl.simpleName, library);
result[setterName] = new _SyntheticAccessor(
result[setterName] = _SyntheticAccessor(
this,
setterName,
false,
@@ -625,8 +623,9 @@ class _ClassMirror extends _ObjectMirror implements ClassMirror, _TypeMirror {
}
}
});
return _cachedInstanceMembers =
new UnmodifiableMapView<Symbol, MethodMirror>(result);
return _cachedInstanceMembers = UnmodifiableMapView<Symbol, MethodMirror>(
result,
);
}
Map<Symbol, DeclarationMirror>? _declarations;
@@ -634,7 +633,7 @@ class _ClassMirror extends _ObjectMirror implements ClassMirror, _TypeMirror {
var d = _declarations;
if (d != null) return d;
var decls = new Map<Symbol, DeclarationMirror>();
var decls = Map<Symbol, DeclarationMirror>();
var members = _computeMembers(mixin, _instantiator, _reflectee);
for (var member in members) {
@@ -652,7 +651,7 @@ class _ClassMirror extends _ObjectMirror implements ClassMirror, _TypeMirror {
decls[typeVariable.simpleName] = typeVariable;
}
return _declarations = new UnmodifiableMapView<Symbol, DeclarationMirror>(
return _declarations = UnmodifiableMapView<Symbol, DeclarationMirror>(
decls,
);
}
@@ -677,12 +676,10 @@ class _ClassMirror extends _ObjectMirror implements ClassMirror, _TypeMirror {
ClassMirror owner = originalDeclaration;
var mirror;
for (var i = 0; i < params.length; i += 2) {
mirror = new _TypeVariableMirror._(params[i + 1], params[i], owner);
mirror = _TypeVariableMirror._(params[i + 1], params[i], owner);
result.add(mirror);
}
return _typeVariables = new UnmodifiableListView<TypeVariableMirror>(
result,
);
return _typeVariables = UnmodifiableListView<TypeVariableMirror>(result);
}
List<TypeMirror>? _typeArguments;
@@ -694,7 +691,7 @@ class _ClassMirror extends _ObjectMirror implements ClassMirror, _TypeMirror {
(!_isTransformedMixinApplication && _isAnonymousMixinApplication)) {
return _typeArguments = const <TypeMirror>[];
} else {
return _typeArguments = new UnmodifiableListView<TypeMirror>(
return _typeArguments = UnmodifiableListView<TypeMirror>(
_computeTypeArguments(_reflectedType).cast<TypeMirror>(),
);
}
@@ -722,9 +719,9 @@ class _ClassMirror extends _ObjectMirror implements ClassMirror, _TypeMirror {
int numPositionalArguments = positionalArguments.length;
int numNamedArguments = namedArguments.length;
int numArguments = numPositionalArguments + numNamedArguments;
List arguments = new List<dynamic>.filled(numArguments, null);
List arguments = List<dynamic>.filled(numArguments, null);
arguments.setRange(0, numPositionalArguments, positionalArguments);
List names = new List<dynamic>.filled(numNamedArguments, null);
List names = List<dynamic>.filled(numNamedArguments, null);
int argumentIndex = numPositionalArguments;
int nameIndex = 0;
if (numNamedArguments > 0) {
@@ -777,7 +774,7 @@ class _ClassMirror extends _ObjectMirror implements ClassMirror, _TypeMirror {
bool isSubclassOf(ClassMirror other) {
// TODO: Remove these null checks once all code is opted into strong nonnullable mode.
if (other == null) {
throw new ArgumentError.notNull('other');
throw ArgumentError.notNull('other');
}
ClassMirror otherDeclaration = other.originalDeclaration as ClassMirror;
ClassMirror? c = this;
@@ -886,7 +883,7 @@ class _FunctionTypeMirror extends _ClassMirror implements FunctionTypeMirror {
List<ParameterMirror> get parameters {
var p = _parameters;
if (p != null) return p;
return _parameters = new UnmodifiableListView<ParameterMirror>(
return _parameters = UnmodifiableListView<ParameterMirror>(
_FunctionTypeMirror_parameters(
_signatureReflectee,
).cast<ParameterMirror>(),
@@ -972,7 +969,7 @@ class _TypeVariableMirror extends _DeclarationMirror
bool get hasReflectedType => false;
Type get reflectedType {
throw new UnsupportedError('Type variables have no reflected type');
throw UnsupportedError('Type variables have no reflected type');
}
Type get _reflectedType => _reflectee;
@@ -1044,13 +1041,13 @@ class _LibraryMirror extends _ObjectMirror implements LibraryMirror {
var d = _declarations;
if (d != null) return d;
var decls = new Map<Symbol, DeclarationMirror>();
var decls = Map<Symbol, DeclarationMirror>();
var members = _computeMembers(_reflectee);
for (var member in members) {
decls[member.simpleName] = member;
}
return _declarations = new UnmodifiableMapView<Symbol, DeclarationMirror>(
return _declarations = UnmodifiableMapView<Symbol, DeclarationMirror>(
decls,
);
}
@@ -1076,7 +1073,7 @@ class _LibraryMirror extends _ObjectMirror implements LibraryMirror {
var d = _cachedLibraryDependencies;
if (d != null) return d;
return _cachedLibraryDependencies =
new UnmodifiableListView<LibraryDependencyMirror>(
UnmodifiableListView<LibraryDependencyMirror>(
_libraryDependencies(_reflectee).cast<LibraryDependencyMirror>(),
);
}
@@ -1116,7 +1113,7 @@ class _LibraryDependencyMirror extends Mirror
this.isDeferred,
List<dynamic> unwrappedMetadata,
) : prefix = _sOpt(prefixString),
combinators = new UnmodifiableListView<CombinatorMirror>(
combinators = UnmodifiableListView<CombinatorMirror>(
mutableCombinators.cast<CombinatorMirror>(),
),
metadata = _wrapMetadata(unwrappedMetadata);
@@ -1136,7 +1133,7 @@ class _LibraryDependencyMirror extends Mirror
Future<LibraryMirror> loadLibrary() {
if (_targetMirrorOrPrefix is _LibraryMirror) {
return new Future.value(_targetMirrorOrPrefix);
return Future.value(_targetMirrorOrPrefix);
}
var savedPrefix = _targetMirrorOrPrefix;
return savedPrefix.loadLibrary().then((_) {
@@ -1155,7 +1152,7 @@ class _CombinatorMirror extends Mirror implements CombinatorMirror {
final bool isShow;
_CombinatorMirror._(identifierString, this.isShow)
: this.identifiers = new UnmodifiableListView<Symbol>(<Symbol>[
: this.identifiers = UnmodifiableListView<Symbol>(<Symbol>[
_s(identifierString),
]);
@@ -1206,7 +1203,7 @@ class _MethodMirror extends _DeclarationMirror implements MethodMirror {
bool get isExtensionTypeMember =>
0 != (_kindFlags & (1 << kExtensionTypeMember));
static const _operators = const [
static const _operators = [
"%", "&", "*", "+", "-", "/", "<", "<<", //
"<=", "==", ">", ">=", ">>", "[]", "[]=",
"^", "|", "~", "unary-", "~/",
@@ -1244,7 +1241,7 @@ class _MethodMirror extends _DeclarationMirror implements MethodMirror {
List<ParameterMirror> get parameters {
var p = _parameters;
if (p != null) return p;
return _parameters = new UnmodifiableListView<ParameterMirror>(
return _parameters = UnmodifiableListView<ParameterMirror>(
_MethodMirror_parameters(_reflectee).cast<ParameterMirror>(),
);
}
@@ -1261,7 +1258,7 @@ class _MethodMirror extends _DeclarationMirror implements MethodMirror {
} else {
var parts = MirrorSystem.getName(simpleName).split('.');
if (parts.length > 2) {
throw new _InternalMirrorError(
throw _InternalMirrorError(
'Internal error in MethodMirror.constructorName: '
'malformed name <$simpleName>',
);
@@ -1334,7 +1331,7 @@ class _VariableMirror extends _DeclarationMirror implements VariableMirror {
} else if (o is _LibraryMirror) {
return o._instantiator;
} else {
throw new UnsupportedError("unexpected owner ${owner}");
throw UnsupportedError("unexpected owner ${owner}");
}
}
@@ -1395,7 +1392,7 @@ class _ParameterMirror extends _VariableMirror implements ParameterMirror {
bool get hasDefaultValue => _defaultValueReflectee != null;
SourceLocation? get location {
throw new UnsupportedError("ParameterMirror.location unimplemented");
throw UnsupportedError("ParameterMirror.location unimplemented");
}
List<InstanceMirror> get metadata {
@@ -1440,7 +1437,7 @@ class _SpecialTypeMirror extends Mirror
bool get hasReflectedType => simpleName == #dynamic;
Type get reflectedType {
if (simpleName == #dynamic) return dynamic;
throw new UnsupportedError("void has no reflected type");
throw UnsupportedError("void has no reflected type");
}
List<TypeVariableMirror> get typeVariables => const <TypeVariableMirror>[];
@@ -1472,7 +1469,7 @@ class _SpecialTypeMirror extends Mirror
}
class _Mirrors {
static MirrorSystem _currentMirrorSystem = new _MirrorSystem();
static MirrorSystem _currentMirrorSystem = _MirrorSystem();
static MirrorSystem currentMirrorSystem() {
return _currentMirrorSystem;
}
@@ -1480,8 +1477,8 @@ class _Mirrors {
// Creates a new local mirror for some Object.
static InstanceMirror reflect(dynamic reflectee) {
return reflectee is Function
? new _ClosureMirror._(reflectee)
: new _InstanceMirror._(reflectee);
? _ClosureMirror._(reflectee)
: _InstanceMirror._(reflectee);
}
@pragma("vm:external-name", "Mirrors_makeLocalClassMirror")
@@ -1491,8 +1488,8 @@ class _Mirrors {
@pragma("vm:external-name", "Mirrors_instantiateGenericType")
external static Type _instantiateGenericType(Type key, typeArguments);
static Expando<_ClassMirror> _declarationCache = new Expando("ClassMirror");
static Expando<TypeMirror> _instantiationCache = new Expando("TypeMirror");
static Expando<_ClassMirror> _declarationCache = Expando("ClassMirror");
static Expando<TypeMirror> _instantiationCache = Expando("TypeMirror");
static ClassMirror reflectClass(Type key) {
var classMirror = _declarationCache[key];
@@ -1523,7 +1520,7 @@ class _Mirrors {
static Type _instantiateType(Type key, List<Type> typeArguments) {
if (typeArguments.isEmpty) {
throw new ArgumentError.value(
throw ArgumentError.value(
typeArguments,
'typeArguments',
'Type arguments list cannot be empty.',
+4 -4
View File
@@ -66,12 +66,12 @@ class MirrorSystem {
}
if (candidates.length > 1) {
var uris = candidates.map((lib) => lib.uri.toString()).toList();
throw new Exception(
throw Exception(
"There are multiple libraries named "
"'${getName(libraryName)}': $uris",
);
}
throw new Exception("There is no library named '${getName(libraryName)}'");
throw Exception("There is no library named '${getName(libraryName)}'");
}
@patch
@@ -83,12 +83,12 @@ class MirrorSystem {
static Symbol getSymbol(String name, [LibraryMirror? library]) {
if ((library != null && library is! _LibraryMirror) ||
((name.length > 0) && (name[0] == '_') && (library == null))) {
throw new ArgumentError(library);
throw ArgumentError(library);
}
if (library != null) {
name = _mangleName(name, (library as _LibraryMirror)._reflectee);
}
return new internal.Symbol.unvalidated(name);
return internal.Symbol.unvalidated(name);
}
@pragma("vm:external-name", "Mirrors_mangleName")
+1 -1
View File
@@ -35,7 +35,7 @@ class Object {
@pragma("vm:entry-point", "call")
dynamic noSuchMethod(Invocation invocation) {
// TODO(regis): Remove temp constructor identifier 'withInvocation'.
throw new NoSuchMethodError.withInvocation(this, invocation);
throw NoSuchMethodError.withInvocation(this, invocation);
}
@patch
+1 -1
View File
@@ -14,7 +14,7 @@ void printToConsole(String line) {
}
void _unsupportedPrint(String line) {
throw new UnsupportedError("'print' is not supported");
throw UnsupportedError("'print' is not supported");
}
// _printClosure can be overwritten by the embedder to supply a different
+1 -1
View File
@@ -8,7 +8,7 @@ part of "developer.dart";
class UserTag {
@patch
factory UserTag(String label) {
return new _UserTag(label);
return _UserTag(label);
}
@patch
static UserTag get defaultTag => _getDefaultTag();
+19 -20
View File
@@ -14,7 +14,7 @@ class RegExp {
bool unicode = false,
bool dotAll = false,
}) {
return new _RegExp(
return _RegExp(
source,
multiLine: multiLine,
caseSensitive: caseSensitive,
@@ -59,7 +59,7 @@ class RegExp {
// If the text contains no characters needing escape, return it directly.
if (escapeCharIndex == text.length) return text;
var buffer = new StringBuffer();
var buffer = StringBuffer();
int previousSliceEndIndex = 0;
do {
// Copy characters from previous escape to current escape into result.
@@ -96,7 +96,7 @@ class _RegExpMatch implements RegExpMatch {
String? group(int groupIdx) {
if (groupIdx < 0 || groupIdx > _regexp._groupCount) {
throw new RangeError.value(groupIdx);
throw RangeError.value(groupIdx);
}
int startIndex = _start(groupIdx);
int endIndex = _end(groupIdx);
@@ -112,7 +112,7 @@ class _RegExpMatch implements RegExpMatch {
}
List<String?> groups(List<int> groupsSpec) {
var groupsList = new List<String?>.filled(groupsSpec.length, null);
var groupsList = List<String?>.filled(groupsSpec.length, null);
for (int i = 0; i < groupsSpec.length; i++) {
groupsList[i] = group(groupsSpec[i]);
}
@@ -156,46 +156,46 @@ class _RegExp implements RegExp {
RegExpMatch? firstMatch(String input) {
// TODO: Remove these null checks once all code is opted into strong nonnullable mode.
if (input == null) throw new ArgumentError.notNull('input');
if (input == null) throw ArgumentError.notNull('input');
final match = _ExecuteMatch(input, 0);
if (match == null) {
return null;
}
return new _RegExpMatch._(this, input, match);
return _RegExpMatch._(this, input, match);
}
Iterable<RegExpMatch> allMatches(String string, [int start = 0]) {
// TODO: Remove these null checks once all code is opted into strong nonnullable mode.
if (string == null) throw new ArgumentError.notNull('string');
if (start == null) throw new ArgumentError.notNull('start');
if (string == null) throw ArgumentError.notNull('string');
if (start == null) throw ArgumentError.notNull('start');
if (0 > start || start > string.length) {
throw new RangeError.range(start, 0, string.length);
throw RangeError.range(start, 0, string.length);
}
return new _AllMatchesIterable(this, string, start);
return _AllMatchesIterable(this, string, start);
}
RegExpMatch? matchAsPrefix(String string, [int start = 0]) {
// TODO: Remove these null checks once all code is opted into strong nonnullable mode.
if (string == null) throw new ArgumentError.notNull('string');
if (start == null) throw new ArgumentError.notNull('start');
if (string == null) throw ArgumentError.notNull('string');
if (start == null) throw ArgumentError.notNull('start');
if (start < 0 || start > string.length) {
throw new RangeError.range(start, 0, string.length);
throw RangeError.range(start, 0, string.length);
}
final list = _ExecuteMatchSticky(string, start);
if (list == null) return null;
return new _RegExpMatch._(this, string, list);
return _RegExpMatch._(this, string, list);
}
bool hasMatch(String input) {
// TODO: Remove these null checks once all code is opted into strong nonnullable mode.
if (input == null) throw new ArgumentError.notNull('input');
if (input == null) throw ArgumentError.notNull('input');
List? match = _ExecuteMatch(input, 0);
return (match == null) ? false : true;
}
String? stringMatch(String input) {
// TODO: Remove these null checks once all code is opted into strong nonnullable mode.
if (input == null) throw new ArgumentError.notNull('input');
if (input == null) throw ArgumentError.notNull('input');
List? match = _ExecuteMatch(input, 0);
if (match == null) {
return null;
@@ -253,7 +253,7 @@ class _RegExp implements RegExp {
// Byte map of one byte characters with a 0xff if the character is a word
// character (digit, letter or underscore) and 0x00 otherwise.
// Used by generated RegExp code.
static const List<int> _wordCharacterMap = const <int>[
static const List<int> _wordCharacterMap = <int>[
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
@@ -337,8 +337,7 @@ class _AllMatchesIterable extends Iterable<RegExpMatch> {
_AllMatchesIterable(this._re, this._str, this._start);
Iterator<RegExpMatch> get iterator =>
new _AllMatchesIterator(_re, _str, _start);
Iterator<RegExpMatch> get iterator => _AllMatchesIterator(_re, _str, _start);
}
class _AllMatchesIterator implements Iterator<RegExpMatch> {
@@ -365,7 +364,7 @@ class _AllMatchesIterator implements Iterator<RegExpMatch> {
if (_nextIndex <= _str.length) {
final match = re._ExecuteMatch(_str, _nextIndex);
if (match != null) {
var current = new _RegExpMatch._(re, _str, match);
var current = _RegExpMatch._(re, _str, match);
_current = current;
_nextIndex = current.end;
if (_nextIndex == current.start) {
@@ -10,7 +10,7 @@ class _AsyncRun {
static void _scheduleImmediate(void callback()) {
final closure = _ScheduleImmediate._closure;
if (closure == null) {
throw new UnsupportedError("Microtasks are not supported");
throw UnsupportedError("Microtasks are not supported");
}
closure(callback);
}
+35 -39
View File
@@ -20,8 +20,8 @@ class String {
int? end,
]) {
// TODO: Remove these null checks once all code is opted into strong nonnullable mode.
if (charCodes == null) throw new ArgumentError.notNull("charCodes");
if (start == null) throw new ArgumentError.notNull("start");
if (charCodes == null) throw ArgumentError.notNull("charCodes");
if (start == null) throw ArgumentError.notNull("start");
return _StringBase.createFromCharCodes(charCodes, start, end, null);
}
@@ -43,7 +43,7 @@ class String {
.._setAt(1, low);
}
}
throw new RangeError.range(charCode, 0, 0x10ffff);
throw RangeError.range(charCode, 0, 0x10ffff);
}
@patch
@@ -96,7 +96,7 @@ abstract final class _StringBase implements String {
static const int _maxJoinReplaceOneByteStringLength = 500;
factory _StringBase._uninstantiable() {
throw new UnsupportedError("_StringBase can't be instantiated");
throw UnsupportedError("_StringBase can't be instantiated");
}
@pragma("vm:recognized", "asm-intrinsic")
@@ -170,7 +170,7 @@ abstract final class _StringBase implements String {
final int actualLimit = limit ?? _scanCodeUnits(typedCharCodes, start, end);
if (actualLimit < 0) {
throw new ArgumentError(typedCharCodes);
throw ArgumentError(typedCharCodes);
}
if (actualLimit <= _maxLatin1) {
return _createOneByteString(typedCharCodes, start, len);
@@ -192,7 +192,7 @@ abstract final class _StringBase implements String {
int bits = 0;
for (int i = start; i < end; i++) {
int code = charCodes[i];
if (code is! _Smi) throw new ArgumentError(charCodes);
if (code is! _Smi) throw ArgumentError(charCodes);
bits |= code;
}
return bits;
@@ -375,7 +375,7 @@ abstract final class _StringBase implements String {
bool startsWith(Pattern pattern, [int index = 0]) {
if ((index < 0) || (index > this.length)) {
throw new RangeError.range(index, 0, this.length);
throw RangeError.range(index, 0, this.length);
}
if (pattern is String) {
return _substringMatches(index, pattern);
@@ -417,7 +417,7 @@ abstract final class _StringBase implements String {
if (start == null) {
start = this.length;
} else if (start < 0 || start > this.length) {
throw new RangeError.range(start, 0, this.length);
throw RangeError.range(start, 0, this.length);
}
if (pattern is String) {
String other = pattern;
@@ -580,7 +580,7 @@ abstract final class _StringBase implements String {
String operator *(int times) {
if (times <= 0) return "";
if (times == 1) return this;
StringBuffer buffer = new StringBuffer(this);
StringBuffer buffer = StringBuffer(this);
for (int i = 1; i < times; i++) {
buffer.write(this);
}
@@ -590,7 +590,7 @@ abstract final class _StringBase implements String {
String padLeft(int width, [String padding = ' ']) {
int delta = width - this.length;
if (delta <= 0) return this;
StringBuffer buffer = new StringBuffer();
StringBuffer buffer = StringBuffer();
for (int i = 0; i < delta; i++) {
buffer.write(padding);
}
@@ -601,7 +601,7 @@ abstract final class _StringBase implements String {
String padRight(int width, [String padding = ' ']) {
int delta = width - this.length;
if (delta <= 0) return this;
StringBuffer buffer = new StringBuffer(this);
StringBuffer buffer = StringBuffer(this);
for (int i = 0; i < delta; i++) {
buffer.write(padding);
}
@@ -671,8 +671,8 @@ abstract final class _StringBase implements String {
}
String replaceAll(Pattern pattern, String replacement) {
if (pattern == null) throw new ArgumentError.notNull("pattern");
if (replacement == null) throw new ArgumentError.notNull("replacement");
if (pattern == null) throw ArgumentError.notNull("pattern");
if (replacement == null) throw ArgumentError.notNull("replacement");
int startIndex = 0;
// String fragments that replace the prefix [this] up to [startIndex].
@@ -770,8 +770,8 @@ abstract final class _StringBase implements String {
);
String replaceAllMapped(Pattern pattern, String replace(Match match)) {
if (pattern == null) throw new ArgumentError.notNull("pattern");
if (replace == null) throw new ArgumentError.notNull("replace");
if (pattern == null) throw ArgumentError.notNull("pattern");
if (replace == null) throw ArgumentError.notNull("replace");
List matches = [];
int length = 0;
int startIndex = 0;
@@ -805,9 +805,9 @@ abstract final class _StringBase implements String {
String replace(Match match), [
int startIndex = 0,
]) {
if (pattern == null) throw new ArgumentError.notNull("pattern");
if (replace == null) throw new ArgumentError.notNull("replace");
if (startIndex == null) throw new ArgumentError.notNull("startIndex");
if (pattern == null) throw ArgumentError.notNull("pattern");
if (replace == null) throw ArgumentError.notNull("replace");
if (startIndex == null) throw ArgumentError.notNull("startIndex");
RangeError.checkValueInInterval(startIndex, 0, this.length, "startIndex");
var matches = pattern.allMatches(this, startIndex).iterator;
@@ -825,12 +825,12 @@ abstract final class _StringBase implements String {
String onNonMatch(String nonMatch),
) {
// Pattern is the empty string.
StringBuffer buffer = new StringBuffer();
StringBuffer buffer = StringBuffer();
int length = this.length;
int i = 0;
buffer.write(onNonMatch(""));
while (i < length) {
buffer.write(onMatch(new _StringMatch(i, this, "")));
buffer.write(onMatch(_StringMatch(i, this, "")));
// Special case to avoid splitting a surrogate pair.
int code = this.codeUnitAt(i);
if ((code & ~0x3FF) == 0xD800 && length > i + 1) {
@@ -846,7 +846,7 @@ abstract final class _StringBase implements String {
buffer.write(onNonMatch(this[i]));
i++;
}
buffer.write(onMatch(new _StringMatch(i, this, "")));
buffer.write(onMatch(_StringMatch(i, this, "")));
buffer.write(onNonMatch(""));
return buffer.toString();
}
@@ -857,7 +857,7 @@ abstract final class _StringBase implements String {
String onNonMatch(String nonMatch)?,
}) {
if (pattern == null) {
throw new ArgumentError.notNull("pattern");
throw ArgumentError.notNull("pattern");
}
onMatch ??= _matchString;
onNonMatch ??= _stringIdentity;
@@ -867,7 +867,7 @@ abstract final class _StringBase implements String {
return _splitMapJoinEmptyString(onMatch, onNonMatch);
}
}
StringBuffer buffer = new StringBuffer();
StringBuffer buffer = StringBuffer();
int startIndex = 0;
for (Match match in pattern.allMatches(this)) {
buffer.write(onNonMatch(this.substring(startIndex, match.start)));
@@ -932,23 +932,19 @@ abstract final class _StringBase implements String {
static ArgumentError _interpolationError(Object? o, Object? result) {
// Since Dart 2.0, [result] can only be null.
return new ArgumentError.value(
o,
"object",
"toString method returned 'null'",
);
return ArgumentError.value(o, "object", "toString method returned 'null'");
}
Iterable<Match> allMatches(String string, [int start = 0]) {
if (start < 0 || start > string.length) {
throw new RangeError.range(start, 0, string.length, "start");
throw RangeError.range(start, 0, string.length, "start");
}
return new _StringAllMatchesIterable(string, this, start);
return _StringAllMatchesIterable(string, this, start);
}
Match? matchAsPrefix(String string, [int start = 0]) {
if (start < 0 || start > string.length) {
throw new RangeError.range(start, 0, string.length);
throw RangeError.range(start, 0, string.length);
}
if (start + this.length > string.length) return null;
for (int i = 0; i < this.length; i++) {
@@ -956,12 +952,12 @@ abstract final class _StringBase implements String {
return null;
}
}
return new _StringMatch(start, string, this);
return _StringMatch(start, string, this);
}
List<String> split(Pattern pattern) {
if ((pattern is String) && pattern.isEmpty) {
List<String> result = new List<String>.generate(
List<String> result = List<String>.generate(
this.length,
(int i) => this[i],
);
@@ -999,9 +995,9 @@ abstract final class _StringBase implements String {
return result;
}
List<int> get codeUnits => new CodeUnits(this);
List<int> get codeUnits => CodeUnits(this);
Runes get runes => new Runes(this);
Runes get runes => Runes(this);
@pragma("vm:external-name", "String_toUpperCase")
external String toUpperCase();
@@ -1446,7 +1442,7 @@ final class _StringMatch implements Match {
String group(int group) {
if (group != 0) {
throw new RangeError.value(group);
throw RangeError.value(group);
}
return pattern;
}
@@ -1472,12 +1468,12 @@ final class _StringAllMatchesIterable extends Iterable<Match> {
_StringAllMatchesIterable(this._input, this._pattern, this._index);
Iterator<Match> get iterator =>
new _StringAllMatchesIterator(_input, _pattern, _index);
_StringAllMatchesIterator(_input, _pattern, _index);
Match get first {
int index = _input.indexOf(_pattern, _index);
if (index >= 0) {
return new _StringMatch(index, _input, _pattern);
return _StringMatch(index, _input, _pattern);
}
throw IterableElementError.noElement();
}
@@ -1503,7 +1499,7 @@ final class _StringAllMatchesIterator implements Iterator<Match> {
return false;
}
int end = index + _pattern.length;
_current = new _StringMatch(index, _input, _pattern);
_current = _StringMatch(index, _input, _pattern);
// Empty match, don't start at same location again.
if (end == _index) end++;
_index = end;
+1 -1
View File
@@ -24,7 +24,7 @@ class Symbol {
// Class._constructor@xxx -> Class._constructor
// _Class@xxx._constructor@xxx -> _Class._constructor
// lib._S@xxx with lib._M1@xxx, lib._M2@xxx -> lib._S with lib._M1, lib._M2
StringBuffer result = new StringBuffer();
StringBuffer result = StringBuffer();
bool add_setter_suffix = false;
var pos = 0;
if (string.length >= 4 && string[3] == ':') {
+4 -4
View File
@@ -133,7 +133,7 @@ class _Timer implements Timer {
// Timers are ordered by wakeup time. Timers with a timeout value of > 0 do
// end up on the TimerHeap. Timers with a timeout of 0 are queued in a list.
static final _heap = new _TimerHeap();
static final _heap = _TimerHeap();
static _Timer? _firstZeroTimer;
static _Timer _lastZeroTimer = _sentinelTimer;
@@ -198,7 +198,7 @@ class _Timer implements Timer {
int now = VMLibraryHooks.timerMillisecondClock();
int wakeupTime = (milliSeconds == 0) ? now : (now + 1 + milliSeconds);
_Timer timer = new _Timer._internal(
_Timer timer = _Timer._internal(
callback,
wakeupTime,
milliSeconds,
@@ -491,9 +491,9 @@ class _Timer implements Timer {
bool repeating,
) {
if (repeating) {
return new _Timer.periodic(milliSeconds, callback);
return _Timer.periodic(milliSeconds, callback);
}
return new _Timer(milliSeconds, callback);
return _Timer(milliSeconds, callback);
}
}
+2 -2
View File
@@ -10,7 +10,7 @@ class Timer {
static Timer _createTimer(Duration duration, void callback()) {
final factory = VMLibraryHooks.timerFactory;
if (factory == null) {
throw new UnsupportedError("Timer interface not supported.");
throw UnsupportedError("Timer interface not supported.");
}
int milliseconds = duration.inMilliseconds;
if (milliseconds < 0) milliseconds = 0;
@@ -26,7 +26,7 @@ class Timer {
) {
final factory = VMLibraryHooks.timerFactory;
if (factory == null) {
throw new UnsupportedError("Timer interface not supported.");
throw UnsupportedError("Timer interface not supported.");
}
int milliseconds = duration.inMilliseconds;
if (milliseconds < 0) milliseconds = 0;
File diff suppressed because it is too large Load Diff
+2 -2
View File
@@ -7,7 +7,7 @@ part of "core_patch.dart";
typedef Uri _UriBaseClosure();
Uri _unsupportedUriBase() {
throw new UnsupportedError("'Uri.base' is not supported");
throw UnsupportedError("'Uri.base' is not supported");
}
// _uriBaseClosure can be overwritten by the embedder to supply a different
@@ -57,7 +57,7 @@ class _Uri {
// Encode the string into bytes then generate an ASCII only string
// by percent encoding selected bytes.
StringBuffer result = new StringBuffer();
StringBuffer result = StringBuffer();
for (int j = 0; j < i; j++) {
result.writeCharCode(text.codeUnitAt(j));
}
@@ -56,14 +56,14 @@ class BigInt implements Comparable<BigInt> {
_BigIntImpl._tryParse(source, radix: radix);
@patch
factory BigInt.from(num value) => new _BigIntImpl.from(value);
factory BigInt.from(num value) => _BigIntImpl.from(value);
}
int _max(int a, int b) => a > b ? a : b;
int _min(int a, int b) => a < b ? a : b;
/// Allocate a new digits list of even length.
Uint32List _newDigits(int length) => new Uint32List(length + (length & 1));
Uint32List _newDigits(int length) => Uint32List(length + (length & 1));
/**
* An implementation for the arbitrarily large integer.
@@ -81,14 +81,14 @@ class _BigIntImpl implements BigInt {
static const int _halfDigitBits = _digitBits >> 1;
static const int _halfDigitMask = (1 << _halfDigitBits) - 1;
static final _BigIntImpl zero = new _BigIntImpl._fromInt(0);
static final _BigIntImpl one = new _BigIntImpl._fromInt(1);
static final _BigIntImpl two = new _BigIntImpl._fromInt(2);
static final _BigIntImpl zero = _BigIntImpl._fromInt(0);
static final _BigIntImpl one = _BigIntImpl._fromInt(1);
static final _BigIntImpl two = _BigIntImpl._fromInt(2);
static final _BigIntImpl _minusOne = -one;
static final _BigIntImpl _oneDigitMask = new _BigIntImpl._fromInt(_digitMask);
static final _BigIntImpl _oneDigitMask = _BigIntImpl._fromInt(_digitMask);
static final _BigIntImpl _twoDigitMask = (one << (2 * _digitBits)) - one;
static final _BigIntImpl _oneBillion = new _BigIntImpl._fromInt(1000000000);
static final _BigIntImpl _oneBillion = _BigIntImpl._fromInt(1000000000);
static const int _minInt = -0x8000000000000000;
static const int _maxInt = 0x7fffffffffffffff;
@@ -101,7 +101,7 @@ class _BigIntImpl implements BigInt {
/// Note that [_isIntrinsified] is still false if intrinsification occurs,
/// so it should be used only inside methods which are replaced by
/// intrinsification.
static final bool _isIntrinsified = new bool.fromEnvironment(
static final bool _isIntrinsified = bool.fromEnvironment(
'dart.vm.not.a.compile.time.constant',
);
@@ -167,7 +167,7 @@ class _BigIntImpl implements BigInt {
static _BigIntImpl parse(String source, {int? radix}) {
var result = _tryParse(source, radix: radix);
if (result == null) {
throw new FormatException("Could not parse BigInt", source);
throw FormatException("Could not parse BigInt", source);
}
return result;
}
@@ -188,7 +188,7 @@ class _BigIntImpl implements BigInt {
for (int i = 0; i < source.length; i++) {
part = part * 10 + source.codeUnitAt(i) - _0;
if (++digitInPartCount == 9) {
result = result * _oneBillion + new _BigIntImpl._fromInt(part);
result = result * _oneBillion + _BigIntImpl._fromInt(part);
part = 0;
digitInPartCount = 0;
}
@@ -252,7 +252,7 @@ class _BigIntImpl implements BigInt {
digits[digitIndex--] = digit;
}
if (used == 1 && digits[0] == 0) return zero;
return new _BigIntImpl._(isNegative, used, digits);
return _BigIntImpl._(isNegative, used, digits);
}
/// Parses the given [source] as a [radix] literal.
@@ -261,11 +261,11 @@ class _BigIntImpl implements BigInt {
/// this function returns `null`.
static _BigIntImpl? _parseRadix(String source, int radix, bool isNegative) {
var result = zero;
var base = new _BigIntImpl._fromInt(radix);
var base = _BigIntImpl._fromInt(radix);
for (int i = 0; i < source.length; i++) {
var value = _codeUnitToRadixValue(source.codeUnitAt(i));
if (value >= radix) return null;
result = result * base + new _BigIntImpl._fromInt(value);
result = result * base + _BigIntImpl._fromInt(value);
}
if (isNegative) return -result;
return result;
@@ -305,7 +305,7 @@ class _BigIntImpl implements BigInt {
}
if (radix < 2 || radix > 36) {
throw new RangeError.range(radix, 2, 36, 'radix');
throw RangeError.range(radix, 2, 36, 'radix');
}
if (radix == 10 && decimalMatch != null) {
return _parseDecimal(decimalMatch, isNegative);
@@ -372,12 +372,12 @@ class _BigIntImpl implements BigInt {
if (value == 2) return two;
if (value.abs() < 0x100000000) {
return new _BigIntImpl._fromInt(value.toInt());
return _BigIntImpl._fromInt(value.toInt());
}
if (value is double) {
return new _BigIntImpl._fromDouble(value);
return _BigIntImpl._fromDouble(value);
}
return new _BigIntImpl._fromInt(value as int);
return _BigIntImpl._fromInt(value as int);
}
factory _BigIntImpl._fromInt(int value) {
@@ -389,28 +389,28 @@ class _BigIntImpl implements BigInt {
// positive.
if (value == _minInt) {
digits[1] = 0x80000000;
return new _BigIntImpl._(true, 2, digits);
return _BigIntImpl._(true, 2, digits);
}
value = -value;
}
if (value < _digitBase) {
digits[0] = value;
return new _BigIntImpl._(isNegative, 1, digits);
return _BigIntImpl._(isNegative, 1, digits);
}
digits[0] = value & _digitMask;
digits[1] = value >> _digitBits;
return new _BigIntImpl._(isNegative, 2, digits);
return _BigIntImpl._(isNegative, 2, digits);
}
/// An 8-byte Uint8List we can reuse for [_fromDouble] to avoid generating
/// garbage.
static final Uint8List _bitsForFromDouble = new Uint8List(8);
static final Uint8List _bitsForFromDouble = Uint8List(8);
factory _BigIntImpl._fromDouble(double value) {
const int exponentBias = 1075;
if (value.isNaN || value.isInfinite) {
throw new ArgumentError("Value must be finite: $value");
throw ArgumentError("Value must be finite: $value");
}
bool isNegative = value < 0;
if (isNegative) value = -value;
@@ -436,7 +436,7 @@ class _BigIntImpl implements BigInt {
unshiftedDigits[1] =
((0x10 | (bits[6] & 0xF)) << 16) + (bits[5] << 8) + bits[4];
var unshiftedBig = new _BigIntImpl._normalized(false, 2, unshiftedDigits);
var unshiftedBig = _BigIntImpl._normalized(false, 2, unshiftedDigits);
_BigIntImpl absResult = unshiftedBig;
if (exponent < 0) {
absResult = unshiftedBig >> -exponent;
@@ -455,7 +455,7 @@ class _BigIntImpl implements BigInt {
*/
_BigIntImpl operator -() {
if (_used == 0) return this;
return new _BigIntImpl._(!_isNegative, _used, _digits);
return _BigIntImpl._(!_isNegative, _used, _digits);
}
/**
@@ -477,7 +477,7 @@ class _BigIntImpl implements BigInt {
for (int i = used - 1; i >= 0; i--) {
resultDigits[i + n] = digits[i];
}
return new _BigIntImpl._(_isNegative, resultUsed, resultDigits);
return _BigIntImpl._(_isNegative, resultUsed, resultDigits);
}
/// Same as [_dlShift] but works on the decomposed big integers.
@@ -526,7 +526,7 @@ class _BigIntImpl implements BigInt {
for (var i = n; i < used; i++) {
resultDigits[i - n] = digits[i];
}
final result = new _BigIntImpl._(_isNegative, resultUsed, resultDigits);
final result = _BigIntImpl._(_isNegative, resultUsed, resultDigits);
if (_isNegative) {
// Round down if any bit was shifted out.
for (var i = 0; i < n; i++) {
@@ -607,7 +607,7 @@ class _BigIntImpl implements BigInt {
*/
_BigIntImpl operator <<(int shiftAmount) {
if (shiftAmount < 0) {
throw new ArgumentError("shift-amount must be positive $shiftAmount");
throw ArgumentError("shift-amount must be positive $shiftAmount");
}
if (_isZero) return this;
final digitShift = shiftAmount ~/ _digitBits;
@@ -620,7 +620,7 @@ class _BigIntImpl implements BigInt {
// The 64-bit intrinsic requires one extra pair to work with.
var resultDigits = _newDigits(resultUsed + 1);
_lsh(_digits, _used, shiftAmount, resultDigits);
return new _BigIntImpl._(_isNegative, resultUsed, resultDigits);
return _BigIntImpl._(_isNegative, resultUsed, resultDigits);
}
/// resultDigits[0..resultUsed-1] = xDigits[0..xUsed-1] << n.
@@ -690,7 +690,7 @@ class _BigIntImpl implements BigInt {
*/
_BigIntImpl operator >>(int shiftAmount) {
if (shiftAmount < 0) {
throw new ArgumentError("shift-amount must be positive $shiftAmount");
throw ArgumentError("shift-amount must be positive $shiftAmount");
}
if (_isZero) return this;
final digitShift = shiftAmount ~/ _digitBits;
@@ -707,7 +707,7 @@ class _BigIntImpl implements BigInt {
// The 64-bit intrinsic requires one extra pair to work with.
final resultDigits = _newDigits(resultUsed + 1);
_rsh(digits, used, shiftAmount, resultDigits);
final result = new _BigIntImpl._(_isNegative, resultUsed, resultDigits);
final result = _BigIntImpl._(_isNegative, resultUsed, resultDigits);
if (_isNegative) {
// Round down if any bit was shifted out.
if ((digits[digitShift] & ((1 << bitShift) - 1)) != 0) {
@@ -867,7 +867,7 @@ class _BigIntImpl implements BigInt {
var resultUsed = used + 1;
var resultDigits = _newDigits(resultUsed);
_absAdd(_digits, used, other._digits, otherUsed, resultDigits);
return new _BigIntImpl._(isNegative, resultUsed, resultDigits);
return _BigIntImpl._(isNegative, resultUsed, resultDigits);
}
/// Returns `abs(this) - abs(other)` with sign set according to [isNegative].
@@ -886,7 +886,7 @@ class _BigIntImpl implements BigInt {
}
var resultDigits = _newDigits(used);
_absSub(_digits, used, other._digits, otherUsed, resultDigits);
return new _BigIntImpl._(isNegative, used, resultDigits);
return _BigIntImpl._(isNegative, used, resultDigits);
}
/// Returns `abs(this) & abs(other)` with sign set according to [isNegative].
@@ -898,7 +898,7 @@ class _BigIntImpl implements BigInt {
for (var i = 0; i < resultUsed; i++) {
resultDigits[i] = digits[i] & otherDigits[i];
}
return new _BigIntImpl._(isNegative, resultUsed, resultDigits);
return _BigIntImpl._(isNegative, resultUsed, resultDigits);
}
/// Returns `abs(this) &~ abs(other)` with sign set according to [isNegative].
@@ -914,7 +914,7 @@ class _BigIntImpl implements BigInt {
for (var i = m; i < resultUsed; i++) {
resultDigits[i] = digits[i];
}
return new _BigIntImpl._(isNegative, resultUsed, resultDigits);
return _BigIntImpl._(isNegative, resultUsed, resultDigits);
}
/// Returns `abs(this) | abs(other)` with sign set according to [isNegative].
@@ -940,7 +940,7 @@ class _BigIntImpl implements BigInt {
for (var i = m; i < resultUsed; i++) {
resultDigits[i] = lDigits[i];
}
return new _BigIntImpl._(isNegative, resultUsed, resultDigits);
return _BigIntImpl._(isNegative, resultUsed, resultDigits);
}
/// Returns `abs(this) ^ abs(other)` with sign set according to [isNegative].
@@ -966,7 +966,7 @@ class _BigIntImpl implements BigInt {
for (var i = m; i < resultUsed; i++) {
resultDigits[i] = lDigits[i];
}
return new _BigIntImpl._(isNegative, resultUsed, resultDigits);
return _BigIntImpl._(isNegative, resultUsed, resultDigits);
}
/**
@@ -1283,7 +1283,7 @@ class _BigIntImpl implements BigInt {
while (i < otherUsed) {
i += _mulAdd(otherDigits, i, digits, 0, resultDigits, i, used);
}
return new _BigIntImpl._(
return _BigIntImpl._(
_isNegative != other._isNegative,
resultUsed,
resultDigits,
@@ -1396,7 +1396,7 @@ class _BigIntImpl implements BigInt {
_lastQuoRemUsed,
lastQuo_used,
);
var quo = new _BigIntImpl._(false, lastQuo_used, quo_digits);
var quo = _BigIntImpl._(false, lastQuo_used, quo_digits);
if ((_isNegative != other._isNegative) && (quo._used > 0)) {
quo = -quo;
}
@@ -1419,7 +1419,7 @@ class _BigIntImpl implements BigInt {
_lastRemUsed,
_lastRemUsed,
);
var rem = new _BigIntImpl._(false, _lastRemUsed, remDigits);
var rem = _BigIntImpl._(false, _lastRemUsed, remDigits);
if (_lastRem_nsh > 0) {
rem = rem >> _lastRem_nsh; // Denormalize remainder.
}
@@ -1869,7 +1869,7 @@ class _BigIntImpl implements BigInt {
_BigIntImpl pow(int exponent) {
if (exponent < 0) {
throw new ArgumentError("Exponent must not be negative: $exponent");
throw ArgumentError("Exponent must not be negative: $exponent");
}
if (exponent == 0) return one;
@@ -1899,10 +1899,10 @@ class _BigIntImpl implements BigInt {
final exponent = _ensureSystemBigInt(bigExponent, 'bigExponent');
final modulus = _ensureSystemBigInt(bigModulus, 'bigModulus');
if (exponent._isNegative) {
throw new ArgumentError("exponent must be positive: $exponent");
throw ArgumentError("exponent must be positive: $exponent");
}
if (modulus <= zero) {
throw new ArgumentError("modulus must be strictly positive: $modulus");
throw ArgumentError("modulus must be strictly positive: $modulus");
}
if (exponent._isZero) return one;
@@ -1912,8 +1912,8 @@ class _BigIntImpl implements BigInt {
if (cannotUseMontgomery || exponentBitlen < 64) {
_BigIntReduction z =
(cannotUseMontgomery || exponentBitlen < 8)
? new _BigIntClassicReduction(modulus)
: new _BigIntMontgomeryReduction(modulus);
? _BigIntClassicReduction(modulus)
: _BigIntMontgomeryReduction(modulus);
var resultDigits = _newDigits(2 * z._normModulusUsed + 2);
var result2Digits = _newDigits(2 * z._normModulusUsed + 2);
var gDigits = _newDigits(z._normModulusUsed);
@@ -1958,12 +1958,12 @@ class _BigIntImpl implements BigInt {
k = 5;
else
k = 6;
_BigIntReduction z = new _BigIntMontgomeryReduction(modulus);
_BigIntReduction z = _BigIntMontgomeryReduction(modulus);
var n = 3;
final int k1 = k - 1;
final km = (1 << k) - 1;
List gDigits = new List.filled(km + 1, null);
List gUsed = new List.filled(km + 1, null);
List gDigits = List.filled(km + 1, null);
List gUsed = List.filled(km + 1, null);
gDigits[1] = _newDigits(z._normModulusUsed);
gUsed[1] = z._convert(this, gDigits[1]);
if (k > 1) {
@@ -2076,14 +2076,14 @@ class _BigIntImpl implements BigInt {
if (inv) {
if ((yUsed == 1) && (yDigits[0] == 1)) return one;
if ((yUsed == 0) || (yDigits[0].isEven && xDigits[0].isEven)) {
throw new Exception("Not coprime");
throw Exception("Not coprime");
}
} else {
if (x._isZero) {
throw new ArgumentError.value(0, "this", "must not be zero");
throw ArgumentError.value(0, "this", "must not be zero");
}
if (y._isZero) {
throw new ArgumentError.value(0, "other", "must not be zero");
throw ArgumentError.value(0, "other", "must not be zero");
}
if (((xUsed == 1) && (xDigits[0] == 1)) ||
((yUsed == 1) && (yDigits[0] == 1)))
@@ -2284,13 +2284,13 @@ class _BigIntImpl implements BigInt {
if (shiftAmount > 0) {
maxUsed = _lShiftDigits(vDigits, maxUsed, shiftAmount, vDigits);
}
return new _BigIntImpl._(false, maxUsed, vDigits);
return _BigIntImpl._(false, maxUsed, vDigits);
}
// No inverse if v != 1.
var i = maxUsed - 1;
while ((i > 0) && (vDigits[i] == 0)) --i;
if ((i != 0) || (vDigits[0] != 1)) {
throw new Exception("Not coprime");
throw Exception("Not coprime");
}
if (dIsNegative) {
@@ -2309,7 +2309,7 @@ class _BigIntImpl implements BigInt {
_absSub(dDigits, abcdUsed, xDigits, maxUsed, dDigits);
}
}
return new _BigIntImpl._(false, maxUsed, dDigits);
return _BigIntImpl._(false, maxUsed, dDigits);
}
/**
@@ -2324,7 +2324,7 @@ class _BigIntImpl implements BigInt {
_BigIntImpl modInverse(BigInt bigInt) {
final modulus = _ensureSystemBigInt(bigInt, 'bigInt');
if (modulus <= zero) {
throw new ArgumentError("Modulus must be strictly positive: $modulus");
throw ArgumentError("Modulus must be strictly positive: $modulus");
}
if (modulus == one) return zero;
var tmp = this;
@@ -2464,7 +2464,7 @@ class _BigIntImpl implements BigInt {
if (_isZero) return 0.0;
// We fill the 53 bits little-endian.
var resultBits = new Uint8List(8);
var resultBits = Uint8List(8);
var length = _digitBits * (_used - 1) + _digits[_used - 1].bitLength;
if (length > maxDoubleExponent + 53) {
@@ -2611,7 +2611,7 @@ class _BigIntImpl implements BigInt {
* The [radix] argument must be an integer in the range 2 to 36.
*/
String toRadixString(int radix) {
if (radix < 2 || radix > 36) throw new RangeError.range(radix, 2, 36);
if (radix < 2 || radix > 36) throw RangeError.range(radix, 2, 36);
if (_used == 0) return "0";
@@ -2623,7 +2623,7 @@ class _BigIntImpl implements BigInt {
if (radix == 16) return _toHexString();
var base = new _BigIntImpl._fromInt(radix);
var base = _BigIntImpl._fromInt(radix);
var reversedDigitCodeUnits = <int>[];
var rest = this.abs();
while (!rest._isZero) {
@@ -2631,7 +2631,7 @@ class _BigIntImpl implements BigInt {
rest = rest ~/ base;
reversedDigitCodeUnits.add(_toRadixCodeUnit(digit));
}
var digitString = new String.fromCharCodes(reversedDigitCodeUnits.reversed);
var digitString = String.fromCharCodes(reversedDigitCodeUnits.reversed);
if (_isNegative) return "-" + digitString;
return digitString;
}
@@ -2654,7 +2654,7 @@ class _BigIntImpl implements BigInt {
const _dash = 45;
chars.add(_dash);
}
return new String.fromCharCodes(chars.reversed);
return String.fromCharCodes(chars.reversed);
}
static _BigIntImpl _ensureSystemBigInt(BigInt bigInt, String parameterName) {
@@ -2829,7 +2829,7 @@ class _BigIntMontgomeryReduction implements _BigIntReduction {
resultDigits[i] = xDigits[i];
}
var resultUsed = _reduce(resultDigits, xUsed);
return new _BigIntImpl._(false, resultUsed, resultDigits);
return _BigIntImpl._(false, resultUsed, resultDigits);
}
// x = x/R mod _modulus.
@@ -3002,7 +3002,7 @@ class _BigIntClassicReduction implements _BigIntReduction {
}
_BigIntImpl _revert(Uint32List xDigits, int xUsed) {
return new _BigIntImpl._(false, xUsed, xDigits);
return _BigIntImpl._(false, xUsed, xDigits);
}
int _reduce(Uint32List xDigits, int xUsed) {
@@ -18,13 +18,13 @@ class HashMap<K, V> {
if (isValidKey == null) {
if (hashCode == null) {
if (equals == null) {
return new _HashMap<K, V>();
return _HashMap<K, V>();
}
hashCode = _defaultHashCode;
} else {
if (identical(identityHashCode, hashCode) &&
identical(identical, equals)) {
return new _IdentityHashMap<K, V>();
return _IdentityHashMap<K, V>();
}
equals ??= _defaultEquals;
}
@@ -32,11 +32,11 @@ class HashMap<K, V> {
hashCode ??= _defaultHashCode;
equals ??= _defaultEquals;
}
return new _CustomHashMap<K, V>(equals, hashCode, isValidKey);
return _CustomHashMap<K, V>(equals, hashCode, isValidKey);
}
@patch
factory HashMap.identity() => new _IdentityHashMap<K, V>();
factory HashMap.identity() => _IdentityHashMap<K, V>();
Set<K> _newKeySet();
}
@@ -54,8 +54,8 @@ base class _HashMap<K, V> extends MapBase<K, V> implements HashMap<K, V> {
bool get isEmpty => _elementCount == 0;
bool get isNotEmpty => _elementCount != 0;
Iterable<K> get keys => new _HashMapKeyIterable<K, V>(this);
Iterable<V> get values => new _HashMapValueIterable<K, V>(this);
Iterable<K> get keys => _HashMapKeyIterable<K, V>(this);
Iterable<V> get values => _HashMapValueIterable<K, V>(this);
bool containsKey(Object? key) {
final hashCode = key.hashCode;
@@ -149,7 +149,7 @@ base class _HashMap<K, V> extends MapBase<K, V> implements HashMap<K, V> {
while (entry != null) {
action(unsafeCast<K>(entry.key), unsafeCast<V>(entry.value));
if (stamp != _modificationCount) {
throw new ConcurrentModificationError(this);
throw ConcurrentModificationError(this);
}
entry = entry.next;
}
@@ -178,7 +178,7 @@ base class _HashMap<K, V> extends MapBase<K, V> implements HashMap<K, V> {
}
void clear() {
_buckets = new List.filled(_INITIAL_CAPACITY, null);
_buckets = List.filled(_INITIAL_CAPACITY, null);
if (_elementCount > 0) {
_elementCount = 0;
_modificationCount = (_modificationCount + 1) & _MODIFICATION_COUNT_MASK;
@@ -205,7 +205,7 @@ base class _HashMap<K, V> extends MapBase<K, V> implements HashMap<K, V> {
V value,
int hashCode,
) {
final entry = new _HashMapEntry(key, value, hashCode, buckets[index]);
final entry = _HashMapEntry(key, value, hashCode, buckets[index]);
buckets[index] = entry;
final newElements = _elementCount + 1;
_elementCount = newElements;
@@ -219,7 +219,7 @@ base class _HashMap<K, V> extends MapBase<K, V> implements HashMap<K, V> {
final oldBuckets = _buckets;
final oldLength = oldBuckets.length;
final newLength = oldLength << 1;
final newBuckets = new List<_HashMapEntry?>.filled(newLength, null);
final newBuckets = List<_HashMapEntry?>.filled(newLength, null);
for (int i = 0; i < oldLength; i++) {
var entry = oldBuckets[i];
while (entry != null) {
@@ -256,7 +256,7 @@ base class _HashMap<K, V> extends MapBase<K, V> implements HashMap<K, V> {
}
}
Set<K> _newKeySet() => new _HashSet<K>();
Set<K> _newKeySet() => _HashSet<K>();
}
base class _CustomHashMap<K, V> extends _HashMap<K, V> {
@@ -364,7 +364,7 @@ base class _CustomHashMap<K, V> extends _HashMap<K, V> {
return null;
}
Set<K> _newKeySet() => new _CustomHashSet<K>(_equals, _hashCode, _validKey);
Set<K> _newKeySet() => _CustomHashSet<K>(_equals, _hashCode, _validKey);
}
base class _IdentityHashMap<K, V> extends _HashMap<K, V> {
@@ -475,7 +475,7 @@ base class _IdentityHashMap<K, V> extends _HashMap<K, V> {
}
}
Set<K> _newKeySet() => new _IdentityHashSet<K>();
Set<K> _newKeySet() => _IdentityHashSet<K>();
}
class _HashMapEntry {
@@ -497,7 +497,7 @@ abstract class _HashMapIterable<K, V, E>
class _HashMapKeyIterable<K, V> extends _HashMapIterable<K, V, K> {
_HashMapKeyIterable(_HashMap<K, V> map) : super(map);
Iterator<K> get iterator => new _HashMapKeyIterator<K, V>(_map);
Iterator<K> get iterator => _HashMapKeyIterator<K, V>(_map);
bool contains(Object? key) => _map.containsKey(key);
void forEach(void action(K key)) {
_map.forEach((K key, _) {
@@ -510,7 +510,7 @@ class _HashMapKeyIterable<K, V> extends _HashMapIterable<K, V, K> {
class _HashMapValueIterable<K, V> extends _HashMapIterable<K, V, V> {
_HashMapValueIterable(_HashMap<K, V> map) : super(map);
Iterator<V> get iterator => new _HashMapValueIterator<K, V>(_map);
Iterator<V> get iterator => _HashMapValueIterator<K, V>(_map);
bool contains(Object? value) => _map.containsValue(value);
void forEach(void action(V value)) {
_map.forEach((_, V value) {
@@ -530,7 +530,7 @@ abstract class _HashMapIterator<K, V, E> implements Iterator<E> {
bool moveNext() {
if (_stamp != _map._modificationCount) {
throw new ConcurrentModificationError(_map);
throw ConcurrentModificationError(_map);
}
var entry = _entry;
if (entry != null) {
@@ -577,13 +577,13 @@ class HashSet<E> {
if (isValidKey == null) {
if (hashCode == null) {
if (equals == null) {
return new _HashSet<E>();
return _HashSet<E>();
}
hashCode = _defaultHashCode;
} else {
if (identical(identityHashCode, hashCode) &&
identical(identical, equals)) {
return new _IdentityHashSet<E>();
return _IdentityHashSet<E>();
}
equals ??= _defaultEquals;
}
@@ -591,11 +591,11 @@ class HashSet<E> {
hashCode ??= _defaultHashCode;
equals ??= _defaultEquals;
}
return new _CustomHashSet<E>(equals, hashCode, isValidKey);
return _CustomHashSet<E>(equals, hashCode, isValidKey);
}
@patch
factory HashSet.identity() => new _IdentityHashSet<E>();
factory HashSet.identity() => _IdentityHashSet<E>();
}
base class _HashSet<E> extends _SetBase<E> implements HashSet<E> {
@@ -608,11 +608,11 @@ base class _HashSet<E> extends _SetBase<E> implements HashSet<E> {
bool _equals(Object? e1, Object? e2) => e1 == e2;
int _hashCode(Object? e) => e.hashCode;
static Set<R> _newEmpty<R>() => new _HashSet<R>();
static Set<R> _newEmpty<R>() => _HashSet<R>();
// Iterable.
Iterator<E> get iterator => new _HashSetIterator<E>(this);
Iterator<E> get iterator => _HashSetIterator<E>(this);
int get length => _elementCount;
@@ -726,7 +726,7 @@ base class _HashSet<E> extends _SetBase<E> implements HashSet<E> {
int modificationCount = _modificationCount;
bool testResult = test(entry.key);
if (modificationCount != _modificationCount) {
throw new ConcurrentModificationError(this);
throw ConcurrentModificationError(this);
}
if (testResult == removeMatching) {
final next = entry.remove();
@@ -764,7 +764,7 @@ base class _HashSet<E> extends _SetBase<E> implements HashSet<E> {
}
void _addEntry(E key, int hashCode, int index) {
_buckets[index] = new _HashSetEntry<E>(key, hashCode, _buckets[index]);
_buckets[index] = _HashSetEntry<E>(key, hashCode, _buckets[index]);
int newElements = _elementCount + 1;
_elementCount = newElements;
int length = _buckets.length;
@@ -792,16 +792,16 @@ base class _HashSet<E> extends _SetBase<E> implements HashSet<E> {
_buckets = newBuckets;
}
HashSet<E> _newSet() => new _HashSet<E>();
HashSet<R> _newSimilarSet<R>() => new _HashSet<R>();
HashSet<E> _newSet() => _HashSet<E>();
HashSet<R> _newSimilarSet<R>() => _HashSet<R>();
}
base class _IdentityHashSet<E> extends _HashSet<E> {
int _hashCode(Object? e) => identityHashCode(e);
bool _equals(Object? e1, Object? e2) => identical(e1, e2);
HashSet<E> _newSet() => new _IdentityHashSet<E>();
HashSet<R> _newSimilarSet<R>() => new _IdentityHashSet<R>();
HashSet<E> _newSet() => _IdentityHashSet<E>();
HashSet<R> _newSimilarSet<R>() => _IdentityHashSet<R>();
}
base class _CustomHashSet<E> extends _HashSet<E> {
@@ -844,8 +844,8 @@ base class _CustomHashSet<E> extends _HashSet<E> {
bool _equals(Object? e1, Object? e2) => _equality(e1 as E, e2 as E);
int _hashCode(Object? e) => _hasher(e as E);
HashSet<E> _newSet() => new _CustomHashSet<E>(_equality, _hasher, _validKey);
HashSet<R> _newSimilarSet<R>() => new _HashSet<R>();
HashSet<E> _newSet() => _CustomHashSet<E>(_equality, _hasher, _validKey);
HashSet<R> _newSimilarSet<R>() => _HashSet<R>();
}
class _HashSetEntry<E> {
@@ -872,7 +872,7 @@ class _HashSetIterator<E> implements Iterator<E> {
bool moveNext() {
if (_modificationCount != _set._modificationCount) {
throw new ConcurrentModificationError(_set);
throw ConcurrentModificationError(_set);
}
var localNext = _next;
if (localNext != null) {
@@ -417,7 +417,7 @@ base class _ConstMap<K, V> extends _HashVMImmutableBase
_ImmutableLinkedHashMapMixin<K, V>
implements LinkedHashMap<K, V> {
factory _ConstMap._uninstantiable() {
throw new UnsupportedError("_ConstMap can only be allocated by the VM");
throw UnsupportedError("_ConstMap can only be allocated by the VM");
}
}
@@ -441,7 +441,7 @@ mixin _ImmutableLinkedHashMapMixin<K, V>
final size = _roundUpToPowerOfTwo(
max(_data.length, _HashBase._INITIAL_INDEX_SIZE),
);
final newIndex = new Uint32List(size);
final newIndex = Uint32List(size);
final hashMask = _HashBase._indexSizeToHashMask(size);
assert(_hashMask == hashMask);
@@ -525,9 +525,9 @@ mixin _LinkedHashMapMixin<K, V> on _HashBase, _EqualsAndHashCode {
}
assert(size & (size - 1) == 0);
assert(_HashBase._UNUSED_PAIR == 0);
_index = new Uint32List(size);
_index = Uint32List(size);
_hashMask = hashMask;
_data = new List.filled(size, null);
_data = List.filled(size, null);
_usedData = 0;
_deletedKeys = 0;
if (oldData != null) {
@@ -556,9 +556,9 @@ mixin _LinkedHashMapMixin<K, V> on _HashBase, _EqualsAndHashCode {
assert(size & (size - 1) == 0);
assert(_HashBase._UNUSED_PAIR == 0);
_index = new Uint32List(size);
_index = Uint32List(size);
_hashMask = hashMask;
_data = new List.filled(size, null);
_data = List.filled(size, null);
_usedData = 0;
_deletedKeys = 0;
for (int i = 0; i < keyValuePairs.length; i += 2) {
@@ -569,8 +569,7 @@ mixin _LinkedHashMapMixin<K, V> on _HashBase, _EqualsAndHashCode {
}
void _regenerateIndex() {
_index =
_data.length == 0 ? _uninitializedIndex : new Uint32List(_data.length);
_index = _data.length == 0 ? _uninitializedIndex : Uint32List(_data.length);
assert(_hashMask == _HashBase._UNINITIALIZED_HASH_MASK);
_hashMask = _HashBase._indexSizeToHashMask(_index.length);
final int tmpUsed = _usedData;
@@ -1038,9 +1037,9 @@ mixin _LinkedHashSetMixin<E> on _HashBase, _EqualsAndHashCode {
size = _HashBase._INITIAL_INDEX_SIZE;
hashMask = _HashBase._indexSizeToHashMask(size);
}
_index = new Uint32List(size);
_index = Uint32List(size);
_hashMask = hashMask;
_data = new List.filled(size >> 1, null);
_data = List.filled(size >> 1, null);
_usedData = 0;
_deletedKeys = 0;
if (oldData != null) {
@@ -1154,7 +1153,7 @@ mixin _LinkedHashSetMixin<E> on _HashBase, _EqualsAndHashCode {
final size = _roundUpToPowerOfTwo(
max(_data.length, _HashBase._INITIAL_INDEX_SIZE),
);
_index = _data.length == 0 ? _uninitializedIndex : new Uint32List(size);
_index = _data.length == 0 ? _uninitializedIndex : Uint32List(size);
assert(_hashMask == _HashBase._UNINITIALIZED_HASH_MASK);
_hashMask = _HashBase._indexSizeToHashMask(_index.length);
_rehash();
@@ -1208,7 +1207,7 @@ base class _ConstSet<E> extends _HashVMImmutableBase
_ImmutableLinkedHashSetMixin<E>
implements LinkedHashSet<E> {
factory _ConstSet._uninstantiable() {
throw new UnsupportedError("_ConstSet can only be allocated by the VM");
throw UnsupportedError("_ConstSet can only be allocated by the VM");
}
Set<R> cast<R>() => Set.castFrom<E, R>(this, newSet: _newEmpty);
@@ -1239,7 +1238,7 @@ mixin _ImmutableLinkedHashSetMixin<E>
final size = _roundUpToPowerOfTwo(
max(_data.length * 2, _HashBase._INITIAL_INDEX_SIZE),
);
final index = new Uint32List(size);
final index = Uint32List(size);
final hashMask = _HashBase._indexSizeToHashMask(size);
assert(_hashMask == hashMask);
@@ -48,7 +48,7 @@ class int {
@patch
static int parse(String source, {int? radix, int onError(String source)?}) {
if (source == null) throw new ArgumentError("The source must not be null");
if (source == null) throw ArgumentError("The source must not be null");
if (source.isEmpty) {
return _handleFormatError(onError, source, 0, radix, null) as int;
}
@@ -57,7 +57,7 @@ class int {
int? result = _tryParseSmi(source, 0, source.length - 1);
if (result != null) return result;
} else if (radix < 2 || radix > 36) {
throw new RangeError("Radix $radix not in range 2..36");
throw RangeError("Radix $radix not in range 2..36");
}
// Split here so improve odds of parse being inlined and the checks omitted.
return _parse(unsafeCast<_StringBase>(source), radix, onError) as int;
@@ -106,14 +106,14 @@ class int {
@patch
static int? tryParse(String source, {int? radix}) {
if (source == null) throw new ArgumentError("The source must not be null");
if (source == null) throw ArgumentError("The source must not be null");
if (source.isEmpty) return null;
if (radix == null || radix == 10) {
// Try parsing immediately, without trimming whitespace.
int? result = _tryParseSmi(source, 0, source.length - 1);
if (result != null) return result;
} else if (radix < 2 || radix > 36) {
throw new RangeError("Radix $radix not in range 2..36");
throw RangeError("Radix $radix not in range 2..36");
}
return _parse(unsafeCast<_StringBase>(source), radix, _kNull);
}
@@ -129,12 +129,12 @@ class int {
) {
if (onError != null) return onError(source);
if (message != null) {
throw new FormatException(message, source, index);
throw FormatException(message, source, index);
}
if (radix == null) {
throw new FormatException("Invalid number", source, index);
throw FormatException("Invalid number", source, index);
}
throw new FormatException("Invalid radix-$radix number", source, index);
throw FormatException("Invalid radix-$radix number", source, index);
}
static int? _parseRadix(
@@ -254,7 +254,7 @@ class int {
// For each radix, 2-36, how many digits are guaranteed to fit in a smi,
// and magnitude of such a block (radix ** digit-count).
// 32-bit limit/multiplier at (radix - 2)*4, 64-bit limit at (radix-2)*4+2
static const _PARSE_LIMITS = const [
static const _PARSE_LIMITS = [
30, 1073741824, 62, 4611686018427387904, // radix: 2
18, 387420489, 39, 4052555153018976267,
15, 1073741824, 30, 1152921504606846976,
@@ -295,11 +295,8 @@ class int {
static const _maxInt64 = 0x7fffffffffffffff;
static const _minInt64 = -0x8000000000000000;
static const _int64UnsignedOverflowLimits = const [0xfffffffff, 0xf];
static const _int64UnsignedSmiOverflowLimits = const [
0xfffffff,
0xfffffffffffffff,
];
static const _int64UnsignedOverflowLimits = [0xfffffffff, 0xf];
static const _int64UnsignedSmiOverflowLimits = [0xfffffff, 0xfffffffffffffff];
/// Calculation of the expression
///
@@ -316,7 +313,7 @@ class int {
/// * `[tableIndex*2 + 1]` = negative limit for result
/// * `[tableIndex*2 + 2]` = limit for smi if result is exactly at positive limit
/// * `[tableIndex*2 + 3]` = limit for smi if result is exactly at negative limit
static final Int64List _int64OverflowLimits = new Int64List(
static final Int64List _int64OverflowLimits = Int64List(
_PARSE_LIMITS.length * 2,
);
@@ -15,7 +15,7 @@ class Map<K, V> {
// The values are at position 2*n+1 and are not yet type checked.
@pragma("vm:entry-point", "call")
factory Map._fromLiteral(List elements) {
var map = new LinkedHashMap<K, V>();
var map = LinkedHashMap<K, V>();
var len = elements.length;
for (int i = 1; i < len; i += 2) {
map[elements[i - 1]] = elements[i];
@@ -25,11 +25,11 @@ class Map<K, V> {
@patch
factory Map.unmodifiable(Map other) {
return new UnmodifiableMapView<K, V>(new Map<K, V>.from(other));
return UnmodifiableMapView<K, V>(Map<K, V>.from(other));
}
@patch
factory Map() => new LinkedHashMap<K, V>();
factory Map() => LinkedHashMap<K, V>();
}
// Used by Dart_MapContainsKey.
@@ -77,7 +77,7 @@ class StringBuffer {
void writeCharCode(int charCode) {
if (charCode <= 0xFFFF) {
if (charCode < 0) {
throw new RangeError.range(charCode, 0, 0x10FFFF);
throw RangeError.range(charCode, 0, 0x10FFFF);
}
_ensureCapacity(1);
final localBuffer = _buffer!;
@@ -85,7 +85,7 @@ class StringBuffer {
_bufferCodeUnitMagnitude |= charCode;
} else {
if (charCode > 0x10FFFF) {
throw new RangeError.range(charCode, 0, 0x10FFFF);
throw RangeError.range(charCode, 0, 0x10FFFF);
}
_ensureCapacity(2);
int bits = charCode - 0x10000;
@@ -140,7 +140,7 @@ class StringBuffer {
void _ensureCapacity(int n) {
final localBuffer = _buffer;
if (localBuffer == null) {
_buffer = new Uint16List(_BUFFER_SIZE);
_buffer = Uint16List(_BUFFER_SIZE);
} else if (_bufferPosition + n > localBuffer.length) {
_consumeBuffer();
}
@@ -171,7 +171,7 @@ class StringBuffer {
if (localParts == null) {
// Empirically this is a good capacity to minimize total bytes allocated.
_parts = new _GrowableList.withCapacity(10)..add(str);
_parts = _GrowableList.withCapacity(10)..add(str);
} else {
localParts.add(str);
int partsSinceCompaction = localParts.length - _partsCompactionIndex;
+1 -1
View File
@@ -294,7 +294,7 @@ final class BoxedDouble implements double {
num clamp(num lowerLimit, num upperLimit) {
if (lowerLimit.compareTo(upperLimit) > 0) {
throw new ArgumentError(lowerLimit);
throw ArgumentError(lowerLimit);
}
if (lowerLimit.isNaN) return lowerLimit;
if (this.compareTo(lowerLimit) < 0) return lowerLimit;
+3 -3
View File
@@ -274,7 +274,7 @@ final class BoxedInt implements int {
}
// Generic case involving doubles, and invalid integer ranges.
if (lowerLimit.compareTo(upperLimit) > 0) {
throw new ArgumentError(lowerLimit);
throw ArgumentError(lowerLimit);
}
if (lowerLimit.isNaN) return lowerLimit;
// Note that we don't need to care for -0.0 for the lower limit.
@@ -394,7 +394,7 @@ final class BoxedInt implements int {
} while (u != 0);
if (!inv) return v << s;
if (v != 1) {
throw new Exception("Not coprime");
throw Exception("Not coprime");
}
if (d < 0) {
d += x;
@@ -415,7 +415,7 @@ final class BoxedInt implements int {
if (t.geU(m)) t %= m;
if (t == 1) return 1;
if ((t == 0) || (t.isEven && m.isEven)) {
throw new Exception("Not coprime");
throw Exception("Not coprime");
}
return _binaryGcd(m, t, true);
}
+3 -7
View File
@@ -103,7 +103,7 @@ mixin _UnmodifiableSetMixin<E> implements LinkedHashSet<E> {
/// field type nullable.
@pragma("wasm:entry-point")
final WasmArray<WasmI32> _uninitializedHashBaseIndex =
const WasmArray<WasmI32>.literal([const WasmI32(0)]);
const WasmArray<WasmI32>.literal([WasmI32(0)]);
/// The object marking uninitialized [_HashFieldBase._data] fields.
///
@@ -312,9 +312,7 @@ base class _ConstMap<K, V> extends _HashFieldBase
_ImmutableLinkedHashMapMixin<K, V>
implements LinkedHashMap<K, V> {
factory _ConstMap._uninstantiable() {
throw new UnsupportedError(
"_ConstMap can only be allocated by the compiler",
);
throw UnsupportedError("_ConstMap can only be allocated by the compiler");
}
}
@@ -1125,9 +1123,7 @@ base class _ConstSet<E> extends _HashFieldBase
_ImmutableLinkedHashSetMixin<E>
implements LinkedHashSet<E> {
factory _ConstSet._uninstantiable() {
throw new UnsupportedError(
"_ConstSet can only be allocated by the compiler",
);
throw UnsupportedError("_ConstSet can only be allocated by the compiler");
}
Set<R> cast<R>() => Set.castFrom<E, R>(this, newSet: _newEmpty);
@@ -2607,7 +2607,7 @@ class _Utf8Decoder {
// This table is the Wasm array version of `_Utf8Decoder.transitionTable`,
// refer to the original type for documentation of the values.
static const _transitionTable = const ImmutableWasmArray<WasmI8>.literal([
static const _transitionTable = ImmutableWasmArray<WasmI8>.literal([
32, 0, 48, 58, 88, 69, 67, 67, 67, 67, 67, 78, 58, 108, 68, 98, 32, 0, //
48, 58, 88, 69, 67, 67, 67, 67, 67, 78, 118, 108, 68, 98, 32, 0, 48, 58, //
88, 69, 67, 67, 67, 67, 67, 78, 58, 108, 68, 98, 32, 65, 65, 65, 65, 65, //
@@ -2620,7 +2620,7 @@ class _Utf8Decoder {
// This table is the Wasm array version of `_Utf8Decoder.typeTable`,
// refer to the original type for documentation of the values.
static const _typeTable = const ImmutableWasmArray<WasmI8>.literal([
static const _typeTable = ImmutableWasmArray<WasmI8>.literal([
65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, //
65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, //
65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, //
+1 -1
View File
@@ -274,7 +274,7 @@ class _DuplicatedFieldInitializerError extends Error {
@patch
class StateError {
static _throwNew(String msg) {
throw new StateError(msg);
throw StateError(msg);
}
}
+1 -1
View File
@@ -248,7 +248,7 @@ class int {
}
// For each radix, 2-36, how many digits are guaranteed to fit in an `int`.
static const _PARSE_LIMITS = const ImmutableWasmArray<WasmI64>.literal([
static const _PARSE_LIMITS = ImmutableWasmArray<WasmI64>.literal([
0, // unused
0, // unused
63, // radix: 2
+106 -106
View File
@@ -12,42 +12,42 @@ import 'dart:typed_data';
class _Directory {
@patch
static _current(_Namespace namespace) {
throw new UnsupportedError("Directory._current");
throw UnsupportedError("Directory._current");
}
@patch
static _setCurrent(_Namespace namespace, Uint8List path) {
throw new UnsupportedError("Directory_SetCurrent");
throw UnsupportedError("Directory_SetCurrent");
}
@patch
static _createTemp(_Namespace namespace, Uint8List path) {
throw new UnsupportedError("Directory._createTemp");
throw UnsupportedError("Directory._createTemp");
}
@patch
static String _systemTemp(_Namespace namespace) {
throw new UnsupportedError("Directory._systemTemp");
throw UnsupportedError("Directory._systemTemp");
}
@patch
static _exists(_Namespace namespace, Uint8List path) {
throw new UnsupportedError("Directory._exists");
throw UnsupportedError("Directory._exists");
}
@patch
static _create(_Namespace namespace, Uint8List path) {
throw new UnsupportedError("Directory._create");
throw UnsupportedError("Directory._create");
}
@patch
static _deleteNative(_Namespace namespace, Uint8List path, bool recursive) {
throw new UnsupportedError("Directory._deleteNative");
throw UnsupportedError("Directory._deleteNative");
}
@patch
static _rename(_Namespace namespace, Uint8List path, String newPath) {
throw new UnsupportedError("Directory._rename");
throw UnsupportedError("Directory._rename");
}
@patch
@@ -58,7 +58,7 @@ class _Directory {
bool recursive,
bool followLinks,
) {
throw new UnsupportedError("Directory._fillWithDirectoryListing");
throw UnsupportedError("Directory._fillWithDirectoryListing");
}
}
@@ -66,7 +66,7 @@ class _Directory {
class _AsyncDirectoryListerOps {
@patch
factory _AsyncDirectoryListerOps(int pointer) {
throw new UnsupportedError("Directory._list");
throw UnsupportedError("Directory._list");
}
}
@@ -74,7 +74,7 @@ class _AsyncDirectoryListerOps {
class _EventHandler {
@patch
static void _sendData(Object? sender, SendPort sendPort, int data) {
throw new UnsupportedError("EventHandler._sendData");
throw UnsupportedError("EventHandler._sendData");
}
}
@@ -82,7 +82,7 @@ class _EventHandler {
class FileStat {
@patch
static _statSync(_Namespace namespace, String path) {
throw new UnsupportedError("FileStat.stat");
throw UnsupportedError("FileStat.stat");
}
}
@@ -94,17 +94,17 @@ class FileSystemEntity {
Uint8List path,
bool followLinks,
) {
throw new UnsupportedError("FileSystemEntity._getType");
throw UnsupportedError("FileSystemEntity._getType");
}
@patch
static _identicalNative(_Namespace namespace, String path1, String path2) {
throw new UnsupportedError("FileSystemEntity._identical");
throw UnsupportedError("FileSystemEntity._identical");
}
@patch
static _resolveSymbolicLinks(_Namespace namespace, Uint8List path) {
throw new UnsupportedError("FileSystemEntity._resolveSymbolicLinks");
throw UnsupportedError("FileSystemEntity._resolveSymbolicLinks");
}
}
@@ -112,17 +112,17 @@ class FileSystemEntity {
class _File {
@patch
static _exists(_Namespace namespace, Uint8List path) {
throw new UnsupportedError("File._exists");
throw UnsupportedError("File._exists");
}
@patch
static _create(_Namespace namespace, Uint8List path, bool exclusive) {
throw new UnsupportedError("File._create");
throw UnsupportedError("File._create");
}
@patch
static _createLink(_Namespace namespace, Uint8List path, String target) {
throw new UnsupportedError("File._createLink");
throw UnsupportedError("File._createLink");
}
@patch
@@ -132,67 +132,67 @@ class _File {
@patch
static _linkTarget(_Namespace namespace, Uint8List path) {
throw new UnsupportedError("File._linkTarget");
throw UnsupportedError("File._linkTarget");
}
@patch
static _deleteNative(_Namespace namespace, Uint8List path) {
throw new UnsupportedError("File._deleteNative");
throw UnsupportedError("File._deleteNative");
}
@patch
static _deleteLinkNative(_Namespace namespace, Uint8List path) {
throw new UnsupportedError("File._deleteLinkNative");
throw UnsupportedError("File._deleteLinkNative");
}
@patch
static _rename(_Namespace namespace, Uint8List oldPath, String newPath) {
throw new UnsupportedError("File._rename");
throw UnsupportedError("File._rename");
}
@patch
static _renameLink(_Namespace namespace, Uint8List oldPath, String newPath) {
throw new UnsupportedError("File._renameLink");
throw UnsupportedError("File._renameLink");
}
@patch
static _copy(_Namespace namespace, Uint8List oldPath, String newPath) {
throw new UnsupportedError("File._copy");
throw UnsupportedError("File._copy");
}
@patch
static _lengthFromPath(_Namespace namespace, Uint8List path) {
throw new UnsupportedError("File._lengthFromPath");
throw UnsupportedError("File._lengthFromPath");
}
@patch
static _lastModified(_Namespace namespace, Uint8List path) {
throw new UnsupportedError("File._lastModified");
throw UnsupportedError("File._lastModified");
}
@patch
static _lastAccessed(_Namespace namespace, Uint8List path) {
throw new UnsupportedError("File._lastAccessed");
throw UnsupportedError("File._lastAccessed");
}
@patch
static _setLastModified(_Namespace namespace, Uint8List path, int millis) {
throw new UnsupportedError("File._setLastModified");
throw UnsupportedError("File._setLastModified");
}
@patch
static _setLastAccessed(_Namespace namespace, Uint8List path, int millis) {
throw new UnsupportedError("File._setLastAccessed");
throw UnsupportedError("File._setLastAccessed");
}
@patch
static _open(_Namespace namespace, Uint8List path, int mode) {
throw new UnsupportedError("File._open");
throw UnsupportedError("File._open");
}
@patch
static int _openStdio(int fd) {
throw new UnsupportedError("File._openStdio");
throw UnsupportedError("File._openStdio");
}
}
@@ -200,17 +200,17 @@ class _File {
class _Namespace {
@patch
static void _setupNamespace(var namespace) {
throw new UnsupportedError("_Namespace");
throw UnsupportedError("_Namespace");
}
@patch
static _Namespace get _namespace {
throw new UnsupportedError("_Namespace");
throw UnsupportedError("_Namespace");
}
@patch
static int get _namespacePointer {
throw new UnsupportedError("_Namespace");
throw UnsupportedError("_Namespace");
}
}
@@ -218,7 +218,7 @@ class _Namespace {
class _RandomAccessFileOps {
@patch
factory _RandomAccessFileOps(int pointer) {
throw new UnsupportedError("RandomAccessFile");
throw UnsupportedError("RandomAccessFile");
}
}
@@ -226,7 +226,7 @@ class _RandomAccessFileOps {
class _IOCrypto {
@patch
static Uint8List getRandomBytes(int count) {
throw new UnsupportedError("_IOCrypto.getRandomBytes");
throw UnsupportedError("_IOCrypto.getRandomBytes");
}
}
@@ -234,67 +234,67 @@ class _IOCrypto {
class _Platform {
@patch
static int _numberOfProcessors() {
throw new UnsupportedError("Platform._numberOfProcessors");
throw UnsupportedError("Platform._numberOfProcessors");
}
@patch
static String _pathSeparator() {
throw new UnsupportedError("Platform._pathSeparator");
throw UnsupportedError("Platform._pathSeparator");
}
@patch
static String _operatingSystem() {
throw new UnsupportedError("Platform._operatingSystem");
throw UnsupportedError("Platform._operatingSystem");
}
@patch
static _operatingSystemVersion() {
throw new UnsupportedError("Platform._operatingSystemVersion");
throw UnsupportedError("Platform._operatingSystemVersion");
}
@patch
static _localHostname() {
throw new UnsupportedError("Platform._localHostname");
throw UnsupportedError("Platform._localHostname");
}
@patch
static _executable() {
throw new UnsupportedError("Platform._executable");
throw UnsupportedError("Platform._executable");
}
@patch
static _resolvedExecutable() {
throw new UnsupportedError("Platform._resolvedExecutable");
throw UnsupportedError("Platform._resolvedExecutable");
}
@patch
static List<String> _executableArguments() {
throw new UnsupportedError("Platform._executableArguments");
throw UnsupportedError("Platform._executableArguments");
}
@patch
static String _packageConfig() {
throw new UnsupportedError("Platform._packageConfig");
throw UnsupportedError("Platform._packageConfig");
}
@patch
static _environment() {
throw new UnsupportedError("Platform._environment");
throw UnsupportedError("Platform._environment");
}
@patch
static String _version() {
throw new UnsupportedError("Platform._version");
throw UnsupportedError("Platform._version");
}
@patch
static String _localeName() {
throw new UnsupportedError("Platform._localeName");
throw UnsupportedError("Platform._localeName");
}
@patch
static Uri _script() {
throw new UnsupportedError("Platform._script");
throw UnsupportedError("Platform._script");
}
}
@@ -302,32 +302,32 @@ class _Platform {
class _ProcessUtils {
@patch
static Never _exit(int status) {
throw new UnsupportedError("ProcessUtils._exit");
throw UnsupportedError("ProcessUtils._exit");
}
@patch
static void _setExitCode(int status) {
throw new UnsupportedError("ProcessUtils._setExitCode");
throw UnsupportedError("ProcessUtils._setExitCode");
}
@patch
static int _getExitCode() {
throw new UnsupportedError("ProcessUtils._getExitCode");
throw UnsupportedError("ProcessUtils._getExitCode");
}
@patch
static void _sleep(int millis) {
throw new UnsupportedError("ProcessUtils._sleep");
throw UnsupportedError("ProcessUtils._sleep");
}
@patch
static int _pid(Process? process) {
throw new UnsupportedError("ProcessUtils._pid");
throw UnsupportedError("ProcessUtils._pid");
}
@patch
static Stream<ProcessSignal> _watchSignal(ProcessSignal signal) {
throw new UnsupportedError("ProcessUtils._watchSignal");
throw UnsupportedError("ProcessUtils._watchSignal");
}
}
@@ -335,12 +335,12 @@ class _ProcessUtils {
class ProcessInfo {
@patch
static int get currentRss {
throw new UnsupportedError("ProcessInfo.currentRss");
throw UnsupportedError("ProcessInfo.currentRss");
}
@patch
static int get maxRss {
throw new UnsupportedError("ProcessInfo.maxRss");
throw UnsupportedError("ProcessInfo.maxRss");
}
}
@@ -356,7 +356,7 @@ class Process {
bool runInShell = false,
ProcessStartMode mode = ProcessStartMode.normal,
}) {
throw new UnsupportedError("Process.start");
throw UnsupportedError("Process.start");
}
@patch
@@ -370,7 +370,7 @@ class Process {
Encoding? stdoutEncoding = systemEncoding,
Encoding? stderrEncoding = systemEncoding,
}) {
throw new UnsupportedError("Process.run");
throw UnsupportedError("Process.run");
}
@patch
@@ -384,12 +384,12 @@ class Process {
Encoding? stdoutEncoding = systemEncoding,
Encoding? stderrEncoding = systemEncoding,
}) {
throw new UnsupportedError("Process.runSync");
throw UnsupportedError("Process.runSync");
}
@patch
static bool killPid(int pid, [ProcessSignal signal = ProcessSignal.sigterm]) {
throw new UnsupportedError("Process.killPid");
throw UnsupportedError("Process.killPid");
}
}
@@ -397,27 +397,27 @@ class Process {
class InternetAddress {
@patch
static InternetAddress get loopbackIPv4 {
throw new UnsupportedError("InternetAddress.loopbackIPv4");
throw UnsupportedError("InternetAddress.loopbackIPv4");
}
@patch
static InternetAddress get loopbackIPv6 {
throw new UnsupportedError("InternetAddress.loopbackIPv6");
throw UnsupportedError("InternetAddress.loopbackIPv6");
}
@patch
static InternetAddress get anyIPv4 {
throw new UnsupportedError("InternetAddress.anyIPv4");
throw UnsupportedError("InternetAddress.anyIPv4");
}
@patch
static InternetAddress get anyIPv6 {
throw new UnsupportedError("InternetAddress.anyIPv6");
throw UnsupportedError("InternetAddress.anyIPv6");
}
@patch
factory InternetAddress(String address, {InternetAddressType? type}) {
throw new UnsupportedError("InternetAddress");
throw UnsupportedError("InternetAddress");
}
@patch
@@ -425,7 +425,7 @@ class InternetAddress {
Uint8List rawAddress, {
InternetAddressType? type,
}) {
throw new UnsupportedError("InternetAddress.fromRawAddress");
throw UnsupportedError("InternetAddress.fromRawAddress");
}
@patch
@@ -433,7 +433,7 @@ class InternetAddress {
String host, {
InternetAddressType type = InternetAddressType.any,
}) {
throw new UnsupportedError("InternetAddress.lookup");
throw UnsupportedError("InternetAddress.lookup");
}
@patch
@@ -441,7 +441,7 @@ class InternetAddress {
InternetAddress address,
String host,
) {
throw new UnsupportedError("InternetAddress._cloneWithNewHost");
throw UnsupportedError("InternetAddress._cloneWithNewHost");
}
@patch
@@ -454,7 +454,7 @@ class InternetAddress {
class NetworkInterface {
@patch
static bool get listSupported {
throw new UnsupportedError("NetworkInterface.listSupported");
throw UnsupportedError("NetworkInterface.listSupported");
}
@patch
@@ -463,7 +463,7 @@ class NetworkInterface {
bool includeLinkLocal = false,
InternetAddressType type = InternetAddressType.any,
}) {
throw new UnsupportedError("NetworkInterface.list");
throw UnsupportedError("NetworkInterface.list");
}
}
@@ -477,7 +477,7 @@ class RawServerSocket {
bool v6Only = false,
bool shared = false,
}) {
throw new UnsupportedError("RawServerSocket.bind");
throw UnsupportedError("RawServerSocket.bind");
}
}
@@ -491,7 +491,7 @@ class ServerSocket {
bool v6Only = false,
bool shared = false,
}) {
throw new UnsupportedError("ServerSocket.bind");
throw UnsupportedError("ServerSocket.bind");
}
}
@@ -505,7 +505,7 @@ class RawSocket {
int sourcePort = 0,
Duration? timeout,
}) {
throw new UnsupportedError("RawSocket constructor");
throw UnsupportedError("RawSocket constructor");
}
@patch
@@ -515,7 +515,7 @@ class RawSocket {
dynamic sourceAddress,
int sourcePort = 0,
}) {
throw new UnsupportedError("RawSocket constructor");
throw UnsupportedError("RawSocket constructor");
}
}
@@ -529,7 +529,7 @@ class Socket {
int sourcePort = 0,
Duration? timeout,
}) {
throw new UnsupportedError("Socket constructor");
throw UnsupportedError("Socket constructor");
}
@patch
@@ -539,7 +539,7 @@ class Socket {
dynamic sourceAddress,
int sourcePort = 0,
}) {
throw new UnsupportedError("Socket constructor");
throw UnsupportedError("Socket constructor");
}
}
@@ -600,7 +600,7 @@ class ResourceHandle {
class SecureSocket {
@patch
factory SecureSocket._(RawSecureSocket rawSocket) {
throw new UnsupportedError("SecureSocket constructor");
throw UnsupportedError("SecureSocket constructor");
}
}
@@ -608,7 +608,7 @@ class SecureSocket {
class RawSynchronousSocket {
@patch
static RawSynchronousSocket connectSync(dynamic host, int port) {
throw new UnsupportedError("RawSynchronousSocket.connectSync");
throw UnsupportedError("RawSynchronousSocket.connectSync");
}
}
@@ -624,17 +624,17 @@ class RawSocketOption {
class SecurityContext {
@patch
factory SecurityContext({bool withTrustedRoots = false}) {
throw new UnsupportedError("SecurityContext constructor");
throw UnsupportedError("SecurityContext constructor");
}
@patch
static SecurityContext get defaultContext {
throw new UnsupportedError("default SecurityContext getter");
throw UnsupportedError("default SecurityContext getter");
}
@patch
static bool get alpnSupported {
throw new UnsupportedError("SecurityContext alpnSupported getter");
throw UnsupportedError("SecurityContext alpnSupported getter");
}
}
@@ -642,7 +642,7 @@ class SecurityContext {
class X509Certificate {
@patch
factory X509Certificate._() {
throw new UnsupportedError("X509Certificate constructor");
throw UnsupportedError("X509Certificate constructor");
}
}
@@ -656,7 +656,7 @@ class RawDatagramSocket {
bool reusePort = false,
int ttl = 1,
}) {
throw new UnsupportedError("RawDatagramSocket.bind");
throw UnsupportedError("RawDatagramSocket.bind");
}
}
@@ -664,7 +664,7 @@ class RawDatagramSocket {
class _SecureFilter {
@patch
factory _SecureFilter._() {
throw new UnsupportedError("_SecureFilter._SecureFilter");
throw UnsupportedError("_SecureFilter._SecureFilter");
}
}
@@ -672,22 +672,22 @@ class _SecureFilter {
class _StdIOUtils {
@patch
static Stdin _getStdioInputStream(int fd) {
throw new UnsupportedError("StdIOUtils._getStdioInputStream");
throw UnsupportedError("StdIOUtils._getStdioInputStream");
}
@patch
static _getStdioOutputStream(int fd) {
throw new UnsupportedError("StdIOUtils._getStdioOutputStream");
throw UnsupportedError("StdIOUtils._getStdioOutputStream");
}
@patch
static int _socketType(Socket socket) {
throw new UnsupportedError("StdIOUtils._socketType");
throw UnsupportedError("StdIOUtils._socketType");
}
@patch
static _getStdioHandleType(int fd) {
throw new UnsupportedError("StdIOUtils._getStdioHandleType");
throw UnsupportedError("StdIOUtils._getStdioHandleType");
}
}
@@ -695,7 +695,7 @@ class _StdIOUtils {
class _WindowsCodePageDecoder {
@patch
static String _decodeBytes(List<int> bytes) {
throw new UnsupportedError("_WindowsCodePageDecoder._decodeBytes");
throw UnsupportedError("_WindowsCodePageDecoder._decodeBytes");
}
}
@@ -703,7 +703,7 @@ class _WindowsCodePageDecoder {
class _WindowsCodePageEncoder {
@patch
static List<int> _encodeString(String string) {
throw new UnsupportedError("_WindowsCodePageEncoder._encodeString");
throw UnsupportedError("_WindowsCodePageEncoder._encodeString");
}
}
@@ -719,7 +719,7 @@ class RawZLibFilter {
List<int>? dictionary,
bool raw,
) {
throw new UnsupportedError("_newZLibDeflateFilter");
throw UnsupportedError("_newZLibDeflateFilter");
}
@patch
@@ -729,7 +729,7 @@ class RawZLibFilter {
List<int>? dictionary,
bool raw,
) {
throw new UnsupportedError("_newZLibInflateFilter");
throw UnsupportedError("_newZLibInflateFilter");
}
}
@@ -737,17 +737,17 @@ class RawZLibFilter {
class Stdin {
@patch
int readByteSync() {
throw new UnsupportedError("Stdin.readByteSync");
throw UnsupportedError("Stdin.readByteSync");
}
@patch
bool get echoMode {
throw new UnsupportedError("Stdin.echoMode");
throw UnsupportedError("Stdin.echoMode");
}
@patch
void set echoMode(bool enabled) {
throw new UnsupportedError("Stdin.echoMode");
throw UnsupportedError("Stdin.echoMode");
}
@patch
@@ -762,17 +762,17 @@ class Stdin {
@patch
bool get lineMode {
throw new UnsupportedError("Stdin.lineMode");
throw UnsupportedError("Stdin.lineMode");
}
@patch
void set lineMode(bool enabled) {
throw new UnsupportedError("Stdin.lineMode");
throw UnsupportedError("Stdin.lineMode");
}
@patch
bool get supportsAnsiEscapes {
throw new UnsupportedError("Stdin.supportsAnsiEscapes");
throw UnsupportedError("Stdin.supportsAnsiEscapes");
}
}
@@ -780,22 +780,22 @@ class Stdin {
class Stdout {
@patch
bool _hasTerminal(int fd) {
throw new UnsupportedError("Stdout.hasTerminal");
throw UnsupportedError("Stdout.hasTerminal");
}
@patch
int _terminalColumns(int fd) {
throw new UnsupportedError("Stdout.terminalColumns");
throw UnsupportedError("Stdout.terminalColumns");
}
@patch
int _terminalLines(int fd) {
throw new UnsupportedError("Stdout.terminalLines");
throw UnsupportedError("Stdout.terminalLines");
}
@patch
static bool _supportsAnsiEscapes(int fd) {
throw new UnsupportedError("Stdout.supportsAnsiEscapes");
throw UnsupportedError("Stdout.supportsAnsiEscapes");
}
}
@@ -807,12 +807,12 @@ class _FileSystemWatcher {
int events,
bool recursive,
) {
throw new UnsupportedError("_FileSystemWatcher.watch");
throw UnsupportedError("_FileSystemWatcher.watch");
}
@patch
static bool get isSupported {
throw new UnsupportedError("_FileSystemWatcher.isSupported");
throw UnsupportedError("_FileSystemWatcher.isSupported");
}
}
@@ -820,6 +820,6 @@ class _FileSystemWatcher {
class _IOService {
@patch
static Future<Object?> _dispatch(int request, List data) {
throw new UnsupportedError("_IOService._dispatch");
throw UnsupportedError("_IOService._dispatch");
}
}
+2 -2
View File
@@ -149,7 +149,7 @@ class Random {
factory Random([int? seed]) {
var state = _Random._setupSeed((seed == null) ? _Random._nextSeed() : seed);
// Crank a couple of times to distribute the seed bits a bit further.
return new _Random._withState(state)
return _Random._withState(state)
.._nextState()
.._nextState()
.._nextState()
@@ -225,7 +225,7 @@ class _Random implements Random {
static const _POW2_27_D = 1.0 * (1 << 27);
// Use a singleton Random object to get a new seed if no seed was passed.
static final _prng = new _Random._withState(_initialSeed());
static final _prng = _Random._withState(_initialSeed());
static int _setupSeed(int seed) => mix64(seed);
+3 -3
View File
@@ -11,7 +11,7 @@ class Object {
external bool operator ==(Object other);
// Random number generator used to generate identity hash codes.
static final _hashCodeRnd = new Random();
static final _hashCodeRnd = Random();
static int _objectHashCode(Object obj) {
var result = getIdentityHashField(obj);
@@ -55,7 +55,7 @@ class Object {
@patch
@pragma("wasm:entry-point")
dynamic noSuchMethod(Invocation invocation) {
throw new NoSuchMethodError.withInvocation(this, invocation);
throw NoSuchMethodError.withInvocation(this, invocation);
}
// Used for `null.toString` tear-offs.
@@ -65,6 +65,6 @@ class Object {
// Used for `null.noSuchMethod` tear-offs.
@pragma("wasm:entry-point")
static dynamic _nullNoSuchMethod(Invocation invocation) {
throw new NoSuchMethodError.withInvocation(null, invocation);
throw NoSuchMethodError.withInvocation(null, invocation);
}
}
@@ -138,7 +138,7 @@ class JSSyntaxRegExp implements RegExp {
RegExpMatch? firstMatch(String string) {
JSNativeMatch? m = _nativeRegExp.exec(string.toJS);
return m == null ? null : new _MatchImplementation(this, m);
return m == null ? null : _MatchImplementation(this, m);
}
bool hasMatch(String string) {
@@ -161,7 +161,7 @@ class JSSyntaxRegExp implements RegExp {
JSNativeRegExp regexp = _nativeGlobalVersion;
regexp.lastIndex = start.toJS;
JSNativeMatch? match = regexp.exec(string);
return match == null ? null : new _MatchImplementation(this, match);
return match == null ? null : _MatchImplementation(this, match);
}
RegExpMatch? _execAnchored(String string, int start) {
@@ -172,7 +172,7 @@ class JSSyntaxRegExp implements RegExp {
// If the last capture group participated, the original regexp did not
// match at the start position.
if (match.pop() != null) return null;
return new _MatchImplementation(this, match);
return _MatchImplementation(this, match);
}
RegExpMatch? matchAsPrefix(String string, [int start = 0]) {
@@ -246,7 +246,7 @@ class _AllMatchesIterable extends Iterable<RegExpMatch> {
_AllMatchesIterable(this._re, this._string, this._start);
Iterator<RegExpMatch> get iterator =>
new _AllMatchesIterator(_re, _string, _start);
_AllMatchesIterator(_re, _string, _start);
}
class _AllMatchesIterator implements Iterator<RegExpMatch> {
+3 -3
View File
@@ -110,7 +110,7 @@ final class NaiveUnmodifiableInt32x4List extends NaiveInt32x4List {
@override
void operator []=(int index, Int32x4 value) {
throw new UnsupportedError("Cannot modify an unmodifiable list");
throw UnsupportedError("Cannot modify an unmodifiable list");
}
@override
@@ -216,7 +216,7 @@ final class NaiveUnmodifiableFloat32x4List extends NaiveFloat32x4List {
@override
void operator []=(int index, Float32x4 value) {
throw new UnsupportedError("Cannot modify an unmodifiable list");
throw UnsupportedError("Cannot modify an unmodifiable list");
}
@override
@@ -316,7 +316,7 @@ final class NaiveUnmodifiableFloat64x2List extends NaiveFloat64x2List {
@override
void operator []=(int index, Float64x2 value) {
throw new UnsupportedError("Cannot modify an unmodifiable list");
throw UnsupportedError("Cannot modify an unmodifiable list");
}
@override
+1 -1
View File
@@ -30,7 +30,7 @@ class Symbol {
// Class._constructor@xxx -> Class._constructor
// _Class@xxx._constructor@xxx -> _Class._constructor
// lib._S@xxx with lib._M1@xxx, lib._M2@xxx -> lib._S with lib._M1, lib._M2
StringBuffer result = new StringBuffer();
StringBuffer result = StringBuffer();
bool add_setter_suffix = false;
var pos = 0;
if (string.length >= 4 && string[3] == ':') {
+1 -1
View File
@@ -17,7 +17,7 @@ void _checkValidWeakTarget(Object object) {
(object is Pointer) ||
(object is Struct) ||
(object is Union)) {
throw new ArgumentError.value(
throw ArgumentError.value(
object,
"A string, number, boolean, record, Pointer, Struct or Union "
"can't be a weak target",
@@ -16,8 +16,8 @@ dynamic _parseJson(
String source,
Object? Function(Object? key, Object? value)? reviver,
) {
_JsonListener listener = new _JsonListener(reviver);
var parser = new _JsonStringParser(listener);
_JsonListener listener = _JsonListener(reviver);
var parser = _JsonStringParser(listener);
parser.chunk = source;
parser.chunkEnd = source.length;
parser.parse(0);
@@ -171,7 +171,7 @@ class _NumberBuffer {
Uint8List list;
int length = 0;
_NumberBuffer(int initialCapacity)
: list = new Uint8List(_initialCapacity(initialCapacity));
: list = Uint8List(_initialCapacity(initialCapacity));
int get capacity => list.length;
@@ -194,13 +194,13 @@ class _NumberBuffer {
void ensureCapacity(int newCapacity) {
Uint8List list = this.list;
if (newCapacity <= list.length) return;
Uint8List newList = new Uint8List(newCapacity);
Uint8List newList = Uint8List(newCapacity);
newList.setRange(0, list.length, list, 0);
this.list = newList;
}
String getString() {
String result = new String.fromCharCodes(list, 0, length);
String result = String.fromCharCodes(list, 0, length);
return result;
}
@@ -1128,7 +1128,7 @@ abstract class _ChunkedJsonParser<T> {
int beginChunkNumber(int state, int start) {
int end = chunkEnd;
int length = end - start;
var buffer = new _NumberBuffer(length);
var buffer = _NumberBuffer(length);
copyCharsToList(start, end, buffer.list, 0);
buffer.length = length;
this.buffer = buffer;
@@ -1337,7 +1337,7 @@ abstract class _ChunkedJsonParser<T> {
message = "Unexpected character";
if (position == chunkEnd) message = "Unexpected end of input";
}
throw new FormatException(message, chunk, position);
throw FormatException(message, chunk, position);
}
}
@@ -1357,7 +1357,7 @@ class _JsonStringParser extends _ChunkedJsonParser<String> {
}
void beginString() {
this.buffer = new StringBuffer();
this.buffer = StringBuffer();
}
void addSliceToString(int start, int end) {
@@ -1441,7 +1441,7 @@ class _JsonUtf8Parser extends _ChunkedJsonParser<List<int>> {
String getString(int start, int end, int bits) {
const int maxAsciiChar = 0x7f;
if (bits <= maxAsciiChar) {
return new String.fromCharCodes(chunk, start, end);
return String.fromCharCodes(chunk, start, end);
}
beginString();
if (start < end) addSliceToString(start, end);
@@ -1450,7 +1450,7 @@ class _JsonUtf8Parser extends _ChunkedJsonParser<List<int>> {
}
void beginString() {
this.buffer = new StringBuffer();
this.buffer = StringBuffer();
}
void addSliceToString(int start, int end) {
+18 -22
View File
@@ -98,34 +98,34 @@ abstract class _BroadcastStreamController<T>
: _state = _STATE_INITIAL;
void Function() get onPause {
throw new UnsupportedError(
throw UnsupportedError(
"Broadcast stream controllers do not support pause callbacks",
);
}
void set onPause(void onPauseHandler()?) {
throw new UnsupportedError(
throw UnsupportedError(
"Broadcast stream controllers do not support pause callbacks",
);
}
void Function() get onResume {
throw new UnsupportedError(
throw UnsupportedError(
"Broadcast stream controllers do not support pause callbacks",
);
}
void set onResume(void onResumeHandler()?) {
throw new UnsupportedError(
throw UnsupportedError(
"Broadcast stream controllers do not support pause callbacks",
);
}
// StreamController interface.
Stream<T> get stream => new _BroadcastStream<T>(this);
Stream<T> get stream => _BroadcastStream<T>(this);
StreamSink<T> get sink => new _StreamSinkWrapper<T>(this);
StreamSink<T> get sink => _StreamSinkWrapper<T>(this);
bool get isClosed => (_state & _STATE_CLOSED) != 0;
@@ -205,9 +205,9 @@ abstract class _BroadcastStreamController<T>
bool cancelOnError,
) {
if (isClosed) {
return new _DoneStreamSubscription<T>(onDone);
return _DoneStreamSubscription<T>(onDone);
}
var subscription = new _BroadcastSubscription<T>(
var subscription = _BroadcastSubscription<T>(
this,
onData,
onError,
@@ -246,10 +246,10 @@ abstract class _BroadcastStreamController<T>
Error _addEventError() {
if (isClosed) {
return new StateError("Cannot add new events after calling close");
return StateError("Cannot add new events after calling close");
}
assert(_isAddingStream);
return new StateError("Cannot add new events while doing an addStream");
return StateError("Cannot add new events while doing an addStream");
}
void add(T data) {
@@ -280,11 +280,7 @@ abstract class _BroadcastStreamController<T>
Future addStream(Stream<T> stream, {bool? cancelOnError}) {
if (!_mayAddEvent) throw _addEventError();
_state |= _STATE_ADDSTREAM;
var addStreamState = new _AddStreamState(
this,
stream,
cancelOnError ?? false,
);
var addStreamState = _AddStreamState(this, stream, cancelOnError ?? false);
_addStreamState = addStreamState;
return addStreamState.addStreamFuture;
}
@@ -311,7 +307,7 @@ abstract class _BroadcastStreamController<T>
void action(_BufferingStreamSubscription<T> subscription),
) {
if (_isFiring) {
throw new StateError(
throw StateError(
"Cannot fire new event. Controller is already firing an event",
);
}
@@ -373,7 +369,7 @@ class _SyncBroadcastStreamController<T> extends _BroadcastStreamController<T>
_addEventError() {
if (_isFiring) {
return new StateError(
return StateError(
"Cannot fire new event. Controller is already firing an event",
);
}
@@ -429,7 +425,7 @@ class _AsyncBroadcastStreamController<T> extends _BroadcastStreamController<T> {
subscription != null;
subscription = subscription._next
) {
subscription._addPending(new _DelayedData<T>(data));
subscription._addPending(_DelayedData<T>(data));
}
}
@@ -439,7 +435,7 @@ class _AsyncBroadcastStreamController<T> extends _BroadcastStreamController<T> {
subscription != null;
subscription = subscription._next
) {
subscription._addPending(new _DelayedError(error, stackTrace));
subscription._addPending(_DelayedError(error, stackTrace));
}
}
@@ -481,12 +477,12 @@ class _AsBroadcastStreamController<T> extends _SyncBroadcastStreamController<T>
}
void _addPendingEvent(_DelayedEvent event) {
(_pending ??= new _PendingEvents<T>()).add(event);
(_pending ??= _PendingEvents<T>()).add(event);
}
void add(T data) {
if (!isClosed && _isFiring) {
_addPendingEvent(new _DelayedData<T>(data));
_addPendingEvent(_DelayedData<T>(data));
return;
}
super.add(data);
@@ -497,7 +493,7 @@ class _AsBroadcastStreamController<T> extends _SyncBroadcastStreamController<T>
if (!_mayAddEvent) throw _addEventError();
AsyncError(:error, :stackTrace) = _interceptUserError(error, stackTrace);
if (!isClosed && _isFiring) {
_addPendingEvent(new _DelayedError(error, stackTrace));
_addPendingEvent(_DelayedError(error, stackTrace));
return;
}
_addError(error, stackTrace);
+10 -10
View File
@@ -41,7 +41,7 @@ abstract class FutureOr<T> {
// Private generative constructor, so that it is not subclassable, mixable,
// or instantiable.
FutureOr._() {
throw new UnsupportedError("FutureOr cannot be instantiated");
throw UnsupportedError("FutureOr cannot be instantiated");
}
}
@@ -235,7 +235,7 @@ abstract interface class Future<T> {
static final _Future<void> _nullFuture = nullFuture as _Future<void>;
/// A `Future<bool>` completed with `false`.
static final _Future<bool> _falseFuture = new _Future<bool>.zoneValue(
static final _Future<bool> _falseFuture = _Future<bool>.zoneValue(
false,
_rootZone,
);
@@ -253,7 +253,7 @@ abstract interface class Future<T> {
/// If a non-future value is returned, the returned future is completed
/// with that value.
factory Future(FutureOr<T> computation()) {
_Future<T> result = new _Future<T>();
_Future<T> result = _Future<T>();
Timer.run(() {
FutureOr<T> computationResult;
try {
@@ -280,7 +280,7 @@ abstract interface class Future<T> {
/// If calling [computation] returns a non-future value,
/// the returned future is completed with that value.
factory Future.microtask(FutureOr<T> computation()) {
_Future<T> result = new _Future<T>();
_Future<T> result = _Future<T>();
scheduleMicrotask(() {
FutureOr<T> computationResult;
try {
@@ -348,7 +348,7 @@ abstract interface class Future<T> {
@pragma("vm:entry-point")
@pragma("vm:prefer-inline")
factory Future.value([FutureOr<T>? value]) {
return new _Future<T>.immediate(value == null ? value as T : value);
return _Future<T>.immediate(value == null ? value as T : value);
}
/// Creates a future that completes with an error.
@@ -410,7 +410,7 @@ abstract interface class Future<T> {
);
}
_Future<T> result = _Future<T>();
new Timer(duration, () {
Timer(duration, () {
if (computation == null) {
result._complete(null as T);
} else {
@@ -612,7 +612,7 @@ abstract interface class Future<T> {
/// }
/// ```
static Future<T> any<T>(Iterable<Future<T>> futures) {
var completer = new Completer<T>.sync();
var completer = Completer<T>.sync();
void onValue(T value) {
if (!completer.isCompleted) completer.complete(value);
}
@@ -697,7 +697,7 @@ abstract interface class Future<T> {
/// // Outputs: 'Finished with 3'
/// ```
static Future<void> doWhile(FutureOr<bool> action()) {
_Future<void> doneSignal = new _Future<void>();
_Future<void> doneSignal = _Future<void>();
late void Function(bool) nextIteration;
// Bind this callback explicitly so that each iteration isn't bound in the
// context of all the previous iterations' callbacks.
@@ -1192,7 +1192,7 @@ abstract interface class Completer<T> {
/// completer.complete('completion value');
/// }
/// ```
factory Completer() => new _AsyncCompleter<T>();
factory Completer() => _AsyncCompleter<T>();
/// Completes the future synchronously.
///
@@ -1243,7 +1243,7 @@ abstract interface class Completer<T> {
/// foo(); // In this case, foo() runs after bar().
/// });
/// ```
factory Completer.sync() => new _SyncCompleter<T>();
factory Completer.sync() => _SyncCompleter<T>();
/// The future that is completed by this completer.
///
+21 -21
View File
@@ -73,14 +73,14 @@ AsyncError _interceptUserError(Object error, StackTrace? stackTrace) {
abstract class _Completer<T> implements Completer<T> {
@pragma("wasm:entry-point")
@pragma("vm:entry-point")
final _Future<T> future = new _Future<T>();
final _Future<T> future = _Future<T>();
// Overridden by either a synchronous or asynchronous implementation.
void complete([FutureOr<T>? value]);
@pragma("wasm:entry-point")
void completeError(Object error, [StackTrace? stackTrace]) {
if (!future._mayComplete) throw new StateError("Future already completed");
if (!future._mayComplete) throw StateError("Future already completed");
_completeErrorObject(_interceptUserError(error, stackTrace));
}
@@ -97,7 +97,7 @@ abstract class _Completer<T> implements Completer<T> {
class _AsyncCompleter<T> extends _Completer<T> {
@pragma("wasm:entry-point")
void complete([FutureOr<T>? value]) {
if (!future._mayComplete) throw new StateError("Future already completed");
if (!future._mayComplete) throw StateError("Future already completed");
future._asyncComplete(value == null ? value as dynamic : value);
}
@@ -112,7 +112,7 @@ class _AsyncCompleter<T> extends _Completer<T> {
@pragma("vm:entry-point")
class _SyncCompleter<T> extends _Completer<T> {
void complete([FutureOr<T>? value]) {
if (!future._mayComplete) throw new StateError("Future already completed");
if (!future._mayComplete) throw StateError("Future already completed");
future._complete(value == null ? value as dynamic : value);
}
@@ -411,8 +411,8 @@ class _Future<T> implements Future<T> {
onError = _registerErrorHandler(onError, currentZone);
}
}
_Future<R> result = new _Future<R>();
_addListener(new _FutureListener<T, R>.then(result, f, onError));
_Future<R> result = _Future<R>();
_addListener(_FutureListener<T, R>.then(result, f, onError));
return result;
}
@@ -421,8 +421,8 @@ class _Future<T> implements Future<T> {
/// Used by the implementation of `await` to listen to a future.
/// The system created listeners are not registered in the zone.
Future<E> _thenAwait<E>(FutureOr<E> f(T value), Function onError) {
_Future<E> result = new _Future<E>();
_addListener(new _FutureListener<T, E>.thenAwait(result, f, onError));
_Future<E> result = _Future<E>();
_addListener(_FutureListener<T, E>.thenAwait(result, f, onError));
return result;
}
@@ -442,12 +442,12 @@ class _Future<T> implements Future<T> {
}
Future<T> catchError(Function onError, {bool test(Object error)?}) {
_Future<T> result = new _Future<T>();
_Future<T> result = _Future<T>();
if (!identical(result._zone, _rootZone)) {
onError = _registerErrorHandler(onError, result._zone);
if (test != null) test = result._zone.registerUnaryCallback(test);
}
_addListener(new _FutureListener<T, T>.catchError(result, onError, test));
_addListener(_FutureListener<T, T>.catchError(result, onError, test));
return result;
}
@@ -469,15 +469,15 @@ class _Future<T> implements Future<T> {
}
Future<T> whenComplete(dynamic action()) {
_Future<T> result = new _Future<T>();
_Future<T> result = _Future<T>();
if (!identical(result._zone, _rootZone)) {
action = result._zone.registerCallback<dynamic>(action);
}
_addListener(new _FutureListener<T, T>.whenComplete(result, action));
_addListener(_FutureListener<T, T>.whenComplete(result, action));
return result;
}
Stream<T> asStream() => new Stream<T>.fromFuture(this);
Stream<T> asStream() => Stream<T>.fromFuture(this);
void _setPendingComplete() {
assert(_mayComplete); // Aka. _stateIncomplete
@@ -914,7 +914,7 @@ class _Future<T> implements Future<T> {
if (hasError && identical(source._error.error, e)) {
listenerValueOrError = source._error;
} else {
listenerValueOrError = new AsyncError(e, s);
listenerValueOrError = AsyncError(e, s);
}
listenerHasError = true;
return;
@@ -950,7 +950,7 @@ class _Future<T> implements Future<T> {
try {
listenerValueOrError = listener.handleValue(sourceResult);
} catch (e, s) {
listenerValueOrError = new AsyncError(e, s);
listenerValueOrError = AsyncError(e, s);
listenerHasError = true;
}
}
@@ -967,7 +967,7 @@ class _Future<T> implements Future<T> {
if (identical(source._error.error, e)) {
listenerValueOrError = source._error;
} else {
listenerValueOrError = new AsyncError(e, s);
listenerValueOrError = AsyncError(e, s);
}
listenerHasError = true;
}
@@ -1033,15 +1033,15 @@ class _Future<T> implements Future<T> {
@pragma("vm:entry-point")
Future<T> timeout(Duration timeLimit, {FutureOr<T> onTimeout()?}) {
if (_isComplete) return new _Future.immediate(this);
if (_isComplete) return _Future.immediate(this);
@pragma('vm:awaiter-link')
_Future<T> _future = new _Future<T>();
_Future<T> _future = _Future<T>();
Timer timer;
if (onTimeout == null) {
timer = new Timer(timeLimit, () {
timer = Timer(timeLimit, () {
_future._completeErrorObject(
AsyncError(
new TimeoutException("Future not completed", timeLimit),
TimeoutException("Future not completed", timeLimit),
StackTrace.current,
),
);
@@ -1052,7 +1052,7 @@ class _Future<T> implements Future<T> {
onTimeout,
);
timer = new Timer(timeLimit, () {
timer = Timer(timeLimit, () {
try {
_future._complete(zone.run(onTimeoutHandler));
} catch (e, s) {
+2 -2
View File
@@ -61,7 +61,7 @@ void _startMicrotaskLoop() {
/// The microtask is called after all other currently scheduled
/// microtasks, but as part of the current system event.
void _scheduleAsyncCallback(_AsyncCallback callback) {
_AsyncCallbackEntry newEntry = new _AsyncCallbackEntry(callback);
_AsyncCallbackEntry newEntry = _AsyncCallbackEntry(callback);
_AsyncCallbackEntry? lastCallback = _lastCallback;
if (lastCallback == null) {
_nextCallback = _lastCallback = newEntry;
@@ -86,7 +86,7 @@ void _schedulePriorityAsyncCallback(_AsyncCallback callback) {
_lastPriorityCallback = _lastCallback;
return;
}
_AsyncCallbackEntry entry = new _AsyncCallbackEntry(callback);
_AsyncCallbackEntry entry = _AsyncCallbackEntry(callback);
_AsyncCallbackEntry? lastPriorityCallback = _lastPriorityCallback;
if (lastPriorityCallback == null) {
entry.next = _nextCallback;
+43 -44
View File
@@ -241,7 +241,7 @@ abstract mixin class Stream<T> {
// Use the controller's buffering to fill in the value even before
// the stream has a listener. For a single value, it's not worth it
// to wait for a listener before doing the `then` on the future.
_StreamController<T> controller = new _SyncStreamController<T>(
_StreamController<T> controller = _SyncStreamController<T>(
null,
null,
null,
@@ -295,7 +295,7 @@ abstract mixin class Stream<T> {
/// // "Done" when stream completed.
/// ```
factory Stream.fromFutures(Iterable<Future<T>> futures) {
_StreamController<T> controller = new _SyncStreamController<T>(
_StreamController<T> controller = _SyncStreamController<T>(
null,
null,
null,
@@ -511,7 +511,7 @@ abstract mixin class Stream<T> {
}
var controller = _SyncStreamController<T>(null, null, null, null);
// Counts the time that the Stream was running (and not paused).
Stopwatch watch = new Stopwatch();
Stopwatch watch = Stopwatch();
controller.onListen = () {
int computationCount = 0;
void sendEvent(_) {
@@ -544,7 +544,7 @@ abstract mixin class Stream<T> {
..onResume = () {
Duration elapsed = watch.elapsed;
watch.start();
timer = new Timer(period - elapsed, () {
timer = Timer(period - elapsed, () {
timer = Timer.periodic(period, sendEvent);
sendEvent(null);
});
@@ -595,7 +595,7 @@ abstract mixin class Stream<T> {
Stream<dynamic> source,
EventSink<dynamic> mapSink(EventSink<T> sink),
) {
return new _BoundSinkStream(source, mapSink);
return _BoundSinkStream(source, mapSink);
}
/// Adapts [source] to be a `Stream<T>`.
@@ -604,8 +604,7 @@ abstract mixin class Stream<T> {
/// must satisfy the requirements of both the new type and its original type.
///
/// Data events created by the source stream must also be instances of [T].
static Stream<T> castFrom<S, T>(Stream<S> source) =>
new CastStream<S, T>(source);
static Stream<T> castFrom<S, T>(Stream<S> source) => CastStream<S, T>(source);
/// Whether this stream is a broadcast stream.
bool get isBroadcast => false;
@@ -683,7 +682,7 @@ abstract mixin class Stream<T> {
void onListen(StreamSubscription<T> subscription)?,
void onCancel(StreamSubscription<T> subscription)?,
}) {
return new _AsBroadcastStream<T>(this, onListen, onCancel);
return _AsBroadcastStream<T>(this, onListen, onCancel);
}
/// Adds a subscription to this stream.
@@ -750,7 +749,7 @@ abstract mixin class Stream<T> {
/// customStream.listen(print); // Outputs event values: 4,5,6.
/// ```
Stream<T> where(bool test(T event)) {
return new _WhereStream<T>(this, test);
return _WhereStream<T>(this, test);
}
/// Transforms each element of this stream into a new stream event.
@@ -794,7 +793,7 @@ abstract mixin class Stream<T> {
/// // Square: 16
/// ```
Stream<S> map<S>(S convert(T event)) {
return new _MapStream<T, S>(this, convert);
return _MapStream<T, S>(this, convert);
}
/// Creates a new stream with each data event of this stream asynchronously
@@ -969,7 +968,7 @@ abstract mixin class Stream<T> {
" as arguments.",
);
}
return new _HandleErrorStream<T>(this, callback, test);
return _HandleErrorStream<T>(this, callback, test);
}
/// Transforms each element of this stream into a sequence of elements.
@@ -990,7 +989,7 @@ abstract mixin class Stream<T> {
/// If a broadcast stream is listened to more than once, each subscription
/// will individually call `convert` and expand the events.
Stream<S> expand<S>(Iterable<S> convert(T element)) {
return new _ExpandStream<T, S>(this, convert);
return _ExpandStream<T, S>(this, convert);
}
/// Pipes the events of this stream into [streamConsumer].
@@ -1065,7 +1064,7 @@ abstract mixin class Stream<T> {
/// print(result); // 28
/// ```
Future<T> reduce(T combine(T previous, T element)) {
_Future<T> result = new _Future<T>();
_Future<T> result = _Future<T>();
bool seenFirst = false;
late T value;
StreamSubscription<T> subscription = this.listen(
@@ -1119,7 +1118,7 @@ abstract mixin class Stream<T> {
/// print(result); // 38
/// ```
Future<S> fold<S>(S initialValue, S combine(S previous, T element)) {
_Future<S> result = new _Future<S>();
_Future<S> result = _Future<S>();
S value = initialValue;
StreamSubscription<T> subscription = this.listen(
null,
@@ -1157,8 +1156,8 @@ abstract mixin class Stream<T> {
/// print(result); // 'Mars--Venus--Earth'
/// ```
Future<String> join([String separator = ""]) {
_Future<String> result = new _Future<String>();
StringBuffer buffer = new StringBuffer();
_Future<String> result = _Future<String>();
StringBuffer buffer = StringBuffer();
bool first = true;
StreamSubscription<T> subscription = this.listen(
null,
@@ -1210,7 +1209,7 @@ abstract mixin class Stream<T> {
/// print(result); // true
/// ```
Future<bool> contains(Object? needle) {
_Future<bool> future = new _Future<bool>();
_Future<bool> future = _Future<bool>();
StreamSubscription<T> subscription = this.listen(
null,
onError: future._completeError,
@@ -1238,7 +1237,7 @@ abstract mixin class Stream<T> {
/// the returned future completes with that error,
/// and processing stops.
Future<void> forEach(void action(T element)) {
_Future future = new _Future();
_Future future = _Future();
StreamSubscription<T> subscription = this.listen(
null,
onError: future._completeError,
@@ -1279,7 +1278,7 @@ abstract mixin class Stream<T> {
/// print(result); // false
/// ```
Future<bool> every(bool test(T element)) {
_Future<bool> future = new _Future<bool>();
_Future<bool> future = _Future<bool>();
StreamSubscription<T> subscription = this.listen(
null,
onError: future._completeError,
@@ -1321,7 +1320,7 @@ abstract mixin class Stream<T> {
/// print(result); // true
/// ```
Future<bool> any(bool test(T element)) {
_Future<bool> future = new _Future<bool>();
_Future<bool> future = _Future<bool>();
StreamSubscription<T> subscription = this.listen(
null,
onError: future._completeError,
@@ -1352,7 +1351,7 @@ abstract mixin class Stream<T> {
/// This operation listens to this stream, and a non-broadcast stream cannot
/// be reused after finding its length.
Future<int> get length {
_Future<int> future = new _Future<int>();
_Future<int> future = _Future<int>();
int count = 0;
this.listen(
(_) {
@@ -1380,7 +1379,7 @@ abstract mixin class Stream<T> {
/// This operation listens to this stream, and a non-broadcast stream cannot
/// be reused after checking whether it is empty.
Future<bool> get isEmpty {
_Future<bool> future = new _Future<bool>();
_Future<bool> future = _Future<bool>();
StreamSubscription<T> subscription = this.listen(
null,
onError: future._completeError,
@@ -1412,7 +1411,7 @@ abstract mixin class Stream<T> {
/// and processing stops.
Future<List<T>> toList() {
List<T> result = <T>[];
_Future<List<T>> future = new _Future<List<T>>();
_Future<List<T>> future = _Future<List<T>>();
this.listen(
(T data) {
result.add(data);
@@ -1442,8 +1441,8 @@ abstract mixin class Stream<T> {
/// the returned future is completed with that error,
/// and processing stops.
Future<Set<T>> toSet() {
Set<T> result = new Set<T>();
_Future<Set<T>> future = new _Future<Set<T>>();
Set<T> result = Set<T>();
_Future<Set<T>> future = _Future<Set<T>>();
this.listen(
(T data) {
result.add(data);
@@ -1512,7 +1511,7 @@ abstract mixin class Stream<T> {
/// stream.forEach(print); // Outputs events: 0, ... 59.
/// ```
Stream<T> take(int count) {
return new _TakeStream<T>(this, count);
return _TakeStream<T>(this, count);
}
/// Forwards data events while [test] is successful.
@@ -1543,7 +1542,7 @@ abstract mixin class Stream<T> {
/// stream.forEach(print); // Outputs events: 0, ..., 5.
/// ```
Stream<T> takeWhile(bool test(T element)) {
return new _TakeWhileStream<T>(this, test);
return _TakeWhileStream<T>(this, test);
}
/// Skips the first [count] data events from this stream.
@@ -1567,7 +1566,7 @@ abstract mixin class Stream<T> {
/// stream.forEach(print); // Skips events 0, ..., 6. Outputs events: 7, ...
/// ```
Stream<T> skip(int count) {
return new _SkipStream<T>(this, count);
return _SkipStream<T>(this, count);
}
/// Skip data events from this stream while they are matched by [test].
@@ -1595,7 +1594,7 @@ abstract mixin class Stream<T> {
/// stream.forEach(print); // Outputs events: 5, ..., 9.
/// ```
Stream<T> skipWhile(bool test(T element)) {
return new _SkipWhileStream<T>(this, test);
return _SkipWhileStream<T>(this, test);
}
/// Skips data events if they are equal to the previous data event.
@@ -1624,7 +1623,7 @@ abstract mixin class Stream<T> {
/// stream.forEach(print); // Outputs events: 2,6,8,12,8,2.
/// ```
Stream<T> distinct([bool equals(T previous, T next)?]) {
return new _DistinctStream<T>(this, equals);
return _DistinctStream<T>(this, equals);
}
/// The first element of this stream.
@@ -1644,7 +1643,7 @@ abstract mixin class Stream<T> {
/// Except for the type of the error, this method is equivalent to
/// `this.elementAt(0)`.
Future<T> get first {
_Future<T> future = new _Future<T>();
_Future<T> future = _Future<T>();
StreamSubscription<T> subscription = this.listen(
null,
onError: future._completeError,
@@ -1671,7 +1670,7 @@ abstract mixin class Stream<T> {
/// If this stream is empty (the done event is the first event),
/// the returned future completes with an error.
Future<T> get last {
_Future<T> future = new _Future<T>();
_Future<T> future = _Future<T>();
late T result;
bool foundResult = false;
listen(
@@ -1704,7 +1703,7 @@ abstract mixin class Stream<T> {
/// If this [Stream] is empty or has more than one element,
/// the returned future completes with an error.
Future<T> get single {
_Future<T> future = new _Future<T>();
_Future<T> future = _Future<T>();
late T result;
bool foundResult = false;
StreamSubscription<T> subscription = this.listen(
@@ -1774,7 +1773,7 @@ abstract mixin class Stream<T> {
/// print(result); // -1
/// ```
Future<T> firstWhere(bool test(T element), {T orElse()?}) {
_Future<T> future = new _Future();
_Future<T> future = _Future();
StreamSubscription<T> subscription = this.listen(
null,
onError: future._completeError,
@@ -1827,7 +1826,7 @@ abstract mixin class Stream<T> {
/// print(result); // -1
/// ```
Future<T> lastWhere(bool test(T element), {T orElse()?}) {
_Future<T> future = new _Future();
_Future<T> future = _Future();
late T result;
bool foundResult = false;
StreamSubscription<T> subscription = this.listen(
@@ -1894,7 +1893,7 @@ abstract mixin class Stream<T> {
/// // Throws.
/// ```
Future<T> singleWhere(bool test(T element), {T orElse()?}) {
_Future<T> future = new _Future<T>();
_Future<T> future = _Future<T>();
late T result;
bool foundResult = false;
StreamSubscription<T> subscription = this.listen(
@@ -1951,7 +1950,7 @@ abstract mixin class Stream<T> {
/// with a [RangeError].
Future<T> elementAt(int index) {
RangeError.checkNotNegative(index, "index");
_Future<T> result = new _Future<T>();
_Future<T> result = _Future<T>();
int elementIndex = 0;
StreamSubscription<T> subscription;
subscription = this.listen(
@@ -1959,7 +1958,7 @@ abstract mixin class Stream<T> {
onError: result._completeError,
onDone: () {
result._completeError(
new IndexError.withLength(
IndexError.withLength(
index,
elementIndex,
indexable: this,
@@ -2035,9 +2034,9 @@ abstract mixin class Stream<T> {
Stream<T> timeout(Duration timeLimit, {void onTimeout(EventSink<T> sink)?}) {
_StreamControllerBase<T> controller;
if (isBroadcast) {
controller = new _SyncBroadcastStreamController<T>(null, null);
controller = _SyncBroadcastStreamController<T>(null, null);
} else {
controller = new _SyncStreamController<T>(null, null, null, null);
controller = _SyncStreamController<T>(null, null, null, null);
}
Zone zone = Zone.current;
@@ -2046,7 +2045,7 @@ abstract mixin class Stream<T> {
if (onTimeout == null) {
timeoutCallback = () {
controller.addError(
new TimeoutException("No stream event", timeLimit),
TimeoutException("No stream event", timeLimit),
null,
);
};
@@ -2054,7 +2053,7 @@ abstract mixin class Stream<T> {
var registeredOnTimeout = zone.registerUnaryCallback<void, EventSink<T>>(
onTimeout,
);
var wrapper = new _ControllerEventSinkWrapper<T>(null);
var wrapper = _ControllerEventSinkWrapper<T>(null);
timeoutCallback = () {
wrapper._sink = controller; // Only valid during call.
zone.runUnaryGuarded(registeredOnTimeout, wrapper);
@@ -2626,7 +2625,7 @@ abstract interface class StreamTransformer<S, T> {
static StreamTransformer<TS, TT> castFrom<SS, ST, TS, TT>(
StreamTransformer<SS, ST> source,
) {
return new CastStreamTransformer<SS, ST, TS, TT>(source);
return CastStreamTransformer<SS, ST, TS, TT>(source);
}
/// Transforms the provided [stream].
@@ -2692,7 +2691,7 @@ abstract interface class StreamIterator<T> {
factory StreamIterator(Stream<T> stream) =>
// TODO(lrn): use redirecting factory constructor when type
// arguments are supported.
new _StreamIterator<T>(stream);
_StreamIterator<T>(stream);
/// Wait for the next stream value to be available.
///
+5 -5
View File
@@ -74,7 +74,7 @@ class _SinkTransformerStreamSubscription<S, T>
/// error.
void _addError(Object error, StackTrace stackTrace) {
if (_isClosed) {
throw new StateError("Stream is already closed");
throw StateError("Stream is already closed");
}
super._addError(error, stackTrace);
}
@@ -86,7 +86,7 @@ class _SinkTransformerStreamSubscription<S, T>
/// error.
void _close() {
if (_isClosed) {
throw new StateError("Stream is already closed");
throw StateError("Stream is already closed");
}
super._close();
}
@@ -153,7 +153,7 @@ class _StreamSinkTransformer<S, T> extends StreamTransformerBase<S, T> {
const _StreamSinkTransformer(this._sinkMapper);
Stream<T> bind(Stream<S> stream) =>
new _BoundSinkStream<S, T>(stream, _sinkMapper);
_BoundSinkStream<S, T>(stream, _sinkMapper);
}
/// The result of binding a [StreamTransformer] for [Sink]-mappers.
@@ -269,7 +269,7 @@ class _StreamHandlerTransformer<S, T> extends _StreamSinkTransformer<S, T> {
void handleError(Object error, StackTrace stackTrace, EventSink<T> sink)?,
void handleDone(EventSink<T> sink)?,
}) : super((EventSink<T> outputSink) {
return new _HandlerEventSink<S, T>(
return _HandlerEventSink<S, T>(
handleData,
handleError,
handleDone,
@@ -312,7 +312,7 @@ class _StreamSubscriptionTransformer<S, T> extends StreamTransformerBase<S, T> {
const _StreamSubscriptionTransformer(this._onListen);
Stream<T> bind(Stream<S> stream) =>
new _BoundSubscriptionStream<S, T>(stream, _onListen);
_BoundSubscriptionStream<S, T>(stream, _onListen);
}
/// A stream transformed by a [_StreamSubscriptionTransformer].
+1 -1
View File
@@ -104,7 +104,7 @@ abstract interface class Timer {
/// Timer.run(() => print('timer run'));
/// ```
static void run(void Function() callback) {
new Timer(Duration.zero, callback);
Timer(Duration.zero, callback);
}
/// Cancels the timer.
+1 -1
View File
@@ -16,7 +16,7 @@ abstract interface class StackTrace {
///
/// This stack trace is used as the default in situations where
/// a stack trace is required, but the user has not supplied one.
static const empty = const _StringStackTrace("");
static const empty = _StringStackTrace("");
StackTrace(); // In case existing classes extend StackTrace.
+4 -5
View File
@@ -17,14 +17,14 @@ class CastStream<S, T> extends Stream<T> {
void Function()? onDone,
bool? cancelOnError,
}) {
return new CastStreamSubscription<S, T>(
return CastStreamSubscription<S, T>(
_source.listen(null, onDone: onDone, cancelOnError: cancelOnError),
)
..onData(onData)
..onError(onError);
}
Stream<R> cast<R>() => new CastStream<S, R>(_source);
Stream<R> cast<R>() => CastStream<S, R>(_source);
}
class CastStreamSubscription<S, T> implements StreamSubscription<T> {
@@ -115,7 +115,7 @@ class CastStreamTransformer<SS, ST, TS, TT>
CastStreamTransformer(this._source);
StreamTransformer<RS, RT> cast<RS, RT>() =>
new CastStreamTransformer<SS, ST, RS, RT>(_source);
CastStreamTransformer<SS, ST, RS, RT>(_source);
Stream<TT> bind(Stream<TS> stream) =>
_source.bind(stream.cast<SS>()).cast<TT>();
}
@@ -131,6 +131,5 @@ class CastConverter<SS, ST, TS, TT> extends Converter<TS, TT> {
Stream<TT> bind(Stream<TS> stream) =>
_source.bind(stream.cast<SS>()).cast<TT>();
Converter<RS, RT> cast<RS, RT>() =>
new CastConverter<SS, ST, RS, RT>(_source);
Converter<RS, RT> cast<RS, RT>() => CastConverter<SS, ST, RS, RT>(_source);
}
+26 -26
View File
@@ -9,7 +9,7 @@ part of dart._internal;
abstract class _CastIterableBase<S, T> extends Iterable<T> {
Iterable<S> get _source;
Iterator<T> get iterator => new CastIterator<S, T>(_source.iterator);
Iterator<T> get iterator => CastIterator<S, T>(_source.iterator);
// The following members use the default implementation on the
// throwing iterator. These are all operations that have no more efficient
@@ -36,8 +36,8 @@ abstract class _CastIterableBase<S, T> extends Iterable<T> {
bool get isEmpty => _source.isEmpty;
bool get isNotEmpty => _source.isNotEmpty;
Iterable<T> skip(int count) => new CastIterable<S, T>(_source.skip(count));
Iterable<T> take(int count) => new CastIterable<S, T>(_source.take(count));
Iterable<T> skip(int count) => CastIterable<S, T>(_source.skip(count));
Iterable<T> take(int count) => CastIterable<S, T>(_source.take(count));
T elementAt(int index) => _source.elementAt(index) as T;
T get first => _source.first as T;
@@ -72,12 +72,12 @@ class CastIterable<S, T> extends _CastIterableBase<S, T> {
factory CastIterable(Iterable<S> source) {
if (source is EfficientLengthIterable<S>) {
return new _EfficientLengthCastIterable<S, T>(source);
return _EfficientLengthCastIterable<S, T>(source);
}
return new CastIterable<S, T>._(source);
return CastIterable<S, T>._(source);
}
Iterable<R> cast<R>() => new CastIterable<S, R>(_source);
Iterable<R> cast<R>() => CastIterable<S, R>(_source);
}
class _EfficientLengthCastIterable<S, T> extends CastIterable<S, T>
@@ -114,7 +114,7 @@ abstract class _CastListBase<S, T> extends _CastIterableBase<S, T>
}
void addAll(Iterable<T> values) {
_source.addAll(new CastIterable<T, S>(values));
_source.addAll(CastIterable<T, S>(values));
}
void sort([int Function(T v1, T v2)? compare]) {
@@ -132,11 +132,11 @@ abstract class _CastListBase<S, T> extends _CastIterableBase<S, T>
}
void insertAll(int index, Iterable<T> elements) {
_source.insertAll(index, new CastIterable<T, S>(elements));
_source.insertAll(index, CastIterable<T, S>(elements));
}
void setAll(int index, Iterable<T> elements) {
_source.setAll(index, new CastIterable<T, S>(elements));
_source.setAll(index, CastIterable<T, S>(elements));
}
bool remove(Object? value) => _source.remove(value);
@@ -154,10 +154,10 @@ abstract class _CastListBase<S, T> extends _CastIterableBase<S, T>
}
Iterable<T> getRange(int start, int end) =>
new CastIterable<S, T>(_source.getRange(start, end));
CastIterable<S, T>(_source.getRange(start, end));
void setRange(int start, int end, Iterable<T> iterable, [int skipCount = 0]) {
_source.setRange(start, end, new CastIterable<T, S>(iterable), skipCount);
_source.setRange(start, end, CastIterable<T, S>(iterable), skipCount);
}
void removeRange(int start, int end) {
@@ -169,7 +169,7 @@ abstract class _CastListBase<S, T> extends _CastIterableBase<S, T>
}
void replaceRange(int start, int end, Iterable<T> replacement) {
_source.replaceRange(start, end, new CastIterable<T, S>(replacement));
_source.replaceRange(start, end, CastIterable<T, S>(replacement));
}
}
@@ -177,7 +177,7 @@ class CastList<S, T> extends _CastListBase<S, T> {
final List<S> _source;
CastList(this._source);
List<R> cast<R>() => new CastList<S, R>(_source);
List<R> cast<R>() => CastList<S, R>(_source);
}
class CastSet<S, T> extends _CastIterableBase<S, T> implements Set<T> {
@@ -190,11 +190,11 @@ class CastSet<S, T> extends _CastIterableBase<S, T> implements Set<T> {
CastSet(this._source, this._emptySet);
Set<R> cast<R>() => new CastSet<S, R>(_source, _emptySet);
Set<R> cast<R>() => CastSet<S, R>(_source, _emptySet);
bool add(T value) => _source.add(value as S);
void addAll(Iterable<T> elements) {
_source.addAll(new CastIterable<T, S>(elements));
_source.addAll(CastIterable<T, S>(elements));
}
bool remove(Object? object) => _source.remove(object);
@@ -219,17 +219,17 @@ class CastSet<S, T> extends _CastIterableBase<S, T> implements Set<T> {
Set<T> intersection(Set<Object?> other) {
if (_emptySet != null) return _conditionalAdd(other, true);
return new CastSet<S, T>(_source.intersection(other), null);
return CastSet<S, T>(_source.intersection(other), null);
}
Set<T> difference(Set<Object?> other) {
if (_emptySet != null) return _conditionalAdd(other, false);
return new CastSet<S, T>(_source.difference(other), null);
return CastSet<S, T>(_source.difference(other), null);
}
Set<T> _conditionalAdd(Set<Object?> other, bool otherContains) {
var emptySet = _emptySet;
Set<T> result = (emptySet == null) ? new Set<T>() : emptySet<T>();
Set<T> result = (emptySet == null) ? Set<T>() : emptySet<T>();
for (var element in _source) {
T castElement = element as T;
if (otherContains == other.contains(castElement)) result.add(castElement);
@@ -245,7 +245,7 @@ class CastSet<S, T> extends _CastIterableBase<S, T> implements Set<T> {
Set<T> _clone() {
var emptySet = _emptySet;
Set<T> result = (emptySet == null) ? new Set<T>() : emptySet<T>();
Set<T> result = (emptySet == null) ? Set<T>() : emptySet<T>();
result.addAll(this);
return result;
}
@@ -260,7 +260,7 @@ class CastMap<SK, SV, K, V> extends MapBase<K, V> {
CastMap(this._source);
Map<RK, RV> cast<RK, RV>() => new CastMap<SK, SV, RK, RV>(_source);
Map<RK, RV> cast<RK, RV>() => CastMap<SK, SV, RK, RV>(_source);
bool containsValue(Object? value) => _source.containsValue(value);
@@ -276,7 +276,7 @@ class CastMap<SK, SV, K, V> extends MapBase<K, V> {
_source.putIfAbsent(key as SK, () => ifAbsent() as SV) as V;
void addAll(Map<K, V> other) {
_source.addAll(new CastMap<K, V, SK, SV>(other));
_source.addAll(CastMap<K, V, SK, SV>(other));
}
V? remove(Object? key) => _source.remove(key) as V?;
@@ -291,9 +291,9 @@ class CastMap<SK, SV, K, V> extends MapBase<K, V> {
});
}
Iterable<K> get keys => new CastIterable<SK, K>(_source.keys);
Iterable<K> get keys => CastIterable<SK, K>(_source.keys);
Iterable<V> get values => new CastIterable<SV, V>(_source.values);
Iterable<V> get values => CastIterable<SV, V>(_source.values);
int get length => _source.length;
@@ -316,7 +316,7 @@ class CastMap<SK, SV, K, V> extends MapBase<K, V> {
Iterable<MapEntry<K, V>> get entries {
return _source.entries.map<MapEntry<K, V>>(
(MapEntry<SK, SV> e) => new MapEntry<K, V>(e.key as K, e.value as V),
(MapEntry<SK, SV> e) => MapEntry<K, V>(e.key as K, e.value as V),
);
}
@@ -334,7 +334,7 @@ class CastMap<SK, SV, K, V> extends MapBase<K, V> {
class CastQueue<S, T> extends _CastIterableBase<S, T> implements Queue<T> {
final Queue<S> _source;
CastQueue(this._source);
Queue<R> cast<R>() => new CastQueue<S, R>(_source);
Queue<R> cast<R>() => CastQueue<S, R>(_source);
T removeFirst() => _source.removeFirst() as T;
T removeLast() => _source.removeLast() as T;
@@ -353,7 +353,7 @@ class CastQueue<S, T> extends _CastIterableBase<S, T> implements Queue<T> {
bool remove(Object? other) => _source.remove(other);
void addAll(Iterable<T> elements) {
_source.addAll(new CastIterable<T, S>(elements));
_source.addAll(CastIterable<T, S>(elements));
}
void removeWhere(bool test(T element)) {
+2 -2
View File
@@ -57,7 +57,7 @@ external T unsafeCast<T>(dynamic value);
// Powers of 10 up to 10^22 are representable as doubles.
// Powers of 10 above that are only approximate due to lack of precision.
// Used by double-parsing.
const POWERS_OF_TEN = const [
const POWERS_OF_TEN = [
1.0, // 0
10.0,
100.0,
@@ -742,7 +742,7 @@ class SentinelValue {
}
/// A default value to use when only one sentinel is needed.
const Object sentinelValue = const SentinelValue(0);
const Object sentinelValue = SentinelValue(0);
/// Given an [instance] of some generic type [T], and [extract], a first-class
/// generic function that takes the same number of type parameters as [T],
+1 -1
View File
@@ -75,7 +75,7 @@ class LinkedList<T extends LinkedListEntry<T>> extends Iterable<T> {
node._list = null;
}
Iterator<T> get iterator => new _LinkedListIterator<T>(this);
Iterator<T> get iterator => _LinkedListIterator<T>(this);
}
class LinkedListEntry<T extends LinkedListEntry<T>> {
+44 -48
View File
@@ -12,69 +12,67 @@ part of dart._internal;
mixin FixedLengthListMixin<E> {
/** This operation is not supported by a fixed length list. */
set length(int newLength) {
throw new UnsupportedError(
"Cannot change the length of a fixed-length list",
);
throw UnsupportedError("Cannot change the length of a fixed-length list");
}
/** This operation is not supported by a fixed length list. */
void add(E value) {
throw new UnsupportedError("Cannot add to a fixed-length list");
throw UnsupportedError("Cannot add to a fixed-length list");
}
/** This operation is not supported by a fixed length list. */
void insert(int index, E value) {
throw new UnsupportedError("Cannot add to a fixed-length list");
throw UnsupportedError("Cannot add to a fixed-length list");
}
/** This operation is not supported by a fixed length list. */
void insertAll(int at, Iterable<E> iterable) {
throw new UnsupportedError("Cannot add to a fixed-length list");
throw UnsupportedError("Cannot add to a fixed-length list");
}
/** This operation is not supported by a fixed length list. */
void addAll(Iterable<E> iterable) {
throw new UnsupportedError("Cannot add to a fixed-length list");
throw UnsupportedError("Cannot add to a fixed-length list");
}
/** This operation is not supported by a fixed length list. */
bool remove(Object? element) {
throw new UnsupportedError("Cannot remove from a fixed-length list");
throw UnsupportedError("Cannot remove from a fixed-length list");
}
/** This operation is not supported by a fixed length list. */
void removeWhere(bool test(E element)) {
throw new UnsupportedError("Cannot remove from a fixed-length list");
throw UnsupportedError("Cannot remove from a fixed-length list");
}
/** This operation is not supported by a fixed length list. */
void retainWhere(bool test(E element)) {
throw new UnsupportedError("Cannot remove from a fixed-length list");
throw UnsupportedError("Cannot remove from a fixed-length list");
}
/** This operation is not supported by a fixed length list. */
void clear() {
throw new UnsupportedError("Cannot clear a fixed-length list");
throw UnsupportedError("Cannot clear a fixed-length list");
}
/** This operation is not supported by a fixed length list. */
E removeAt(int index) {
throw new UnsupportedError("Cannot remove from a fixed-length list");
throw UnsupportedError("Cannot remove from a fixed-length list");
}
/** This operation is not supported by a fixed length list. */
E removeLast() {
throw new UnsupportedError("Cannot remove from a fixed-length list");
throw UnsupportedError("Cannot remove from a fixed-length list");
}
/** This operation is not supported by a fixed length list. */
void removeRange(int start, int end) {
throw new UnsupportedError("Cannot remove from a fixed-length list");
throw UnsupportedError("Cannot remove from a fixed-length list");
}
/** This operation is not supported by a fixed length list. */
void replaceRange(int start, int end, Iterable<E> iterable) {
throw new UnsupportedError("Cannot remove from a fixed-length list");
throw UnsupportedError("Cannot remove from a fixed-length list");
}
}
@@ -88,107 +86,105 @@ mixin FixedLengthListMixin<E> {
mixin UnmodifiableListMixin<E> implements List<E> {
/** This operation is not supported by an unmodifiable list. */
void operator []=(int index, E value) {
throw new UnsupportedError("Cannot modify an unmodifiable list");
throw UnsupportedError("Cannot modify an unmodifiable list");
}
/** This operation is not supported by an unmodifiable list. */
set length(int newLength) {
throw new UnsupportedError(
"Cannot change the length of an unmodifiable list",
);
throw UnsupportedError("Cannot change the length of an unmodifiable list");
}
set first(E element) {
throw new UnsupportedError("Cannot modify an unmodifiable list");
throw UnsupportedError("Cannot modify an unmodifiable list");
}
set last(E element) {
throw new UnsupportedError("Cannot modify an unmodifiable list");
throw UnsupportedError("Cannot modify an unmodifiable list");
}
/** This operation is not supported by an unmodifiable list. */
void setAll(int at, Iterable<E> iterable) {
throw new UnsupportedError("Cannot modify an unmodifiable list");
throw UnsupportedError("Cannot modify an unmodifiable list");
}
/** This operation is not supported by an unmodifiable list. */
void add(E value) {
throw new UnsupportedError("Cannot add to an unmodifiable list");
throw UnsupportedError("Cannot add to an unmodifiable list");
}
/** This operation is not supported by an unmodifiable list. */
void insert(int index, E element) {
throw new UnsupportedError("Cannot add to an unmodifiable list");
throw UnsupportedError("Cannot add to an unmodifiable list");
}
/** This operation is not supported by an unmodifiable list. */
void insertAll(int at, Iterable<E> iterable) {
throw new UnsupportedError("Cannot add to an unmodifiable list");
throw UnsupportedError("Cannot add to an unmodifiable list");
}
/** This operation is not supported by an unmodifiable list. */
void addAll(Iterable<E> iterable) {
throw new UnsupportedError("Cannot add to an unmodifiable list");
throw UnsupportedError("Cannot add to an unmodifiable list");
}
/** This operation is not supported by an unmodifiable list. */
bool remove(Object? element) {
throw new UnsupportedError("Cannot remove from an unmodifiable list");
throw UnsupportedError("Cannot remove from an unmodifiable list");
}
/** This operation is not supported by an unmodifiable list. */
void removeWhere(bool test(E element)) {
throw new UnsupportedError("Cannot remove from an unmodifiable list");
throw UnsupportedError("Cannot remove from an unmodifiable list");
}
/** This operation is not supported by an unmodifiable list. */
void retainWhere(bool test(E element)) {
throw new UnsupportedError("Cannot remove from an unmodifiable list");
throw UnsupportedError("Cannot remove from an unmodifiable list");
}
/** This operation is not supported by an unmodifiable list. */
void sort([Comparator<E>? compare]) {
throw new UnsupportedError("Cannot modify an unmodifiable list");
throw UnsupportedError("Cannot modify an unmodifiable list");
}
/** This operation is not supported by an unmodifiable list. */
void shuffle([Random? random]) {
throw new UnsupportedError("Cannot modify an unmodifiable list");
throw UnsupportedError("Cannot modify an unmodifiable list");
}
/** This operation is not supported by an unmodifiable list. */
void clear() {
throw new UnsupportedError("Cannot clear an unmodifiable list");
throw UnsupportedError("Cannot clear an unmodifiable list");
}
/** This operation is not supported by an unmodifiable list. */
E removeAt(int index) {
throw new UnsupportedError("Cannot remove from an unmodifiable list");
throw UnsupportedError("Cannot remove from an unmodifiable list");
}
/** This operation is not supported by an unmodifiable list. */
E removeLast() {
throw new UnsupportedError("Cannot remove from an unmodifiable list");
throw UnsupportedError("Cannot remove from an unmodifiable list");
}
/** This operation is not supported by an unmodifiable list. */
void setRange(int start, int end, Iterable<E> iterable, [int skipCount = 0]) {
throw new UnsupportedError("Cannot modify an unmodifiable list");
throw UnsupportedError("Cannot modify an unmodifiable list");
}
/** This operation is not supported by an unmodifiable list. */
void removeRange(int start, int end) {
throw new UnsupportedError("Cannot remove from an unmodifiable list");
throw UnsupportedError("Cannot remove from an unmodifiable list");
}
/** This operation is not supported by an unmodifiable list. */
void replaceRange(int start, int end, Iterable<E> iterable) {
throw new UnsupportedError("Cannot remove from an unmodifiable list");
throw UnsupportedError("Cannot remove from an unmodifiable list");
}
/** This operation is not supported by an unmodifiable list. */
void fillRange(int start, int end, [E? fillValue]) {
throw new UnsupportedError("Cannot modify an unmodifiable list");
throw UnsupportedError("Cannot modify an unmodifiable list");
}
}
@@ -230,8 +226,8 @@ class ListMapView<E> extends UnmodifiableMapBase<int, E> {
E? operator [](Object? key) => containsKey(key) ? _values[key as int] : null;
int get length => _values.length;
Iterable<E> get values => new SubListIterable<E>(_values, 0, null);
Iterable<int> get keys => new _ListIndicesIterable(_values);
Iterable<E> get values => SubListIterable<E>(_values, 0, null);
Iterable<int> get keys => _ListIndicesIterable(_values);
bool get isEmpty => _values.isEmpty;
bool get isNotEmpty => _values.isNotEmpty;
@@ -243,7 +239,7 @@ class ListMapView<E> extends UnmodifiableMapBase<int, E> {
for (int i = 0; i < length; i++) {
f(i, _values[i]);
if (length != _values.length) {
throw new ConcurrentModificationError(_values);
throw ConcurrentModificationError(_values);
}
}
}
@@ -266,19 +262,19 @@ final class ReversedListIterable<E> extends ListIterable<E> {
abstract class UnmodifiableListError {
/** Error thrown when trying to add elements to an unmodifiable list. */
static UnsupportedError add() =>
new UnsupportedError("Cannot add to unmodifiable List");
UnsupportedError("Cannot add to unmodifiable List");
/** Error thrown when trying to add elements to an unmodifiable list. */
static UnsupportedError change() =>
new UnsupportedError("Cannot change the content of an unmodifiable List");
UnsupportedError("Cannot change the content of an unmodifiable List");
/** Error thrown when trying to change the length of an unmodifiable list. */
static UnsupportedError length() =>
new UnsupportedError("Cannot change length of unmodifiable List");
UnsupportedError("Cannot change length of unmodifiable List");
/** Error thrown when trying to remove elements from an unmodifiable list. */
static UnsupportedError remove() =>
new UnsupportedError("Cannot remove from unmodifiable List");
UnsupportedError("Cannot remove from unmodifiable List");
}
/**
@@ -289,15 +285,15 @@ abstract class UnmodifiableListError {
abstract class NonGrowableListError {
/** Error thrown when trying to add elements to an non-growable list. */
static UnsupportedError add() =>
new UnsupportedError("Cannot add to non-growable List");
UnsupportedError("Cannot add to non-growable List");
/** Error thrown when trying to change the length of an non-growable list. */
static UnsupportedError length() =>
new UnsupportedError("Cannot change length of non-growable List");
UnsupportedError("Cannot change length of non-growable List");
/** Error thrown when trying to remove elements from an non-growable list. */
static UnsupportedError remove() =>
new UnsupportedError("Cannot remove from non-growable List");
UnsupportedError("Cannot remove from non-growable List");
}
/**
+4 -4
View File
@@ -92,7 +92,7 @@ class OSError implements Exception {
/// Converts an OSError object to a string representation.
String toString() {
StringBuffer sb = new StringBuffer();
StringBuffer sb = StringBuffer();
sb.write("OS Error");
if (message.isNotEmpty) {
sb
@@ -129,12 +129,12 @@ _BufferAndStart _ensureFastAndSerializableByteData(
// Send typed data directly, unless it is a partial view, in which case we
// would rather copy than drag in the potentially much large backing store.
// See issue 50206.
return new _BufferAndStart(buffer, start);
return _BufferAndStart(buffer, start);
}
int length = end - start;
var newBuffer = new Uint8List(length);
var newBuffer = Uint8List(length);
newBuffer.setRange(0, length, buffer, start);
return new _BufferAndStart(newBuffer, 0);
return _BufferAndStart(newBuffer, 0);
}
class _IOCrypto {
+19 -23
View File
@@ -56,7 +56,7 @@ abstract final class ZLibOption {
}
/// An instance of the default implementation of the [ZLibCodec].
const ZLibCodec zlib = const ZLibCodec._default();
const ZLibCodec zlib = ZLibCodec._default();
/// The [ZLibCodec] encodes raw bytes to ZLib compressed bytes and decodes ZLib
/// compressed bytes to raw bytes.
@@ -131,7 +131,7 @@ final class ZLibCodec extends Codec<List<int>, List<int>> {
dictionary = null;
/// Get a [ZLibEncoder] for encoding to `ZLib` compressed data.
ZLibEncoder get encoder => new ZLibEncoder(
ZLibEncoder get encoder => ZLibEncoder(
gzip: false,
level: level,
windowBits: windowBits,
@@ -143,11 +143,11 @@ final class ZLibCodec extends Codec<List<int>, List<int>> {
/// Get a [ZLibDecoder] for decoding `ZLib` compressed data.
ZLibDecoder get decoder =>
new ZLibDecoder(windowBits: windowBits, dictionary: dictionary, raw: raw);
ZLibDecoder(windowBits: windowBits, dictionary: dictionary, raw: raw);
}
/// An instance of the default implementation of the [GZipCodec].
const GZipCodec gzip = const GZipCodec._default();
const GZipCodec gzip = GZipCodec._default();
/// The [GZipCodec] encodes raw bytes to GZip compressed bytes and decodes GZip
/// compressed bytes to raw bytes.
@@ -224,7 +224,7 @@ final class GZipCodec extends Codec<List<int>, List<int>> {
dictionary = null;
/// Get a [ZLibEncoder] for encoding to `GZip` compressed data.
ZLibEncoder get encoder => new ZLibEncoder(
ZLibEncoder get encoder => ZLibEncoder(
gzip: true,
level: level,
windowBits: windowBits,
@@ -235,7 +235,7 @@ final class GZipCodec extends Codec<List<int>, List<int>> {
);
/// Get a [ZLibDecoder] for decoding `GZip` compressed data.
ZLibDecoder get decoder => new ZLibDecoder(
ZLibDecoder get decoder => ZLibDecoder(
gzip: true,
windowBits: windowBits,
dictionary: dictionary,
@@ -311,7 +311,7 @@ final class ZLibEncoder extends Converter<List<int>, List<int>> {
/// Convert a list of bytes using the options given to the ZLibEncoder
/// constructor.
List<int> convert(List<int> bytes) {
_BufferSink sink = new _BufferSink();
_BufferSink sink = _BufferSink();
startChunkedConversion(sink)
..add(bytes)
..close();
@@ -326,9 +326,9 @@ final class ZLibEncoder extends Converter<List<int>, List<int>> {
/// using it.
ByteConversionSink startChunkedConversion(Sink<List<int>> sink) {
if (sink is! ByteConversionSink) {
sink = new ByteConversionSink.from(sink);
sink = ByteConversionSink.from(sink);
}
return new _ZLibEncoderSink._(
return _ZLibEncoderSink._(
sink,
gzip,
level,
@@ -378,7 +378,7 @@ final class ZLibDecoder extends Converter<List<int>, List<int>> {
/// Convert a list of bytes using the options given to the [ZLibDecoder]
/// constructor.
List<int> convert(List<int> bytes) {
_BufferSink sink = new _BufferSink();
_BufferSink sink = _BufferSink();
startChunkedConversion(sink)
..add(bytes)
..close();
@@ -392,9 +392,9 @@ final class ZLibDecoder extends Converter<List<int>, List<int>> {
/// using it.
ByteConversionSink startChunkedConversion(Sink<List<int>> sink) {
if (sink is! ByteConversionSink) {
sink = new ByteConversionSink.from(sink);
sink = ByteConversionSink.from(sink);
}
return new _ZLibDecoderSink._(sink, gzip, windowBits, dictionary, raw);
return _ZLibDecoderSink._(sink, gzip, windowBits, dictionary, raw);
}
}
@@ -468,7 +468,7 @@ abstract interface class RawZLibFilter {
}
class _BufferSink extends ByteConversionSink {
final BytesBuilder builder = new BytesBuilder(copy: false);
final BytesBuilder builder = BytesBuilder(copy: false);
void add(List<int> chunk) {
builder.add(chunk);
@@ -478,11 +478,7 @@ class _BufferSink extends ByteConversionSink {
if (chunk is Uint8List) {
Uint8List list = chunk;
builder.add(
new Uint8List.view(
list.buffer,
list.offsetInBytes + start,
end - start,
),
Uint8List.view(list.buffer, list.offsetInBytes + start, end - start),
);
} else {
builder.add(chunk.sublist(start, end));
@@ -594,7 +590,7 @@ class _FilterSink extends ByteConversionSink {
void _validateZLibWindowBits(int windowBits) {
if (ZLibOption.minWindowBits > windowBits ||
ZLibOption.maxWindowBits < windowBits) {
throw new RangeError.range(
throw RangeError.range(
windowBits,
ZLibOption.minWindowBits,
ZLibOption.maxWindowBits,
@@ -604,13 +600,13 @@ void _validateZLibWindowBits(int windowBits) {
void _validateZLibeLevel(int level) {
if (ZLibOption.minLevel > level || ZLibOption.maxLevel < level) {
throw new RangeError.range(level, ZLibOption.minLevel, ZLibOption.maxLevel);
throw RangeError.range(level, ZLibOption.minLevel, ZLibOption.maxLevel);
}
}
void _validateZLibMemLevel(int memLevel) {
if (ZLibOption.minMemLevel > memLevel || ZLibOption.maxMemLevel < memLevel) {
throw new RangeError.range(
throw RangeError.range(
memLevel,
ZLibOption.minMemLevel,
ZLibOption.maxMemLevel,
@@ -619,7 +615,7 @@ void _validateZLibMemLevel(int memLevel) {
}
void _validateZLibStrategy(int strategy) {
const strategies = const <int>[
const strategies = <int>[
ZLibOption.strategyFiltered,
ZLibOption.strategyHuffmanOnly,
ZLibOption.strategyRle,
@@ -627,6 +623,6 @@ void _validateZLibStrategy(int strategy) {
ZLibOption.strategyDefault,
];
if (strategies.indexOf(strategy) == -1) {
throw new ArgumentError("Unsupported 'strategy'");
throw ArgumentError("Unsupported 'strategy'");
}
}
+3 -3
View File
@@ -112,7 +112,7 @@ abstract interface class Directory implements FileSystemEntity {
factory Directory(String path) {
final IOOverrides? overrides = IOOverrides.current;
if (overrides == null) {
return new _Directory(path);
return _Directory(path);
}
return overrides.createDirectory(path);
}
@@ -120,13 +120,13 @@ abstract interface class Directory implements FileSystemEntity {
@pragma("vm:entry-point")
factory Directory.fromRawPath(Uint8List path) {
// TODO(bkonyi): Handle overrides.
return new _Directory.fromRawPath(path);
return _Directory.fromRawPath(path);
}
/// Create a [Directory] from a URI.
///
/// If [uri] cannot reference a directory this throws [UnsupportedError].
factory Directory.fromUri(Uri uri) => new Directory(uri.toFilePath());
factory Directory.fromUri(Uri uri) => Directory(uri.toFilePath());
/// Creates a directory object pointing to the current working
/// directory.
+23 -23
View File
@@ -53,7 +53,7 @@ class _Directory extends FileSystemEntity implements Directory {
"",
);
}
return new _Directory(result);
return _Directory(result);
}
static void set current(Object? path) {
@@ -72,7 +72,7 @@ class _Directory extends FileSystemEntity implements Directory {
};
if (!_EmbedderConfig._mayChdir) {
throw new UnsupportedError(
throw UnsupportedError(
"This embedder disallows setting Directory.current",
);
}
@@ -88,7 +88,7 @@ class _Directory extends FileSystemEntity implements Directory {
}
Uri get uri {
return new Uri.directory(path);
return Uri.directory(path);
}
Future<bool> exists() {
@@ -104,12 +104,12 @@ class _Directory extends FileSystemEntity implements Directory {
bool existsSync() {
var result = _exists(_Namespace._namespace, _rawPath);
if (result is OSError) {
throw new FileSystemException("Exists failed", path, result);
throw FileSystemException("Exists failed", path, result);
}
return (result == 1);
}
Directory get absolute => new Directory(_absolutePath);
Directory get absolute => Directory(_absolutePath);
Future<Directory> create({bool recursive = false}) {
if (recursive) {
@@ -148,12 +148,12 @@ class _Directory extends FileSystemEntity implements Directory {
}
static Directory get systemTemp =>
new Directory(_systemTemp(_Namespace._namespace));
Directory(_systemTemp(_Namespace._namespace));
Future<Directory> createTemp([String? prefix]) {
prefix ??= '';
if (path == '') {
throw new ArgumentError(
throw ArgumentError(
"Directory.createTemp called with an empty path. "
"To use the system temp directory, use Directory.systemTemp",
);
@@ -182,7 +182,7 @@ class _Directory extends FileSystemEntity implements Directory {
Directory createTempSync([String? prefix]) {
prefix ??= '';
if (path == '') {
throw new ArgumentError(
throw ArgumentError(
"Directory.createTemp called with an empty path. "
"To use the system temp directory, use Directory.systemTemp",
);
@@ -200,13 +200,13 @@ class _Directory extends FileSystemEntity implements Directory {
FileSystemEntity._toUtf8Array(fullPrefix),
);
if (result is OSError) {
throw new FileSystemException._fromOSError(
throw FileSystemException._fromOSError(
result,
"Creation of temporary directory failed",
fullPrefix,
);
}
return new Directory(result);
return Directory(result);
}
Future<Directory> _delete({bool recursive = false}) {
@@ -234,7 +234,7 @@ class _Directory extends FileSystemEntity implements Directory {
newPath,
]).then((response) {
_checkForErrorResponse(response, "Rename failed", path);
return new Directory(newPath);
return Directory(newPath);
});
}
@@ -245,14 +245,14 @@ class _Directory extends FileSystemEntity implements Directory {
if (result is OSError) {
throw FileSystemException._fromOSError(result, "Rename failed", path);
}
return new Directory(newPath);
return Directory(newPath);
}
Stream<FileSystemEntity> list({
bool recursive = false,
bool followLinks = true,
}) {
return new _AsyncDirectoryLister(
return _AsyncDirectoryLister(
// FIXME(bkonyi): here we're using `path` directly, which might cause issues
// if it is not UTF-8 encoded.
FileSystemEntity._toUtf8Array(
@@ -316,12 +316,12 @@ class _AsyncDirectoryLister {
final bool recursive;
final bool followLinks;
final controller = new StreamController<FileSystemEntity>(sync: true);
final controller = StreamController<FileSystemEntity>(sync: true);
bool canceled = false;
bool nextRunning = false;
bool closed = false;
_AsyncDirectoryListerOps? _ops;
Completer closeCompleter = new Completer();
Completer closeCompleter = Completer();
_AsyncDirectoryLister(this.rawPath, this.recursive, this.followLinks) {
controller
@@ -349,7 +349,7 @@ class _AsyncDirectoryLister {
followLinks,
]).then((response) {
if (response is int) {
_ops = new _AsyncDirectoryListerOps(response);
_ops = _AsyncDirectoryListerOps(response);
next();
} else if (response is Error) {
controller.addError(response, response.stackTrace);
@@ -401,13 +401,13 @@ class _AsyncDirectoryLister {
assert(i % 2 == 0);
switch (result[i++]) {
case listFile:
controller.add(new File.fromRawPath(result[i]));
controller.add(File.fromRawPath(result[i]));
break;
case listDirectory:
controller.add(new Directory.fromRawPath(result[i]));
controller.add(Directory.fromRawPath(result[i]));
break;
case listLink:
controller.add(new Link.fromRawPath(result[i]));
controller.add(Link.fromRawPath(result[i]));
break;
case listError:
error(result[i]);
@@ -418,7 +418,7 @@ class _AsyncDirectoryLister {
}
}
} else {
controller.addError(new FileSystemException("Internal error"));
controller.addError(FileSystemException("Internal error"));
}
});
}
@@ -452,9 +452,9 @@ class _AsyncDirectoryLister {
var errorResponseInfo = message[responseError]! as List<Object?>;
var errorType = errorResponseInfo[_errorResponseErrorType];
if (errorType == _illegalArgumentResponse) {
controller.addError(new ArgumentError());
controller.addError(ArgumentError());
} else if (errorType == _osErrorResponse) {
var err = new OSError(
var err = OSError(
errorResponseInfo[_osErrorResponseMessage] as String,
errorResponseInfo[_osErrorResponseErrorCode] as int,
);
@@ -472,7 +472,7 @@ class _AsyncDirectoryLister {
),
);
} else {
controller.addError(new FileSystemException("Internal error"));
controller.addError(FileSystemException("Internal error"));
}
}
}
+13 -13
View File
@@ -7,25 +7,25 @@ part of dart.io;
/// The modes in which a [File] can be opened.
class FileMode {
/// The mode for opening a file only for reading.
static const read = const FileMode._internal(0);
static const read = FileMode._internal(0);
/// Mode for opening a file for reading and writing. The file is
/// overwritten if it already exists. The file is created if it does not
/// already exist.
static const write = const FileMode._internal(1);
static const write = FileMode._internal(1);
/// Mode for opening a file for reading and writing to the
/// end of it. The file is created if it does not already exist.
static const append = const FileMode._internal(2);
static const append = FileMode._internal(2);
/// Mode for opening a file for writing *only*. The file is
/// overwritten if it already exists. The file is created if it does not
/// already exist.
static const writeOnly = const FileMode._internal(3);
static const writeOnly = FileMode._internal(3);
/// Mode for opening a file for writing *only* to the
/// end of it. The file is created if it does not already exist.
static const writeOnlyAppend = const FileMode._internal(4);
static const writeOnlyAppend = FileMode._internal(4);
final int _mode;
@@ -35,16 +35,16 @@ class FileMode {
/// Type of lock when requesting a lock on a file.
class FileLock {
/// Shared file lock.
static const shared = const FileLock._internal(1);
static const shared = FileLock._internal(1);
/// Exclusive file lock.
static const exclusive = const FileLock._internal(2);
static const exclusive = FileLock._internal(2);
/// Blocking shared file lock.
static const blockingShared = const FileLock._internal(3);
static const blockingShared = FileLock._internal(3);
/// Blocking exclusive file lock.
static const blockingExclusive = const FileLock._internal(4);
static const blockingExclusive = FileLock._internal(4);
final int _type;
@@ -201,7 +201,7 @@ abstract interface class File implements FileSystemEntity {
factory File(String path) {
final IOOverrides? overrides = IOOverrides.current;
if (overrides == null) {
return new _File(path);
return _File(path);
}
return overrides.createFile(path);
}
@@ -209,7 +209,7 @@ abstract interface class File implements FileSystemEntity {
/// Create a [File] object from a URI.
///
/// If [uri] cannot reference a file this throws [UnsupportedError].
factory File.fromUri(Uri uri) => new File(uri.toFilePath());
factory File.fromUri(Uri uri) => File(uri.toFilePath());
/// Creates a [File] object from a raw path.
///
@@ -217,7 +217,7 @@ abstract interface class File implements FileSystemEntity {
@pragma("vm:entry-point")
factory File.fromRawPath(Uint8List rawPath) {
// TODO(bkonyi): Handle overrides.
return new _File.fromRawPath(rawPath);
return _File.fromRawPath(rawPath);
}
/// Creates the file.
@@ -1120,7 +1120,7 @@ class FileSystemException implements IOException {
}
String _toStringHelper(String className) {
StringBuffer sb = new StringBuffer();
StringBuffer sb = StringBuffer();
sb.write(className);
if (message.isNotEmpty) {
sb.write(": $message");
+12 -12
View File
@@ -31,7 +31,7 @@ abstract interface class IOSink implements StreamSink<List<int>>, StringSink {
factory IOSink(
StreamConsumer<List<int>> target, {
Encoding encoding = utf8,
}) => new _IOSinkImpl(target, encoding);
}) => _IOSinkImpl(target, encoding);
/// The [Encoding] used when writing strings.
///
@@ -139,7 +139,7 @@ abstract interface class IOSink implements StreamSink<List<int>>, StringSink {
class _StreamSinkImpl<T> implements StreamSink<T> {
final StreamConsumer<T> _target;
final Completer _doneCompleter = new Completer();
final Completer _doneCompleter = Completer();
StreamController<T>? _controllerInstance;
Completer? _controllerCompleter;
bool _isClosed = false;
@@ -164,7 +164,7 @@ class _StreamSinkImpl<T> implements StreamSink<T> {
Future addStream(Stream<T> stream) {
if (_isBound) {
throw new StateError("StreamSink is already bound to a stream");
throw StateError("StreamSink is already bound to a stream");
}
if (_hasError) return done;
@@ -186,9 +186,9 @@ class _StreamSinkImpl<T> implements StreamSink<T> {
Future flush() {
if (_isBound) {
throw new StateError("StreamSink is bound to a stream");
throw StateError("StreamSink is bound to a stream");
}
if (_controllerInstance == null) return new Future.value(this);
if (_controllerInstance == null) return Future.value(this);
// Adding an empty stream-controller will return a future that will complete
// when all data is done.
_isBound = true;
@@ -201,7 +201,7 @@ class _StreamSinkImpl<T> implements StreamSink<T> {
Future close() {
if (_isBound) {
throw new StateError("StreamSink is bound to a stream");
throw StateError("StreamSink is bound to a stream");
}
if (!_isClosed) {
_isClosed = true;
@@ -235,14 +235,14 @@ class _StreamSinkImpl<T> implements StreamSink<T> {
StreamController<T> get _controller {
if (_isBound) {
throw new StateError("StreamSink is bound to a stream");
throw StateError("StreamSink is bound to a stream");
}
if (_isClosed) {
throw new StateError("StreamSink is closed");
throw StateError("StreamSink is closed");
}
if (_controllerInstance == null) {
_controllerInstance = new StreamController<T>(sync: true);
_controllerCompleter = new Completer();
_controllerInstance = StreamController<T>(sync: true);
_controllerCompleter = Completer();
_target
.addStream(_controller.stream)
.then(
@@ -285,7 +285,7 @@ class _IOSinkImpl extends _StreamSinkImpl<List<int>> implements IOSink {
void set encoding(Encoding value) {
if (!_encodingMutable) {
throw new StateError("IOSink encoding is not mutable");
throw StateError("IOSink encoding is not mutable");
}
_encoding = value;
}
@@ -317,6 +317,6 @@ class _IOSinkImpl extends _StreamSinkImpl<List<int>> implements IOSink {
}
void writeCharCode(int charCode) {
write(new String.fromCharCode(charCode));
write(String.fromCharCode(charCode));
}
}
+2 -2
View File
@@ -39,7 +39,7 @@ Map<String, Object?> _createHttpProfileRequestFromProfileMap(
};
}
@pragma('vm:entry-point', !const bool.fromEnvironment("dart.vm.product"))
@pragma('vm:entry-point', !bool.fromEnvironment("dart.vm.product"))
abstract class _NetworkProfiling {
// Http relative RPCs
static const _kHttpEnableTimelineLogging =
@@ -58,7 +58,7 @@ abstract class _NetworkProfiling {
// if more methods added to dart:io,
static const _kGetVersionRPC = 'ext.dart.io.getVersion';
@pragma('vm:entry-point', !const bool.fromEnvironment("dart.vm.product"))
@pragma('vm:entry-point', !bool.fromEnvironment("dart.vm.product"))
static void _registerServiceExtension() {
registerExtension(_kHttpEnableTimelineLogging, _serviceExtensionHandler);
registerExtension(_kGetSocketProfileRPC, _serviceExtensionHandler);
+5 -5
View File
@@ -4,7 +4,7 @@
part of dart.io;
final _ioOverridesToken = new Object();
final _ioOverridesToken = Object();
/// Facilities for overriding various APIs of `dart:io` with mock
/// implementations.
@@ -117,7 +117,7 @@ abstract class IOOverrides {
currentScope = current;
current = currentScope._previous;
}
IOOverrides overrides = new _IOOverridesScope(
IOOverrides overrides = _IOOverridesScope(
current,
// Directory
createDirectory ?? currentScope?._createDirectory,
@@ -180,7 +180,7 @@ abstract class IOOverrides {
///
/// When this override is installed, this function overrides the behavior of
/// `new Directory()` and `new Directory.fromUri()`.
Directory createDirectory(String path) => new _Directory(path);
Directory createDirectory(String path) => _Directory(path);
/// Returns the current working directory.
///
@@ -208,7 +208,7 @@ abstract class IOOverrides {
///
/// When this override is installed, this function overrides the behavior of
/// `new File()` and `new File.fromUri()`.
File createFile(String path) => new _File(path);
File createFile(String path) => _File(path);
// FileStat
@@ -286,7 +286,7 @@ abstract class IOOverrides {
///
/// When this override is installed, this function overrides the behavior of
/// `new Link()` and `new Link.fromUri()`.
Link createLink(String path) => new _Link(path);
Link createLink(String path) => _Link(path);
// Socket
+4 -4
View File
@@ -84,8 +84,8 @@ class _Platform {
if (env is Iterable<Object?>) {
var result =
Platform.isWindows
? new _CaseInsensitiveStringMap<String>()
: new Map<String, String>();
? _CaseInsensitiveStringMap<String>()
: Map<String, String>();
for (var environmentEntry in env) {
if (environmentEntry == null) {
continue;
@@ -107,7 +107,7 @@ class _Platform {
);
}
}
_environmentCache = new UnmodifiableMapView<String, String>(result);
_environmentCache = UnmodifiableMapView<String, String>(result);
} else {
_environmentCache = env;
}
@@ -126,7 +126,7 @@ class _Platform {
// Environment variables are case-insensitive on Windows. In order
// to reflect that we use a case-insensitive string map on Windows.
class _CaseInsensitiveStringMap<V> extends MapBase<String, V> {
final Map<String, V> _map = new Map<String, V>();
final Map<String, V> _map = Map<String, V>();
bool containsKey(Object? key) =>
key is String && _map.containsKey(key.toUpperCase());
+28 -33
View File
@@ -68,7 +68,7 @@ abstract interface class SecureSocket implements Socket {
keyLog: keyLog,
supportedProtocols: supportedProtocols,
timeout: timeout,
).then((rawSocket) => new SecureSocket._(rawSocket));
).then((rawSocket) => SecureSocket._(rawSocket));
}
/// Like [connect], but returns a [Future] that completes with a
@@ -91,9 +91,9 @@ abstract interface class SecureSocket implements Socket {
supportedProtocols: supportedProtocols,
).then((rawState) {
Future<SecureSocket> socket = rawState.socket.then(
(rawSocket) => new SecureSocket._(rawSocket),
(rawSocket) => SecureSocket._(rawSocket),
);
return new ConnectionTask<SecureSocket>._(socket, rawState._onCancel);
return ConnectionTask<SecureSocket>._(socket, rawState._onCancel);
});
}
@@ -170,7 +170,7 @@ abstract interface class SecureSocket implements Socket {
supportedProtocols: supportedProtocols,
);
})
.then<SecureSocket>((raw) => new SecureSocket._(raw));
.then<SecureSocket>((raw) => SecureSocket._(raw));
}
/// Initiates TLS on an existing server connection.
@@ -214,7 +214,7 @@ abstract interface class SecureSocket implements Socket {
supportedProtocols: supportedProtocols,
);
})
.then<SecureSocket>((raw) => new SecureSocket._(raw));
.then<SecureSocket>((raw) => SecureSocket._(raw));
}
/// The peer certificate for a connected SecureSocket.
@@ -343,7 +343,7 @@ abstract interface class RawSecureSocket implements RawSocket {
supportedProtocols: supportedProtocols,
);
});
return new ConnectionTask<RawSecureSocket>._(socket, rawState._onCancel);
return ConnectionTask<RawSecureSocket>._(socket, rawState._onCancel);
});
}
@@ -559,8 +559,8 @@ class _RawSecureSocket extends Stream<RawSocketEvent>
final RawSocket _socket;
final Completer<_RawSecureSocket> _handshakeComplete =
new Completer<_RawSecureSocket>();
final _controller = new StreamController<RawSocketEvent>(sync: true);
Completer<_RawSecureSocket>();
final _controller = StreamController<RawSocketEvent>(sync: true);
late final StreamSubscription<RawSocketEvent> _socketSubscription;
List<int>? _bufferedData;
int _bufferedDataIndex = 0;
@@ -583,13 +583,13 @@ class _RawSecureSocket extends Stream<RawSocketEvent>
bool _closedRead = false; // The secure socket has fired an onClosed event.
bool _closedWrite = false; // The secure socket has been closed for writing.
// The network socket is gone.
Completer<RawSecureSocket> _closeCompleter = new Completer<RawSecureSocket>();
_FilterStatus _filterStatus = new _FilterStatus();
Completer<RawSecureSocket> _closeCompleter = Completer<RawSecureSocket>();
_FilterStatus _filterStatus = _FilterStatus();
bool _connectPending = true;
bool _filterPending = false;
bool _filterActive = false;
_SecureFilter? _secureFilter = new _SecureFilter._();
_SecureFilter? _secureFilter = _SecureFilter._();
String? _selectedProtocol;
static Future<_RawSecureSocket> connect(
@@ -617,7 +617,7 @@ class _RawSecureSocket extends Stream<RawSocketEvent>
if (host != null) {
address = InternetAddress._cloneWithNewHost(address, host);
}
return new _RawSecureSocket(
return _RawSecureSocket(
address,
requestedPort,
isServer,
@@ -693,7 +693,7 @@ class _RawSecureSocket extends Stream<RawSocketEvent>
_socketSubscription = subscription;
if (_socketSubscription.isPaused) {
_socket.close();
throw new ArgumentError("Subscription passed to TLS upgrade is paused");
throw ArgumentError("Subscription passed to TLS upgrade is paused");
}
// If we are upgrading a socket that is already closed for read,
// report an error as if we received readClosed during the handshake.
@@ -745,7 +745,7 @@ class _RawSecureSocket extends Stream<RawSocketEvent>
bool requireClientCertificate,
) {
if (host is! String && host is! InternetAddress) {
throw new ArgumentError("host is not a String or an InternetAddress");
throw ArgumentError("host is not a String or an InternetAddress");
}
// TODO(40614): Remove once non-nullability is sound.
ArgumentError.checkNotNull(requestedPort, "requestedPort");
@@ -850,12 +850,12 @@ class _RawSecureSocket extends Stream<RawSocketEvent>
Uint8List? read([int? length]) {
if (length != null && length < 0) {
throw new ArgumentError(
throw ArgumentError(
"Invalid length parameter in SecureSocket.read (length: $length)",
);
}
if (_closedRead) {
throw new SocketException("Reading from a closed socket");
throw SocketException("Reading from a closed socket");
}
if (_status != connectedStatus) {
return null;
@@ -874,19 +874,19 @@ class _RawSecureSocket extends Stream<RawSocketEvent>
// Write the data to the socket, and schedule the filter to encrypt it.
int write(List<int> data, [int offset = 0, int? bytes]) {
if (bytes != null && bytes < 0) {
throw new ArgumentError(
throw ArgumentError(
"Invalid bytes parameter in SecureSocket.read (bytes: $bytes)",
);
}
// TODO(40614): Remove once non-nullability is sound.
offset = _fixOffset(offset);
if (offset < 0) {
throw new ArgumentError(
throw ArgumentError(
"Invalid offset parameter in SecureSocket.read (offset: $offset)",
);
}
if (_closedWrite) {
_controller.addError(new SocketException("Writing to a closed socket"));
_controller.addError(SocketException("Writing to a closed socket"));
return 0;
}
if (_status != connectedStatus) return 0;
@@ -997,7 +997,7 @@ class _RawSecureSocket extends Stream<RawSocketEvent>
// bytes available we can continue handshake.
if (_filterStatus.readEmpty) {
_reportError(
new HandshakeException('Connection terminated during handshake'),
HandshakeException('Connection terminated during handshake'),
null,
);
}
@@ -1028,9 +1028,7 @@ class _RawSecureSocket extends Stream<RawSocketEvent>
bool requireClientCertificate = false,
}) {
if (_status != connectedStatus) {
throw new HandshakeException(
"Called renegotiate on a non-connected socket",
);
throw HandshakeException("Called renegotiate on a non-connected socket");
}
_status = handshakeStatus;
_filterStatus.writeEmpty = false;
@@ -1113,7 +1111,7 @@ class _RawSecureSocket extends Stream<RawSocketEvent>
if (_status == handshakeStatus) {
_secureFilter!.handshake();
if (_status == handshakeStatus) {
throw new HandshakeException(
throw HandshakeException(
'Connection terminated during handshake',
);
}
@@ -1226,7 +1224,7 @@ class _RawSecureSocket extends Stream<RawSocketEvent>
Future<_FilterStatus> _pushAllFilterStages() async {
bool wasInHandshake = _status != connectedStatus;
List args = new List<dynamic>.filled(2 + bufferCount * 2, null);
List args = List<dynamic>.filled(2 + bufferCount * 2, null);
args[0] = _secureFilter!._pointer();
args[1] = wasInHandshake;
var bufs = _secureFilter!.buffers!;
@@ -1242,21 +1240,18 @@ class _RawSecureSocket extends Stream<RawSocketEvent>
if (wasInHandshake) {
// If we're in handshake, throw a handshake error.
_reportError(
new HandshakeException('${response[1]} error ${response[0]}'),
HandshakeException('${response[1]} error ${response[0]}'),
null,
);
} else {
// If we're connected, throw a TLS error.
_reportError(
new TlsException('${response[1]} error ${response[0]}'),
null,
);
_reportError(TlsException('${response[1]} error ${response[0]}'), null);
}
}
int start(int index) => response[2 * index] as int;
int end(int index) => response[2 * index + 1] as int;
_FilterStatus status = new _FilterStatus();
_FilterStatus status = _FilterStatus();
// Compute writeEmpty as "write plaintext buffer and write encrypted
// buffer were empty when we started and are empty now".
status.writeEmpty =
@@ -1371,7 +1366,7 @@ class _ExternalBuffer {
bytes = min(bytes, length);
}
if (bytes == 0) return null;
Uint8List result = new Uint8List(bytes);
Uint8List result = Uint8List(bytes);
int bytesRead = 0;
// Loop over zero, one, or two linear data ranges.
while (bytesRead < bytes) {
@@ -1477,7 +1472,7 @@ class TlsException implements IOException {
const TlsException._(this.type, this.message, this.osError);
String toString() {
StringBuffer sb = new StringBuffer();
StringBuffer sb = StringBuffer();
sb.write(type);
if (message.isNotEmpty) {
sb.write(": $message");
+7 -11
View File
@@ -231,7 +231,7 @@ abstract final class SecurityContext {
/// We will be conservative and support only messages up to (1<<13)-1 bytes.
static Uint8List _protocolsToLengthEncoding(List<String>? protocols) {
if (protocols == null || protocols.length == 0) {
return new Uint8List(0);
return Uint8List(0);
}
int protocolsLength = protocols.length;
@@ -242,20 +242,18 @@ abstract final class SecurityContext {
if (length > 0 && length <= 255) {
expectedLength += length;
} else {
throw new ArgumentError(
throw ArgumentError(
'Length of protocol must be between 1 and 255 (was: $length).',
);
}
}
if (expectedLength >= (1 << 13)) {
throw new ArgumentError(
'The maximum message length supported is 2^13-1.',
);
throw ArgumentError('The maximum message length supported is 2^13-1.');
}
// Try encoding the `List<String> protocols` array using fast ASCII path.
var bytes = new Uint8List(expectedLength);
var bytes = Uint8List(expectedLength);
int bytesOffset = 0;
for (int i = 0; i < protocolsLength; i++) {
String proto = protocols[i];
@@ -287,7 +285,7 @@ abstract final class SecurityContext {
var len = protocolBytes.length;
if (len > 255) {
throw new ArgumentError(
throw ArgumentError(
'Length of protocol must be between 1 and 255 (was: $len)',
);
}
@@ -304,11 +302,9 @@ abstract final class SecurityContext {
}
if (bytes.length >= (1 << 13)) {
throw new ArgumentError(
'The maximum message length supported is 2^13-1.',
);
throw ArgumentError('The maximum message length supported is 2^13-1.');
}
return new Uint8List.fromList(bytes);
return Uint8List.fromList(bytes);
}
}
+18 -18
View File
@@ -10,10 +10,10 @@ part of dart.io;
/// and Unix domain address are supported.
/// Unix domain sockets are available only on Linux, MacOS and Android.
final class InternetAddressType {
static const InternetAddressType IPv4 = const InternetAddressType._(0);
static const InternetAddressType IPv6 = const InternetAddressType._(1);
static const InternetAddressType unix = const InternetAddressType._(2);
static const InternetAddressType any = const InternetAddressType._(-1);
static const InternetAddressType IPv4 = InternetAddressType._(0);
static const InternetAddressType IPv6 = InternetAddressType._(1);
static const InternetAddressType unix = InternetAddressType._(2);
static const InternetAddressType any = InternetAddressType._(-1);
final int _value;
@@ -23,7 +23,7 @@ final class InternetAddressType {
if (value == IPv4._value) return IPv4;
if (value == IPv6._value) return IPv6;
if (value == unix._value) return unix;
throw new ArgumentError("Invalid type: $value");
throw ArgumentError("Invalid type: $value");
}
/// Get the name of the type, e.g. "IPv4" or "IPv6".
@@ -362,9 +362,9 @@ abstract interface class ServerSocket implements ServerSocketBase<Socket> {
/// The [SocketDirection] is used as a parameter to [Socket.close] and
/// [RawSocket.close] to close a socket in the specified direction(s).
final class SocketDirection {
static const SocketDirection receive = const SocketDirection._(0);
static const SocketDirection send = const SocketDirection._(1);
static const SocketDirection both = const SocketDirection._(2);
static const SocketDirection receive = SocketDirection._(0);
static const SocketDirection send = SocketDirection._(1);
static const SocketDirection both = SocketDirection._(2);
final _value;
@@ -382,12 +382,12 @@ final class SocketOption {
/// as an individual TCP packet.
///
/// tcpNoDelay is disabled by default.
static const SocketOption tcpNoDelay = const SocketOption._(0);
static const SocketOption tcpNoDelay = SocketOption._(0);
static const SocketOption _ipMulticastLoop = const SocketOption._(1);
static const SocketOption _ipMulticastHops = const SocketOption._(2);
static const SocketOption _ipMulticastIf = const SocketOption._(3);
static const SocketOption _ipBroadcast = const SocketOption._(4);
static const SocketOption _ipMulticastLoop = SocketOption._(1);
static const SocketOption _ipMulticastHops = SocketOption._(2);
static const SocketOption _ipMulticastIf = SocketOption._(3);
static const SocketOption _ipBroadcast = SocketOption._(4);
final _value;
@@ -531,16 +531,16 @@ final class RawSocketOption {
/// ```
class RawSocketEvent {
/// An event indicates the socket is ready to be read.
static const RawSocketEvent read = const RawSocketEvent._(0);
static const RawSocketEvent read = RawSocketEvent._(0);
/// An event indicates the socket is ready to write.
static const RawSocketEvent write = const RawSocketEvent._(1);
static const RawSocketEvent write = RawSocketEvent._(1);
/// An event indicates the reading from the socket is closed
static const RawSocketEvent readClosed = const RawSocketEvent._(2);
static const RawSocketEvent readClosed = RawSocketEvent._(2);
/// An event indicates the socket is closed.
static const RawSocketEvent closed = const RawSocketEvent._(3);
static const RawSocketEvent closed = RawSocketEvent._(3);
final int _value;
@@ -1408,7 +1408,7 @@ class SocketException implements IOException {
port = null;
String toString() {
StringBuffer sb = new StringBuffer();
StringBuffer sb = StringBuffer();
sb.write("SocketException");
if (message.isNotEmpty) {
sb.write(": $message");
+3 -3
View File
@@ -402,10 +402,10 @@ final class Endian {
final bool _littleEndian;
const Endian._(this._littleEndian);
static const Endian big = const Endian._(false);
static const Endian little = const Endian._(true);
static const Endian big = Endian._(false);
static const Endian little = Endian._(true);
static final Endian host =
(new ByteData.view(new Uint16List.fromList([1]).buffer)).getInt8(0) == 1
(ByteData.view(Uint16List.fromList([1]).buffer)).getInt8(0) == 1
? little
: big;
}
+2 -2
View File
@@ -876,14 +876,14 @@ class VMService extends MessageRouter {
@pragma(
'vm:entry-point',
const bool.fromEnvironment('dart.vm.product') ? false : 'call',
bool.fromEnvironment('dart.vm.product') ? false : 'call',
)
RawReceivePort boot() {
// Return the port we expect isolate control messages on.
return isolateControlPort;
}
@pragma('vm:entry-point', !const bool.fromEnvironment('dart.vm.product'))
@pragma('vm:entry-point', !bool.fromEnvironment('dart.vm.product'))
// ignore: unused_element
void _registerIsolate(int port_id, SendPort sp, String name) =>
VMService().runningIsolates.isolateStartup(port_id, sp, name);