mirror of
https://github.com/dart-lang/sdk
synced 2024-10-06 14:59:41 +00:00
Revert "Fix observatory tests broken by running dartfmt."
This reverts commit b1f7e6d94673b098c93c187fe3efc45c15f27edc.
BUG=
Committed: 62be0eacfb
Review-Url: https://codereview.chromium.org/2767533002 .
This commit is contained in:
parent
25282fbf64
commit
4360e99d18
|
@ -3,6 +3,7 @@
|
|||
// BSD-style license that can be found in the LICENSE file.
|
||||
|
||||
library builtin;
|
||||
|
||||
// NOTE: Do not import 'dart:io' in builtin.
|
||||
import 'dart:async';
|
||||
import 'dart:collection';
|
||||
|
@ -14,37 +15,30 @@ import 'dart:typed_data';
|
|||
// command line.
|
||||
bool _traceLoading = false;
|
||||
|
||||
|
||||
// Before handling an embedder entrypoint we finalize the setup of the
|
||||
// dart:_builtin library.
|
||||
bool _setupCompleted = false;
|
||||
|
||||
|
||||
// The root library (aka the script) is imported into this library. The
|
||||
// standalone embedder uses this to lookup the main entrypoint in the
|
||||
// root library's namespace.
|
||||
Function _getMainClosure() => main;
|
||||
|
||||
|
||||
// 'print' implementation.
|
||||
// The standalone embedder registers the closurized _print function with the
|
||||
// dart:core library.
|
||||
void _printString(String s) native "Builtin_PrintString";
|
||||
|
||||
|
||||
void _print(arg) {
|
||||
_printString(arg.toString());
|
||||
}
|
||||
|
||||
|
||||
_getPrintClosure() => _print;
|
||||
|
||||
|
||||
// Corelib 'Uri.base' implementation.
|
||||
// Uri.base is susceptible to changes in the current working directory.
|
||||
_getCurrentDirectoryPath() native "Builtin_GetCurrentDirectory";
|
||||
|
||||
|
||||
Uri _uriBase() {
|
||||
// We are not using Dircetory.current here to limit the dependency
|
||||
// on dart:io. This code is the same as:
|
||||
|
@ -53,7 +47,6 @@ Uri _uriBase() {
|
|||
return new Uri.directory(path);
|
||||
}
|
||||
|
||||
|
||||
_getUriBaseClosure() => _uriBase;
|
||||
|
||||
// Asynchronous loading of resources.
|
||||
|
@ -68,11 +61,11 @@ int _isolateId;
|
|||
// Requests made to the service isolate over the load port.
|
||||
|
||||
// Extra requests. Keep these in sync between loader.dart and builtin.dart.
|
||||
const _Dart_kInitLoader = 4; // Initialize the loader.
|
||||
const _Dart_kResourceLoad = 5; // Resource class support.
|
||||
const _Dart_kGetPackageRootUri = 6; // Uri of the packages/ directory.
|
||||
const _Dart_kGetPackageConfigUri = 7; // Uri of the .packages file.
|
||||
const _Dart_kResolvePackageUri = 8; // Resolve a package: uri.
|
||||
const _Dart_kInitLoader = 4; // Initialize the loader.
|
||||
const _Dart_kResourceLoad = 5; // Resource class support.
|
||||
const _Dart_kGetPackageRootUri = 6; // Uri of the packages/ directory.
|
||||
const _Dart_kGetPackageConfigUri = 7; // Uri of the .packages file.
|
||||
const _Dart_kResolvePackageUri = 8; // Resolve a package: uri.
|
||||
|
||||
// Make a request to the loader. Future will complete with result which is
|
||||
// either a Uri or a List<int>.
|
||||
|
@ -90,7 +83,6 @@ Future _makeLoaderRequest(int tag, String uri) {
|
|||
return completer.future;
|
||||
}
|
||||
|
||||
|
||||
// The current working directory when the embedder was launched.
|
||||
Uri _workingDirectory;
|
||||
// The URI that the root script was loaded from. Remembered so that
|
||||
|
@ -301,20 +293,20 @@ String _filePathFromUri(String userUri) {
|
|||
switch (uri.scheme) {
|
||||
case '':
|
||||
case 'file':
|
||||
return uri.toFilePath();
|
||||
return uri.toFilePath();
|
||||
case 'package':
|
||||
return _filePathFromUri(_resolvePackageUri(uri).toString());
|
||||
return _filePathFromUri(_resolvePackageUri(uri).toString());
|
||||
case 'data':
|
||||
case 'http':
|
||||
case 'https':
|
||||
return uri.toString();
|
||||
return uri.toString();
|
||||
default:
|
||||
// Only handling file, http, and package URIs
|
||||
// in standalone binary.
|
||||
if (_traceLoading) {
|
||||
_log('Unknown scheme (${uri.scheme}) in $uri.');
|
||||
}
|
||||
throw 'Not a known scheme: $uri';
|
||||
// Only handling file, http, and package URIs
|
||||
// in standalone binary.
|
||||
if (_traceLoading) {
|
||||
_log('Unknown scheme (${uri.scheme}) in $uri.');
|
||||
}
|
||||
throw 'Not a known scheme: $uri';
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -380,8 +372,8 @@ Future<Uri> _resolvePackageUriFuture(Uri packageUri) async {
|
|||
// Return the incoming parameter if not passed a package: URI.
|
||||
return packageUri;
|
||||
}
|
||||
var result = await _makeLoaderRequest(_Dart_kResolvePackageUri,
|
||||
packageUri.toString());
|
||||
var result =
|
||||
await _makeLoaderRequest(_Dart_kResolvePackageUri, packageUri.toString());
|
||||
if (result is! Uri) {
|
||||
if (_traceLoading) {
|
||||
_log("Exception when resolving package URI: $packageUri");
|
||||
|
|
|
@ -4,9 +4,10 @@
|
|||
|
||||
import 'dart:nativewrappers';
|
||||
|
||||
@patch class _IOCrypto {
|
||||
@patch static Uint8List getRandomBytes(int count)
|
||||
native "Crypto_GetRandomBytes";
|
||||
@patch
|
||||
class _IOCrypto {
|
||||
@patch
|
||||
static Uint8List getRandomBytes(int count) native "Crypto_GetRandomBytes";
|
||||
}
|
||||
|
||||
_setupHooks() {
|
||||
|
|
|
@ -2,37 +2,47 @@
|
|||
// for details. All rights reserved. Use of this source code is governed by a
|
||||
// BSD-style license that can be found in the LICENSE file.
|
||||
|
||||
@patch class _Directory {
|
||||
@patch static _current() native "Directory_Current";
|
||||
@patch static _setCurrent(path) native "Directory_SetCurrent";
|
||||
@patch static _createTemp(String path) native "Directory_CreateTemp";
|
||||
@patch static String _systemTemp() native "Directory_SystemTemp";
|
||||
@patch static _exists(String path) native "Directory_Exists";
|
||||
@patch static _create(String path) native "Directory_Create";
|
||||
@patch static _deleteNative(String path, bool recursive)
|
||||
native "Directory_Delete";
|
||||
@patch static _rename(String path, String newPath)
|
||||
native "Directory_Rename";
|
||||
@patch static void _fillWithDirectoryListing(
|
||||
List<FileSystemEntity> list, String path, bool recursive,
|
||||
bool followLinks)
|
||||
native "Directory_FillWithDirectoryListing";
|
||||
@patch
|
||||
class _Directory {
|
||||
@patch
|
||||
static _current() native "Directory_Current";
|
||||
@patch
|
||||
static _setCurrent(path) native "Directory_SetCurrent";
|
||||
@patch
|
||||
static _createTemp(String path) native "Directory_CreateTemp";
|
||||
@patch
|
||||
static String _systemTemp() native "Directory_SystemTemp";
|
||||
@patch
|
||||
static _exists(String path) native "Directory_Exists";
|
||||
@patch
|
||||
static _create(String path) native "Directory_Create";
|
||||
@patch
|
||||
static _deleteNative(String path, bool recursive) native "Directory_Delete";
|
||||
@patch
|
||||
static _rename(String path, String newPath) native "Directory_Rename";
|
||||
@patch
|
||||
static void _fillWithDirectoryListing(
|
||||
List<FileSystemEntity> list,
|
||||
String path,
|
||||
bool recursive,
|
||||
bool followLinks) native "Directory_FillWithDirectoryListing";
|
||||
}
|
||||
|
||||
@patch class _AsyncDirectoryListerOps {
|
||||
@patch factory _AsyncDirectoryListerOps(int pointer) =>
|
||||
@patch
|
||||
class _AsyncDirectoryListerOps {
|
||||
@patch
|
||||
factory _AsyncDirectoryListerOps(int pointer) =>
|
||||
new _AsyncDirectoryListerOpsImpl(pointer);
|
||||
}
|
||||
|
||||
class _AsyncDirectoryListerOpsImpl extends NativeFieldWrapperClass1
|
||||
implements _AsyncDirectoryListerOps {
|
||||
implements _AsyncDirectoryListerOps {
|
||||
_AsyncDirectoryListerOpsImpl._();
|
||||
|
||||
factory _AsyncDirectoryListerOpsImpl(int pointer)
|
||||
=> new _AsyncDirectoryListerOpsImpl._().._setPointer(pointer);
|
||||
factory _AsyncDirectoryListerOpsImpl(int pointer) =>
|
||||
new _AsyncDirectoryListerOpsImpl._().._setPointer(pointer);
|
||||
|
||||
void _setPointer(int pointer)
|
||||
native "Directory_SetAsyncDirectoryListerPointer";
|
||||
int getPointer()
|
||||
native "Directory_GetAsyncDirectoryListerPointer";
|
||||
int getPointer() native "Directory_GetAsyncDirectoryListerPointer";
|
||||
}
|
||||
|
|
|
@ -2,13 +2,12 @@
|
|||
// for details. All rights reserved. Use of this source code is governed by a
|
||||
// BSD-style license that can be found in the LICENSE file.
|
||||
|
||||
@patch class _EventHandler {
|
||||
@patch static void _sendData(Object sender,
|
||||
SendPort sendPort,
|
||||
int data)
|
||||
@patch
|
||||
class _EventHandler {
|
||||
@patch
|
||||
static void _sendData(Object sender, SendPort sendPort, int data)
|
||||
native "EventHandler_SendData";
|
||||
|
||||
static int _timerMillisecondClock()
|
||||
native "EventHandler_TimerMillisecondClock";
|
||||
}
|
||||
|
||||
|
|
|
@ -2,43 +2,57 @@
|
|||
// for details. All rights reserved. Use of this source code is governed by a
|
||||
// BSD-style license that can be found in the LICENSE file.
|
||||
|
||||
@patch class _File {
|
||||
@patch static _exists(String path) native "File_Exists";
|
||||
@patch static _create(String path) native "File_Create";
|
||||
@patch static _createLink(String path, String target)
|
||||
native "File_CreateLink";
|
||||
@patch static _linkTarget(String path) native "File_LinkTarget";
|
||||
@patch static _deleteNative(String path) native "File_Delete";
|
||||
@patch static _deleteLinkNative(String path) native "File_DeleteLink";
|
||||
@patch static _rename(String oldPath, String newPath)
|
||||
native "File_Rename";
|
||||
@patch static _renameLink(String oldPath, String newPath)
|
||||
native "File_RenameLink";
|
||||
@patch static _copy(String oldPath, String newPath) native "File_Copy";
|
||||
@patch static _lengthFromPath(String path) native "File_LengthFromPath";
|
||||
@patch static _lastModified(String path) native "File_LastModified";
|
||||
@patch static _setLastModified(String path, int millis)
|
||||
@patch
|
||||
class _File {
|
||||
@patch
|
||||
static _exists(String path) native "File_Exists";
|
||||
@patch
|
||||
static _create(String path) native "File_Create";
|
||||
@patch
|
||||
static _createLink(String path, String target) native "File_CreateLink";
|
||||
@patch
|
||||
static _linkTarget(String path) native "File_LinkTarget";
|
||||
@patch
|
||||
static _deleteNative(String path) native "File_Delete";
|
||||
@patch
|
||||
static _deleteLinkNative(String path) native "File_DeleteLink";
|
||||
@patch
|
||||
static _rename(String oldPath, String newPath) native "File_Rename";
|
||||
@patch
|
||||
static _renameLink(String oldPath, String newPath) native "File_RenameLink";
|
||||
@patch
|
||||
static _copy(String oldPath, String newPath) native "File_Copy";
|
||||
@patch
|
||||
static _lengthFromPath(String path) native "File_LengthFromPath";
|
||||
@patch
|
||||
static _lastModified(String path) native "File_LastModified";
|
||||
@patch
|
||||
static _setLastModified(String path, int millis)
|
||||
native "File_SetLastModified";
|
||||
@patch static _lastAccessed(String path) native "File_LastAccessed";
|
||||
@patch static _setLastAccessed(String path, int millis)
|
||||
@patch
|
||||
static _lastAccessed(String path) native "File_LastAccessed";
|
||||
@patch
|
||||
static _setLastAccessed(String path, int millis)
|
||||
native "File_SetLastAccessed";
|
||||
@patch static _open(String path, int mode) native "File_Open";
|
||||
@patch static int _openStdio(int fd) native "File_OpenStdio";
|
||||
@patch
|
||||
static _open(String path, int mode) native "File_Open";
|
||||
@patch
|
||||
static int _openStdio(int fd) native "File_OpenStdio";
|
||||
}
|
||||
|
||||
|
||||
@patch class _RandomAccessFileOps {
|
||||
@patch factory _RandomAccessFileOps(int pointer)
|
||||
=> new _RandomAccessFileOpsImpl(pointer);
|
||||
@patch
|
||||
class _RandomAccessFileOps {
|
||||
@patch
|
||||
factory _RandomAccessFileOps(int pointer) =>
|
||||
new _RandomAccessFileOpsImpl(pointer);
|
||||
}
|
||||
|
||||
|
||||
class _RandomAccessFileOpsImpl extends NativeFieldWrapperClass1
|
||||
implements _RandomAccessFileOps {
|
||||
implements _RandomAccessFileOps {
|
||||
_RandomAccessFileOpsImpl._();
|
||||
|
||||
factory _RandomAccessFileOpsImpl(int pointer)
|
||||
=> new _RandomAccessFileOpsImpl._().._setPointer(pointer);
|
||||
factory _RandomAccessFileOpsImpl(int pointer) =>
|
||||
new _RandomAccessFileOpsImpl._().._setPointer(pointer);
|
||||
|
||||
void _setPointer(int pointer) native "File_SetPointer";
|
||||
|
||||
|
@ -58,7 +72,6 @@ class _RandomAccessFileOpsImpl extends NativeFieldWrapperClass1
|
|||
setTranslation(int translation) native "File_SetTranslation";
|
||||
}
|
||||
|
||||
|
||||
class _WatcherPath {
|
||||
final int pathId;
|
||||
final String path;
|
||||
|
@ -67,8 +80,8 @@ class _WatcherPath {
|
|||
_WatcherPath(this.pathId, this.path, this.events);
|
||||
}
|
||||
|
||||
|
||||
@patch class _FileSystemWatcher {
|
||||
@patch
|
||||
class _FileSystemWatcher {
|
||||
static int _id;
|
||||
static final Map<int, _WatcherPath> _idMap = {};
|
||||
|
||||
|
@ -80,7 +93,8 @@ class _WatcherPath {
|
|||
|
||||
StreamController _broadcastController;
|
||||
|
||||
@patch static Stream<FileSystemEvent> _watch(
|
||||
@patch
|
||||
static Stream<FileSystemEvent> _watch(
|
||||
String path, int events, bool recursive) {
|
||||
if (Platform.isLinux) {
|
||||
return new _InotifyFileSystemWatcher(path, events, recursive)._stream;
|
||||
|
@ -89,8 +103,8 @@ class _WatcherPath {
|
|||
return new _Win32FileSystemWatcher(path, events, recursive)._stream;
|
||||
}
|
||||
if (Platform.isMacOS) {
|
||||
return new _FSEventStreamFileSystemWatcher(
|
||||
path, events, recursive)._stream;
|
||||
return new _FSEventStreamFileSystemWatcher(path, events, recursive)
|
||||
._stream;
|
||||
}
|
||||
throw new FileSystemException(
|
||||
"File system watching is not supported on this platform");
|
||||
|
@ -99,11 +113,10 @@ class _WatcherPath {
|
|||
_FileSystemWatcher._(this._path, this._events, this._recursive) {
|
||||
if (!isSupported) {
|
||||
throw new FileSystemException(
|
||||
"File system watching is not supported on this platform",
|
||||
_path);
|
||||
"File system watching is not supported on this platform", _path);
|
||||
}
|
||||
_broadcastController = new StreamController.broadcast(onListen: _listen,
|
||||
onCancel: _cancel);
|
||||
_broadcastController =
|
||||
new StreamController.broadcast(onListen: _listen, onCancel: _cancel);
|
||||
}
|
||||
|
||||
Stream get _stream => _broadcastController.stream;
|
||||
|
@ -124,8 +137,8 @@ class _WatcherPath {
|
|||
try {
|
||||
pathId = _watchPath(_id, _path, _events, _recursive);
|
||||
} catch (e) {
|
||||
_broadcastController.addError(new FileSystemException(
|
||||
"Failed to watch path", _path, e));
|
||||
_broadcastController
|
||||
.addError(new FileSystemException("Failed to watch path", _path, e));
|
||||
_broadcastController.close();
|
||||
return;
|
||||
}
|
||||
|
@ -184,6 +197,7 @@ class _WatcherPath {
|
|||
}
|
||||
return path;
|
||||
}
|
||||
|
||||
bool getIsDir(event) {
|
||||
if (Platform.isWindows) {
|
||||
// Windows does not get 'isDir' as part of the event.
|
||||
|
@ -191,10 +205,12 @@ class _WatcherPath {
|
|||
}
|
||||
return (event[0] & FileSystemEvent._IS_DIR) != 0;
|
||||
}
|
||||
|
||||
void add(id, event) {
|
||||
if ((event.type & _pathFromPathId(id).events) == 0) return;
|
||||
events.add([id, event]);
|
||||
}
|
||||
|
||||
void rewriteMove(event, isDir) {
|
||||
if (event[3]) {
|
||||
add(event[4], new FileSystemCreateEvent._(getPath(event), isDir));
|
||||
|
@ -202,6 +218,7 @@ class _WatcherPath {
|
|||
add(event[4], new FileSystemDeleteEvent._(getPath(event), isDir));
|
||||
}
|
||||
}
|
||||
|
||||
int eventCount;
|
||||
do {
|
||||
eventCount = 0;
|
||||
|
@ -229,7 +246,8 @@ class _WatcherPath {
|
|||
if (link > 0) {
|
||||
pair.putIfAbsent(pathId, () => {});
|
||||
if (pair[pathId].containsKey(link)) {
|
||||
add(event[4],
|
||||
add(
|
||||
event[4],
|
||||
new FileSystemMoveEvent._(
|
||||
getPath(pair[pathId][link]), isDir, path));
|
||||
pair[pathId].remove(link);
|
||||
|
@ -258,9 +276,8 @@ class _WatcherPath {
|
|||
rewriteMove(event, getIsDir(event));
|
||||
}
|
||||
}
|
||||
} else if (event == RawSocketEvent.CLOSED) {
|
||||
} else if (event == RawSocketEvent.READ_CLOSED) {
|
||||
} else {
|
||||
} else if (event == RawSocketEvent.CLOSED) {} else if (event ==
|
||||
RawSocketEvent.READ_CLOSED) {} else {
|
||||
assert(false);
|
||||
}
|
||||
events.addAll(stops);
|
||||
|
@ -268,8 +285,8 @@ class _WatcherPath {
|
|||
});
|
||||
}
|
||||
|
||||
@patch static bool get isSupported
|
||||
native "FileSystemWatcher_IsSupported";
|
||||
@patch
|
||||
static bool get isSupported native "FileSystemWatcher_IsSupported";
|
||||
|
||||
static int _initWatcher() native "FileSystemWatcher_InitWatcher";
|
||||
static void _closeWatcher(int id) native "FileSystemWatcher_CloseWatcher";
|
||||
|
@ -284,7 +301,6 @@ class _WatcherPath {
|
|||
native "FileSystemWatcher_GetSocketId";
|
||||
}
|
||||
|
||||
|
||||
class _InotifyFileSystemWatcher extends _FileSystemWatcher {
|
||||
static final Map<int, StreamController> _idMap = {};
|
||||
static StreamSubscription _subscription;
|
||||
|
@ -294,16 +310,16 @@ class _InotifyFileSystemWatcher extends _FileSystemWatcher {
|
|||
|
||||
void _newWatcher() {
|
||||
int id = _FileSystemWatcher._id;
|
||||
_subscription = _FileSystemWatcher._listenOnSocket(id, id, 0)
|
||||
.listen((event) {
|
||||
if (_idMap.containsKey(event[0])) {
|
||||
if (event[1] != null) {
|
||||
_idMap[event[0]].add(event[1]);
|
||||
} else {
|
||||
_idMap[event[0]].close();
|
||||
}
|
||||
_subscription =
|
||||
_FileSystemWatcher._listenOnSocket(id, id, 0).listen((event) {
|
||||
if (_idMap.containsKey(event[0])) {
|
||||
if (event[1] != null) {
|
||||
_idMap[event[0]].add(event[1]);
|
||||
} else {
|
||||
_idMap[event[0]].close();
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
void _doneWatcher() {
|
||||
|
@ -326,7 +342,6 @@ class _InotifyFileSystemWatcher extends _FileSystemWatcher {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
class _Win32FileSystemWatcher extends _FileSystemWatcher {
|
||||
StreamSubscription _subscription;
|
||||
StreamController _controller;
|
||||
|
@ -337,15 +352,15 @@ class _Win32FileSystemWatcher extends _FileSystemWatcher {
|
|||
Stream _pathWatched() {
|
||||
var pathId = _watcherPath.pathId;
|
||||
_controller = new StreamController();
|
||||
_subscription = _FileSystemWatcher._listenOnSocket(pathId, 0, pathId)
|
||||
.listen((event) {
|
||||
assert(event[0] == pathId);
|
||||
if (event[1] != null) {
|
||||
_controller.add(event[1]);
|
||||
} else {
|
||||
_controller.close();
|
||||
}
|
||||
});
|
||||
_subscription =
|
||||
_FileSystemWatcher._listenOnSocket(pathId, 0, pathId).listen((event) {
|
||||
assert(event[0] == pathId);
|
||||
if (event[1] != null) {
|
||||
_controller.add(event[1]);
|
||||
} else {
|
||||
_controller.close();
|
||||
}
|
||||
});
|
||||
return _controller.stream;
|
||||
}
|
||||
|
||||
|
@ -355,7 +370,6 @@ class _Win32FileSystemWatcher extends _FileSystemWatcher {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
class _FSEventStreamFileSystemWatcher extends _FileSystemWatcher {
|
||||
StreamSubscription _subscription;
|
||||
StreamController _controller;
|
||||
|
@ -367,14 +381,14 @@ class _FSEventStreamFileSystemWatcher extends _FileSystemWatcher {
|
|||
var pathId = _watcherPath.pathId;
|
||||
var socketId = _FileSystemWatcher._getSocketId(0, pathId);
|
||||
_controller = new StreamController();
|
||||
_subscription = _FileSystemWatcher._listenOnSocket(socketId, 0, pathId)
|
||||
.listen((event) {
|
||||
if (event[1] != null) {
|
||||
_controller.add(event[1]);
|
||||
} else {
|
||||
_controller.close();
|
||||
}
|
||||
});
|
||||
_subscription =
|
||||
_FileSystemWatcher._listenOnSocket(socketId, 0, pathId).listen((event) {
|
||||
if (event[1] != null) {
|
||||
_controller.add(event[1]);
|
||||
} else {
|
||||
_controller.close();
|
||||
}
|
||||
});
|
||||
return _controller.stream;
|
||||
}
|
||||
|
||||
|
@ -384,7 +398,6 @@ class _FSEventStreamFileSystemWatcher extends _FileSystemWatcher {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
Uint8List _makeUint8ListView(Uint8List source, int offsetInBytes, int length) {
|
||||
return new Uint8List.view(source.buffer, offsetInBytes, length);
|
||||
}
|
||||
|
|
|
@ -2,16 +2,18 @@
|
|||
// for details. All rights reserved. Use of this source code is governed by a
|
||||
// BSD-style license that can be found in the LICENSE file.
|
||||
|
||||
@patch class FileStat {
|
||||
@patch static _statSync(String path) native "File_Stat";
|
||||
@patch
|
||||
class FileStat {
|
||||
@patch
|
||||
static _statSync(String path) native "File_Stat";
|
||||
}
|
||||
|
||||
|
||||
@patch class FileSystemEntity {
|
||||
@patch static _getType(String path, bool followLinks)
|
||||
native "File_GetType";
|
||||
@patch static _identical(String path1, String path2)
|
||||
native "File_AreIdentical";
|
||||
@patch static _resolveSymbolicLinks(String path)
|
||||
native "File_ResolveSymbolicLinks";
|
||||
@patch
|
||||
class FileSystemEntity {
|
||||
@patch
|
||||
static _getType(String path, bool followLinks) native "File_GetType";
|
||||
@patch
|
||||
static _identical(String path1, String path2) native "File_AreIdentical";
|
||||
@patch
|
||||
static _resolveSymbolicLinks(String path) native "File_ResolveSymbolicLinks";
|
||||
}
|
||||
|
|
|
@ -2,7 +2,6 @@
|
|||
// for details. All rights reserved. Use of this source code is governed by a
|
||||
// BSD-style license that can be found in the LICENSE file.
|
||||
|
||||
|
||||
class _FilterImpl extends NativeFieldWrapperClass1 implements _Filter {
|
||||
void process(List<int> data, int start, int end) native "Filter_Process";
|
||||
|
||||
|
@ -20,24 +19,22 @@ class _ZLibInflateFilter extends _FilterImpl {
|
|||
|
||||
class _ZLibDeflateFilter extends _FilterImpl {
|
||||
_ZLibDeflateFilter(bool gzip, int level, int windowBits, int memLevel,
|
||||
int strategy, List<int> dictionary, bool raw) {
|
||||
int strategy, List<int> dictionary, bool raw) {
|
||||
_init(gzip, level, windowBits, memLevel, strategy, dictionary, raw);
|
||||
}
|
||||
void _init(bool gzip, int level, int windowBits, int memLevel,
|
||||
int strategy, List<int> dictionary, bool raw)
|
||||
native "Filter_CreateZLibDeflate";
|
||||
void _init(bool gzip, int level, int windowBits, int memLevel, int strategy,
|
||||
List<int> dictionary, bool raw) native "Filter_CreateZLibDeflate";
|
||||
}
|
||||
|
||||
@patch class _Filter {
|
||||
@patch static _Filter _newZLibDeflateFilter(bool gzip, int level,
|
||||
int windowBits, int memLevel,
|
||||
int strategy,
|
||||
List<int> dictionary,
|
||||
bool raw) =>
|
||||
new _ZLibDeflateFilter(gzip, level, windowBits, memLevel, strategy,
|
||||
dictionary, raw);
|
||||
@patch static _Filter _newZLibInflateFilter(int windowBits,
|
||||
List<int> dictionary,
|
||||
bool raw) =>
|
||||
@patch
|
||||
class _Filter {
|
||||
@patch
|
||||
static _Filter _newZLibDeflateFilter(bool gzip, int level, int windowBits,
|
||||
int memLevel, int strategy, List<int> dictionary, bool raw) =>
|
||||
new _ZLibDeflateFilter(
|
||||
gzip, level, windowBits, memLevel, strategy, dictionary, raw);
|
||||
@patch
|
||||
static _Filter _newZLibInflateFilter(
|
||||
int windowBits, List<int> dictionary, bool raw) =>
|
||||
new _ZLibInflateFilter(windowBits, dictionary, raw);
|
||||
}
|
||||
|
|
|
@ -2,7 +2,8 @@
|
|||
// for details. All rights reserved. Use of this source code is governed by a
|
||||
// BSD-style license that can be found in the LICENSE file.
|
||||
|
||||
@patch class _IOService {
|
||||
@patch
|
||||
class _IOService {
|
||||
// Lazy initialize service ports, 32 per isolate.
|
||||
static const int _SERVICE_PORT_COUNT = 32;
|
||||
static List<SendPort> _servicePort = new List(_SERVICE_PORT_COUNT);
|
||||
|
@ -11,7 +12,8 @@
|
|||
static Map<int, Completer> _messageMap = {};
|
||||
static int _id = 0;
|
||||
|
||||
@patch static Future _dispatch(int request, List data) {
|
||||
@patch
|
||||
static Future _dispatch(int request, List data) {
|
||||
int id;
|
||||
do {
|
||||
id = _getNextId();
|
||||
|
|
|
@ -2,30 +2,32 @@
|
|||
// for details. All rights reserved. Use of this source code is governed by a
|
||||
// BSD-style license that can be found in the LICENSE file.
|
||||
|
||||
@patch class _Platform {
|
||||
@patch static int _numberOfProcessors()
|
||||
native "Platform_NumberOfProcessors";
|
||||
@patch static String _pathSeparator()
|
||||
native "Platform_PathSeparator";
|
||||
@patch static String _operatingSystem()
|
||||
native "Platform_OperatingSystem";
|
||||
@patch static _localHostname()
|
||||
native "Platform_LocalHostname";
|
||||
@patch static _executable()
|
||||
native "Platform_ExecutableName";
|
||||
@patch static _resolvedExecutable()
|
||||
native "Platform_ResolvedExecutableName";
|
||||
@patch static _environment()
|
||||
native "Platform_Environment";
|
||||
@patch static List<String> _executableArguments()
|
||||
@patch
|
||||
class _Platform {
|
||||
@patch
|
||||
static int _numberOfProcessors() native "Platform_NumberOfProcessors";
|
||||
@patch
|
||||
static String _pathSeparator() native "Platform_PathSeparator";
|
||||
@patch
|
||||
static String _operatingSystem() native "Platform_OperatingSystem";
|
||||
@patch
|
||||
static _localHostname() native "Platform_LocalHostname";
|
||||
@patch
|
||||
static _executable() native "Platform_ExecutableName";
|
||||
@patch
|
||||
static _resolvedExecutable() native "Platform_ResolvedExecutableName";
|
||||
@patch
|
||||
static _environment() native "Platform_Environment";
|
||||
@patch
|
||||
static List<String> _executableArguments()
|
||||
native "Platform_ExecutableArguments";
|
||||
@patch static String _version()
|
||||
native "Platform_GetVersion";
|
||||
@patch
|
||||
static String _version() native "Platform_GetVersion";
|
||||
|
||||
@patch static String _packageRoot()
|
||||
=> VMLibraryHooks.packageRootString;
|
||||
@patch static String _packageConfig()
|
||||
=> VMLibraryHooks.packageConfigString;
|
||||
@patch
|
||||
static String _packageRoot() => VMLibraryHooks.packageRootString;
|
||||
@patch
|
||||
static String _packageConfig() => VMLibraryHooks.packageConfigString;
|
||||
|
||||
// This script singleton is written to by the embedder if applicable.
|
||||
static void set _nativeScript(String path) {
|
||||
|
|
|
@ -2,89 +2,87 @@
|
|||
// for details. All rights reserved. Use of this source code is governed by a
|
||||
// BSD-style license that can be found in the LICENSE file.
|
||||
|
||||
@patch class _WindowsCodePageDecoder {
|
||||
@patch static String _decodeBytes(List<int> bytes)
|
||||
native "SystemEncodingToString";
|
||||
@patch
|
||||
class _WindowsCodePageDecoder {
|
||||
@patch
|
||||
static String _decodeBytes(List<int> bytes) native "SystemEncodingToString";
|
||||
}
|
||||
|
||||
|
||||
@patch class _WindowsCodePageEncoder {
|
||||
@patch static List<int> _encodeString(String string)
|
||||
native "StringToSystemEncoding";
|
||||
@patch
|
||||
class _WindowsCodePageEncoder {
|
||||
@patch
|
||||
static List<int> _encodeString(String string) native "StringToSystemEncoding";
|
||||
}
|
||||
|
||||
|
||||
@patch class Process {
|
||||
@patch static Future<Process> start(
|
||||
String executable,
|
||||
List<String> arguments,
|
||||
@patch
|
||||
class Process {
|
||||
@patch
|
||||
static Future<Process> start(String executable, List<String> arguments,
|
||||
{String workingDirectory,
|
||||
Map<String, String> environment,
|
||||
bool includeParentEnvironment: true,
|
||||
bool runInShell: false,
|
||||
ProcessStartMode mode: ProcessStartMode.NORMAL}) {
|
||||
_ProcessImpl process = new _ProcessImpl(executable,
|
||||
arguments,
|
||||
workingDirectory,
|
||||
environment,
|
||||
includeParentEnvironment,
|
||||
runInShell,
|
||||
mode);
|
||||
Map<String, String> environment,
|
||||
bool includeParentEnvironment: true,
|
||||
bool runInShell: false,
|
||||
ProcessStartMode mode: ProcessStartMode.NORMAL}) {
|
||||
_ProcessImpl process = new _ProcessImpl(
|
||||
executable,
|
||||
arguments,
|
||||
workingDirectory,
|
||||
environment,
|
||||
includeParentEnvironment,
|
||||
runInShell,
|
||||
mode);
|
||||
return process._start();
|
||||
}
|
||||
|
||||
@patch static Future<ProcessResult> run(
|
||||
String executable,
|
||||
List<String> arguments,
|
||||
@patch
|
||||
static Future<ProcessResult> run(String executable, List<String> arguments,
|
||||
{String workingDirectory,
|
||||
Map<String, String> environment,
|
||||
bool includeParentEnvironment: true,
|
||||
bool runInShell: false,
|
||||
Encoding stdoutEncoding: SYSTEM_ENCODING,
|
||||
Encoding stderrEncoding: SYSTEM_ENCODING}) {
|
||||
return _runNonInteractiveProcess(executable,
|
||||
arguments,
|
||||
workingDirectory,
|
||||
environment,
|
||||
includeParentEnvironment,
|
||||
runInShell,
|
||||
stdoutEncoding,
|
||||
stderrEncoding);
|
||||
Map<String, String> environment,
|
||||
bool includeParentEnvironment: true,
|
||||
bool runInShell: false,
|
||||
Encoding stdoutEncoding: SYSTEM_ENCODING,
|
||||
Encoding stderrEncoding: SYSTEM_ENCODING}) {
|
||||
return _runNonInteractiveProcess(
|
||||
executable,
|
||||
arguments,
|
||||
workingDirectory,
|
||||
environment,
|
||||
includeParentEnvironment,
|
||||
runInShell,
|
||||
stdoutEncoding,
|
||||
stderrEncoding);
|
||||
}
|
||||
|
||||
@patch static ProcessResult runSync(
|
||||
String executable,
|
||||
List<String> arguments,
|
||||
@patch
|
||||
static ProcessResult runSync(String executable, List<String> arguments,
|
||||
{String workingDirectory,
|
||||
Map<String, String> environment,
|
||||
bool includeParentEnvironment: true,
|
||||
bool runInShell: false,
|
||||
Encoding stdoutEncoding: SYSTEM_ENCODING,
|
||||
Encoding stderrEncoding: SYSTEM_ENCODING}) {
|
||||
return _runNonInteractiveProcessSync(executable,
|
||||
arguments,
|
||||
workingDirectory,
|
||||
environment,
|
||||
includeParentEnvironment,
|
||||
runInShell,
|
||||
stdoutEncoding,
|
||||
stderrEncoding);
|
||||
Map<String, String> environment,
|
||||
bool includeParentEnvironment: true,
|
||||
bool runInShell: false,
|
||||
Encoding stdoutEncoding: SYSTEM_ENCODING,
|
||||
Encoding stderrEncoding: SYSTEM_ENCODING}) {
|
||||
return _runNonInteractiveProcessSync(
|
||||
executable,
|
||||
arguments,
|
||||
workingDirectory,
|
||||
environment,
|
||||
includeParentEnvironment,
|
||||
runInShell,
|
||||
stdoutEncoding,
|
||||
stderrEncoding);
|
||||
}
|
||||
|
||||
@patch static bool killPid(
|
||||
int pid, [ProcessSignal signal = ProcessSignal.SIGTERM]) {
|
||||
@patch
|
||||
static bool killPid(int pid, [ProcessSignal signal = ProcessSignal.SIGTERM]) {
|
||||
if (signal is! ProcessSignal) {
|
||||
throw new ArgumentError(
|
||||
"Argument 'signal' must be a ProcessSignal");
|
||||
throw new ArgumentError("Argument 'signal' must be a ProcessSignal");
|
||||
}
|
||||
return _ProcessUtils._killPid(pid, signal._signalNumber);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
List<_SignalController> _signalControllers = new List(32);
|
||||
|
||||
|
||||
class _SignalController {
|
||||
final ProcessSignal signal;
|
||||
|
||||
|
@ -92,9 +90,8 @@ class _SignalController {
|
|||
var _id;
|
||||
|
||||
_SignalController(this.signal) {
|
||||
_controller = new StreamController.broadcast(
|
||||
onListen: _listen,
|
||||
onCancel: _cancel);
|
||||
_controller =
|
||||
new StreamController.broadcast(onListen: _listen, onCancel: _cancel);
|
||||
}
|
||||
|
||||
Stream<ProcessSignal> get stream => _controller.stream;
|
||||
|
@ -102,8 +99,8 @@ 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(new SignalException("Failed to listen for $signal", id));
|
||||
return;
|
||||
}
|
||||
_id = id;
|
||||
|
@ -125,32 +122,35 @@ class _SignalController {
|
|||
}
|
||||
}
|
||||
|
||||
static _setSignalHandler(int signal)
|
||||
native "Process_SetSignalHandler";
|
||||
static _setSignalHandler(int signal) native "Process_SetSignalHandler";
|
||||
static int _clearSignalHandler(int signal)
|
||||
native "Process_ClearSignalHandler";
|
||||
}
|
||||
|
||||
Function _getWatchSignalInternal() => _ProcessUtils._watchSignalInternal;
|
||||
|
||||
|
||||
@patch class _ProcessUtils {
|
||||
@patch static void _exit(int status) native "Process_Exit";
|
||||
@patch static void _setExitCode(int status)
|
||||
native "Process_SetExitCode";
|
||||
@patch static int _getExitCode() native "Process_GetExitCode";
|
||||
@patch static void _sleep(int millis) native "Process_Sleep";
|
||||
@patch static int _pid(Process process) native "Process_Pid";
|
||||
static bool _killPid(int pid, int signal)
|
||||
native "Process_KillPid";
|
||||
@patch static Stream<ProcessSignal> _watchSignal(ProcessSignal signal) {
|
||||
@patch
|
||||
class _ProcessUtils {
|
||||
@patch
|
||||
static void _exit(int status) native "Process_Exit";
|
||||
@patch
|
||||
static void _setExitCode(int status) native "Process_SetExitCode";
|
||||
@patch
|
||||
static int _getExitCode() native "Process_GetExitCode";
|
||||
@patch
|
||||
static void _sleep(int millis) native "Process_Sleep";
|
||||
@patch
|
||||
static int _pid(Process process) native "Process_Pid";
|
||||
static bool _killPid(int pid, int signal) native "Process_KillPid";
|
||||
@patch
|
||||
static Stream<ProcessSignal> _watchSignal(ProcessSignal signal) {
|
||||
if (signal != ProcessSignal.SIGHUP &&
|
||||
signal != ProcessSignal.SIGINT &&
|
||||
signal != ProcessSignal.SIGTERM &&
|
||||
(Platform.isWindows ||
|
||||
(signal != ProcessSignal.SIGUSR1 &&
|
||||
signal != ProcessSignal.SIGUSR2 &&
|
||||
signal != ProcessSignal.SIGWINCH))) {
|
||||
(signal != ProcessSignal.SIGUSR1 &&
|
||||
signal != ProcessSignal.SIGUSR2 &&
|
||||
signal != ProcessSignal.SIGWINCH))) {
|
||||
throw new SignalException(
|
||||
"Listening for signal $signal is not supported");
|
||||
}
|
||||
|
@ -165,13 +165,11 @@ Function _getWatchSignalInternal() => _ProcessUtils._watchSignalInternal;
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
class _ProcessStartStatus {
|
||||
int _errorCode; // Set to OS error code if process start failed.
|
||||
String _errorMessage; // Set to OS error message if process start failed.
|
||||
int _errorCode; // Set to OS error code if process start failed.
|
||||
String _errorMessage; // Set to OS error message if process start failed.
|
||||
}
|
||||
|
||||
|
||||
// The NativeFieldWrapperClass1 can not be used with a mixin, due to missing
|
||||
// implicit constructor.
|
||||
class _ProcessImplNativeWrapper extends NativeFieldWrapperClass1 {}
|
||||
|
@ -180,18 +178,20 @@ class _ProcessImpl extends _ProcessImplNativeWrapper implements Process {
|
|||
_ProcessResourceInfo _resourceInfo;
|
||||
static bool connectedResourceHandler = false;
|
||||
|
||||
_ProcessImpl(String path,
|
||||
List<String> arguments,
|
||||
this._workingDirectory,
|
||||
Map<String, String> environment,
|
||||
bool includeParentEnvironment,
|
||||
bool runInShell,
|
||||
ProcessStartMode mode) : super() {
|
||||
_ProcessImpl(
|
||||
String path,
|
||||
List<String> arguments,
|
||||
this._workingDirectory,
|
||||
Map<String, String> environment,
|
||||
bool includeParentEnvironment,
|
||||
bool runInShell,
|
||||
ProcessStartMode mode)
|
||||
: super() {
|
||||
if (!connectedResourceHandler) {
|
||||
registerExtension('ext.dart.io.getProcesses',
|
||||
_ProcessResourceInfo.getStartedProcesses);
|
||||
registerExtension(
|
||||
'ext.dart.io.getProcesses', _ProcessResourceInfo.getStartedProcesses);
|
||||
registerExtension('ext.dart.io.getProcessById',
|
||||
_ProcessResourceInfo.getProcessInfoMapById);
|
||||
_ProcessResourceInfo.getProcessInfoMapById);
|
||||
connectedResourceHandler = true;
|
||||
}
|
||||
|
||||
|
@ -200,19 +200,19 @@ class _ProcessImpl extends _ProcessImplNativeWrapper implements Process {
|
|||
path = _getShellCommand();
|
||||
}
|
||||
|
||||
if (path is !String) {
|
||||
if (path is! String) {
|
||||
throw new ArgumentError("Path is not a String: $path");
|
||||
}
|
||||
_path = path;
|
||||
|
||||
if (arguments is !List) {
|
||||
if (arguments is! List) {
|
||||
throw new ArgumentError("Arguments is not a List: $arguments");
|
||||
}
|
||||
int len = arguments.length;
|
||||
_arguments = new List<String>(len);
|
||||
for (int i = 0; i < len; i++) {
|
||||
var arg = arguments[i];
|
||||
if (arg is !String) {
|
||||
if (arg is! String) {
|
||||
throw new ArgumentError("Non-string argument: $arg");
|
||||
}
|
||||
_arguments[i] = arguments[i];
|
||||
|
@ -221,7 +221,7 @@ class _ProcessImpl extends _ProcessImplNativeWrapper implements Process {
|
|||
}
|
||||
}
|
||||
|
||||
if (_workingDirectory != null && _workingDirectory is !String) {
|
||||
if (_workingDirectory != null && _workingDirectory is! String) {
|
||||
throw new ArgumentError(
|
||||
"WorkingDirectory is not a String: $_workingDirectory");
|
||||
}
|
||||
|
@ -229,13 +229,13 @@ class _ProcessImpl extends _ProcessImplNativeWrapper implements Process {
|
|||
_environment = [];
|
||||
// Ensure that we have a non-null environment.
|
||||
environment = (environment == null) ? (const {}) : environment;
|
||||
if (environment is !Map) {
|
||||
if (environment is! Map) {
|
||||
throw new ArgumentError("Environment is not a map: $environment");
|
||||
}
|
||||
environment.forEach((key, value) {
|
||||
if (key is !String || value is !String) {
|
||||
if (key is! String || value is! String) {
|
||||
throw new ArgumentError(
|
||||
"Environment key or value is not a string: ($key, $value)");
|
||||
"Environment key or value is not a string: ($key, $value)");
|
||||
}
|
||||
_environment.add('$key=$value');
|
||||
});
|
||||
|
@ -250,7 +250,7 @@ class _ProcessImpl extends _ProcessImplNativeWrapper implements Process {
|
|||
});
|
||||
}
|
||||
|
||||
if (mode is !ProcessStartMode) {
|
||||
if (mode is! ProcessStartMode) {
|
||||
throw new ArgumentError("Mode is not a ProcessStartMode: $mode");
|
||||
}
|
||||
_mode = mode;
|
||||
|
@ -280,8 +280,8 @@ class _ProcessImpl extends _ProcessImplNativeWrapper implements Process {
|
|||
return '/bin/sh';
|
||||
}
|
||||
|
||||
static List<String> _getShellArguments(String executable,
|
||||
List<String> arguments) {
|
||||
static List<String> _getShellArguments(
|
||||
String executable, List<String> arguments) {
|
||||
List<String> shellArguments = [];
|
||||
if (Platform.isWindows) {
|
||||
shellArguments.add('/c');
|
||||
|
@ -353,9 +353,9 @@ class _ProcessImpl extends _ProcessImplNativeWrapper implements Process {
|
|||
|
||||
int _intFromBytes(List<int> bytes, int offset) {
|
||||
return (bytes[offset] +
|
||||
(bytes[offset + 1] << 8) +
|
||||
(bytes[offset + 2] << 16) +
|
||||
(bytes[offset + 3] << 24));
|
||||
(bytes[offset + 1] << 8) +
|
||||
(bytes[offset + 2] << 16) +
|
||||
(bytes[offset + 3] << 24));
|
||||
}
|
||||
|
||||
Future<Process> _start() {
|
||||
|
@ -367,27 +367,26 @@ class _ProcessImpl extends _ProcessImplNativeWrapper implements Process {
|
|||
// simulating it with a timer.
|
||||
Timer.run(() {
|
||||
var status = new _ProcessStartStatus();
|
||||
bool success =
|
||||
_startNative(_path,
|
||||
_arguments,
|
||||
_workingDirectory,
|
||||
_environment,
|
||||
_mode.index,
|
||||
_mode == ProcessStartMode.DETACHED
|
||||
? null : _stdin._sink._nativeSocket,
|
||||
_mode == ProcessStartMode.DETACHED
|
||||
? null : _stdout._stream._nativeSocket,
|
||||
_mode == ProcessStartMode.DETACHED
|
||||
? null : _stderr._stream._nativeSocket,
|
||||
_mode != ProcessStartMode.NORMAL
|
||||
? null : _exitHandler._nativeSocket,
|
||||
status);
|
||||
bool success = _startNative(
|
||||
_path,
|
||||
_arguments,
|
||||
_workingDirectory,
|
||||
_environment,
|
||||
_mode.index,
|
||||
_mode == ProcessStartMode.DETACHED
|
||||
? null
|
||||
: _stdin._sink._nativeSocket,
|
||||
_mode == ProcessStartMode.DETACHED
|
||||
? null
|
||||
: _stdout._stream._nativeSocket,
|
||||
_mode == ProcessStartMode.DETACHED
|
||||
? null
|
||||
: _stderr._stream._nativeSocket,
|
||||
_mode != ProcessStartMode.NORMAL ? null : _exitHandler._nativeSocket,
|
||||
status);
|
||||
if (!success) {
|
||||
completer.completeError(
|
||||
new ProcessException(_path,
|
||||
_arguments,
|
||||
status._errorMessage,
|
||||
status._errorCode));
|
||||
completer.completeError(new ProcessException(
|
||||
_path, _arguments, status._errorMessage, status._errorCode));
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -401,7 +400,6 @@ class _ProcessImpl extends _ProcessImplNativeWrapper implements Process {
|
|||
final int EXIT_DATA_SIZE = 8;
|
||||
List<int> exitDataBuffer = new List<int>(EXIT_DATA_SIZE);
|
||||
_exitHandler.listen((data) {
|
||||
|
||||
int exitCode(List<int> ints) {
|
||||
var code = _intFromBytes(ints, 0);
|
||||
var negative = _intFromBytes(ints, 4);
|
||||
|
@ -431,25 +429,23 @@ class _ProcessImpl extends _ProcessImplNativeWrapper implements Process {
|
|||
return completer.future;
|
||||
}
|
||||
|
||||
ProcessResult _runAndWait(Encoding stdoutEncoding,
|
||||
Encoding stderrEncoding) {
|
||||
ProcessResult _runAndWait(Encoding stdoutEncoding, Encoding stderrEncoding) {
|
||||
var status = new _ProcessStartStatus();
|
||||
_exitCode = new Completer<int>();
|
||||
bool success = _startNative(_path,
|
||||
_arguments,
|
||||
_workingDirectory,
|
||||
_environment,
|
||||
ProcessStartMode.NORMAL.index,
|
||||
_stdin._sink._nativeSocket,
|
||||
_stdout._stream._nativeSocket,
|
||||
_stderr._stream._nativeSocket,
|
||||
_exitHandler._nativeSocket,
|
||||
status);
|
||||
bool success = _startNative(
|
||||
_path,
|
||||
_arguments,
|
||||
_workingDirectory,
|
||||
_environment,
|
||||
ProcessStartMode.NORMAL.index,
|
||||
_stdin._sink._nativeSocket,
|
||||
_stdout._stream._nativeSocket,
|
||||
_stderr._stream._nativeSocket,
|
||||
_exitHandler._nativeSocket,
|
||||
status);
|
||||
if (!success) {
|
||||
throw new ProcessException(_path,
|
||||
_arguments,
|
||||
status._errorMessage,
|
||||
status._errorCode);
|
||||
throw new ProcessException(
|
||||
_path, _arguments, status._errorMessage, status._errorCode);
|
||||
}
|
||||
|
||||
_resourceInfo = new _ProcessResourceInfo(this);
|
||||
|
@ -474,21 +470,20 @@ class _ProcessImpl extends _ProcessImplNativeWrapper implements Process {
|
|||
getOutput(result[3], stderrEncoding));
|
||||
}
|
||||
|
||||
bool _startNative(String path,
|
||||
List<String> arguments,
|
||||
String workingDirectory,
|
||||
List<String> environment,
|
||||
int mode,
|
||||
_NativeSocket stdin,
|
||||
_NativeSocket stdout,
|
||||
_NativeSocket stderr,
|
||||
_NativeSocket exitHandler,
|
||||
_ProcessStartStatus status) native "Process_Start";
|
||||
bool _startNative(
|
||||
String path,
|
||||
List<String> arguments,
|
||||
String workingDirectory,
|
||||
List<String> environment,
|
||||
int mode,
|
||||
_NativeSocket stdin,
|
||||
_NativeSocket stdout,
|
||||
_NativeSocket stderr,
|
||||
_NativeSocket exitHandler,
|
||||
_ProcessStartStatus status) native "Process_Start";
|
||||
|
||||
_wait(_NativeSocket stdin,
|
||||
_NativeSocket stdout,
|
||||
_NativeSocket stderr,
|
||||
_NativeSocket exitHandler) native "Process_Wait";
|
||||
_wait(_NativeSocket stdin, _NativeSocket stdout, _NativeSocket stderr,
|
||||
_NativeSocket exitHandler) native "Process_Wait";
|
||||
|
||||
Stream<List<int>> get stdout {
|
||||
return _stdout;
|
||||
|
@ -506,8 +501,7 @@ class _ProcessImpl extends _ProcessImplNativeWrapper implements Process {
|
|||
|
||||
bool kill([ProcessSignal signal = ProcessSignal.SIGTERM]) {
|
||||
if (signal is! ProcessSignal) {
|
||||
throw new ArgumentError(
|
||||
"Argument 'signal' must be a ProcessSignal");
|
||||
throw new ArgumentError("Argument 'signal' must be a ProcessSignal");
|
||||
}
|
||||
assert(_started);
|
||||
if (_ended) return false;
|
||||
|
@ -531,26 +525,27 @@ class _ProcessImpl extends _ProcessImplNativeWrapper implements Process {
|
|||
Completer<int> _exitCode;
|
||||
}
|
||||
|
||||
|
||||
// _NonInteractiveProcess is a wrapper around an interactive process
|
||||
// that buffers output so it can be delivered when the process exits.
|
||||
// _NonInteractiveProcess is used to implement the Process.run
|
||||
// method.
|
||||
Future<ProcessResult> _runNonInteractiveProcess(String path,
|
||||
List<String> arguments,
|
||||
String workingDirectory,
|
||||
Map<String, String> environment,
|
||||
bool includeParentEnvironment,
|
||||
bool runInShell,
|
||||
Encoding stdoutEncoding,
|
||||
Encoding stderrEncoding) {
|
||||
Future<ProcessResult> _runNonInteractiveProcess(
|
||||
String path,
|
||||
List<String> arguments,
|
||||
String workingDirectory,
|
||||
Map<String, String> environment,
|
||||
bool includeParentEnvironment,
|
||||
bool runInShell,
|
||||
Encoding stdoutEncoding,
|
||||
Encoding stderrEncoding) {
|
||||
// Start the underlying process.
|
||||
return Process.start(path,
|
||||
arguments,
|
||||
workingDirectory: workingDirectory,
|
||||
environment: environment,
|
||||
includeParentEnvironment: includeParentEnvironment,
|
||||
runInShell: runInShell).then((Process p) {
|
||||
return Process
|
||||
.start(path, arguments,
|
||||
workingDirectory: workingDirectory,
|
||||
environment: environment,
|
||||
includeParentEnvironment: includeParentEnvironment,
|
||||
runInShell: runInShell)
|
||||
.then((Process p) {
|
||||
int pid = p.pid;
|
||||
|
||||
// Make sure the process stdin is closed.
|
||||
|
@ -563,15 +558,11 @@ Future<ProcessResult> _runNonInteractiveProcess(String path,
|
|||
.fold(new BytesBuilder(), (builder, data) => builder..add(data))
|
||||
.then((builder) => builder.takeBytes());
|
||||
} else {
|
||||
return stream
|
||||
.transform(encoding.decoder)
|
||||
.fold(
|
||||
new StringBuffer(),
|
||||
(buf, data) {
|
||||
buf.write(data);
|
||||
return buf;
|
||||
})
|
||||
.then((sb) => sb.toString());
|
||||
return stream.transform(encoding.decoder).fold(new StringBuffer(),
|
||||
(buf, data) {
|
||||
buf.write(data);
|
||||
return buf;
|
||||
}).then((sb) => sb.toString());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -585,20 +576,21 @@ Future<ProcessResult> _runNonInteractiveProcess(String path,
|
|||
}
|
||||
|
||||
ProcessResult _runNonInteractiveProcessSync(
|
||||
String executable,
|
||||
List<String> arguments,
|
||||
String workingDirectory,
|
||||
Map<String, String> environment,
|
||||
bool includeParentEnvironment,
|
||||
bool runInShell,
|
||||
Encoding stdoutEncoding,
|
||||
Encoding stderrEncoding) {
|
||||
var process = new _ProcessImpl(executable,
|
||||
arguments,
|
||||
workingDirectory,
|
||||
environment,
|
||||
includeParentEnvironment,
|
||||
runInShell,
|
||||
ProcessStartMode.NORMAL);
|
||||
String executable,
|
||||
List<String> arguments,
|
||||
String workingDirectory,
|
||||
Map<String, String> environment,
|
||||
bool includeParentEnvironment,
|
||||
bool runInShell,
|
||||
Encoding stdoutEncoding,
|
||||
Encoding stderrEncoding) {
|
||||
var process = new _ProcessImpl(
|
||||
executable,
|
||||
arguments,
|
||||
workingDirectory,
|
||||
environment,
|
||||
includeParentEnvironment,
|
||||
runInShell,
|
||||
ProcessStartMode.NORMAL);
|
||||
return process._runAndWait(stdoutEncoding, stderrEncoding);
|
||||
}
|
||||
|
|
|
@ -2,18 +2,23 @@
|
|||
// for details. All rights reserved. Use of this source code is governed by a
|
||||
// BSD-style license that can be found in the LICENSE file.
|
||||
|
||||
@patch class SecureSocket {
|
||||
@patch factory SecureSocket._(RawSecureSocket rawSocket) =>
|
||||
@patch
|
||||
class SecureSocket {
|
||||
@patch
|
||||
factory SecureSocket._(RawSecureSocket rawSocket) =>
|
||||
new _SecureSocket(rawSocket);
|
||||
}
|
||||
|
||||
|
||||
@patch class _SecureFilter {
|
||||
@patch factory _SecureFilter() => new _SecureFilterImpl();
|
||||
@patch
|
||||
class _SecureFilter {
|
||||
@patch
|
||||
factory _SecureFilter() => new _SecureFilterImpl();
|
||||
}
|
||||
|
||||
@patch class X509Certificate {
|
||||
@patch factory X509Certificate._() => new _X509CertificateImpl();
|
||||
@patch
|
||||
class X509Certificate {
|
||||
@patch
|
||||
factory X509Certificate._() => new _X509CertificateImpl();
|
||||
}
|
||||
|
||||
class _SecureSocket extends _Socket implements SecureSocket {
|
||||
|
@ -26,30 +31,31 @@ class _SecureSocket extends _Socket implements SecureSocket {
|
|||
_raw.onBadCertificate = callback;
|
||||
}
|
||||
|
||||
void renegotiate({bool useSessionCache: true,
|
||||
bool requestClientCertificate: false,
|
||||
bool requireClientCertificate: false}) {
|
||||
_raw.renegotiate(useSessionCache: useSessionCache,
|
||||
requestClientCertificate: requestClientCertificate,
|
||||
requireClientCertificate: requireClientCertificate);
|
||||
void renegotiate(
|
||||
{bool useSessionCache: true,
|
||||
bool requestClientCertificate: false,
|
||||
bool requireClientCertificate: false}) {
|
||||
_raw.renegotiate(
|
||||
useSessionCache: useSessionCache,
|
||||
requestClientCertificate: requestClientCertificate,
|
||||
requireClientCertificate: requireClientCertificate);
|
||||
}
|
||||
|
||||
X509Certificate get peerCertificate {
|
||||
if (_raw == null) {
|
||||
throw new StateError("peerCertificate called on destroyed SecureSocket");
|
||||
throw new StateError("peerCertificate called on destroyed SecureSocket");
|
||||
}
|
||||
return _raw.peerCertificate;
|
||||
}
|
||||
|
||||
String get selectedProtocol {
|
||||
if (_raw == null) {
|
||||
throw new StateError("selectedProtocol called on destroyed SecureSocket");
|
||||
throw new StateError("selectedProtocol called on destroyed SecureSocket");
|
||||
}
|
||||
return _raw.selectedProtocol;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* _SecureFilterImpl wraps a filter that encrypts and decrypts data travelling
|
||||
* over an encrypted socket. The filter also handles the handshaking
|
||||
|
@ -59,8 +65,7 @@ class _SecureSocket extends _Socket implements SecureSocket {
|
|||
* are backed by an external C array of bytes, so that both Dart code and
|
||||
* native code can access the same data.
|
||||
*/
|
||||
class _SecureFilterImpl
|
||||
extends NativeFieldWrapperClass1
|
||||
class _SecureFilterImpl extends NativeFieldWrapperClass1
|
||||
implements _SecureFilter {
|
||||
// Performance is improved if a full buffer of plaintext fits
|
||||
// in the encrypted buffer, when encrypted.
|
||||
|
@ -70,18 +75,18 @@ class _SecureFilterImpl
|
|||
_SecureFilterImpl() {
|
||||
buffers = new List<_ExternalBuffer>(_RawSecureSocket.NUM_BUFFERS);
|
||||
for (int i = 0; i < _RawSecureSocket.NUM_BUFFERS; ++i) {
|
||||
buffers[i] = new _ExternalBuffer(_RawSecureSocket._isBufferEncrypted(i) ?
|
||||
ENCRYPTED_SIZE :
|
||||
SIZE);
|
||||
buffers[i] = new _ExternalBuffer(
|
||||
_RawSecureSocket._isBufferEncrypted(i) ? ENCRYPTED_SIZE : SIZE);
|
||||
}
|
||||
}
|
||||
|
||||
void connect(String hostName,
|
||||
SecurityContext context,
|
||||
bool is_server,
|
||||
bool requestClientCertificate,
|
||||
bool requireClientCertificate,
|
||||
Uint8List protocols) native "SecureSocket_Connect";
|
||||
void connect(
|
||||
String hostName,
|
||||
SecurityContext context,
|
||||
bool is_server,
|
||||
bool requestClientCertificate,
|
||||
bool requireClientCertificate,
|
||||
Uint8List protocols) native "SecureSocket_Connect";
|
||||
|
||||
void destroy() {
|
||||
buffers = null;
|
||||
|
@ -94,10 +99,8 @@ class _SecureFilterImpl
|
|||
|
||||
String selectedProtocol() native "SecureSocket_GetSelectedProtocol";
|
||||
|
||||
void renegotiate(bool useSessionCache,
|
||||
bool requestClientCertificate,
|
||||
bool requireClientCertificate)
|
||||
native "SecureSocket_Renegotiate";
|
||||
void renegotiate(bool useSessionCache, bool requestClientCertificate,
|
||||
bool requireClientCertificate) native "SecureSocket_Renegotiate";
|
||||
|
||||
void init() native "SecureSocket_Init";
|
||||
|
||||
|
@ -115,22 +118,25 @@ class _SecureFilterImpl
|
|||
List<_ExternalBuffer> buffers;
|
||||
}
|
||||
|
||||
@patch class SecurityContext {
|
||||
@patch factory SecurityContext() {
|
||||
@patch
|
||||
class SecurityContext {
|
||||
@patch
|
||||
factory SecurityContext() {
|
||||
return new _SecurityContext();
|
||||
}
|
||||
|
||||
@patch static SecurityContext get defaultContext {
|
||||
@patch
|
||||
static SecurityContext get defaultContext {
|
||||
return _SecurityContext.defaultContext;
|
||||
}
|
||||
|
||||
@patch static bool get alpnSupported {
|
||||
@patch
|
||||
static bool get alpnSupported {
|
||||
return _SecurityContext.alpnSupported;
|
||||
}
|
||||
}
|
||||
|
||||
class _SecurityContext
|
||||
extends NativeFieldWrapperClass1
|
||||
class _SecurityContext extends NativeFieldWrapperClass1
|
||||
implements SecurityContext {
|
||||
_SecurityContext() {
|
||||
_createNativeContext();
|
||||
|
@ -138,13 +144,14 @@ class _SecurityContext
|
|||
|
||||
void _createNativeContext() native "SecurityContext_Allocate";
|
||||
|
||||
static final SecurityContext defaultContext =
|
||||
new _SecurityContext().._trustBuiltinRoots();
|
||||
static final SecurityContext defaultContext = new _SecurityContext()
|
||||
.._trustBuiltinRoots();
|
||||
|
||||
void usePrivateKey(String file, {String password}) {
|
||||
List<int> bytes = (new File(file)).readAsBytesSync();
|
||||
usePrivateKeyBytes(bytes, password: password);
|
||||
}
|
||||
|
||||
void usePrivateKeyBytes(List<int> keyBytes, {String password})
|
||||
native "SecurityContext_UsePrivateKeyBytes";
|
||||
|
||||
|
@ -152,6 +159,7 @@ class _SecurityContext
|
|||
List<int> bytes = (new File(file)).readAsBytesSync();
|
||||
setTrustedCertificatesBytes(bytes, password: password);
|
||||
}
|
||||
|
||||
void setTrustedCertificatesBytes(List<int> certBytes, {String password})
|
||||
native "SecurityContext_SetTrustedCertificatesBytes";
|
||||
|
||||
|
@ -159,6 +167,7 @@ class _SecurityContext
|
|||
List<int> bytes = (new File(file)).readAsBytesSync();
|
||||
useCertificateChainBytes(bytes, password: password);
|
||||
}
|
||||
|
||||
void useCertificateChainBytes(List<int> chainBytes, {String password})
|
||||
native "SecurityContext_UseCertificateChainBytes";
|
||||
|
||||
|
@ -166,6 +175,7 @@ class _SecurityContext
|
|||
List<int> bytes = (new File(file)).readAsBytesSync();
|
||||
setClientAuthoritiesBytes(bytes, password: password);
|
||||
}
|
||||
|
||||
void setClientAuthoritiesBytes(List<int> authCertBytes, {String password})
|
||||
native "SecurityContext_SetClientAuthoritiesBytes";
|
||||
|
||||
|
@ -176,10 +186,10 @@ class _SecurityContext
|
|||
SecurityContext._protocolsToLengthEncoding(protocols);
|
||||
_setAlpnProtocols(encodedProtocols, isServer);
|
||||
}
|
||||
|
||||
void _setAlpnProtocols(Uint8List protocols, bool isServer)
|
||||
native "SecurityContext_SetAlpnProtocols";
|
||||
void _trustBuiltinRoots()
|
||||
native "SecurityContext_TrustBuiltinRoots";
|
||||
void _trustBuiltinRoots() native "SecurityContext_TrustBuiltinRoots";
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -196,12 +206,13 @@ class _X509CertificateImpl extends NativeFieldWrapperClass1
|
|||
String get issuer native "X509_Issuer";
|
||||
DateTime get startValidity {
|
||||
return new DateTime.fromMillisecondsSinceEpoch(_startValidity(),
|
||||
isUtc: true);
|
||||
isUtc: true);
|
||||
}
|
||||
|
||||
DateTime get endValidity {
|
||||
return new DateTime.fromMillisecondsSinceEpoch(_endValidity(),
|
||||
isUtc: true);
|
||||
return new DateTime.fromMillisecondsSinceEpoch(_endValidity(), isUtc: true);
|
||||
}
|
||||
|
||||
int _startValidity() native "X509_StartValidity";
|
||||
int _endValidity() native "X509_EndValidity";
|
||||
}
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -2,8 +2,10 @@
|
|||
// for details. All rights reserved. Use of this source code is governed by a
|
||||
// BSD-style license that can be found in the LICENSE file.
|
||||
|
||||
@patch class _StdIOUtils {
|
||||
@patch static Stdin _getStdioInputStream() {
|
||||
@patch
|
||||
class _StdIOUtils {
|
||||
@patch
|
||||
static Stdin _getStdioInputStream() {
|
||||
switch (_getStdioHandleType(0)) {
|
||||
case _STDIO_HANDLE_TYPE_TERMINAL:
|
||||
case _STDIO_HANDLE_TYPE_PIPE:
|
||||
|
@ -16,7 +18,8 @@
|
|||
}
|
||||
}
|
||||
|
||||
@patch static _getStdioOutputStream(int fd) {
|
||||
@patch
|
||||
static _getStdioOutputStream(int fd) {
|
||||
assert(fd == 1 || fd == 2);
|
||||
switch (_getStdioHandleType(fd)) {
|
||||
case _STDIO_HANDLE_TYPE_TERMINAL:
|
||||
|
@ -29,7 +32,8 @@
|
|||
}
|
||||
}
|
||||
|
||||
@patch static int _socketType(Socket socket) {
|
||||
@patch
|
||||
static int _socketType(Socket socket) {
|
||||
if (socket is _Socket) return _nativeSocketType(socket._nativeSocket);
|
||||
return null;
|
||||
}
|
||||
|
@ -37,17 +41,19 @@
|
|||
static int _nativeSocketType(_NativeSocket nativeSocket) {
|
||||
var result = _getSocketType(nativeSocket);
|
||||
if (result is OSError) {
|
||||
throw new FileSystemException(
|
||||
"Error retrieving socket type", "", result);
|
||||
throw new FileSystemException("Error retrieving socket type", "", result);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
@patch static _getStdioHandleType(int fd) native "File_GetStdioHandleType";
|
||||
@patch
|
||||
static _getStdioHandleType(int fd) native "File_GetStdioHandleType";
|
||||
}
|
||||
|
||||
@patch class Stdin {
|
||||
@patch int readByteSync() {
|
||||
@patch
|
||||
class Stdin {
|
||||
@patch
|
||||
int readByteSync() {
|
||||
var result = _readByte();
|
||||
if (result is OSError) {
|
||||
throw new StdinException("Error reading byte from stdin", result);
|
||||
|
@ -55,28 +61,34 @@
|
|||
return result;
|
||||
}
|
||||
|
||||
@patch bool get echoMode {
|
||||
@patch
|
||||
bool get echoMode {
|
||||
var result = _echoMode();
|
||||
if (result is OSError) {
|
||||
throw new StdinException("Error getting terminal echo mode", result);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
@patch void set echoMode(bool enabled) {
|
||||
|
||||
@patch
|
||||
void set echoMode(bool enabled) {
|
||||
var result = _setEchoMode(enabled);
|
||||
if (result is OSError) {
|
||||
throw new StdinException("Error setting terminal echo mode", result);
|
||||
}
|
||||
}
|
||||
|
||||
@patch bool get lineMode {
|
||||
@patch
|
||||
bool get lineMode {
|
||||
var result = _lineMode();
|
||||
if (result is OSError) {
|
||||
throw new StdinException("Error getting terminal line mode", result);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
@patch void set lineMode(bool enabled) {
|
||||
|
||||
@patch
|
||||
void set lineMode(bool enabled) {
|
||||
var result = _setLineMode(enabled);
|
||||
if (result is OSError) {
|
||||
throw new StdinException("Error setting terminal line mode", result);
|
||||
|
@ -99,8 +111,10 @@
|
|||
static _supportsAnsiEscapes() native "Stdin_AnsiSupported";
|
||||
}
|
||||
|
||||
@patch class Stdout {
|
||||
@patch bool _hasTerminal(int fd) {
|
||||
@patch
|
||||
class Stdout {
|
||||
@patch
|
||||
bool _hasTerminal(int fd) {
|
||||
try {
|
||||
_terminalSize(fd);
|
||||
return true;
|
||||
|
@ -109,8 +123,10 @@
|
|||
}
|
||||
}
|
||||
|
||||
@patch int _terminalColumns(int fd) => _terminalSize(fd)[0];
|
||||
@patch int _terminalLines(int fd) => _terminalSize(fd)[1];
|
||||
@patch
|
||||
int _terminalColumns(int fd) => _terminalSize(fd)[0];
|
||||
@patch
|
||||
int _terminalLines(int fd) => _terminalSize(fd)[1];
|
||||
|
||||
static List _terminalSize(int fd) {
|
||||
var size = _getTerminalSize(fd);
|
||||
|
@ -133,6 +149,5 @@
|
|||
static _getAnsiSupported(int fd) native "Stdout_AnsiSupported";
|
||||
}
|
||||
|
||||
|
||||
_getStdioHandle(_NativeSocket socket, int num) native "Socket_GetStdioHandle";
|
||||
_getSocketType(_NativeSocket nativeSocket) native "Socket_GetType";
|
||||
|
|
|
@ -4,8 +4,7 @@
|
|||
|
||||
part of vmservice_io;
|
||||
|
||||
final bool silentObservatory =
|
||||
const bool.fromEnvironment('SILENT_OBSERVATORY');
|
||||
final bool silentObservatory = const bool.fromEnvironment('SILENT_OBSERVATORY');
|
||||
|
||||
void serverPrint(String s) {
|
||||
if (silentObservatory) {
|
||||
|
@ -63,7 +62,7 @@ class WebSocketClient extends Client {
|
|||
}
|
||||
try {
|
||||
if (result is String || result is Uint8List) {
|
||||
socket.add(result); // String or binary message.
|
||||
socket.add(result); // String or binary message.
|
||||
} else {
|
||||
// String message as external Uint8List.
|
||||
assert(result is List);
|
||||
|
@ -85,14 +84,13 @@ class WebSocketClient extends Client {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
class HttpRequestClient extends Client {
|
||||
static ContentType jsonContentType =
|
||||
new ContentType("application", "json", charset: "utf-8");
|
||||
final HttpRequest request;
|
||||
|
||||
HttpRequestClient(this.request, VMService service)
|
||||
: super(service, sendEvents:false);
|
||||
: super(service, sendEvents: false);
|
||||
|
||||
disconnect() {
|
||||
request.response.close();
|
||||
|
@ -112,7 +110,7 @@ class HttpRequestClient extends Client {
|
|||
response.write(result);
|
||||
} else {
|
||||
assert(result is List);
|
||||
Uint8List cstring = result[0]; // Already in UTF-8.
|
||||
Uint8List cstring = result[0]; // Already in UTF-8.
|
||||
response.add(cstring);
|
||||
}
|
||||
response.close();
|
||||
|
@ -169,7 +167,7 @@ class Server {
|
|||
|
||||
if ((uri.port == _server.port) &&
|
||||
((uri.host == _server.address.address) ||
|
||||
(uri.host == _server.address.host))) {
|
||||
(uri.host == _server.address.host))) {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -217,8 +215,9 @@ class Server {
|
|||
return null;
|
||||
}
|
||||
// Construct the actual request path by chopping off the auth token.
|
||||
return (requestPathSegments[1] == '') ?
|
||||
ROOT_REDIRECT_PATH : '/${requestPathSegments.sublist(1).join('/')}';
|
||||
return (requestPathSegments[1] == '')
|
||||
? ROOT_REDIRECT_PATH
|
||||
: '/${requestPathSegments.sublist(1).join('/')}';
|
||||
}
|
||||
|
||||
Future _requestHandler(HttpRequest request) async {
|
||||
|
@ -261,16 +260,13 @@ class Server {
|
|||
fsPath = fsPathList[0];
|
||||
}
|
||||
}
|
||||
} catch (e) { /* ignore */ }
|
||||
} catch (e) {/* ignore */}
|
||||
|
||||
String result;
|
||||
try {
|
||||
result = await _service.devfs.handlePutStream(
|
||||
fsName,
|
||||
fsPath,
|
||||
fsUri,
|
||||
request.transform(GZIP.decoder));
|
||||
} catch (e) { /* ignore */ }
|
||||
fsName, fsPath, fsUri, request.transform(GZIP.decoder));
|
||||
} catch (e) {/* ignore */}
|
||||
|
||||
if (result != null) {
|
||||
request.response.headers.contentType =
|
||||
|
@ -294,8 +290,7 @@ class Server {
|
|||
}
|
||||
|
||||
if (path == WEBSOCKET_PATH) {
|
||||
WebSocketTransformer.upgrade(request).then(
|
||||
(WebSocket webSocket) {
|
||||
WebSocketTransformer.upgrade(request).then((WebSocket webSocket) {
|
||||
new WebSocketClient(webSocket, _service);
|
||||
});
|
||||
return;
|
||||
|
@ -304,8 +299,7 @@ class Server {
|
|||
Asset asset = assets[path];
|
||||
if (asset != null) {
|
||||
// Serving up a static asset (e.g. .css, .html, .png).
|
||||
request.response.headers.contentType =
|
||||
ContentType.parse(asset.mimeType);
|
||||
request.response.headers.contentType = ContentType.parse(asset.mimeType);
|
||||
request.response.add(asset.data);
|
||||
request.response.close();
|
||||
return;
|
||||
|
@ -317,7 +311,7 @@ class Server {
|
|||
client.onMessage(null, message);
|
||||
} catch (e) {
|
||||
serverPrint('Unexpected error processing HTTP request uri: '
|
||||
'${request.uri}\n$e\n');
|
||||
'${request.uri}\n$e\n');
|
||||
rethrow;
|
||||
}
|
||||
}
|
||||
|
@ -399,8 +393,6 @@ class Server {
|
|||
return this;
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void _notifyServerState(String uri)
|
||||
native "VMServiceIO_NotifyServerState";
|
||||
void _notifyServerState(String uri) native "VMServiceIO_NotifyServerState";
|
||||
|
|
|
@ -146,7 +146,7 @@ Future<List<int>> readFileCallback(Uri path) async {
|
|||
return await file.readAsBytes();
|
||||
}
|
||||
|
||||
Future<List<Map<String,String>>> listFilesCallback(Uri dirPath) async {
|
||||
Future<List<Map<String, String>>> listFilesCallback(Uri dirPath) async {
|
||||
var dir = new Directory.fromUri(dirPath);
|
||||
var dirPathStr = dirPath.path;
|
||||
var stream = dir.list(recursive: true);
|
||||
|
|
|
@ -2,10 +2,8 @@
|
|||
// for details. All rights reserved. Use of this source code is governed by a
|
||||
// BSD-style license that can be found in the LICENSE file.
|
||||
|
||||
|
||||
// TODO(srdjan): Use shared array implementation.
|
||||
class _List<E> extends FixedLengthListBase<E> {
|
||||
|
||||
factory _List(length) native "List_allocate";
|
||||
|
||||
E operator [](int index) native "List_getIndexed";
|
||||
|
@ -16,8 +14,7 @@ class _List<E> extends FixedLengthListBase<E> {
|
|||
|
||||
List _slice(int start, int count, bool needsTypeArgument) {
|
||||
if (count <= 64) {
|
||||
final result = needsTypeArgument ? new _List<E>(count)
|
||||
: new _List(count);
|
||||
final result = needsTypeArgument ? new _List<E>(count) : new _List(count);
|
||||
for (int i = 0; i < result.length; i++) {
|
||||
result[i] = this[start + i];
|
||||
}
|
||||
|
@ -97,7 +94,7 @@ class _List<E> extends FixedLengthListBase<E> {
|
|||
throw IterableElementError.tooMany();
|
||||
}
|
||||
|
||||
List<E> toList({ bool growable: true }) {
|
||||
List<E> toList({bool growable: true}) {
|
||||
var length = this.length;
|
||||
if (length > 0) {
|
||||
var result = _slice(0, length, !growable);
|
||||
|
@ -112,7 +109,6 @@ class _List<E> extends FixedLengthListBase<E> {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
// This is essentially the same class as _List, but it does not
|
||||
// permit any modification of array elements from Dart code. We use
|
||||
// this class for arrays constructed from Dart array literals.
|
||||
|
@ -121,7 +117,6 @@ class _List<E> extends FixedLengthListBase<E> {
|
|||
// implementation (checks when modifying). We should keep watching
|
||||
// the inline cache misses.
|
||||
class _ImmutableList<E> extends UnmodifiableListBase<E> {
|
||||
|
||||
factory _ImmutableList._uninstantiable() {
|
||||
throw new UnsupportedError(
|
||||
"ImmutableArray can only be allocated by the VM");
|
||||
|
@ -176,7 +171,7 @@ class _ImmutableList<E> extends UnmodifiableListBase<E> {
|
|||
throw IterableElementError.tooMany();
|
||||
}
|
||||
|
||||
List<E> toList({ bool growable: true }) {
|
||||
List<E> toList({bool growable: true}) {
|
||||
var length = this.length;
|
||||
if (length > 0) {
|
||||
List list = growable ? new _List(length) : new _List<E>(length);
|
||||
|
@ -192,16 +187,17 @@ class _ImmutableList<E> extends UnmodifiableListBase<E> {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
// Iterator for arrays with fixed size.
|
||||
class _FixedSizeArrayIterator<E> implements Iterator<E> {
|
||||
final List<E> _array;
|
||||
final int _length; // Cache array length for faster access.
|
||||
final int _length; // Cache array length for faster access.
|
||||
int _index;
|
||||
E _current;
|
||||
|
||||
_FixedSizeArrayIterator(List array)
|
||||
: _array = array, _length = array.length, _index = 0 {
|
||||
: _array = array,
|
||||
_length = array.length,
|
||||
_index = 0 {
|
||||
assert(array is _List || array is _ImmutableList);
|
||||
}
|
||||
|
||||
|
|
|
@ -10,10 +10,13 @@ class _GrowableArrayMarker implements int {
|
|||
|
||||
const _GROWABLE_ARRAY_MARKER = const _GrowableArrayMarker();
|
||||
|
||||
@patch class List<E> {
|
||||
@patch factory List([int length]) = List<E>._internal;
|
||||
@patch
|
||||
class List<E> {
|
||||
@patch
|
||||
factory List([int length]) = List<E>._internal;
|
||||
|
||||
@patch factory List.filled(int length, E fill, {bool growable: false}) {
|
||||
@patch
|
||||
factory List.filled(int length, E fill, {bool growable: false}) {
|
||||
// All error handling on the length parameter is done at the implementation
|
||||
// of new _List.
|
||||
var result = growable ? new _GrowableList<E>(length) : new _List<E>(length);
|
||||
|
@ -25,13 +28,17 @@ const _GROWABLE_ARRAY_MARKER = const _GrowableArrayMarker();
|
|||
return result;
|
||||
}
|
||||
|
||||
@patch factory List.from(Iterable elements, { bool growable: true }) {
|
||||
@patch
|
||||
factory List.from(Iterable elements, {bool growable: true}) {
|
||||
if (elements is EfficientLengthIterable) {
|
||||
int length = elements.length;
|
||||
var list = growable ? new _GrowableList<E>(length) : new _List<E>(length);
|
||||
if (length > 0) { // Avoid creating iterator unless necessary.
|
||||
if (length > 0) {
|
||||
// Avoid creating iterator unless necessary.
|
||||
int i = 0;
|
||||
for (var element in elements) { list[i++] = element; }
|
||||
for (var element in elements) {
|
||||
list[i++] = element;
|
||||
}
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
@ -47,7 +54,8 @@ const _GROWABLE_ARRAY_MARKER = const _GrowableArrayMarker();
|
|||
return makeListFixedLength(list);
|
||||
}
|
||||
|
||||
@patch factory List.unmodifiable(Iterable elements) {
|
||||
@patch
|
||||
factory List.unmodifiable(Iterable elements) {
|
||||
List result = new List<E>.from(elements, growable: false);
|
||||
return makeFixedListUnmodifiable(result);
|
||||
}
|
||||
|
|
|
@ -45,10 +45,7 @@ Function _asyncErrorWrapperHelper(continuation) {
|
|||
///
|
||||
/// Returns the result of registering with `.then`.
|
||||
Future _awaitHelper(
|
||||
var object,
|
||||
Function thenCallback,
|
||||
Function errorCallback,
|
||||
var awaiter) {
|
||||
var object, Function thenCallback, Function errorCallback, var awaiter) {
|
||||
if (object is! Future) {
|
||||
object = new _Future().._setValue(object);
|
||||
} else if (object is! _Future) {
|
||||
|
@ -179,9 +176,10 @@ class _AsyncStarStreamController {
|
|||
}
|
||||
|
||||
_AsyncStarStreamController(this.asyncStarBody) {
|
||||
controller = new StreamController(onListen: this.onListen,
|
||||
onResume: this.onResume,
|
||||
onCancel: this.onCancel);
|
||||
controller = new StreamController(
|
||||
onListen: this.onListen,
|
||||
onResume: this.onResume,
|
||||
onCancel: this.onCancel);
|
||||
}
|
||||
|
||||
onListen() {
|
||||
|
@ -213,16 +211,20 @@ class _AsyncStarStreamController {
|
|||
}
|
||||
}
|
||||
|
||||
@patch void _rethrow(Object error, StackTrace stackTrace) native "Async_rethrow";
|
||||
@patch
|
||||
void _rethrow(Object error, StackTrace stackTrace) native "Async_rethrow";
|
||||
|
||||
@patch class _Future<T> {
|
||||
@patch
|
||||
class _Future<T> {
|
||||
/// The closure implementing the async[*]-body that is `await`ing this future.
|
||||
Function _awaiter;
|
||||
}
|
||||
|
||||
@patch class _StreamImpl<T> {
|
||||
@patch
|
||||
class _StreamImpl<T> {
|
||||
/// The closure implementing the async[*]-body that is `await`ing this future.
|
||||
Function _awaiter;
|
||||
|
||||
/// The closure implementing the async-generator body that is creating events
|
||||
/// for this stream.
|
||||
Function _generator;
|
||||
|
@ -230,11 +232,10 @@ class _AsyncStarStreamController {
|
|||
|
||||
/// Returns a [StackTrace] object containing the synchronous prefix for this
|
||||
/// asynchronous method.
|
||||
Object _asyncStackTraceHelper()
|
||||
native "StackTrace_asyncStackTraceHelper";
|
||||
Object _asyncStackTraceHelper() native "StackTrace_asyncStackTraceHelper";
|
||||
|
||||
void _clearAsyncThreadStackTrace()
|
||||
native "StackTrace_clearAsyncThreadStackTrace";
|
||||
|
||||
void _setAsyncThreadStackTrace(StackTrace stackTrace) native
|
||||
"StackTrace_setAsyncThreadStackTrace";
|
||||
void _setAsyncThreadStackTrace(StackTrace stackTrace)
|
||||
native "StackTrace_setAsyncThreadStackTrace";
|
||||
|
|
|
@ -119,9 +119,9 @@ class _Bigint extends _IntegerImplementation implements int {
|
|||
// Allocate an array of the given length (+1 for at least one leading zero
|
||||
// digit if odd) and copy digits[from..to-1] starting at index 0, followed by
|
||||
// leading zero digits.
|
||||
static Uint32List _cloneDigits(Uint32List digits, int from, int to,
|
||||
int length) {
|
||||
length += length & 1; // Even number of digits.
|
||||
static Uint32List _cloneDigits(
|
||||
Uint32List digits, int from, int to, int length) {
|
||||
length += length & 1; // Even number of digits.
|
||||
var r_digits = new Uint32List(length);
|
||||
var n = to - from;
|
||||
for (var i = 0; i < n; i++) {
|
||||
|
@ -132,7 +132,7 @@ class _Bigint extends _IntegerImplementation implements int {
|
|||
|
||||
// Return most compact integer (i.e. possibly Smi or Mint).
|
||||
int _toValidInt() {
|
||||
assert(_DIGIT_BITS == 32); // Otherwise this code needs to be revised.
|
||||
assert(_DIGIT_BITS == 32); // Otherwise this code needs to be revised.
|
||||
var used = _used;
|
||||
if (used == 0) return 0;
|
||||
var digits = _digits;
|
||||
|
@ -174,11 +174,25 @@ class _Bigint extends _IntegerImplementation implements int {
|
|||
// Return the bit length of digit x.
|
||||
static int _nbits(int x) {
|
||||
var r = 1, t;
|
||||
if ((t = x >> 16) != 0) { x = t; r += 16; }
|
||||
if ((t = x >> 8) != 0) { x = t; r += 8; }
|
||||
if ((t = x >> 4) != 0) { x = t; r += 4; }
|
||||
if ((t = x >> 2) != 0) { x = t; r += 2; }
|
||||
if ((x >> 1) != 0) { r += 1; }
|
||||
if ((t = x >> 16) != 0) {
|
||||
x = t;
|
||||
r += 16;
|
||||
}
|
||||
if ((t = x >> 8) != 0) {
|
||||
x = t;
|
||||
r += 8;
|
||||
}
|
||||
if ((t = x >> 4) != 0) {
|
||||
x = t;
|
||||
r += 4;
|
||||
}
|
||||
if ((t = x >> 2) != 0) {
|
||||
x = t;
|
||||
r += 2;
|
||||
}
|
||||
if ((x >> 1) != 0) {
|
||||
r += 1;
|
||||
}
|
||||
return r;
|
||||
}
|
||||
|
||||
|
@ -200,8 +214,8 @@ class _Bigint extends _IntegerImplementation implements int {
|
|||
|
||||
// r_digits[0..r_used-1] = x_digits[0..x_used-1] << n*_DIGIT_BITS.
|
||||
// Return r_used.
|
||||
static int _dlShiftDigits(Uint32List x_digits, int x_used, int n,
|
||||
Uint32List r_digits) {
|
||||
static int _dlShiftDigits(
|
||||
Uint32List x_digits, int x_used, int n, Uint32List r_digits) {
|
||||
if (x_used == 0) {
|
||||
return 0;
|
||||
}
|
||||
|
@ -253,8 +267,8 @@ class _Bigint extends _IntegerImplementation implements int {
|
|||
|
||||
// r_digits[0..r_used-1] = x_digits[0..x_used-1] >> n*_DIGIT_BITS.
|
||||
// Return r_used.
|
||||
static int _drShiftDigits(Uint32List x_digits, int x_used, int n,
|
||||
Uint32List r_digits) {
|
||||
static int _drShiftDigits(
|
||||
Uint32List x_digits, int x_used, int n, Uint32List r_digits) {
|
||||
final r_used = x_used - n;
|
||||
if (r_used <= 0) {
|
||||
return 0;
|
||||
|
@ -272,8 +286,8 @@ class _Bigint extends _IntegerImplementation implements int {
|
|||
// r_digits[ds..x_used+ds] = x_digits[0..x_used-1] << (n % _DIGIT_BITS)
|
||||
// where ds = ceil(n / _DIGIT_BITS)
|
||||
// Doesn't clear digits below ds.
|
||||
static void _lsh(Uint32List x_digits, int x_used, int n,
|
||||
Uint32List r_digits) {
|
||||
static void _lsh(
|
||||
Uint32List x_digits, int x_used, int n, Uint32List r_digits) {
|
||||
final ds = n ~/ _DIGIT_BITS;
|
||||
final bs = n % _DIGIT_BITS;
|
||||
final cbs = _DIGIT_BITS - bs;
|
||||
|
@ -296,29 +310,29 @@ class _Bigint extends _IntegerImplementation implements int {
|
|||
return _dlShift(ds);
|
||||
}
|
||||
var r_used = _used + ds + 1;
|
||||
var r_digits = new Uint32List(r_used + 2 - (r_used & 1)); // for 64-bit.
|
||||
var r_digits = new Uint32List(r_used + 2 - (r_used & 1)); // for 64-bit.
|
||||
_lsh(_digits, _used, n, r_digits);
|
||||
return new _Bigint(_neg, r_used, r_digits);
|
||||
}
|
||||
|
||||
// r_digits[0..r_used-1] = x_digits[0..x_used-1] << n.
|
||||
// Return r_used.
|
||||
static int _lShiftDigits(Uint32List x_digits, int x_used, int n,
|
||||
Uint32List r_digits) {
|
||||
static int _lShiftDigits(
|
||||
Uint32List x_digits, int x_used, int n, Uint32List r_digits) {
|
||||
final ds = n ~/ _DIGIT_BITS;
|
||||
final bs = n % _DIGIT_BITS;
|
||||
if (bs == 0) {
|
||||
return _dlShiftDigits(x_digits, x_used, ds, r_digits);
|
||||
}
|
||||
var r_used = x_used + ds + 1;
|
||||
assert(r_digits.length >= r_used + 2 - (r_used & 1)); // for 64-bit.
|
||||
assert(r_digits.length >= r_used + 2 - (r_used & 1)); // for 64-bit.
|
||||
_lsh(x_digits, x_used, n, r_digits);
|
||||
var i = ds;
|
||||
while (--i >= 0) {
|
||||
r_digits[i] = 0;
|
||||
}
|
||||
if (r_digits[r_used - 1] == 0) {
|
||||
r_used--; // Clamp result.
|
||||
r_used--; // Clamp result.
|
||||
} else if (r_used.isOdd) {
|
||||
r_digits[r_used] = 0;
|
||||
}
|
||||
|
@ -326,8 +340,8 @@ class _Bigint extends _IntegerImplementation implements int {
|
|||
}
|
||||
|
||||
// r_digits[0..r_used-1] = x_digits[0..x_used-1] >> n.
|
||||
static void _rsh(Uint32List x_digits, int x_used, int n,
|
||||
Uint32List r_digits) {
|
||||
static void _rsh(
|
||||
Uint32List x_digits, int x_used, int n, Uint32List r_digits) {
|
||||
final ds = n ~/ _DIGIT_BITS;
|
||||
final bs = n % _DIGIT_BITS;
|
||||
final cbs = _DIGIT_BITS - bs;
|
||||
|
@ -374,8 +388,8 @@ class _Bigint extends _IntegerImplementation implements int {
|
|||
|
||||
// r_digits[0..r_used-1] = x_digits[0..x_used-1] >> n.
|
||||
// Return r_used.
|
||||
static int _rShiftDigits(Uint32List x_digits, int x_used, int n,
|
||||
Uint32List r_digits) {
|
||||
static int _rShiftDigits(
|
||||
Uint32List x_digits, int x_used, int n, Uint32List r_digits) {
|
||||
final ds = n ~/ _DIGIT_BITS;
|
||||
final bs = n % _DIGIT_BITS;
|
||||
if (bs == 0) {
|
||||
|
@ -388,7 +402,7 @@ class _Bigint extends _IntegerImplementation implements int {
|
|||
assert(r_digits.length >= r_used + (r_used & 1));
|
||||
_rsh(x_digits, x_used, n, r_digits);
|
||||
if (r_digits[r_used - 1] == 0) {
|
||||
r_used--; // Clamp result.
|
||||
r_used--; // Clamp result.
|
||||
} else if (r_used.isOdd) {
|
||||
r_digits[r_used] = 0;
|
||||
}
|
||||
|
@ -424,8 +438,8 @@ class _Bigint extends _IntegerImplementation implements int {
|
|||
// Return 0 if equal.
|
||||
// Return a positive number if larger.
|
||||
// Return a negative number if smaller.
|
||||
static int _compareDigits(Uint32List digits, int used,
|
||||
Uint32List a_digits, int a_used) {
|
||||
static int _compareDigits(
|
||||
Uint32List digits, int used, Uint32List a_digits, int a_used) {
|
||||
var r = used - a_used;
|
||||
if (r == 0) {
|
||||
var i = a_used;
|
||||
|
@ -437,9 +451,8 @@ class _Bigint extends _IntegerImplementation implements int {
|
|||
// r_digits[0..used] = digits[0..used-1] + a_digits[0..a_used-1].
|
||||
// used >= a_used > 0.
|
||||
// Note: Intrinsics on 64-bit platforms process digit pairs at even indices.
|
||||
static void _absAdd(Uint32List digits, int used,
|
||||
Uint32List a_digits, int a_used,
|
||||
Uint32List r_digits) {
|
||||
static void _absAdd(Uint32List digits, int used, Uint32List a_digits,
|
||||
int a_used, Uint32List r_digits) {
|
||||
assert(used >= a_used && a_used > 0);
|
||||
// Verify that digit pairs are accessible for 64-bit processing.
|
||||
assert(digits.length > ((used - 1) | 1));
|
||||
|
@ -462,9 +475,8 @@ class _Bigint extends _IntegerImplementation implements int {
|
|||
// r_digits[0..used-1] = digits[0..used-1] - a_digits[0..a_used-1].
|
||||
// used >= a_used > 0.
|
||||
// Note: Intrinsics on 64-bit platforms process digit pairs at even indices.
|
||||
static void _absSub(Uint32List digits, int used,
|
||||
Uint32List a_digits, int a_used,
|
||||
Uint32List r_digits) {
|
||||
static void _absSub(Uint32List digits, int used, Uint32List a_digits,
|
||||
int a_used, Uint32List r_digits) {
|
||||
assert(used >= a_used && a_used > 0);
|
||||
// Verify that digit pairs are accessible for 64-bit processing.
|
||||
assert(digits.length > ((used - 1) | 1));
|
||||
|
@ -541,7 +553,7 @@ class _Bigint extends _IntegerImplementation implements int {
|
|||
var r_digits = new Uint32List(r_used + (r_used & 1));
|
||||
var m = (r_used < a._used) ? r_used : a._used;
|
||||
for (var i = 0; i < m; i++) {
|
||||
r_digits[i] = digits[i] &~ a_digits[i];
|
||||
r_digits[i] = digits[i] & ~a_digits[i];
|
||||
}
|
||||
for (var i = m; i < r_used; i++) {
|
||||
r_digits[i] = digits[i];
|
||||
|
@ -620,7 +632,8 @@ class _Bigint extends _IntegerImplementation implements int {
|
|||
if (_neg) {
|
||||
p = a;
|
||||
n = this;
|
||||
} else { // & is symmetric.
|
||||
} else {
|
||||
// & is symmetric.
|
||||
p = this;
|
||||
n = a;
|
||||
}
|
||||
|
@ -675,7 +688,8 @@ class _Bigint extends _IntegerImplementation implements int {
|
|||
if (_neg) {
|
||||
p = a;
|
||||
n = this;
|
||||
} else { // | is symmetric.
|
||||
} else {
|
||||
// | is symmetric.
|
||||
p = this;
|
||||
n = a;
|
||||
}
|
||||
|
@ -701,7 +715,8 @@ class _Bigint extends _IntegerImplementation implements int {
|
|||
if (_neg) {
|
||||
p = a;
|
||||
n = this;
|
||||
} else { // ^ is symmetric.
|
||||
} else {
|
||||
// ^ is symmetric.
|
||||
p = this;
|
||||
n = a;
|
||||
}
|
||||
|
@ -764,9 +779,8 @@ class _Bigint extends _IntegerImplementation implements int {
|
|||
// return 1.
|
||||
// Note: Intrinsics on 64-bit platforms process digit pairs at even indices
|
||||
// and return 2.
|
||||
static int _mulAdd(Uint32List x_digits, int xi,
|
||||
Uint32List m_digits, int i,
|
||||
Uint32List a_digits, int j, int n) {
|
||||
static int _mulAdd(Uint32List x_digits, int xi, Uint32List m_digits, int i,
|
||||
Uint32List a_digits, int j, int n) {
|
||||
// Verify that digit pairs are accessible for 64-bit processing.
|
||||
assert(x_digits.length > (xi | 1));
|
||||
assert(m_digits.length > ((i + n - 1) | 1));
|
||||
|
@ -782,9 +796,9 @@ class _Bigint extends _IntegerImplementation implements int {
|
|||
while (--n >= 0) {
|
||||
int l = m_digits[i] & _DIGIT2_MASK;
|
||||
int h = m_digits[i++] >> _DIGIT2_BITS;
|
||||
int m = xh*l + h*xl;
|
||||
l = xl*l + ((m & _DIGIT2_MASK) << _DIGIT2_BITS) + a_digits[j] + c;
|
||||
c = (l >> _DIGIT_BITS) + (m >> _DIGIT2_BITS) + xh*h;
|
||||
int m = xh * l + h * xl;
|
||||
l = xl * l + ((m & _DIGIT2_MASK) << _DIGIT2_BITS) + a_digits[j] + c;
|
||||
c = (l >> _DIGIT_BITS) + (m >> _DIGIT2_BITS) + xh * h;
|
||||
a_digits[j++] = l & _DIGIT_MASK;
|
||||
}
|
||||
while (c != 0) {
|
||||
|
@ -805,20 +819,20 @@ class _Bigint extends _IntegerImplementation implements int {
|
|||
// return 1.
|
||||
// Note: Intrinsics on 64-bit platforms process digit pairs at even indices
|
||||
// and return 2.
|
||||
static int _sqrAdd(Uint32List x_digits, int i,
|
||||
Uint32List a_digits, int used) {
|
||||
static int _sqrAdd(
|
||||
Uint32List x_digits, int i, Uint32List a_digits, int used) {
|
||||
// Verify that digit pairs are accessible for 64-bit processing.
|
||||
assert(x_digits.length > ((used - 1) | 1));
|
||||
assert(a_digits.length > ((i + used - 1) | 1));
|
||||
int x = x_digits[i];
|
||||
if (x == 0) return 1;
|
||||
int j = 2*i;
|
||||
int j = 2 * i;
|
||||
int c = 0;
|
||||
int xl = x & _DIGIT2_MASK;
|
||||
int xh = x >> _DIGIT2_BITS;
|
||||
int m = 2*xh*xl;
|
||||
int l = xl*xl + ((m & _DIGIT2_MASK) << _DIGIT2_BITS) + a_digits[j];
|
||||
c = (l >> _DIGIT_BITS) + (m >> _DIGIT2_BITS) + xh*xh;
|
||||
int m = 2 * xh * xl;
|
||||
int l = xl * xl + ((m & _DIGIT2_MASK) << _DIGIT2_BITS) + a_digits[j];
|
||||
c = (l >> _DIGIT_BITS) + (m >> _DIGIT2_BITS) + xh * xh;
|
||||
a_digits[j] = l & _DIGIT_MASK;
|
||||
x <<= 1;
|
||||
xl = x & _DIGIT2_MASK;
|
||||
|
@ -829,9 +843,9 @@ class _Bigint extends _IntegerImplementation implements int {
|
|||
while (--n >= 0) {
|
||||
int l = x_digits[k] & _DIGIT2_MASK;
|
||||
int h = x_digits[k++] >> _DIGIT2_BITS;
|
||||
int m = xh*l + h*xl;
|
||||
l = xl*l + ((m & _DIGIT2_MASK) << _DIGIT2_BITS) + a_digits[j] + c;
|
||||
c = (l >> _DIGIT_BITS) + (m >> _DIGIT2_BITS) + xh*h;
|
||||
int m = xh * l + h * xl;
|
||||
l = xl * l + ((m & _DIGIT2_MASK) << _DIGIT2_BITS) + a_digits[j] + c;
|
||||
c = (l >> _DIGIT_BITS) + (m >> _DIGIT2_BITS) + xh * h;
|
||||
a_digits[j++] = l & _DIGIT_MASK;
|
||||
}
|
||||
c += a_digits[i + used];
|
||||
|
@ -865,9 +879,8 @@ class _Bigint extends _IntegerImplementation implements int {
|
|||
|
||||
// r_digits[0..r_used-1] = x_digits[0..x_used-1]*a_digits[0..a_used-1].
|
||||
// Return r_used = x_used + a_used.
|
||||
static int _mulDigits(Uint32List x_digits, int x_used,
|
||||
Uint32List a_digits, int a_used,
|
||||
Uint32List r_digits) {
|
||||
static int _mulDigits(Uint32List x_digits, int x_used, Uint32List a_digits,
|
||||
int a_used, Uint32List r_digits) {
|
||||
var r_used = x_used + a_used;
|
||||
var i = r_used + (r_used & 1);
|
||||
assert(r_digits.length >= i);
|
||||
|
@ -897,7 +910,7 @@ class _Bigint extends _IntegerImplementation implements int {
|
|||
}
|
||||
// The last step is already done if digit pairs were processed above.
|
||||
if (i < used) {
|
||||
_mulAdd(digits, i, digits, i, r_digits, 2*i, 1);
|
||||
_mulAdd(digits, i, digits, i, r_digits, 2 * i, 1);
|
||||
}
|
||||
return new _Bigint(false, r_used, r_digits);
|
||||
}
|
||||
|
@ -918,7 +931,7 @@ class _Bigint extends _IntegerImplementation implements int {
|
|||
}
|
||||
// The last step is already done if digit pairs were processed above.
|
||||
if (i < x_used) {
|
||||
_mulAdd(x_digits, i, x_digits, i, r_digits, 2*i, 1);
|
||||
_mulAdd(x_digits, i, x_digits, i, r_digits, 2 * i, 1);
|
||||
}
|
||||
return r_used;
|
||||
}
|
||||
|
@ -928,10 +941,10 @@ class _Bigint extends _IntegerImplementation implements int {
|
|||
// of divisor y is provided in the args array, and a 64-bit estimated quotient
|
||||
// is returned. However, on 32-bit platforms, the low 32-bit digit is ignored
|
||||
// and only one 32-bit digit is returned as the estimated quotient.
|
||||
static const int _YT_LO = 0; // Low digit of top digit pair of y, for 64-bit.
|
||||
static const int _YT = 1; // Top digit of divisor y.
|
||||
static const int _QD = 2; // Estimated quotient.
|
||||
static const int _QD_HI = 3; // High digit of estimated quotient, for 64-bit.
|
||||
static const int _YT_LO = 0; // Low digit of top digit pair of y, for 64-bit.
|
||||
static const int _YT = 1; // Top digit of divisor y.
|
||||
static const int _QD = 2; // Estimated quotient.
|
||||
static const int _QD_HI = 3; // High digit of estimated quotient, for 64-bit.
|
||||
|
||||
// Operation:
|
||||
// Estimate args[_QD] = digits[i-1..i] ~/ args[_YT]
|
||||
|
@ -946,8 +959,8 @@ class _Bigint extends _IntegerImplementation implements int {
|
|||
args[_QD] = _DIGIT_MASK;
|
||||
} else {
|
||||
// Chop off one bit, since a Mint cannot hold 2 DIGITs.
|
||||
var qd = ((digits[i] << (_DIGIT_BITS - 1)) | (digits[i - 1] >> 1))
|
||||
~/ (args[_YT] >> 1);
|
||||
var qd = ((digits[i] << (_DIGIT_BITS - 1)) | (digits[i - 1] >> 1)) ~/
|
||||
(args[_YT] >> 1);
|
||||
if (qd > _DIGIT_MASK) {
|
||||
args[_QD] = _DIGIT_MASK;
|
||||
} else {
|
||||
|
@ -967,10 +980,8 @@ class _Bigint extends _IntegerImplementation implements int {
|
|||
// Return quotient, i.e.
|
||||
// _lastQuoRem_digits[_lastRem_used.._lastQuoRem_used-1] with proper sign.
|
||||
var lastQuo_used = _lastQuoRem_used - _lastRem_used;
|
||||
var quo_digits = _cloneDigits(_lastQuoRem_digits,
|
||||
_lastRem_used,
|
||||
_lastQuoRem_used,
|
||||
lastQuo_used);
|
||||
var quo_digits = _cloneDigits(
|
||||
_lastQuoRem_digits, _lastRem_used, _lastQuoRem_used, lastQuo_used);
|
||||
var quo = new _Bigint(false, lastQuo_used, quo_digits);
|
||||
if ((_neg != a._neg) && (quo._used > 0)) {
|
||||
quo = quo._negate();
|
||||
|
@ -987,13 +998,11 @@ class _Bigint extends _IntegerImplementation implements int {
|
|||
_divRem(a);
|
||||
// Return remainder, i.e.
|
||||
// denormalized _lastQuoRem_digits[0.._lastRem_used-1] with proper sign.
|
||||
var rem_digits = _cloneDigits(_lastQuoRem_digits,
|
||||
0,
|
||||
_lastRem_used,
|
||||
_lastRem_used);
|
||||
var rem_digits =
|
||||
_cloneDigits(_lastQuoRem_digits, 0, _lastRem_used, _lastRem_used);
|
||||
var rem = new _Bigint(false, _lastRem_used, rem_digits);
|
||||
if (_lastRem_nsh > 0) {
|
||||
rem = rem._rShift(_lastRem_nsh); // Denormalize remainder.
|
||||
rem = rem._rShift(_lastRem_nsh); // Denormalize remainder.
|
||||
}
|
||||
if (_neg && (rem._used > 0)) {
|
||||
rem = rem._negate();
|
||||
|
@ -1022,9 +1031,9 @@ class _Bigint extends _IntegerImplementation implements int {
|
|||
var y_digits;
|
||||
var y_used;
|
||||
if (nsh > 0) {
|
||||
y_digits = new Uint32List(a._used + 5); // +5 for norm. and 64-bit.
|
||||
y_digits = new Uint32List(a._used + 5); // +5 for norm. and 64-bit.
|
||||
y_used = _lShiftDigits(a._digits, a._used, nsh, y_digits);
|
||||
r_digits = new Uint32List(_used + 5); // +5 for normalization and 64-bit.
|
||||
r_digits = new Uint32List(_used + 5); // +5 for normalization and 64-bit.
|
||||
r_used = _lShiftDigits(_digits, _used, nsh, r_digits);
|
||||
} else {
|
||||
y_digits = a._digits;
|
||||
|
@ -1046,14 +1055,14 @@ class _Bigint extends _IntegerImplementation implements int {
|
|||
// equal to shifted normalized divisor.
|
||||
if (_compareDigits(r_digits, r_used, t_digits, t_used) >= 0) {
|
||||
assert(i == r_used);
|
||||
r_digits[r_used++] = 1; // Quotient = 1.
|
||||
r_digits[r_used++] = 1; // Quotient = 1.
|
||||
// Subtract divisor from remainder.
|
||||
_absSub(r_digits, r_used, t_digits, t_used, r_digits);
|
||||
} else {
|
||||
// Account for possible carry in _mulAdd step.
|
||||
r_digits[r_used++] = 0;
|
||||
}
|
||||
r_digits[r_used] = 0; // Leading zero for 64-bit processing.
|
||||
r_digits[r_used] = 0; // Leading zero for 64-bit processing.
|
||||
// Negate y so we can later use _mulAdd instead of non-existent _mulSub.
|
||||
var ny_digits = new Uint32List(y_used + 2);
|
||||
ny_digits[y_used] = 1;
|
||||
|
@ -1082,7 +1091,7 @@ class _Bigint extends _IntegerImplementation implements int {
|
|||
} else {
|
||||
assert(d0 == 2);
|
||||
assert(r_digits[i] <= yt_qd[_QD_HI]);
|
||||
if ((r_digits[i] < yt_qd[_QD_HI]) || (r_digits[i-1] < yt_qd[_QD])) {
|
||||
if ((r_digits[i] < yt_qd[_QD_HI]) || (r_digits[i - 1] < yt_qd[_QD])) {
|
||||
var t_used = _dlShiftDigits(ny_digits, y_used, j, t_digits);
|
||||
_absSub(r_digits, r_used, t_digits, t_used, r_digits);
|
||||
if (yt_qd[_QD] == 0) {
|
||||
|
@ -1090,8 +1099,8 @@ class _Bigint extends _IntegerImplementation implements int {
|
|||
}
|
||||
--yt_qd[_QD];
|
||||
assert(r_digits[i] <= yt_qd[_QD_HI]);
|
||||
while ((r_digits[i] < yt_qd[_QD_HI]) ||
|
||||
(r_digits[i-1] < yt_qd[_QD])) {
|
||||
while (
|
||||
(r_digits[i] < yt_qd[_QD_HI]) || (r_digits[i - 1] < yt_qd[_QD])) {
|
||||
_absSub(r_digits, r_used, t_digits, t_used, r_digits);
|
||||
if (yt_qd[_QD] == 0) {
|
||||
--yt_qd[_QD_HI];
|
||||
|
@ -1127,12 +1136,16 @@ class _Bigint extends _IntegerImplementation implements int {
|
|||
// Output:
|
||||
// r_digits[0..r_used-1]: positive remainder.
|
||||
// Returns r_used.
|
||||
static int _remDigits(Uint32List x_digits, int x_used,
|
||||
Uint32List y_digits, int y_used, Uint32List ny_digits,
|
||||
int nsh,
|
||||
Uint32List yt_qd,
|
||||
Uint32List t_digits,
|
||||
Uint32List r_digits) {
|
||||
static int _remDigits(
|
||||
Uint32List x_digits,
|
||||
int x_used,
|
||||
Uint32List y_digits,
|
||||
int y_used,
|
||||
Uint32List ny_digits,
|
||||
int nsh,
|
||||
Uint32List yt_qd,
|
||||
Uint32List t_digits,
|
||||
Uint32List r_digits) {
|
||||
// Initialize r_digits to normalized positive dividend.
|
||||
var r_used = _lShiftDigits(x_digits, x_used, nsh, r_digits);
|
||||
// For 64-bit processing, make sure y_used, i, and j are even.
|
||||
|
@ -1144,14 +1157,14 @@ class _Bigint extends _IntegerImplementation implements int {
|
|||
// equal to shifted normalized divisor.
|
||||
if (_compareDigits(r_digits, r_used, t_digits, t_used) >= 0) {
|
||||
assert(i == r_used);
|
||||
r_digits[r_used++] = 1; // Quotient = 1.
|
||||
r_digits[r_used++] = 1; // Quotient = 1.
|
||||
// Subtract divisor from remainder.
|
||||
_absSub(r_digits, r_used, t_digits, t_used, r_digits);
|
||||
} else {
|
||||
// Account for possible carry in _mulAdd step.
|
||||
r_digits[r_used++] = 0;
|
||||
}
|
||||
r_digits[r_used] = 0; // Leading zero for 64-bit processing.
|
||||
r_digits[r_used] = 0; // Leading zero for 64-bit processing.
|
||||
// Negated y_digits passed in ny_digits allow the use of _mulAdd instead of
|
||||
// unimplemented _mulSub.
|
||||
// ny_digits is read-only and has y_used digits (possibly including several
|
||||
|
@ -1178,7 +1191,7 @@ class _Bigint extends _IntegerImplementation implements int {
|
|||
} else {
|
||||
assert(d0 == 2);
|
||||
assert(r_digits[i] <= yt_qd[_QD_HI]);
|
||||
if ((r_digits[i] < yt_qd[_QD_HI]) || (r_digits[i-1] < yt_qd[_QD])) {
|
||||
if ((r_digits[i] < yt_qd[_QD_HI]) || (r_digits[i - 1] < yt_qd[_QD])) {
|
||||
var t_used = _dlShiftDigits(ny_digits, y_used, j, t_digits);
|
||||
_absSub(r_digits, r_used, t_digits, t_used, r_digits);
|
||||
if (yt_qd[_QD] == 0) {
|
||||
|
@ -1186,8 +1199,8 @@ class _Bigint extends _IntegerImplementation implements int {
|
|||
}
|
||||
--yt_qd[_QD];
|
||||
assert(r_digits[i] <= yt_qd[_QD_HI]);
|
||||
while ((r_digits[i] < yt_qd[_QD_HI]) ||
|
||||
(r_digits[i-1] < yt_qd[_QD])) {
|
||||
while (
|
||||
(r_digits[i] < yt_qd[_QD_HI]) || (r_digits[i - 1] < yt_qd[_QD])) {
|
||||
_absSub(r_digits, r_used, t_digits, t_used, r_digits);
|
||||
if (yt_qd[_QD] == 0) {
|
||||
--yt_qd[_QD_HI];
|
||||
|
@ -1218,14 +1231,14 @@ class _Bigint extends _IntegerImplementation implements int {
|
|||
int get bitLength {
|
||||
if (_used == 0) return 0;
|
||||
if (_neg) return (~this).bitLength;
|
||||
return _DIGIT_BITS*(_used - 1) + _nbits(_digits[_used - 1]);
|
||||
return _DIGIT_BITS * (_used - 1) + _nbits(_digits[_used - 1]);
|
||||
}
|
||||
|
||||
// This method must support smi._toBigint()._shrFromInt(int).
|
||||
int _shrFromInt(int other) {
|
||||
if (_used == 0) return other; // Shift amount is zero.
|
||||
if (_used == 0) return other; // Shift amount is zero.
|
||||
if (_neg) throw new RangeError.range(this, 0, null);
|
||||
assert(_DIGIT_BITS == 32); // Otherwise this code needs to be revised.
|
||||
assert(_DIGIT_BITS == 32); // Otherwise this code needs to be revised.
|
||||
var shift;
|
||||
if ((_used > 2) || ((_used == 2) && (_digits[1] > 0x10000000))) {
|
||||
if (other < 0) {
|
||||
|
@ -1242,12 +1255,12 @@ class _Bigint extends _IntegerImplementation implements int {
|
|||
// This method must support smi._toBigint()._shlFromInt(int).
|
||||
// An out of memory exception is thrown if the result cannot be allocated.
|
||||
int _shlFromInt(int other) {
|
||||
if (_used == 0) return other; // Shift amount is zero.
|
||||
if (_used == 0) return other; // Shift amount is zero.
|
||||
if (_neg) throw new RangeError.range(this, 0, null);
|
||||
assert(_DIGIT_BITS == 32); // Otherwise this code needs to be revised.
|
||||
assert(_DIGIT_BITS == 32); // Otherwise this code needs to be revised.
|
||||
var shift;
|
||||
if (_used > 2 || (_used == 2 && _digits[1] > 0x10000000)) {
|
||||
if (other == 0) return 0; // Shifted value is zero.
|
||||
if (other == 0) return 0; // Shifted value is zero.
|
||||
throw new OutOfMemoryError();
|
||||
} else {
|
||||
shift = ((_used == 2) ? (_digits[1] << _DIGIT_BITS) : 0) + _digits[0];
|
||||
|
@ -1263,30 +1276,39 @@ class _Bigint extends _IntegerImplementation implements int {
|
|||
num operator +(num other) {
|
||||
return other._toBigintOrDouble()._addFromInteger(this);
|
||||
}
|
||||
|
||||
num operator -(num other) {
|
||||
return other._toBigintOrDouble()._subFromInteger(this);
|
||||
}
|
||||
|
||||
num operator *(num other) {
|
||||
return other._toBigintOrDouble()._mulFromInteger(this);
|
||||
}
|
||||
|
||||
num operator ~/(num other) {
|
||||
return other._toBigintOrDouble()._truncDivFromInteger(this);
|
||||
}
|
||||
|
||||
num operator %(num other) {
|
||||
return other._toBigintOrDouble()._moduloFromInteger(this);
|
||||
}
|
||||
|
||||
int operator &(int other) {
|
||||
return other._toBigintOrDouble()._bitAndFromInteger(this);
|
||||
}
|
||||
|
||||
int operator |(int other) {
|
||||
return other._toBigintOrDouble()._bitOrFromInteger(this);
|
||||
}
|
||||
|
||||
int operator ^(int other) {
|
||||
return other._toBigintOrDouble()._bitXorFromInteger(this);
|
||||
}
|
||||
|
||||
int operator >>(int other) {
|
||||
return other._toBigintOrDouble()._shrFromInt(this);
|
||||
}
|
||||
|
||||
int operator <<(int other) {
|
||||
return other._toBigintOrDouble()._shlFromInt(this);
|
||||
}
|
||||
|
@ -1307,16 +1329,16 @@ class _Bigint extends _IntegerImplementation implements int {
|
|||
if (_used == 0) return "0";
|
||||
assert(radix & (radix - 1) == 0);
|
||||
final bitsPerChar = radix.bitLength - 1;
|
||||
final firstcx = _neg ? 1 : 0; // Index of first char in str after the sign.
|
||||
final lastdx = _used - 1; // Index of last digit in bigint.
|
||||
final bitLength = lastdx*_DIGIT_BITS + _nbits(_digits[lastdx]);
|
||||
final firstcx = _neg ? 1 : 0; // Index of first char in str after the sign.
|
||||
final lastdx = _used - 1; // Index of last digit in bigint.
|
||||
final bitLength = lastdx * _DIGIT_BITS + _nbits(_digits[lastdx]);
|
||||
// Index of char in str. Initialize with str length.
|
||||
var cx = firstcx + (bitLength + bitsPerChar - 1) ~/ bitsPerChar;
|
||||
_OneByteString str = _OneByteString._allocate(cx);
|
||||
str._setAt(0, 0x2d); // '-'. Is overwritten if not negative.
|
||||
str._setAt(0, 0x2d); // '-'. Is overwritten if not negative.
|
||||
final mask = radix - 1;
|
||||
var dx = 0; // Digit index in bigint.
|
||||
var bx = 0; // Bit index in bigint digit.
|
||||
var dx = 0; // Digit index in bigint.
|
||||
var bx = 0; // Bit index in bigint digit.
|
||||
do {
|
||||
var ch;
|
||||
if (bx > (_DIGIT_BITS - bitsPerChar)) {
|
||||
|
@ -1343,27 +1365,34 @@ class _Bigint extends _IntegerImplementation implements int {
|
|||
int _bitAndFromInteger(int other) {
|
||||
return other._toBigint()._and(this)._toValidInt();
|
||||
}
|
||||
|
||||
int _bitOrFromInteger(int other) {
|
||||
return other._toBigint()._or(this)._toValidInt();
|
||||
}
|
||||
|
||||
int _bitXorFromInteger(int other) {
|
||||
return other._toBigint()._xor(this)._toValidInt();
|
||||
}
|
||||
|
||||
int _addFromInteger(int other) {
|
||||
return other._toBigint()._add(this)._toValidInt();
|
||||
}
|
||||
|
||||
int _subFromInteger(int other) {
|
||||
return other._toBigint()._sub(this)._toValidInt();
|
||||
}
|
||||
|
||||
int _mulFromInteger(int other) {
|
||||
return other._toBigint()._mul(this)._toValidInt();
|
||||
}
|
||||
|
||||
int _truncDivFromInteger(int other) {
|
||||
if (_used == 0) {
|
||||
throw const IntegerDivisionByZeroException();
|
||||
}
|
||||
return other._toBigint()._div(this)._toValidInt();
|
||||
}
|
||||
|
||||
int _moduloFromInteger(int other) {
|
||||
if (_used == 0) {
|
||||
throw const IntegerDivisionByZeroException();
|
||||
|
@ -1378,15 +1407,18 @@ class _Bigint extends _IntegerImplementation implements int {
|
|||
}
|
||||
return result._toValidInt();
|
||||
}
|
||||
|
||||
int _remainderFromInteger(int other) {
|
||||
if (_used == 0) {
|
||||
throw const IntegerDivisionByZeroException();
|
||||
}
|
||||
return other._toBigint()._rem(this)._toValidInt();
|
||||
}
|
||||
|
||||
bool _greaterThanFromInteger(int other) {
|
||||
return other._toBigint()._compare(this) > 0;
|
||||
}
|
||||
|
||||
bool _equalToInteger(int other) {
|
||||
return other._toBigint()._compare(this) == 0;
|
||||
}
|
||||
|
@ -1409,8 +1441,9 @@ class _Bigint extends _IntegerImplementation implements int {
|
|||
if (e_bitlen <= 0) return 1;
|
||||
final bool cannotUseMontgomery = m.isEven || _abs() >= m;
|
||||
if (cannotUseMontgomery || e_bitlen < 64) {
|
||||
_Reduction z = (cannotUseMontgomery || e_bitlen < 8) ?
|
||||
new _Classic(m) : new _Montgomery(m);
|
||||
_Reduction z = (cannotUseMontgomery || e_bitlen < 8)
|
||||
? new _Classic(m)
|
||||
: new _Montgomery(m);
|
||||
// TODO(regis): Should we use Barrett reduction for an even modulus and a
|
||||
// large exponent?
|
||||
var r_digits = new Uint32List(m_used2p4);
|
||||
|
@ -1418,7 +1451,7 @@ class _Bigint extends _IntegerImplementation implements int {
|
|||
var g_digits = new Uint32List(m_used + (m_used & 1));
|
||||
var g_used = z._convert(this, g_digits);
|
||||
// Initialize r with g.
|
||||
var j = g_used + (g_used & 1); // Copy leading zero if any.
|
||||
var j = g_used + (g_used & 1); // Copy leading zero if any.
|
||||
while (--j >= 0) {
|
||||
r_digits[j] = g_digits[j];
|
||||
}
|
||||
|
@ -1442,11 +1475,16 @@ class _Bigint extends _IntegerImplementation implements int {
|
|||
}
|
||||
e = e._toBigint();
|
||||
var k;
|
||||
if (e_bitlen < 18) k = 1;
|
||||
else if (e_bitlen < 48) k = 3;
|
||||
else if (e_bitlen < 144) k = 4;
|
||||
else if (e_bitlen < 768) k = 5;
|
||||
else k = 6;
|
||||
if (e_bitlen < 18)
|
||||
k = 1;
|
||||
else if (e_bitlen < 48)
|
||||
k = 3;
|
||||
else if (e_bitlen < 144)
|
||||
k = 4;
|
||||
else if (e_bitlen < 768)
|
||||
k = 5;
|
||||
else
|
||||
k = 6;
|
||||
_Reduction z = new _Montgomery(m);
|
||||
var n = 3;
|
||||
final k1 = k - 1;
|
||||
|
@ -1460,9 +1498,8 @@ class _Bigint extends _IntegerImplementation implements int {
|
|||
var g2_used = z._sqr(g_digits[1], g_used[1], g2_digits);
|
||||
while (n <= km) {
|
||||
g_digits[n] = new Uint32List(m_used2p4);
|
||||
g_used[n] = z._mul(g2_digits, g2_used,
|
||||
g_digits[n - 2], g_used[n - 2],
|
||||
g_digits[n]);
|
||||
g_used[n] = z._mul(
|
||||
g2_digits, g2_used, g_digits[n - 2], g_used[n - 2], g_digits[n]);
|
||||
n += 2;
|
||||
}
|
||||
}
|
||||
|
@ -1493,17 +1530,17 @@ class _Bigint extends _IntegerImplementation implements int {
|
|||
i += _DIGIT_BITS;
|
||||
--j;
|
||||
}
|
||||
if (is1) { // r == 1, don't bother squaring or multiplying it.
|
||||
if (is1) {
|
||||
// r == 1, don't bother squaring or multiplying it.
|
||||
r_digits = new Uint32List(m_used2p4);
|
||||
r_used = g_used[w];
|
||||
var gw_digits = g_digits[w];
|
||||
var ri = r_used + (r_used & 1); // Copy leading zero if any.
|
||||
var ri = r_used + (r_used & 1); // Copy leading zero if any.
|
||||
while (--ri >= 0) {
|
||||
r_digits[ri] = gw_digits[ri];
|
||||
}
|
||||
is1 = false;
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
while (n > 1) {
|
||||
r2_used = z._sqr(r_digits, r_used, r2_digits);
|
||||
r_used = z._sqr(r2_digits, r2_used, r_digits);
|
||||
|
@ -1588,12 +1625,12 @@ class _Bigint extends _IntegerImplementation implements int {
|
|||
}
|
||||
}
|
||||
var u_digits = _cloneDigits(x_digits, 0, x_used, m_len);
|
||||
var v_digits = _cloneDigits(y_digits, 0, y_used, m_len + 2); // +2 for lsh.
|
||||
var v_digits = _cloneDigits(y_digits, 0, y_used, m_len + 2); // +2 for lsh.
|
||||
final bool ac = (x_digits[0] & 1) == 0;
|
||||
|
||||
// Variables a, b, c, and d require one more digit.
|
||||
final abcd_used = m_used + 1;
|
||||
final abcd_len = abcd_used + (abcd_used & 1) + 2; // +2 to satisfy _absAdd.
|
||||
final abcd_len = abcd_used + (abcd_used & 1) + 2; // +2 to satisfy _absAdd.
|
||||
var a_digits, b_digits, c_digits, d_digits;
|
||||
bool a_neg, b_neg, c_neg, d_neg;
|
||||
if (ac) {
|
||||
|
@ -1640,7 +1677,7 @@ class _Bigint extends _IntegerImplementation implements int {
|
|||
if (b_neg) {
|
||||
_absAdd(b_digits, abcd_used, x_digits, m_used, b_digits);
|
||||
} else if ((b_digits[m_used] != 0) ||
|
||||
(_compareDigits(b_digits, m_used, x_digits, m_used) > 0)) {
|
||||
(_compareDigits(b_digits, m_used, x_digits, m_used) > 0)) {
|
||||
_absSub(b_digits, abcd_used, x_digits, m_used, b_digits);
|
||||
} else {
|
||||
_absSub(x_digits, m_used, b_digits, m_used, b_digits);
|
||||
|
@ -1679,7 +1716,7 @@ class _Bigint extends _IntegerImplementation implements int {
|
|||
if (d_neg) {
|
||||
_absAdd(d_digits, abcd_used, x_digits, m_used, d_digits);
|
||||
} else if ((d_digits[m_used] != 0) ||
|
||||
(_compareDigits(d_digits, m_used, x_digits, m_used) > 0)) {
|
||||
(_compareDigits(d_digits, m_used, x_digits, m_used) > 0)) {
|
||||
_absSub(d_digits, abcd_used, x_digits, m_used, d_digits);
|
||||
} else {
|
||||
_absSub(x_digits, m_used, d_digits, m_used, d_digits);
|
||||
|
@ -1779,7 +1816,7 @@ class _Bigint extends _IntegerImplementation implements int {
|
|||
d_neg = false;
|
||||
}
|
||||
} else if ((d_digits[m_used] != 0) ||
|
||||
(_compareDigits(d_digits, m_used, x_digits, m_used) > 0)) {
|
||||
(_compareDigits(d_digits, m_used, x_digits, m_used) > 0)) {
|
||||
_absSub(d_digits, abcd_used, x_digits, m_used, d_digits);
|
||||
if ((d_digits[m_used] != 0) ||
|
||||
(_compareDigits(d_digits, m_used, x_digits, m_used) > 0)) {
|
||||
|
@ -1821,8 +1858,8 @@ class _Bigint extends _IntegerImplementation implements int {
|
|||
class _Reduction {
|
||||
// Return the number of digits used by r_digits.
|
||||
int _convert(_Bigint x, Uint32List r_digits);
|
||||
int _mul(Uint32List x_digits, int x_used,
|
||||
Uint32List y_digits, int y_used, Uint32List r_digits);
|
||||
int _mul(Uint32List x_digits, int x_used, Uint32List y_digits, int y_used,
|
||||
Uint32List r_digits);
|
||||
int _sqr(Uint32List x_digits, int x_used, Uint32List r_digits);
|
||||
|
||||
// Return x reverted to _Bigint.
|
||||
|
@ -1831,20 +1868,20 @@ class _Reduction {
|
|||
|
||||
// Montgomery reduction on _Bigint.
|
||||
class _Montgomery implements _Reduction {
|
||||
_Bigint _m; // Modulus.
|
||||
_Bigint _m; // Modulus.
|
||||
int _mused2p2;
|
||||
Uint32List _args;
|
||||
int _digits_per_step; // Number of digits processed in one step. 1 or 2.
|
||||
static const int _X = 0; // Index of x.
|
||||
static const int _X_HI = 1; // Index of high 32-bits of x (64-bit only).
|
||||
static const int _RHO = 2; // Index of rho.
|
||||
static const int _RHO_HI = 3; // Index of high 32-bits of rho (64-bit only).
|
||||
static const int _MU = 4; // Index of mu.
|
||||
static const int _MU_HI = 5; // Index of high 32-bits of mu (64-bit only).
|
||||
int _digits_per_step; // Number of digits processed in one step. 1 or 2.
|
||||
static const int _X = 0; // Index of x.
|
||||
static const int _X_HI = 1; // Index of high 32-bits of x (64-bit only).
|
||||
static const int _RHO = 2; // Index of rho.
|
||||
static const int _RHO_HI = 3; // Index of high 32-bits of rho (64-bit only).
|
||||
static const int _MU = 4; // Index of mu.
|
||||
static const int _MU_HI = 5; // Index of high 32-bits of mu (64-bit only).
|
||||
|
||||
_Montgomery(m) {
|
||||
_m = m._toBigint();
|
||||
_mused2p2 = 2*_m._used + 2;
|
||||
_mused2p2 = 2 * _m._used + 2;
|
||||
_args = new Uint32List(6);
|
||||
// Determine if we can process digit pairs by calling an intrinsic.
|
||||
_digits_per_step = _mulMod(_args, _args, 0);
|
||||
|
@ -1871,15 +1908,15 @@ class _Montgomery implements _Reduction {
|
|||
// args[_RHO] = 1/args[_X] mod _DIGIT_BASE.
|
||||
static void _invDigit(Uint32List args) {
|
||||
var x = args[_X];
|
||||
var y = x & 3; // y == 1/x mod 2^2
|
||||
y = (y*(2 - (x & 0xf)*y)) & 0xf; // y == 1/x mod 2^4
|
||||
y = (y*(2 - (x & 0xff)*y)) & 0xff; // y == 1/x mod 2^8
|
||||
y = (y*(2 - (((x & 0xffff)*y) & 0xffff))) & 0xffff; // y == 1/x mod 2^16
|
||||
var y = x & 3; // y == 1/x mod 2^2
|
||||
y = (y * (2 - (x & 0xf) * y)) & 0xf; // y == 1/x mod 2^4
|
||||
y = (y * (2 - (x & 0xff) * y)) & 0xff; // y == 1/x mod 2^8
|
||||
y = (y * (2 - (((x & 0xffff) * y) & 0xffff))) & 0xffff; // y == 1/x mod 2^16
|
||||
// Last step - calculate inverse mod _DIGIT_BASE directly;
|
||||
// Assumes 16 < _DIGIT_BITS <= 32 and assumes ability to handle 48-bit ints.
|
||||
y = (y*(2 - x*y % _Bigint._DIGIT_BASE)) % _Bigint._DIGIT_BASE;
|
||||
y = (y * (2 - x * y % _Bigint._DIGIT_BASE)) % _Bigint._DIGIT_BASE;
|
||||
// y == 1/x mod _DIGIT_BASE
|
||||
y = -y; // We really want the negative inverse.
|
||||
y = -y; // We really want the negative inverse.
|
||||
args[_RHO] = y & _Bigint._DIGIT_MASK;
|
||||
}
|
||||
|
||||
|
@ -1887,16 +1924,17 @@ class _Montgomery implements _Reduction {
|
|||
// Operation:
|
||||
// args[_RHO.._RHO_HI] = 1/args[_X.._X_HI] mod _DIGIT_BASE^2.
|
||||
static void _invDigitPair(Uint32List args) {
|
||||
var xl = args[_X]; // Lower 32-bit digit of x.
|
||||
var y = xl & 3; // y == 1/x mod 2^2
|
||||
y = (y*(2 - (xl & 0xf)*y)) & 0xf; // y == 1/x mod 2^4
|
||||
y = (y*(2 - (xl & 0xff)*y)) & 0xff; // y == 1/x mod 2^8
|
||||
y = (y*(2 - (((xl & 0xffff)*y) & 0xffff))) & 0xffff; // y == 1/x mod 2^16
|
||||
y = (y*(2 - ((xl*y) & 0xffffffff))) & 0xffffffff; // y == 1/x mod 2^32
|
||||
var xl = args[_X]; // Lower 32-bit digit of x.
|
||||
var y = xl & 3; // y == 1/x mod 2^2
|
||||
y = (y * (2 - (xl & 0xf) * y)) & 0xf; // y == 1/x mod 2^4
|
||||
y = (y * (2 - (xl & 0xff) * y)) & 0xff; // y == 1/x mod 2^8
|
||||
y = (y * (2 - (((xl & 0xffff) * y) & 0xffff))) &
|
||||
0xffff; // y == 1/x mod 2^16
|
||||
y = (y * (2 - ((xl * y) & 0xffffffff))) & 0xffffffff; // y == 1/x mod 2^32
|
||||
var x = (args[_X_HI] << _Bigint._DIGIT_BITS) | xl;
|
||||
y = (y*(2 - ((x*y) & 0xffffffffffffffff))) & 0xffffffffffffffff;
|
||||
y = (y * (2 - ((x * y) & 0xffffffffffffffff))) & 0xffffffffffffffff;
|
||||
// y == 1/x mod _DIGIT_BASE^2
|
||||
y = -y; // We really want the negative inverse.
|
||||
y = -y; // We really want the negative inverse.
|
||||
args[_RHO] = y & _Bigint._DIGIT_MASK;
|
||||
args[_RHO_HI] = (y >> _Bigint._DIGIT_BITS) & _Bigint._DIGIT_MASK;
|
||||
}
|
||||
|
@ -1915,9 +1953,9 @@ class _Montgomery implements _Reduction {
|
|||
var rhoh = args[_RHO] >> _Bigint._DIGIT2_BITS;
|
||||
var dh = digits[i] >> _Bigint._DIGIT2_BITS;
|
||||
var dl = digits[i] & _Bigint._DIGIT2_MASK;
|
||||
args[_MU] =
|
||||
(dl*rhol + (((dl*rhoh + dh*rhol) & MU_MASK) << _Bigint._DIGIT2_BITS))
|
||||
& _Bigint._DIGIT_MASK;
|
||||
args[_MU] = (dl * rhol +
|
||||
(((dl * rhoh + dh * rhol) & MU_MASK) << _Bigint._DIGIT2_BITS)) &
|
||||
_Bigint._DIGIT_MASK;
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
@ -1952,7 +1990,8 @@ class _Montgomery implements _Reduction {
|
|||
// x = x/R mod _m.
|
||||
// Return x_used.
|
||||
int _reduce(Uint32List x_digits, int x_used) {
|
||||
while (x_used < _mused2p2) { // Pad x so _mulAdd has enough room later.
|
||||
while (x_used < _mused2p2) {
|
||||
// Pad x so _mulAdd has enough room later.
|
||||
x_digits[x_used++] = 0;
|
||||
}
|
||||
var m_used = _m._used;
|
||||
|
@ -1986,25 +2025,23 @@ class _Montgomery implements _Reduction {
|
|||
return _reduce(r_digits, r_used);
|
||||
}
|
||||
|
||||
int _mul(Uint32List x_digits, int x_used,
|
||||
Uint32List y_digits, int y_used,
|
||||
Uint32List r_digits) {
|
||||
var r_used = _Bigint._mulDigits(x_digits, x_used,
|
||||
y_digits, y_used,
|
||||
r_digits);
|
||||
int _mul(Uint32List x_digits, int x_used, Uint32List y_digits, int y_used,
|
||||
Uint32List r_digits) {
|
||||
var r_used =
|
||||
_Bigint._mulDigits(x_digits, x_used, y_digits, y_used, r_digits);
|
||||
return _reduce(r_digits, r_used);
|
||||
}
|
||||
}
|
||||
|
||||
// Modular reduction using "classic" algorithm.
|
||||
class _Classic implements _Reduction {
|
||||
_Bigint _m; // Modulus.
|
||||
_Bigint _norm_m; // Normalized _m.
|
||||
Uint32List _neg_norm_m_digits; // Negated _norm_m digits.
|
||||
int _m_nsh; // Normalization shift amount.
|
||||
Uint32List _mt_qd; // Top _norm_m digit(s) and place holder for
|
||||
// estimated quotient digit(s).
|
||||
Uint32List _t_digits; // Temporary digits used during reduction.
|
||||
_Bigint _m; // Modulus.
|
||||
_Bigint _norm_m; // Normalized _m.
|
||||
Uint32List _neg_norm_m_digits; // Negated _norm_m digits.
|
||||
int _m_nsh; // Normalization shift amount.
|
||||
Uint32List _mt_qd; // Top _norm_m digit(s) and place holder for
|
||||
// estimated quotient digit(s).
|
||||
Uint32List _t_digits; // Temporary digits used during reduction.
|
||||
|
||||
_Classic(int m) {
|
||||
_m = m._toBigint();
|
||||
|
@ -2033,7 +2070,7 @@ class _Classic implements _Reduction {
|
|||
// _neg_norm_m_digits is read-only and has nm_used digits (possibly
|
||||
// including several leading zeros) plus a leading zero for 64-bit
|
||||
// processing.
|
||||
_t_digits = new Uint32List(2*nm_used);
|
||||
_t_digits = new Uint32List(2 * nm_used);
|
||||
}
|
||||
|
||||
int _convert(_Bigint x, Uint32List r_digits) {
|
||||
|
@ -2051,7 +2088,7 @@ class _Classic implements _Reduction {
|
|||
used = x._used;
|
||||
digits = x._digits;
|
||||
}
|
||||
var i = used + (used & 1); // Copy leading zero if any.
|
||||
var i = used + (used & 1); // Copy leading zero if any.
|
||||
while (--i >= 0) {
|
||||
r_digits[i] = digits[i];
|
||||
}
|
||||
|
@ -2068,13 +2105,8 @@ class _Classic implements _Reduction {
|
|||
}
|
||||
// The function _remDigits(...) is optimized for reduction and equivalent to
|
||||
// calling _convert(_revert(x_digits, x_used)._rem(_m), x_digits);
|
||||
return _Bigint._remDigits(x_digits, x_used,
|
||||
_norm_m._digits, _norm_m._used,
|
||||
_neg_norm_m_digits,
|
||||
_m_nsh,
|
||||
_mt_qd,
|
||||
_t_digits,
|
||||
x_digits);
|
||||
return _Bigint._remDigits(x_digits, x_used, _norm_m._digits, _norm_m._used,
|
||||
_neg_norm_m_digits, _m_nsh, _mt_qd, _t_digits, x_digits);
|
||||
}
|
||||
|
||||
int _sqr(Uint32List x_digits, int x_used, Uint32List r_digits) {
|
||||
|
@ -2082,12 +2114,10 @@ class _Classic implements _Reduction {
|
|||
return _reduce(r_digits, r_used);
|
||||
}
|
||||
|
||||
int _mul(Uint32List x_digits, int x_used,
|
||||
Uint32List y_digits, int y_used,
|
||||
Uint32List r_digits) {
|
||||
var r_used = _Bigint._mulDigits(x_digits, x_used,
|
||||
y_digits, y_used,
|
||||
r_digits);
|
||||
int _mul(Uint32List x_digits, int x_used, Uint32List y_digits, int y_used,
|
||||
Uint32List r_digits) {
|
||||
var r_used =
|
||||
_Bigint._mulDigits(x_digits, x_used, y_digits, y_used, r_digits);
|
||||
return _reduce(r_digits, r_used);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4,10 +4,10 @@
|
|||
|
||||
// Dart core library.
|
||||
|
||||
@patch class bool {
|
||||
|
||||
@patch const factory bool.fromEnvironment(String name,
|
||||
{bool defaultValue: false})
|
||||
@patch
|
||||
class bool {
|
||||
@patch
|
||||
const factory bool.fromEnvironment(String name, {bool defaultValue: false})
|
||||
native "Bool_fromEnvironment";
|
||||
|
||||
@patch
|
||||
|
|
|
@ -5,10 +5,13 @@
|
|||
import 'dart:typed_data';
|
||||
import 'dart:_internal' as internal;
|
||||
|
||||
@patch class HashMap<K, V> {
|
||||
@patch factory HashMap({ bool equals(K key1, K key2),
|
||||
int hashCode(K key),
|
||||
bool isValidKey(potentialKey) }) {
|
||||
@patch
|
||||
class HashMap<K, V> {
|
||||
@patch
|
||||
factory HashMap(
|
||||
{bool equals(K key1, K key2),
|
||||
int hashCode(K key),
|
||||
bool isValidKey(potentialKey)}) {
|
||||
if (isValidKey == null) {
|
||||
if (hashCode == null) {
|
||||
if (equals == null) {
|
||||
|
@ -35,18 +38,17 @@ import 'dart:_internal' as internal;
|
|||
return new _CustomHashMap<K, V>(equals, hashCode, isValidKey);
|
||||
}
|
||||
|
||||
@patch factory HashMap.identity() = _IdentityHashMap<K, V>;
|
||||
@patch
|
||||
factory HashMap.identity() = _IdentityHashMap<K, V>;
|
||||
|
||||
Set<K> _newKeySet();
|
||||
}
|
||||
|
||||
|
||||
const int _MODIFICATION_COUNT_MASK = 0x3fffffff;
|
||||
|
||||
class _HashMap<K, V> implements HashMap<K, V> {
|
||||
static const int _INITIAL_CAPACITY = 8;
|
||||
|
||||
|
||||
int _elementCount = 0;
|
||||
List<_HashMapEntry> _buckets = new List(_INITIAL_CAPACITY);
|
||||
int _modificationCount = 0;
|
||||
|
@ -83,7 +85,7 @@ class _HashMap<K, V> implements HashMap<K, V> {
|
|||
return false;
|
||||
}
|
||||
|
||||
V operator[](Object key) {
|
||||
V operator [](Object key) {
|
||||
int hashCode = key.hashCode;
|
||||
List buckets = _buckets;
|
||||
int index = hashCode & (buckets.length - 1);
|
||||
|
@ -186,9 +188,8 @@ class _HashMap<K, V> implements HashMap<K, V> {
|
|||
}
|
||||
}
|
||||
|
||||
void _removeEntry(_HashMapEntry entry,
|
||||
_HashMapEntry previousInBucket,
|
||||
int bucketIndex) {
|
||||
void _removeEntry(
|
||||
_HashMapEntry entry, _HashMapEntry previousInBucket, int bucketIndex) {
|
||||
if (previousInBucket == null) {
|
||||
_buckets[bucketIndex] = entry.next;
|
||||
} else {
|
||||
|
@ -196,8 +197,8 @@ class _HashMap<K, V> implements HashMap<K, V> {
|
|||
}
|
||||
}
|
||||
|
||||
void _addEntry(List buckets, int index, int length,
|
||||
K key, V value, int hashCode) {
|
||||
void _addEntry(
|
||||
List buckets, int index, int length, K key, V value, int hashCode) {
|
||||
_HashMapEntry entry =
|
||||
new _HashMapEntry(key, value, hashCode, buckets[index]);
|
||||
buckets[index] = entry;
|
||||
|
@ -240,7 +241,6 @@ class _CustomHashMap<K, V> extends _HashMap<K, V> {
|
|||
_CustomHashMap(this._equals, this._hashCode, validKey)
|
||||
: _validKey = (validKey != null) ? validKey : new _TypeTest<K>().test;
|
||||
|
||||
|
||||
bool containsKey(Object key) {
|
||||
if (!_validKey(key)) return false;
|
||||
int hashCode = _hashCode(key);
|
||||
|
@ -254,7 +254,7 @@ class _CustomHashMap<K, V> extends _HashMap<K, V> {
|
|||
return false;
|
||||
}
|
||||
|
||||
V operator[](Object key) {
|
||||
V operator [](Object key) {
|
||||
if (!_validKey(key)) return null;
|
||||
int hashCode = _hashCode(key);
|
||||
List buckets = _buckets;
|
||||
|
@ -335,7 +335,6 @@ class _CustomHashMap<K, V> extends _HashMap<K, V> {
|
|||
}
|
||||
|
||||
class _IdentityHashMap<K, V> extends _HashMap<K, V> {
|
||||
|
||||
bool containsKey(Object key) {
|
||||
int hashCode = identityHashCode(key);
|
||||
List buckets = _buckets;
|
||||
|
@ -348,7 +347,7 @@ class _IdentityHashMap<K, V> extends _HashMap<K, V> {
|
|||
return false;
|
||||
}
|
||||
|
||||
V operator[](Object key) {
|
||||
V operator [](Object key) {
|
||||
int hashCode = identityHashCode(key);
|
||||
List buckets = _buckets;
|
||||
int index = hashCode & (buckets.length - 1);
|
||||
|
@ -426,7 +425,6 @@ class _IdentityHashMap<K, V> extends _HashMap<K, V> {
|
|||
Set<K> _newKeySet() => new _IdentityHashSet<K>();
|
||||
}
|
||||
|
||||
|
||||
class _HashMapEntry {
|
||||
final key;
|
||||
var value;
|
||||
|
@ -452,6 +450,7 @@ class _HashMapKeyIterable<K> extends _HashMapIterable<K> {
|
|||
action(key);
|
||||
});
|
||||
}
|
||||
|
||||
Set<K> toSet() => _map._newKeySet()..addAll(this);
|
||||
}
|
||||
|
||||
|
@ -474,7 +473,8 @@ abstract class _HashMapIterator<E> implements Iterator<E> {
|
|||
_HashMapEntry _entry;
|
||||
|
||||
_HashMapIterator(HashMap map)
|
||||
: _map = map, _stamp = map._modificationCount;
|
||||
: _map = map,
|
||||
_stamp = map._modificationCount;
|
||||
|
||||
bool moveNext() {
|
||||
if (_stamp != _map._modificationCount) {
|
||||
|
@ -520,10 +520,13 @@ class _HashMapValueIterator<V> extends _HashMapIterator<V> {
|
|||
}
|
||||
}
|
||||
|
||||
@patch class HashSet<E> {
|
||||
@patch factory HashSet({ bool equals(E e1, E e2),
|
||||
int hashCode(E e),
|
||||
bool isValidKey(potentialKey) }) {
|
||||
@patch
|
||||
class HashSet<E> {
|
||||
@patch
|
||||
factory HashSet(
|
||||
{bool equals(E e1, E e2),
|
||||
int hashCode(E e),
|
||||
bool isValidKey(potentialKey)}) {
|
||||
if (isValidKey == null) {
|
||||
if (hashCode == null) {
|
||||
if (equals == null) {
|
||||
|
@ -550,7 +553,8 @@ class _HashMapValueIterator<V> extends _HashMapIterator<V> {
|
|||
return new _CustomHashSet<E>(equals, hashCode, isValidKey);
|
||||
}
|
||||
|
||||
@patch factory HashSet.identity() = _IdentityHashSet<E>;
|
||||
@patch
|
||||
factory HashSet.identity() = _IdentityHashSet<E>;
|
||||
}
|
||||
|
||||
class _HashSet<E> extends _HashSetBase<E> implements HashSet<E> {
|
||||
|
@ -649,7 +653,7 @@ class _HashSet<E> extends _HashSetBase<E> implements HashSet<E> {
|
|||
|
||||
void _filterWhere(bool test(E element), bool removeMatching) {
|
||||
int length = _buckets.length;
|
||||
for (int index = 0; index < length; index++) {
|
||||
for (int index = 0; index < length; index++) {
|
||||
_HashSetEntry entry = _buckets[index];
|
||||
_HashSetEntry previous = null;
|
||||
while (entry != null) {
|
||||
|
@ -795,7 +799,8 @@ class _HashSetIterator<E> implements Iterator<E> {
|
|||
E _current;
|
||||
|
||||
_HashSetIterator(_HashSet hashSet)
|
||||
: _set = hashSet, _modificationCount = hashSet._modificationCount;
|
||||
: _set = hashSet,
|
||||
_modificationCount = hashSet._modificationCount;
|
||||
|
||||
bool moveNext() {
|
||||
if (_modificationCount != _set._modificationCount) {
|
||||
|
@ -830,7 +835,7 @@ class _LinkedHashMapEntry extends _HashMapEntry {
|
|||
var _nextEntry;
|
||||
var _previousEntry;
|
||||
_LinkedHashMapEntry(key, value, int hashCode, _LinkedHashMapEntry next,
|
||||
this._previousEntry, this._nextEntry)
|
||||
this._previousEntry, this._nextEntry)
|
||||
: super(key, value, hashCode, next) {
|
||||
_previousEntry._nextEntry = this;
|
||||
_nextEntry._previousEntry = this;
|
||||
|
@ -897,11 +902,11 @@ class _LinkedHashMapValueIterator<V> extends _LinkedHashMapIterator<V> {
|
|||
V _getValue(_LinkedHashMapEntry entry) => entry.value;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* A hash-based map that iterates keys and values in key insertion order.
|
||||
*/
|
||||
@patch class LinkedHashMap<K, V> {
|
||||
@patch
|
||||
class LinkedHashMap<K, V> {
|
||||
/// Holds a double-linked list of entries in insertion order.
|
||||
/// The fields have the same name as the ones in [_LinkedHashMapEntry],
|
||||
/// and this map is itself used as the head entry of the list.
|
||||
|
@ -910,9 +915,11 @@ class _LinkedHashMapValueIterator<V> extends _LinkedHashMapIterator<V> {
|
|||
var _nextEntry;
|
||||
var _previousEntry;
|
||||
|
||||
@patch factory LinkedHashMap({ bool equals(K key1, K key2),
|
||||
int hashCode(K key),
|
||||
bool isValidKey(potentialKey) }) {
|
||||
@patch
|
||||
factory LinkedHashMap(
|
||||
{bool equals(K key1, K key2),
|
||||
int hashCode(K key),
|
||||
bool isValidKey(potentialKey)}) {
|
||||
if (isValidKey == null) {
|
||||
if (hashCode == null) {
|
||||
if (equals == null) {
|
||||
|
@ -939,14 +946,17 @@ class _LinkedHashMapValueIterator<V> extends _LinkedHashMapIterator<V> {
|
|||
return new _CompactLinkedCustomHashMap<K, V>(equals, hashCode, isValidKey);
|
||||
}
|
||||
|
||||
@patch factory LinkedHashMap.identity() =
|
||||
_CompactLinkedIdentityHashMap<K, V>;
|
||||
@patch
|
||||
factory LinkedHashMap.identity() = _CompactLinkedIdentityHashMap<K, V>;
|
||||
}
|
||||
|
||||
@patch class LinkedHashSet<E> {
|
||||
@patch factory LinkedHashSet({ bool equals(E e1, E e2),
|
||||
int hashCode(E e),
|
||||
bool isValidKey(potentialKey) }) {
|
||||
@patch
|
||||
class LinkedHashSet<E> {
|
||||
@patch
|
||||
factory LinkedHashSet(
|
||||
{bool equals(E e1, E e2),
|
||||
int hashCode(E e),
|
||||
bool isValidKey(potentialKey)}) {
|
||||
if (isValidKey == null) {
|
||||
if (hashCode == null) {
|
||||
if (equals == null) {
|
||||
|
@ -973,6 +983,6 @@ class _LinkedHashMapValueIterator<V> extends _LinkedHashMapIterator<V> {
|
|||
return new _CompactLinkedCustomHashSet<E>(equals, hashCode, isValidKey);
|
||||
}
|
||||
|
||||
@patch factory LinkedHashSet.identity() =
|
||||
_CompactLinkedIdentityHashSet<E>;
|
||||
@patch
|
||||
factory LinkedHashSet.identity() = _CompactLinkedIdentityHashSet<E>;
|
||||
}
|
||||
|
|
|
@ -18,7 +18,7 @@ abstract class _HashFieldBase {
|
|||
// TODO(koda): Consider also using null _index for tiny, linear-search tables.
|
||||
Uint32List _index = new Uint32List(_HashBase._INITIAL_INDEX_SIZE);
|
||||
|
||||
// Cached in-place mask for the hash pattern component.
|
||||
// Cached in-place mask for the hash pattern component.
|
||||
int _hashMask = _HashBase._indexSizeToHashMask(_HashBase._INITIAL_INDEX_SIZE);
|
||||
|
||||
// Fixed-length list of keys (set) or key/value at even/odd indices (map).
|
||||
|
@ -63,10 +63,10 @@ abstract class _HashBase {
|
|||
// The length of _index is twice the number of entries in _data, and both
|
||||
// are doubled when _data is full. Thus, _index will have a max load factor
|
||||
// of 1/2, which enables one more bit to be used for the hash.
|
||||
// TODO(koda): Consider growing _data by factor sqrt(2), twice as often.
|
||||
// TODO(koda): Consider growing _data by factor sqrt(2), twice as often.
|
||||
static const int _INITIAL_INDEX_BITS = 3;
|
||||
static const int _INITIAL_INDEX_SIZE = 1 << (_INITIAL_INDEX_BITS + 1);
|
||||
|
||||
|
||||
// Unused and deleted entries are marked by 0 and 1, respectively.
|
||||
static const int _UNUSED_PAIR = 0;
|
||||
static const int _DELETED_PAIR = 1;
|
||||
|
@ -76,8 +76,9 @@ abstract class _HashBase {
|
|||
// as unsigned words.
|
||||
static int _indexSizeToHashMask(int indexSize) {
|
||||
int indexBits = indexSize.bitLength - 2;
|
||||
return internal.is64Bit ? (1 << (32 - indexBits)) - 1 :
|
||||
(1 << (30 - indexBits)) - 1;
|
||||
return internal.is64Bit
|
||||
? (1 << (32 - indexBits)) - 1
|
||||
: (1 << (30 - indexBits)) - 1;
|
||||
}
|
||||
|
||||
static int _hashPattern(int fullHash, int hashMask, int size) {
|
||||
|
@ -92,8 +93,9 @@ abstract class _HashBase {
|
|||
// Light, fast shuffle to mitigate bad hashCode (e.g., sequential).
|
||||
return ((i << 1) + i) & sizeMask;
|
||||
}
|
||||
|
||||
static int _nextProbe(int i, int sizeMask) => (i + 1) & sizeMask;
|
||||
|
||||
|
||||
// A self-loop is used to mark a deleted key or value.
|
||||
static bool _isDeleted(List data, Object keyOrValue) =>
|
||||
identical(keyOrValue, data);
|
||||
|
@ -120,8 +122,11 @@ class _IdenticalAndIdentityHashCode {
|
|||
|
||||
// VM-internalized implementation of a default-constructed LinkedHashMap.
|
||||
class _InternalLinkedHashMap<K, V> extends _HashVMBase
|
||||
with MapMixin<K, V>, _LinkedHashMapMixin<K, V>, _HashBase,
|
||||
_OperatorEqualsAndHashCode
|
||||
with
|
||||
MapMixin<K, V>,
|
||||
_LinkedHashMapMixin<K, V>,
|
||||
_HashBase,
|
||||
_OperatorEqualsAndHashCode
|
||||
implements LinkedHashMap<K, V> {
|
||||
_InternalLinkedHashMap() {
|
||||
_index = new Uint32List(_HashBase._INITIAL_INDEX_SIZE);
|
||||
|
@ -132,7 +137,7 @@ class _InternalLinkedHashMap<K, V> extends _HashVMBase
|
|||
}
|
||||
}
|
||||
|
||||
class _LinkedHashMapMixin<K, V> {
|
||||
class _LinkedHashMapMixin<K, V> {
|
||||
int get length => (_usedData >> 1) - _deletedKeys;
|
||||
bool get isEmpty => length == 0;
|
||||
bool get isNotEmpty => !isEmpty;
|
||||
|
@ -147,7 +152,7 @@ class _LinkedHashMapMixin<K, V> {
|
|||
_init(_index.length << 1, _hashMask >> 1, _data, _usedData);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void clear() {
|
||||
if (!isEmpty) {
|
||||
// Use _data.length, since _index might be null.
|
||||
|
@ -192,13 +197,13 @@ class _LinkedHashMapMixin<K, V> {
|
|||
}
|
||||
return _index.length;
|
||||
}
|
||||
|
||||
|
||||
void _insert(K key, V value, int hashPattern, int i) {
|
||||
if (_usedData == _data.length) {
|
||||
_rehash();
|
||||
this[key] = value;
|
||||
} else {
|
||||
assert(1 <= hashPattern && hashPattern < (1 << 32));
|
||||
assert(1 <= hashPattern && hashPattern < (1 << 32));
|
||||
final int index = _usedData >> 1;
|
||||
assert((index & hashPattern) == 0);
|
||||
_index[i] = hashPattern | index;
|
||||
|
@ -206,7 +211,7 @@ class _LinkedHashMapMixin<K, V> {
|
|||
_data[_usedData++] = value;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// If key is present, returns the index of the value in _data, else returns
|
||||
// the negated insertion point in _index.
|
||||
int _findValueOrInsertPoint(K key, int fullHash, int hashPattern, int size) {
|
||||
|
@ -234,8 +239,8 @@ class _LinkedHashMapMixin<K, V> {
|
|||
}
|
||||
return firstDeleted >= 0 ? -firstDeleted : -i;
|
||||
}
|
||||
|
||||
void operator[]=(K key, V value) {
|
||||
|
||||
void operator []=(K key, V value) {
|
||||
final int size = _getIndexLength();
|
||||
final int sizeMask = size - 1;
|
||||
final int fullHash = _hashCode(key);
|
||||
|
@ -248,7 +253,7 @@ class _LinkedHashMapMixin<K, V> {
|
|||
_insert(key, value, hashPattern, i);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
V putIfAbsent(K key, V ifAbsent()) {
|
||||
final int size = _getIndexLength();
|
||||
final int sizeMask = size - 1;
|
||||
|
@ -271,7 +276,7 @@ class _LinkedHashMapMixin<K, V> {
|
|||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
|
||||
V remove(Object key) {
|
||||
final int size = _getIndexLength();
|
||||
final int sizeMask = size - 1;
|
||||
|
@ -300,7 +305,7 @@ class _LinkedHashMapMixin<K, V> {
|
|||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
// If key is absent, return _data (which is never a value).
|
||||
Object _getValueOrData(Object key) {
|
||||
final int size = _getIndexLength();
|
||||
|
@ -325,14 +330,14 @@ class _LinkedHashMapMixin<K, V> {
|
|||
}
|
||||
return _data;
|
||||
}
|
||||
|
||||
|
||||
bool containsKey(Object key) => !identical(_data, _getValueOrData(key));
|
||||
|
||||
V operator[](Object key) {
|
||||
|
||||
V operator [](Object key) {
|
||||
var v = _getValueOrData(key);
|
||||
return identical(_data, v) ? null : v;
|
||||
}
|
||||
|
||||
|
||||
bool containsValue(Object value) {
|
||||
for (var v in values) {
|
||||
// Spec. says this should always use "==", also for identity maps, etc.
|
||||
|
@ -359,10 +364,12 @@ class _LinkedHashMapMixin<K, V> {
|
|||
}
|
||||
|
||||
class _CompactLinkedIdentityHashMap<K, V> extends _HashFieldBase
|
||||
with MapMixin<K, V>, _LinkedHashMapMixin<K, V>, _HashBase,
|
||||
_IdenticalAndIdentityHashCode
|
||||
with
|
||||
MapMixin<K, V>,
|
||||
_LinkedHashMapMixin<K, V>,
|
||||
_HashBase,
|
||||
_IdenticalAndIdentityHashCode
|
||||
implements LinkedHashMap<K, V> {
|
||||
|
||||
_CompactLinkedIdentityHashMap() : super(_HashBase._INITIAL_INDEX_SIZE);
|
||||
}
|
||||
|
||||
|
@ -378,7 +385,7 @@ class _CompactLinkedCustomHashMap<K, V> extends _HashFieldBase
|
|||
bool _equals(e1, e2) => _equality(e1, e2);
|
||||
|
||||
bool containsKey(Object o) => _validKey(o) ? super.containsKey(o) : false;
|
||||
V operator[](Object o) => _validKey(o) ? super[o] : null;
|
||||
V operator [](Object o) => _validKey(o) ? super[o] : null;
|
||||
V remove(Object o) => _validKey(o) ? super.remove(o) : null;
|
||||
|
||||
_CompactLinkedCustomHashMap(this._equality, this._hasher, validKey)
|
||||
|
@ -395,8 +402,8 @@ class _CompactIterable<E> extends IterableBase<E> {
|
|||
final int _offset;
|
||||
final int _step;
|
||||
|
||||
_CompactIterable(this._table, this._data, this._len,
|
||||
this._offset, this._step);
|
||||
_CompactIterable(
|
||||
this._table, this._data, this._len, this._offset, this._step);
|
||||
|
||||
Iterator<E> get iterator =>
|
||||
new _CompactIterator<E>(_table, _data, _len, _offset, _step);
|
||||
|
@ -415,8 +422,9 @@ class _CompactIterator<E> implements Iterator<E> {
|
|||
final int _checkSum;
|
||||
E current;
|
||||
|
||||
_CompactIterator(table, this._data, this._len, this._offset, this._step) :
|
||||
_table = table, _checkSum = table._checkSum;
|
||||
_CompactIterator(table, this._data, this._len, this._offset, this._step)
|
||||
: _table = table,
|
||||
_checkSum = table._checkSum;
|
||||
|
||||
bool moveNext() {
|
||||
if (_table._isModifiedSince(_data, _checkSum)) {
|
||||
|
@ -439,7 +447,6 @@ class _CompactIterator<E> implements Iterator<E> {
|
|||
class _CompactLinkedHashSet<E> extends _HashFieldBase
|
||||
with _HashBase, _OperatorEqualsAndHashCode, SetMixin<E>
|
||||
implements LinkedHashSet<E> {
|
||||
|
||||
_CompactLinkedHashSet() : super(_HashBase._INITIAL_INDEX_SIZE >> 1) {
|
||||
assert(_HashBase._UNUSED_PAIR == 0);
|
||||
}
|
||||
|
@ -525,7 +532,7 @@ class _CompactLinkedHashSet<E> extends _HashFieldBase
|
|||
if (pair != _HashBase._DELETED_PAIR) {
|
||||
final int d = hashPattern ^ pair;
|
||||
if (d < maxEntries && _equals(key, _data[d])) {
|
||||
return _data[d]; // Note: Must return the existing key.
|
||||
return _data[d]; // Note: Must return the existing key.
|
||||
}
|
||||
}
|
||||
i = _HashBase._nextProbe(i, sizeMask);
|
||||
|
@ -574,13 +581,12 @@ class _CompactLinkedHashSet<E> extends _HashFieldBase
|
|||
Set<E> toSet() => new _CompactLinkedHashSet<E>()..addAll(this);
|
||||
}
|
||||
|
||||
class _CompactLinkedIdentityHashSet<E>
|
||||
extends _CompactLinkedHashSet<E> with _IdenticalAndIdentityHashCode {
|
||||
class _CompactLinkedIdentityHashSet<E> extends _CompactLinkedHashSet<E>
|
||||
with _IdenticalAndIdentityHashCode {
|
||||
Set<E> toSet() => new _CompactLinkedIdentityHashSet<E>()..addAll(this);
|
||||
}
|
||||
|
||||
class _CompactLinkedCustomHashSet<E>
|
||||
extends _CompactLinkedHashSet<E> {
|
||||
class _CompactLinkedCustomHashSet<E> extends _CompactLinkedHashSet<E> {
|
||||
final _equality;
|
||||
final _hasher;
|
||||
final _validKey;
|
||||
|
@ -597,5 +603,5 @@ class _CompactLinkedCustomHashSet<E>
|
|||
|
||||
Set<E> toSet() =>
|
||||
new _CompactLinkedCustomHashSet<E>(_equality, _hasher, _validKey)
|
||||
..addAll(this);
|
||||
..addAll(this);
|
||||
}
|
||||
|
|
|
@ -36,14 +36,13 @@ class _SyncIterable extends IterableBase {
|
|||
}
|
||||
|
||||
class _SyncIterator implements Iterator {
|
||||
bool isYieldEach; // Set by generated code for the yield* statement.
|
||||
bool isYieldEach; // Set by generated code for the yield* statement.
|
||||
Iterator yieldEachIterator;
|
||||
var _current; // Set by generated code for the yield and yield* statement.
|
||||
var _current; // Set by generated code for the yield and yield* statement.
|
||||
_SyncGeneratorCallback _moveNextFn;
|
||||
|
||||
get current => yieldEachIterator != null
|
||||
? yieldEachIterator.current
|
||||
: _current;
|
||||
get current =>
|
||||
yieldEachIterator != null ? yieldEachIterator.current : _current;
|
||||
|
||||
_SyncIterator(this._moveNextFn);
|
||||
|
||||
|
@ -51,7 +50,7 @@ class _SyncIterator implements Iterator {
|
|||
if (_moveNextFn == null) {
|
||||
return false;
|
||||
}
|
||||
while(true) {
|
||||
while (true) {
|
||||
if (yieldEachIterator != null) {
|
||||
if (yieldEachIterator.moveNext()) {
|
||||
return true;
|
||||
|
@ -77,6 +76,8 @@ class _SyncIterator implements Iterator {
|
|||
}
|
||||
}
|
||||
|
||||
@patch class StackTrace {
|
||||
@patch static StackTrace get current native "StackTrace_current";
|
||||
@patch
|
||||
class StackTrace {
|
||||
@patch
|
||||
static StackTrace get current native "StackTrace_current";
|
||||
}
|
||||
|
|
|
@ -4,7 +4,8 @@
|
|||
// Dart core library.
|
||||
|
||||
// VM implementation of DateTime.
|
||||
@patch class DateTime {
|
||||
@patch
|
||||
class DateTime {
|
||||
// Natives.
|
||||
// The natives have been moved up here to work around Issue 10401.
|
||||
static int _getCurrentMicros() native "DateTime_currentTimeMicros";
|
||||
|
@ -30,44 +31,41 @@
|
|||
|
||||
List __parts;
|
||||
|
||||
@patch DateTime.fromMillisecondsSinceEpoch(int millisecondsSinceEpoch,
|
||||
{bool isUtc: false})
|
||||
@patch
|
||||
DateTime.fromMillisecondsSinceEpoch(int millisecondsSinceEpoch,
|
||||
{bool isUtc: false})
|
||||
: this._withValue(
|
||||
millisecondsSinceEpoch * Duration.MICROSECONDS_PER_MILLISECOND,
|
||||
isUtc: isUtc);
|
||||
millisecondsSinceEpoch * Duration.MICROSECONDS_PER_MILLISECOND,
|
||||
isUtc: isUtc);
|
||||
|
||||
@patch DateTime.fromMicrosecondsSinceEpoch(int microsecondsSinceEpoch,
|
||||
{bool isUtc: false})
|
||||
@patch
|
||||
DateTime.fromMicrosecondsSinceEpoch(int microsecondsSinceEpoch,
|
||||
{bool isUtc: false})
|
||||
: this._withValue(microsecondsSinceEpoch, isUtc: isUtc);
|
||||
|
||||
@patch DateTime._internal(int year,
|
||||
int month,
|
||||
int day,
|
||||
int hour,
|
||||
int minute,
|
||||
int second,
|
||||
int millisecond,
|
||||
int microsecond,
|
||||
bool isUtc)
|
||||
@patch
|
||||
DateTime._internal(int year, int month, int day, int hour, int minute,
|
||||
int second, int millisecond, int microsecond, bool isUtc)
|
||||
: this.isUtc = isUtc,
|
||||
this._value = _brokenDownDateToValue(
|
||||
year, month, day, hour, minute, second, millisecond, microsecond,
|
||||
isUtc) {
|
||||
this._value = _brokenDownDateToValue(year, month, day, hour, minute,
|
||||
second, millisecond, microsecond, isUtc) {
|
||||
if (_value == null) throw new ArgumentError();
|
||||
if (isUtc == null) throw new ArgumentError();
|
||||
}
|
||||
|
||||
@patch DateTime._now()
|
||||
@patch
|
||||
DateTime._now()
|
||||
: isUtc = false,
|
||||
_value = _getCurrentMicros() {
|
||||
}
|
||||
_value = _getCurrentMicros() {}
|
||||
|
||||
@patch String get timeZoneName {
|
||||
@patch
|
||||
String get timeZoneName {
|
||||
if (isUtc) return "UTC";
|
||||
return _timeZoneName(microsecondsSinceEpoch);
|
||||
}
|
||||
|
||||
@patch Duration get timeZoneOffset {
|
||||
@patch
|
||||
Duration get timeZoneOffset {
|
||||
if (isUtc) return new Duration();
|
||||
int offsetInSeconds = _timeZoneOffsetInSeconds(microsecondsSinceEpoch);
|
||||
return new Duration(seconds: offsetInSeconds);
|
||||
|
@ -75,17 +73,18 @@
|
|||
|
||||
/** The first list contains the days until each month in non-leap years. The
|
||||
* second list contains the days in leap years. */
|
||||
static const List<List<int>> _DAYS_UNTIL_MONTH =
|
||||
const [const [0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334],
|
||||
const [0, 31, 60, 91, 121, 152, 182, 213, 244, 274, 305, 335]];
|
||||
static const List<List<int>> _DAYS_UNTIL_MONTH = const [
|
||||
const [0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334],
|
||||
const [0, 31, 60, 91, 121, 152, 182, 213, 244, 274, 305, 335]
|
||||
];
|
||||
|
||||
static List _computeUpperPart(int localMicros) {
|
||||
const int DAYS_IN_4_YEARS = 4 * 365 + 1;
|
||||
const int DAYS_IN_100_YEARS = 25 * DAYS_IN_4_YEARS - 1;
|
||||
const int DAYS_IN_400_YEARS = 4 * DAYS_IN_100_YEARS + 1;
|
||||
const int DAYS_1970_TO_2000 = 30 * 365 + 7;
|
||||
const int DAYS_OFFSET = 1000 * DAYS_IN_400_YEARS + 5 * DAYS_IN_400_YEARS -
|
||||
DAYS_1970_TO_2000;
|
||||
const int DAYS_OFFSET =
|
||||
1000 * DAYS_IN_400_YEARS + 5 * DAYS_IN_400_YEARS - DAYS_1970_TO_2000;
|
||||
const int YEARS_OFFSET = 400000;
|
||||
|
||||
int resultYear = 0;
|
||||
|
@ -93,8 +92,8 @@
|
|||
int resultDay = 0;
|
||||
|
||||
// Always round down.
|
||||
final int daysSince1970 = _flooredDivision(localMicros,
|
||||
Duration.MICROSECONDS_PER_DAY);
|
||||
final int daysSince1970 =
|
||||
_flooredDivision(localMicros, Duration.MICROSECONDS_PER_DAY);
|
||||
int days = daysSince1970;
|
||||
days += DAYS_OFFSET;
|
||||
resultYear = 400 * (days ~/ DAYS_IN_400_YEARS) - YEARS_OFFSET;
|
||||
|
@ -117,8 +116,8 @@
|
|||
|
||||
List<int> daysUntilMonth = _DAYS_UNTIL_MONTH[isLeap ? 1 : 0];
|
||||
for (resultMonth = 12;
|
||||
daysUntilMonth[resultMonth - 1] > days;
|
||||
resultMonth--) {
|
||||
daysUntilMonth[resultMonth - 1] > days;
|
||||
resultMonth--) {
|
||||
// Do nothing.
|
||||
}
|
||||
resultDay = days - daysUntilMonth[resultMonth - 1] + 1;
|
||||
|
@ -131,8 +130,8 @@
|
|||
_flooredDivision(localMicros, Duration.MICROSECONDS_PER_SECOND) %
|
||||
Duration.SECONDS_PER_MINUTE;
|
||||
|
||||
int resultMinute = _flooredDivision(localMicros,
|
||||
Duration.MICROSECONDS_PER_MINUTE);
|
||||
int resultMinute =
|
||||
_flooredDivision(localMicros, Duration.MICROSECONDS_PER_MINUTE);
|
||||
resultMinute %= Duration.MINUTES_PER_HOUR;
|
||||
|
||||
int resultHour =
|
||||
|
@ -143,7 +142,8 @@
|
|||
// starts with Monday. Monday has the value 1 up to Sunday with 7.
|
||||
// 1970-1-1 was a Thursday.
|
||||
int resultWeekday = ((daysSince1970 + DateTime.THURSDAY - DateTime.MONDAY) %
|
||||
DateTime.DAYS_PER_WEEK) + DateTime.MONDAY;
|
||||
DateTime.DAYS_PER_WEEK) +
|
||||
DateTime.MONDAY;
|
||||
|
||||
List list = new List(_YEAR_INDEX + 1);
|
||||
list[_MICROSECOND_INDEX] = resultMicrosecond;
|
||||
|
@ -165,42 +165,56 @@
|
|||
return __parts;
|
||||
}
|
||||
|
||||
@patch DateTime add(Duration duration) {
|
||||
return new DateTime._withValue(
|
||||
_value + duration.inMicroseconds, isUtc: isUtc);
|
||||
@patch
|
||||
DateTime add(Duration duration) {
|
||||
return new DateTime._withValue(_value + duration.inMicroseconds,
|
||||
isUtc: isUtc);
|
||||
}
|
||||
|
||||
@patch DateTime subtract(Duration duration) {
|
||||
return new DateTime._withValue(
|
||||
_value - duration.inMicroseconds, isUtc: isUtc);
|
||||
@patch
|
||||
DateTime subtract(Duration duration) {
|
||||
return new DateTime._withValue(_value - duration.inMicroseconds,
|
||||
isUtc: isUtc);
|
||||
}
|
||||
|
||||
@patch Duration difference(DateTime other) {
|
||||
@patch
|
||||
Duration difference(DateTime other) {
|
||||
return new Duration(microseconds: _value - other._value);
|
||||
}
|
||||
|
||||
@patch int get millisecondsSinceEpoch =>
|
||||
@patch
|
||||
int get millisecondsSinceEpoch =>
|
||||
_value ~/ Duration.MICROSECONDS_PER_MILLISECOND;
|
||||
|
||||
@patch int get microsecondsSinceEpoch => _value;
|
||||
@patch
|
||||
int get microsecondsSinceEpoch => _value;
|
||||
|
||||
@patch int get microsecond => _parts[_MICROSECOND_INDEX];
|
||||
@patch
|
||||
int get microsecond => _parts[_MICROSECOND_INDEX];
|
||||
|
||||
@patch int get millisecond => _parts[_MILLISECOND_INDEX];
|
||||
@patch
|
||||
int get millisecond => _parts[_MILLISECOND_INDEX];
|
||||
|
||||
@patch int get second => _parts[_SECOND_INDEX];
|
||||
@patch
|
||||
int get second => _parts[_SECOND_INDEX];
|
||||
|
||||
@patch int get minute => _parts[_MINUTE_INDEX];
|
||||
@patch
|
||||
int get minute => _parts[_MINUTE_INDEX];
|
||||
|
||||
@patch int get hour => _parts[_HOUR_INDEX];
|
||||
@patch
|
||||
int get hour => _parts[_HOUR_INDEX];
|
||||
|
||||
@patch int get day => _parts[_DAY_INDEX];
|
||||
@patch
|
||||
int get day => _parts[_DAY_INDEX];
|
||||
|
||||
@patch int get weekday => _parts[_WEEKDAY_INDEX];
|
||||
@patch
|
||||
int get weekday => _parts[_WEEKDAY_INDEX];
|
||||
|
||||
@patch int get month => _parts[_MONTH_INDEX];
|
||||
@patch
|
||||
int get month => _parts[_MONTH_INDEX];
|
||||
|
||||
@patch int get year => _parts[_YEAR_INDEX];
|
||||
@patch
|
||||
int get year => _parts[_YEAR_INDEX];
|
||||
|
||||
/**
|
||||
* Returns the amount of microseconds in UTC that represent the same values
|
||||
|
@ -232,10 +246,10 @@
|
|||
// Returns the days since 1970 for the start of the given [year].
|
||||
// [year] may be before epoch.
|
||||
static int _dayFromYear(int year) {
|
||||
return 365 * (year - 1970)
|
||||
+ _flooredDivision(year - 1969, 4)
|
||||
- _flooredDivision(year - 1901, 100)
|
||||
+ _flooredDivision(year - 1601, 400);
|
||||
return 365 * (year - 1970) +
|
||||
_flooredDivision(year - 1969, 4) -
|
||||
_flooredDivision(year - 1901, 100) +
|
||||
_flooredDivision(year - 1601, 400);
|
||||
}
|
||||
|
||||
static bool _isLeapYear(y) {
|
||||
|
@ -244,10 +258,9 @@
|
|||
}
|
||||
|
||||
/// Converts the given broken down date to microseconds.
|
||||
@patch static int _brokenDownDateToValue(
|
||||
int year, int month, int day,
|
||||
int hour, int minute, int second, int millisecond, int microsecond,
|
||||
bool isUtc) {
|
||||
@patch
|
||||
static int _brokenDownDateToValue(int year, int month, int day, int hour,
|
||||
int minute, int second, int millisecond, int microsecond, bool isUtc) {
|
||||
// Simplify calculations by working with zero-based month.
|
||||
--month;
|
||||
// Deal with under and overflow.
|
||||
|
@ -265,9 +278,8 @@
|
|||
int days = day - 1;
|
||||
days += _DAYS_UNTIL_MONTH[_isLeapYear(year) ? 1 : 0][month];
|
||||
days += _dayFromYear(year);
|
||||
int microsecondsSinceEpoch =
|
||||
days * Duration.MICROSECONDS_PER_DAY +
|
||||
hour * Duration.MICROSECONDS_PER_HOUR +
|
||||
int microsecondsSinceEpoch = days * Duration.MICROSECONDS_PER_DAY +
|
||||
hour * Duration.MICROSECONDS_PER_HOUR +
|
||||
minute * Duration.MICROSECONDS_PER_MINUTE +
|
||||
second * Duration.MICROSECONDS_PER_SECOND +
|
||||
millisecond * Duration.MICROSECONDS_PER_MILLISECOND +
|
||||
|
@ -377,8 +389,8 @@
|
|||
static int _equivalentSeconds(int microsecondsSinceEpoch) {
|
||||
const int CUT_OFF_SECONDS = 0x7FFFFFFF;
|
||||
|
||||
int secondsSinceEpoch = _flooredDivision(microsecondsSinceEpoch,
|
||||
Duration.MICROSECONDS_PER_SECOND);
|
||||
int secondsSinceEpoch = _flooredDivision(
|
||||
microsecondsSinceEpoch, Duration.MICROSECONDS_PER_SECOND);
|
||||
|
||||
if (secondsSinceEpoch.abs() > CUT_OFF_SECONDS) {
|
||||
int year = _yearsFromSecondsSinceEpoch(secondsSinceEpoch);
|
||||
|
|
|
@ -4,12 +4,13 @@
|
|||
|
||||
final Set<String> _loadedLibraries = new Set<String>();
|
||||
|
||||
@patch class DeferredLibrary {
|
||||
@patch Future<Null> load() {
|
||||
@patch
|
||||
class DeferredLibrary {
|
||||
@patch
|
||||
Future<Null> load() {
|
||||
// Dummy implementation that should eventually be replaced by real
|
||||
// implementation.
|
||||
Future future =
|
||||
new Future<Null>.value(null);
|
||||
Future future = new Future<Null>.value(null);
|
||||
_loadedLibraries.add(libraryName);
|
||||
return future;
|
||||
}
|
||||
|
|
|
@ -5,19 +5,21 @@
|
|||
import 'dart:isolate';
|
||||
import 'dart:_internal' hide Symbol;
|
||||
|
||||
@patch bool debugger({bool when: true,
|
||||
String message}) native "Developer_debugger";
|
||||
@patch
|
||||
bool debugger({bool when: true, String message}) native "Developer_debugger";
|
||||
|
||||
@patch Object inspect(Object object) native "Developer_inspect";
|
||||
@patch
|
||||
Object inspect(Object object) native "Developer_inspect";
|
||||
|
||||
@patch void log(String message,
|
||||
{DateTime time,
|
||||
int sequenceNumber,
|
||||
int level: 0,
|
||||
String name: '',
|
||||
Zone zone,
|
||||
Object error,
|
||||
StackTrace stackTrace}) {
|
||||
@patch
|
||||
void log(String message,
|
||||
{DateTime time,
|
||||
int sequenceNumber,
|
||||
int level: 0,
|
||||
String name: '',
|
||||
Zone zone,
|
||||
Object error,
|
||||
StackTrace stackTrace}) {
|
||||
if (message is! String) {
|
||||
throw new ArgumentError.value(message, "message", "Must be a String");
|
||||
}
|
||||
|
@ -32,44 +34,36 @@ import 'dart:_internal' hide Symbol;
|
|||
} else {
|
||||
_nextSequenceNumber = sequenceNumber + 1;
|
||||
}
|
||||
_log(message,
|
||||
time.millisecondsSinceEpoch,
|
||||
sequenceNumber,
|
||||
level,
|
||||
name,
|
||||
zone,
|
||||
error,
|
||||
stackTrace);
|
||||
_log(message, time.millisecondsSinceEpoch, sequenceNumber, level, name, zone,
|
||||
error, stackTrace);
|
||||
}
|
||||
|
||||
int _nextSequenceNumber = 0;
|
||||
|
||||
_log(String message,
|
||||
int timestamp,
|
||||
int sequenceNumber,
|
||||
int level,
|
||||
String name,
|
||||
Zone zone,
|
||||
Object error,
|
||||
StackTrace stackTrace) native "Developer_log";
|
||||
_log(String message, int timestamp, int sequenceNumber, int level, String name,
|
||||
Zone zone, Object error, StackTrace stackTrace) native "Developer_log";
|
||||
|
||||
@patch void _postEvent(String eventKind, String eventData)
|
||||
@patch
|
||||
void _postEvent(String eventKind, String eventData)
|
||||
native "Developer_postEvent";
|
||||
|
||||
@patch ServiceExtensionHandler _lookupExtension(String method)
|
||||
@patch
|
||||
ServiceExtensionHandler _lookupExtension(String method)
|
||||
native "Developer_lookupExtension";
|
||||
|
||||
@patch _registerExtension(String method, ServiceExtensionHandler handler)
|
||||
@patch
|
||||
_registerExtension(String method, ServiceExtensionHandler handler)
|
||||
native "Developer_registerExtension";
|
||||
|
||||
// This code is only invoked when there is no other Dart code on the stack.
|
||||
_runExtension(ServiceExtensionHandler handler,
|
||||
String method,
|
||||
List<String> parameterKeys,
|
||||
List<String> parameterValues,
|
||||
SendPort replyPort,
|
||||
Object id,
|
||||
bool trace_service) {
|
||||
_runExtension(
|
||||
ServiceExtensionHandler handler,
|
||||
String method,
|
||||
List<String> parameterKeys,
|
||||
List<String> parameterValues,
|
||||
SendPort replyPort,
|
||||
Object id,
|
||||
bool trace_service) {
|
||||
var parameters = {};
|
||||
for (var i = 0; i < parameterKeys.length; i++) {
|
||||
parameters[parameterKeys[i]] = parameterValues[i];
|
||||
|
@ -80,15 +74,14 @@ _runExtension(ServiceExtensionHandler handler,
|
|||
} catch (e, st) {
|
||||
var errorDetails = (st == null) ? '$e' : '$e\n$st';
|
||||
response = new ServiceExtensionResponse.error(
|
||||
ServiceExtensionResponse.kExtensionError,
|
||||
errorDetails);
|
||||
ServiceExtensionResponse.kExtensionError, errorDetails);
|
||||
_postResponse(replyPort, id, response, trace_service);
|
||||
return;
|
||||
}
|
||||
if (response is! Future) {
|
||||
response = new ServiceExtensionResponse.error(
|
||||
ServiceExtensionResponse.kExtensionError,
|
||||
"Extension handler must return a Future");
|
||||
ServiceExtensionResponse.kExtensionError,
|
||||
"Extension handler must return a Future");
|
||||
_postResponse(replyPort, id, response, trace_service);
|
||||
return;
|
||||
}
|
||||
|
@ -96,8 +89,7 @@ _runExtension(ServiceExtensionHandler handler,
|
|||
// Catch any errors eagerly and wrap them in a ServiceExtensionResponse.
|
||||
var errorDetails = (st == null) ? '$e' : '$e\n$st';
|
||||
return new ServiceExtensionResponse.error(
|
||||
ServiceExtensionResponse.kExtensionError,
|
||||
errorDetails);
|
||||
ServiceExtensionResponse.kExtensionError, errorDetails);
|
||||
}).then((response) {
|
||||
// Post the valid response or the wrapped error after verifying that
|
||||
// the response is a ServiceExtensionResponse.
|
||||
|
@ -114,10 +106,8 @@ _runExtension(ServiceExtensionHandler handler,
|
|||
}
|
||||
|
||||
// This code is only invoked by _runExtension.
|
||||
_postResponse(SendPort replyPort,
|
||||
Object id,
|
||||
ServiceExtensionResponse response,
|
||||
bool trace_service) {
|
||||
_postResponse(SendPort replyPort, Object id, ServiceExtensionResponse response,
|
||||
bool trace_service) {
|
||||
assert(replyPort != null);
|
||||
if (id == null) {
|
||||
if (trace_service) {
|
||||
|
@ -150,14 +140,19 @@ _postResponse(SendPort replyPort,
|
|||
replyPort.send(sb.toString());
|
||||
}
|
||||
|
||||
@patch int _getServiceMajorVersion() native "Developer_getServiceMajorVersion";
|
||||
@patch
|
||||
int _getServiceMajorVersion() native "Developer_getServiceMajorVersion";
|
||||
|
||||
@patch int _getServiceMinorVersion() native "Developer_getServiceMinorVersion";
|
||||
@patch
|
||||
int _getServiceMinorVersion() native "Developer_getServiceMinorVersion";
|
||||
|
||||
@patch void _getServerInfo(SendPort sendPort) native "Developer_getServerInfo";
|
||||
@patch
|
||||
void _getServerInfo(SendPort sendPort) native "Developer_getServerInfo";
|
||||
|
||||
@patch void _webServerControl(SendPort sendPort, bool enable)
|
||||
@patch
|
||||
void _webServerControl(SendPort sendPort, bool enable)
|
||||
native "Developer_webServerControl";
|
||||
|
||||
@patch String _getIsolateIDFromSendPort(SendPort sendPort)
|
||||
@patch
|
||||
String _getIsolateIDFromSendPort(SendPort sendPort)
|
||||
native "Developer_getIsolateIDFromSendPort";
|
||||
|
|
|
@ -3,48 +3,54 @@
|
|||
// BSD-style license that can be found in the LICENSE file.
|
||||
|
||||
class _Double implements double {
|
||||
factory _Double.fromInteger(int value)
|
||||
native "Double_doubleFromInteger";
|
||||
factory _Double.fromInteger(int value) native "Double_doubleFromInteger";
|
||||
|
||||
// TODO: Make a stared static method for hashCode and _identityHashCode
|
||||
// when semantics are corrected as described in:
|
||||
// https://github.com/dart-lang/sdk/issues/2884
|
||||
int get hashCode => (isNaN || isInfinite) ? 0 : toInt();
|
||||
int get _identityHashCode => (isNaN || isInfinite) ? 0 : toInt();
|
||||
int get hashCode => (isNaN || isInfinite) ? 0 : toInt();
|
||||
int get _identityHashCode => (isNaN || isInfinite) ? 0 : toInt();
|
||||
|
||||
double operator +(num other) {
|
||||
return _add(other.toDouble());
|
||||
}
|
||||
|
||||
double _add(double other) native "Double_add";
|
||||
|
||||
double operator -(num other) {
|
||||
return _sub(other.toDouble());
|
||||
}
|
||||
|
||||
double _sub(double other) native "Double_sub";
|
||||
|
||||
double operator *(num other) {
|
||||
return _mul(other.toDouble());
|
||||
}
|
||||
|
||||
double _mul(double other) native "Double_mul";
|
||||
|
||||
int operator ~/(num other) {
|
||||
return _trunc_div(other.toDouble());
|
||||
}
|
||||
|
||||
int _trunc_div(double other) native "Double_trunc_div";
|
||||
|
||||
double operator /(num other) {
|
||||
return _div(other.toDouble());
|
||||
}
|
||||
|
||||
double _div(double other) native "Double_div";
|
||||
|
||||
double operator %(num other) {
|
||||
return _modulo(other.toDouble());
|
||||
}
|
||||
|
||||
double _modulo(double other) native "Double_modulo";
|
||||
|
||||
double remainder(num other) {
|
||||
return _remainder(other.toDouble());
|
||||
}
|
||||
|
||||
double _remainder(double other) native "Double_remainder";
|
||||
|
||||
double operator -() native "Double_flipSignBit";
|
||||
|
@ -53,46 +59,57 @@ class _Double implements double {
|
|||
if (!(other is num)) return false;
|
||||
return _equal(other.toDouble());
|
||||
}
|
||||
|
||||
bool _equal(double other) native "Double_equal";
|
||||
bool _equalToInteger(int other) native "Double_equalToInteger";
|
||||
bool operator <(num other) {
|
||||
return other > this;
|
||||
}
|
||||
|
||||
bool operator >(num other) {
|
||||
return _greaterThan(other.toDouble());
|
||||
}
|
||||
|
||||
bool _greaterThan(double other) native "Double_greaterThan";
|
||||
bool operator >=(num other) {
|
||||
return (this == other) || (this > other);
|
||||
}
|
||||
|
||||
bool operator <=(num other) {
|
||||
return (this == other) || (this < other);
|
||||
}
|
||||
|
||||
double _addFromInteger(int other) {
|
||||
return new _Double.fromInteger(other)._add(this);
|
||||
}
|
||||
|
||||
double _subFromInteger(int other) {
|
||||
return new _Double.fromInteger(other)._sub(this);
|
||||
}
|
||||
|
||||
double _mulFromInteger(int other) {
|
||||
return new _Double.fromInteger(other)._mul(this);
|
||||
}
|
||||
|
||||
int _truncDivFromInteger(int other) {
|
||||
return new _Double.fromInteger(other)._trunc_div(this);
|
||||
}
|
||||
|
||||
double _moduloFromInteger(int other) {
|
||||
return new _Double.fromInteger(other)._modulo(this);
|
||||
}
|
||||
|
||||
double _remainderFromInteger(int other) {
|
||||
return new _Double.fromInteger(other)._remainder(this);
|
||||
}
|
||||
|
||||
bool _greaterThanFromInteger(int other)
|
||||
native "Double_greaterThanFromInteger";
|
||||
|
||||
bool get isNegative native "Double_getIsNegative";
|
||||
bool get isInfinite native "Double_getIsInfinite";
|
||||
bool get isNaN native "Double_getIsNaN";
|
||||
bool get isFinite => !isInfinite && !isNaN; // Can be optimized.
|
||||
bool get isFinite => !isInfinite && !isNaN; // Can be optimized.
|
||||
|
||||
double abs() {
|
||||
// Handle negative 0.0.
|
||||
|
@ -103,12 +120,12 @@ class _Double implements double {
|
|||
double get sign {
|
||||
if (this > 0.0) return 1.0;
|
||||
if (this < 0.0) return -1.0;
|
||||
return this; // +/-0.0 or NaN.
|
||||
return this; // +/-0.0 or NaN.
|
||||
}
|
||||
|
||||
int round() => roundToDouble().toInt();
|
||||
int floor() => floorToDouble().toInt();
|
||||
int ceil () => ceilToDouble().toInt();
|
||||
int ceil() => ceilToDouble().toInt();
|
||||
int truncate() => truncateToDouble().toInt();
|
||||
|
||||
double roundToDouble() native "Double_round";
|
||||
|
@ -134,8 +151,13 @@ class _Double implements double {
|
|||
}
|
||||
|
||||
int toInt() native "Double_toInt";
|
||||
num _toBigintOrDouble() { return this; }
|
||||
double toDouble() { return this; }
|
||||
num _toBigintOrDouble() {
|
||||
return this;
|
||||
}
|
||||
|
||||
double toDouble() {
|
||||
return this;
|
||||
}
|
||||
|
||||
static const int CACHE_SIZE_LOG2 = 3;
|
||||
static const int CACHE_LENGTH = 1 << (CACHE_SIZE_LOG2 + 1);
|
||||
|
@ -193,6 +215,7 @@ class _Double implements double {
|
|||
|
||||
return _toStringAsFixed(fractionDigits);
|
||||
}
|
||||
|
||||
String _toStringAsFixed(int fractionDigits) native "Double_toStringAsFixed";
|
||||
|
||||
String toStringAsExponential([int fractionDigits]) {
|
||||
|
@ -223,6 +246,7 @@ class _Double implements double {
|
|||
|
||||
return _toStringAsExponential(fractionDigits);
|
||||
}
|
||||
|
||||
String _toStringAsExponential(int fractionDigits)
|
||||
native "Double_toStringAsExponential";
|
||||
|
||||
|
@ -247,6 +271,7 @@ class _Double implements double {
|
|||
|
||||
return _toStringAsPrecision(precision);
|
||||
}
|
||||
|
||||
String _toStringAsPrecision(int fractionDigits)
|
||||
native "Double_toStringAsPrecision";
|
||||
|
||||
|
|
|
@ -5,20 +5,20 @@
|
|||
|
||||
// VM implementation of double.
|
||||
|
||||
@patch class double {
|
||||
|
||||
static double _nativeParse(String str,
|
||||
int start, int end) native "Double_parse";
|
||||
@patch
|
||||
class double {
|
||||
static double _nativeParse(String str, int start, int end)
|
||||
native "Double_parse";
|
||||
|
||||
static double _tryParseDouble(var str, var start, var end) {
|
||||
assert(start < end);
|
||||
const int _DOT = 0x2e; // '.'
|
||||
const int _ZERO = 0x30; // '0'
|
||||
const int _MINUS = 0x2d; // '-'
|
||||
const int _N = 0x4e; // 'N'
|
||||
const int _a = 0x61; // 'a'
|
||||
const int _I = 0x49; // 'I'
|
||||
const int _e = 0x65; // 'e'
|
||||
const int _DOT = 0x2e; // '.'
|
||||
const int _ZERO = 0x30; // '0'
|
||||
const int _MINUS = 0x2d; // '-'
|
||||
const int _N = 0x4e; // 'N'
|
||||
const int _a = 0x61; // 'a'
|
||||
const int _I = 0x49; // 'I'
|
||||
const int _e = 0x65; // 'e'
|
||||
int exponent = 0;
|
||||
// Set to non-zero if a digit is seen. Avoids accepting ".".
|
||||
bool digitsSeen = false;
|
||||
|
@ -56,7 +56,7 @@
|
|||
}
|
||||
for (int i = start; i < end; i++) {
|
||||
int c = str.codeUnitAt(i);
|
||||
int digit = c ^ _ZERO; // '0'-'9' characters are now 0-9 integers.
|
||||
int digit = c ^ _ZERO; // '0'-'9' characters are now 0-9 integers.
|
||||
if (digit <= 9) {
|
||||
doubleValue = 10.0 * doubleValue + digit;
|
||||
// Doubles at or above this value (2**53) might have lost precission.
|
||||
|
@ -78,9 +78,9 @@
|
|||
return null;
|
||||
}
|
||||
}
|
||||
if (!digitsSeen) return null; // No digits.
|
||||
if (!digitsSeen) return null; // No digits.
|
||||
if (exponent == 0) return sign * doubleValue;
|
||||
const P10 = POWERS_OF_TEN; // From shared library
|
||||
const P10 = POWERS_OF_TEN; // From shared library
|
||||
if (exponent < 0) {
|
||||
int negExponent = -exponent;
|
||||
if (negExponent >= P10.length) return null;
|
||||
|
@ -93,7 +93,7 @@
|
|||
static double _parse(var str) {
|
||||
int len = str.length;
|
||||
int start = str._firstNonWhitespace();
|
||||
if (start == len) return null; // All whitespace.
|
||||
if (start == len) return null; // All whitespace.
|
||||
int end = str._lastNonWhitespace() + 1;
|
||||
assert(start < end);
|
||||
var result = _tryParseDouble(str, start, end);
|
||||
|
|
|
@ -2,25 +2,27 @@
|
|||
// for details. All rights reserved. Use of this source code is governed by a
|
||||
// BSD-style license that can be found in the LICENSE file.
|
||||
|
||||
@patch class Error {
|
||||
@patch static String _objectToString(Object object) {
|
||||
@patch
|
||||
class Error {
|
||||
@patch
|
||||
static String _objectToString(Object object) {
|
||||
return Object._toString(object);
|
||||
}
|
||||
|
||||
@patch static String _stringToSafeString(String string) {
|
||||
@patch
|
||||
static String _stringToSafeString(String string) {
|
||||
return JSON.encode(string);
|
||||
}
|
||||
|
||||
@patch StackTrace get stackTrace => _stackTrace;
|
||||
@patch
|
||||
StackTrace get stackTrace => _stackTrace;
|
||||
|
||||
StackTrace _stackTrace;
|
||||
}
|
||||
|
||||
class _AssertionError extends Error implements AssertionError {
|
||||
_AssertionError._create(
|
||||
this._failedAssertion, this._url, this._line, this._column,
|
||||
this.message);
|
||||
|
||||
this._failedAssertion, this._url, this._line, this._column, this.message);
|
||||
|
||||
// AssertionError_throwNew in errors.cc fishes the assertion source code
|
||||
// out of the script. It expects a Dart stack frame from class
|
||||
|
@ -30,7 +32,7 @@ class _AssertionError extends Error implements AssertionError {
|
|||
}
|
||||
|
||||
static _doThrowNew(int assertionStart, int assertionEnd, Object message)
|
||||
native "AssertionError_throwNew";
|
||||
native "AssertionError_throwNew";
|
||||
|
||||
static _evaluateAssertion(condition) {
|
||||
if (identical(condition, true) || identical(condition, false)) {
|
||||
|
@ -64,6 +66,7 @@ class _AssertionError extends Error implements AssertionError {
|
|||
return "'$_url': Failed assertion: line $_line$columnInfo: "
|
||||
"'$_failedAssertion': $_messageString";
|
||||
}
|
||||
|
||||
final String _failedAssertion;
|
||||
final String _url;
|
||||
final int _line;
|
||||
|
@ -75,19 +78,16 @@ class _TypeError extends _AssertionError implements TypeError {
|
|||
_TypeError._create(String url, int line, int column, String errorMsg)
|
||||
: super._create("is assignable", url, line, column, errorMsg);
|
||||
|
||||
static _throwNew(int location,
|
||||
Object src_value,
|
||||
_Type dst_type,
|
||||
String dst_name,
|
||||
String bound_error_msg)
|
||||
native "TypeError_throwNew";
|
||||
static _throwNew(int location, Object src_value, _Type dst_type,
|
||||
String dst_name, String bound_error_msg) native "TypeError_throwNew";
|
||||
|
||||
static _throwNewIfNotLoaded(_LibraryPrefix prefix,
|
||||
int location,
|
||||
Object src_value,
|
||||
_Type dst_type,
|
||||
String dst_name,
|
||||
String bound_error_msg) {
|
||||
static _throwNewIfNotLoaded(
|
||||
_LibraryPrefix prefix,
|
||||
int location,
|
||||
Object src_value,
|
||||
_Type dst_type,
|
||||
String dst_name,
|
||||
String bound_error_msg) {
|
||||
if (!prefix.isLoaded()) {
|
||||
_throwNew(location, src_value, dst_type, dst_name, bound_error_msg);
|
||||
}
|
||||
|
@ -111,7 +111,8 @@ class _CastError extends Error implements CastError {
|
|||
final String _errorMsg;
|
||||
}
|
||||
|
||||
@patch class FallThroughError {
|
||||
@patch
|
||||
class FallThroughError {
|
||||
FallThroughError._create(this._url, this._line);
|
||||
|
||||
static _throwNew(int case_clause_pos) native "FallThroughError_throwNew";
|
||||
|
@ -133,28 +134,32 @@ class _InternalError {
|
|||
final String _msg;
|
||||
}
|
||||
|
||||
@patch class UnsupportedError {
|
||||
@patch
|
||||
class UnsupportedError {
|
||||
static _throwNew(String msg) {
|
||||
throw new UnsupportedError(msg);
|
||||
}
|
||||
}
|
||||
|
||||
@patch class CyclicInitializationError {
|
||||
@patch
|
||||
class CyclicInitializationError {
|
||||
static _throwNew(String variableName) {
|
||||
throw new CyclicInitializationError(variableName);
|
||||
}
|
||||
}
|
||||
|
||||
@patch class AbstractClassInstantiationError {
|
||||
@patch
|
||||
class AbstractClassInstantiationError {
|
||||
AbstractClassInstantiationError._create(
|
||||
this._className, this._url, this._line);
|
||||
|
||||
static _throwNew(int case_clause_pos, String className)
|
||||
native "AbstractClassInstantiationError_throwNew";
|
||||
|
||||
@patch String toString() {
|
||||
@patch
|
||||
String toString() {
|
||||
return "Cannot instantiate abstract class $_className: "
|
||||
"_url '$_url' line $_line";
|
||||
"_url '$_url' line $_line";
|
||||
}
|
||||
|
||||
// These new fields cannot be declared final, because a constructor exists
|
||||
|
@ -163,16 +168,13 @@ class _InternalError {
|
|||
int _line;
|
||||
}
|
||||
|
||||
@patch class NoSuchMethodError {
|
||||
@patch
|
||||
class NoSuchMethodError {
|
||||
// The compiler emits a call to _throwNew when it cannot resolve a static
|
||||
// method at compile time. The receiver is actually the literal class of the
|
||||
// unresolved method.
|
||||
static void _throwNew(Object receiver,
|
||||
String memberName,
|
||||
int invocation_type,
|
||||
List arguments,
|
||||
List argumentNames,
|
||||
List existingArgumentNames) {
|
||||
static void _throwNew(Object receiver, String memberName, int invocation_type,
|
||||
List arguments, List argumentNames, List existingArgumentNames) {
|
||||
int numNamedArguments = argumentNames == null ? 0 : argumentNames.length;
|
||||
int numPositionalArguments = arguments == null ? 0 : arguments.length;
|
||||
numPositionalArguments -= numNamedArguments;
|
||||
|
@ -191,24 +193,26 @@ class _InternalError {
|
|||
var arg_value = arguments[numPositionalArguments + i];
|
||||
namedArguments[new Symbol(argumentNames[i])] = arg_value;
|
||||
}
|
||||
throw new NoSuchMethodError._withType(receiver,
|
||||
new Symbol(memberName),
|
||||
invocation_type,
|
||||
positionalArguments,
|
||||
namedArguments,
|
||||
existingArgumentNames);
|
||||
throw new NoSuchMethodError._withType(
|
||||
receiver,
|
||||
new Symbol(memberName),
|
||||
invocation_type,
|
||||
positionalArguments,
|
||||
namedArguments,
|
||||
existingArgumentNames);
|
||||
}
|
||||
|
||||
static void _throwNewIfNotLoaded(_LibraryPrefix prefix,
|
||||
Object receiver,
|
||||
String memberName,
|
||||
int invocation_type,
|
||||
List arguments,
|
||||
List argumentNames,
|
||||
List existingArgumentNames) {
|
||||
static void _throwNewIfNotLoaded(
|
||||
_LibraryPrefix prefix,
|
||||
Object receiver,
|
||||
String memberName,
|
||||
int invocation_type,
|
||||
List arguments,
|
||||
List argumentNames,
|
||||
List existingArgumentNames) {
|
||||
if (!prefix.isLoaded()) {
|
||||
_throwNew(receiver, memberName, invocation_type, arguments,
|
||||
argumentNames, existingArgumentNames);
|
||||
_throwNew(receiver, memberName, invocation_type, arguments, argumentNames,
|
||||
existingArgumentNames);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -218,11 +222,9 @@ class _InternalError {
|
|||
final int _invocation_type;
|
||||
|
||||
@patch
|
||||
NoSuchMethodError(Object receiver,
|
||||
Symbol memberName,
|
||||
List positionalArguments,
|
||||
Map<Symbol, dynamic> namedArguments,
|
||||
[List existingArgumentNames = null])
|
||||
NoSuchMethodError(Object receiver, Symbol memberName,
|
||||
List positionalArguments, Map<Symbol, dynamic> namedArguments,
|
||||
[List existingArgumentNames = null])
|
||||
: _receiver = receiver,
|
||||
_memberName = memberName,
|
||||
_arguments = positionalArguments,
|
||||
|
@ -232,29 +234,30 @@ class _InternalError {
|
|||
|
||||
// This constructor seems to be called with either strings or
|
||||
// values read from another NoSuchMethodError.
|
||||
NoSuchMethodError._withType(this._receiver,
|
||||
/*String|Symbol*/ memberName,
|
||||
this._invocation_type,
|
||||
this._arguments,
|
||||
Map<dynamic, dynamic> namedArguments,
|
||||
[List existingArgumentNames = null])
|
||||
NoSuchMethodError._withType(
|
||||
this._receiver,
|
||||
/*String|Symbol*/ memberName,
|
||||
this._invocation_type,
|
||||
this._arguments,
|
||||
Map<dynamic, dynamic> namedArguments,
|
||||
[List existingArgumentNames = null])
|
||||
: this._memberName =
|
||||
(memberName is String) ? new Symbol(memberName) : memberName,
|
||||
this._namedArguments =
|
||||
(namedArguments == null)
|
||||
? null
|
||||
: new Map<Symbol, dynamic>.fromIterable(
|
||||
namedArguments.keys,
|
||||
key: (k) => (k is String) ? new Symbol(k) : k,
|
||||
value: (k) => namedArguments[k]),
|
||||
this._namedArguments = (namedArguments == null)
|
||||
? null
|
||||
: new Map<Symbol, dynamic>.fromIterable(namedArguments.keys,
|
||||
key: (k) => (k is String) ? new Symbol(k) : k,
|
||||
value: (k) => namedArguments[k]),
|
||||
this._existingArgumentNames = existingArgumentNames;
|
||||
|
||||
@patch String toString() {
|
||||
@patch
|
||||
String toString() {
|
||||
var level = (_invocation_type >> _InvocationMirror._CALL_SHIFT) &
|
||||
_InvocationMirror._CALL_MASK;
|
||||
var type = _invocation_type & _InvocationMirror._TYPE_MASK;
|
||||
String memberName = (_memberName == null) ? "" :
|
||||
internal.Symbol.getUnmangledName(_memberName);
|
||||
String memberName = (_memberName == null)
|
||||
? ""
|
||||
: internal.Symbol.getUnmangledName(_memberName);
|
||||
|
||||
if (type == _InvocationMirror._LOCAL_VAR) {
|
||||
return "NoSuchMethodError: Cannot assign to final variable '$memberName'";
|
||||
|
@ -286,61 +289,73 @@ class _InternalError {
|
|||
|
||||
String type_str;
|
||||
if (type >= 0 && type < 5) {
|
||||
type_str = (const ["method", "getter", "setter", "getter or setter",
|
||||
"variable"])[type];
|
||||
type_str = (const [
|
||||
"method",
|
||||
"getter",
|
||||
"setter",
|
||||
"getter or setter",
|
||||
"variable"
|
||||
])[type];
|
||||
}
|
||||
|
||||
StringBuffer msg_buf = new StringBuffer("NoSuchMethodError: ");
|
||||
bool is_type_call = false;
|
||||
switch (level) {
|
||||
case _InvocationMirror._DYNAMIC: {
|
||||
if (_receiver == null) {
|
||||
if (args_mismatch) {
|
||||
msg_buf.writeln("The null object does not have a $type_str "
|
||||
"'$memberName'$args_message.");
|
||||
case _InvocationMirror._DYNAMIC:
|
||||
{
|
||||
if (_receiver == null) {
|
||||
if (args_mismatch) {
|
||||
msg_buf.writeln("The null object does not have a $type_str "
|
||||
"'$memberName'$args_message.");
|
||||
} else {
|
||||
msg_buf
|
||||
.writeln("The $type_str '$memberName' was called on null.");
|
||||
}
|
||||
} else {
|
||||
msg_buf.writeln("The $type_str '$memberName' was called on null.");
|
||||
}
|
||||
} else {
|
||||
if (_receiver is Function) {
|
||||
msg_buf.writeln("Closure call with mismatched arguments: "
|
||||
"function '$memberName'");
|
||||
} else if (_receiver is _Type && memberName == "call") {
|
||||
is_type_call = true;
|
||||
String name = _receiver.toString();
|
||||
msg_buf.writeln("Attempted to use type '$name' as a function. "
|
||||
"Since types do not define a method 'call', this is not "
|
||||
"possible. Did you intend to call the $name constructor and "
|
||||
"forget the 'new' operator?");
|
||||
} else {
|
||||
msg_buf.writeln("Class '${_receiver.runtimeType}' has no instance "
|
||||
"$type_str '$memberName'$args_message.");
|
||||
if (_receiver is Function) {
|
||||
msg_buf.writeln("Closure call with mismatched arguments: "
|
||||
"function '$memberName'");
|
||||
} else if (_receiver is _Type && memberName == "call") {
|
||||
is_type_call = true;
|
||||
String name = _receiver.toString();
|
||||
msg_buf.writeln("Attempted to use type '$name' as a function. "
|
||||
"Since types do not define a method 'call', this is not "
|
||||
"possible. Did you intend to call the $name constructor and "
|
||||
"forget the 'new' operator?");
|
||||
} else {
|
||||
msg_buf
|
||||
.writeln("Class '${_receiver.runtimeType}' has no instance "
|
||||
"$type_str '$memberName'$args_message.");
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case _InvocationMirror._SUPER: {
|
||||
msg_buf.writeln("Super class of class '${_receiver.runtimeType}' has "
|
||||
case _InvocationMirror._SUPER:
|
||||
{
|
||||
msg_buf.writeln("Super class of class '${_receiver.runtimeType}' has "
|
||||
"no instance $type_str '$memberName'$args_message.");
|
||||
memberName = "super.$memberName";
|
||||
break;
|
||||
}
|
||||
case _InvocationMirror._STATIC: {
|
||||
msg_buf.writeln("No static $type_str '$memberName'$args_message "
|
||||
"declared in class '$_receiver'.");
|
||||
break;
|
||||
}
|
||||
case _InvocationMirror._CONSTRUCTOR: {
|
||||
msg_buf.writeln("No constructor '$memberName'$args_message declared "
|
||||
"in class '$_receiver'.");
|
||||
memberName = "new $memberName";
|
||||
break;
|
||||
}
|
||||
case _InvocationMirror._TOP_LEVEL: {
|
||||
msg_buf.writeln("No top-level $type_str '$memberName'$args_message "
|
||||
"declared.");
|
||||
break;
|
||||
}
|
||||
memberName = "super.$memberName";
|
||||
break;
|
||||
}
|
||||
case _InvocationMirror._STATIC:
|
||||
{
|
||||
msg_buf.writeln("No static $type_str '$memberName'$args_message "
|
||||
"declared in class '$_receiver'.");
|
||||
break;
|
||||
}
|
||||
case _InvocationMirror._CONSTRUCTOR:
|
||||
{
|
||||
msg_buf.writeln("No constructor '$memberName'$args_message declared "
|
||||
"in class '$_receiver'.");
|
||||
memberName = "new $memberName";
|
||||
break;
|
||||
}
|
||||
case _InvocationMirror._TOP_LEVEL:
|
||||
{
|
||||
msg_buf.writeln("No top-level $type_str '$memberName'$args_message "
|
||||
"declared.");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (level == _InvocationMirror._TOP_LEVEL) {
|
||||
|
@ -375,7 +390,6 @@ class _InternalError {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
class _CompileTimeError extends Error {
|
||||
final String _errorMsg;
|
||||
_CompileTimeError(this._errorMsg);
|
||||
|
|
|
@ -2,8 +2,10 @@
|
|||
// for details. All rights reserved. Use of this source code is governed by a
|
||||
// BSD-style license that can be found in the LICENSE file.
|
||||
|
||||
@patch class Expando<T> {
|
||||
@patch Expando([String name])
|
||||
@patch
|
||||
class Expando<T> {
|
||||
@patch
|
||||
Expando([String name])
|
||||
: name = name,
|
||||
_data = new List(_minSize),
|
||||
_used = 0;
|
||||
|
@ -11,7 +13,8 @@
|
|||
static const _minSize = 8;
|
||||
static final _deletedEntry = new _WeakProperty(null, null);
|
||||
|
||||
@patch T operator[](Object object) {
|
||||
@patch
|
||||
T operator [](Object object) {
|
||||
_checkType(object);
|
||||
|
||||
var mask = _size - 1;
|
||||
|
@ -32,7 +35,8 @@
|
|||
return null;
|
||||
}
|
||||
|
||||
@patch void operator[]=(Object object, T value) {
|
||||
@patch
|
||||
void operator []=(Object object, T value) {
|
||||
_checkType(object);
|
||||
|
||||
var mask = _size - 1;
|
||||
|
@ -51,12 +55,12 @@
|
|||
}
|
||||
return;
|
||||
} else if ((empty_idx < 0) && identical(wp, _deletedEntry)) {
|
||||
empty_idx = idx; // Insert at this location if not found.
|
||||
empty_idx = idx; // Insert at this location if not found.
|
||||
} else if (wp.key == null) {
|
||||
// This entry has been cleared by the GC.
|
||||
_data[idx] = _deletedEntry;
|
||||
if (empty_idx < 0) {
|
||||
empty_idx = idx; // Insert at this location if not found.
|
||||
empty_idx = idx; // Insert at this location if not found.
|
||||
}
|
||||
}
|
||||
idx = (idx + 1) & mask;
|
||||
|
@ -83,7 +87,7 @@
|
|||
|
||||
// Grow/reallocate if too many slots have been used.
|
||||
_rehash();
|
||||
this[object] = value; // Recursively add the value.
|
||||
this[object] = value; // Recursively add the value.
|
||||
}
|
||||
|
||||
_rehash() {
|
||||
|
@ -129,9 +133,9 @@
|
|||
|
||||
static _checkType(object) {
|
||||
if ((object == null) ||
|
||||
(object is bool) ||
|
||||
(object is num) ||
|
||||
(object is String)) {
|
||||
(object is bool) ||
|
||||
(object is num) ||
|
||||
(object is String)) {
|
||||
throw new ArgumentError.value(object,
|
||||
"Expandos are not allowed on strings, numbers, booleans or null");
|
||||
}
|
||||
|
@ -141,5 +145,5 @@
|
|||
get _limit => (3 * (_size ~/ 4));
|
||||
|
||||
List _data;
|
||||
int _used; // Number of used (active and deleted) slots.
|
||||
int _used; // Number of used (active and deleted) slots.
|
||||
}
|
||||
|
|
|
@ -3,7 +3,6 @@
|
|||
// BSD-style license that can be found in the LICENSE file.
|
||||
|
||||
class _Closure implements Function {
|
||||
|
||||
bool operator ==(other) native "Closure_equals";
|
||||
|
||||
int get hashCode native "Closure_hashCode";
|
||||
|
|
|
@ -2,14 +2,14 @@
|
|||
// for details. All rights reserved. Use of this source code is governed by a
|
||||
// BSD-style license that can be found in the LICENSE file.
|
||||
|
||||
@patch class Function {
|
||||
static _apply(List arguments, List names)
|
||||
native "Function_apply";
|
||||
@patch
|
||||
class Function {
|
||||
static _apply(List arguments, List names) native "Function_apply";
|
||||
|
||||
@patch static apply(Function function,
|
||||
List positionalArguments,
|
||||
[Map<Symbol, dynamic> namedArguments]) {
|
||||
int numPositionalArguments = 1 + // Function is first implicit argument.
|
||||
@patch
|
||||
static apply(Function function, List positionalArguments,
|
||||
[Map<Symbol, dynamic> namedArguments]) {
|
||||
int numPositionalArguments = 1 + // Function is first implicit argument.
|
||||
(positionalArguments != null ? positionalArguments.length : 0);
|
||||
int numNamedArguments = namedArguments != null ? namedArguments.length : 0;
|
||||
int numArguments = numPositionalArguments + numNamedArguments;
|
||||
|
|
|
@ -3,7 +3,6 @@
|
|||
// BSD-style license that can be found in the LICENSE file.
|
||||
|
||||
class _GrowableList<T> extends ListBase<T> {
|
||||
|
||||
void insert(int index, T element) {
|
||||
if ((index < 0) || (index > length)) {
|
||||
throw new RangeError.range(index, 0, length);
|
||||
|
@ -100,12 +99,11 @@ class _GrowableList<T> extends ListBase<T> {
|
|||
}
|
||||
|
||||
factory _GrowableList.withCapacity(int capacity) {
|
||||
var data = new _List((capacity == 0)? _kDefaultCapacity : capacity);
|
||||
var data = new _List((capacity == 0) ? _kDefaultCapacity : capacity);
|
||||
return new _GrowableList<T>.withData(data);
|
||||
}
|
||||
|
||||
factory _GrowableList.withData(_List data)
|
||||
native "GrowableList_allocate";
|
||||
factory _GrowableList.withData(_List data) native "GrowableList_allocate";
|
||||
|
||||
int get _capacity native "GrowableList_getCapacity";
|
||||
|
||||
|
@ -170,8 +168,7 @@ class _GrowableList<T> extends ListBase<T> {
|
|||
void addAll(Iterable<T> iterable) {
|
||||
var len = length;
|
||||
final cid = ClassID.getID(iterable);
|
||||
final isVMList =
|
||||
(cid == ClassID.cidArray) ||
|
||||
final isVMList = (cid == ClassID.cidArray) ||
|
||||
(cid == ClassID.cidGrowableObjectArray) ||
|
||||
(cid == ClassID.cidImmutableArray);
|
||||
if (isVMList || (iterable is EfficientLengthIterable)) {
|
||||
|
@ -231,7 +228,8 @@ class _GrowableList<T> extends ListBase<T> {
|
|||
T get single {
|
||||
if (length == 1) return this[0];
|
||||
if (length == 0) throw IterableElementError.noElement();
|
||||
throw IterableElementError.tooMany();;
|
||||
throw IterableElementError.tooMany();
|
||||
;
|
||||
}
|
||||
|
||||
void _grow(int new_capacity) {
|
||||
|
@ -348,7 +346,7 @@ class _GrowableList<T> extends ListBase<T> {
|
|||
return new ListIterator<T>(this);
|
||||
}
|
||||
|
||||
List<T> toList({ bool growable: true }) {
|
||||
List<T> toList({bool growable: true}) {
|
||||
var length = this.length;
|
||||
if (length > 0) {
|
||||
List list = growable ? new _List(length) : new _List<T>(length);
|
||||
|
|
|
@ -2,6 +2,8 @@
|
|||
// for details. All rights reserved. Use of this source code is governed by a
|
||||
// BSD-style license that can be found in the LICENSE file.
|
||||
|
||||
@patch bool identical(Object a, Object b) native "Identical_comparison";
|
||||
@patch
|
||||
bool identical(Object a, Object b) native "Identical_comparison";
|
||||
|
||||
@patch int identityHashCode(Object object) => object._identityHashCode;
|
||||
@patch
|
||||
int identityHashCode(Object object) => object._identityHashCode;
|
||||
|
|
|
@ -9,14 +9,13 @@ class _ImmutableMap<K, V> implements Map<K, V> {
|
|||
const _ImmutableMap._create(_ImmutableList keyValuePairs)
|
||||
: _kvPairs = keyValuePairs;
|
||||
|
||||
|
||||
V operator [](Object key) {
|
||||
// To preserve the key-value order of the map literal, the keys are
|
||||
// not sorted. Need to do linear search or implement an additional
|
||||
// lookup table.
|
||||
for (int i = 0; i < _kvPairs.length - 1; i += 2) {
|
||||
if (key == _kvPairs[i]) {
|
||||
return _kvPairs[i+1];
|
||||
return _kvPairs[i + 1];
|
||||
}
|
||||
}
|
||||
return null;
|
||||
|
@ -34,7 +33,7 @@ class _ImmutableMap<K, V> implements Map<K, V> {
|
|||
|
||||
void forEach(void f(K key, V value)) {
|
||||
for (int i = 0; i < _kvPairs.length; i += 2) {
|
||||
f(_kvPairs[i], _kvPairs[i+1]);
|
||||
f(_kvPairs[i], _kvPairs[i + 1]);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -4,10 +4,12 @@
|
|||
|
||||
import 'dart:core' hide Symbol;
|
||||
|
||||
@patch List makeListFixedLength(List growableList)
|
||||
@patch
|
||||
List makeListFixedLength(List growableList)
|
||||
native "Internal_makeListFixedLength";
|
||||
|
||||
@patch List makeFixedListUnmodifiable(List fixedLengthList)
|
||||
@patch
|
||||
List makeFixedListUnmodifiable(List fixedLengthList)
|
||||
native "Internal_makeFixedListUnmodifiable";
|
||||
|
||||
class VMLibraryHooks {
|
||||
|
@ -48,11 +50,11 @@ bool _classRangeCheckNegative(int cid, int lowerLimit, int upperLimit) {
|
|||
|
||||
// Utility class now only used by the VM.
|
||||
class Lists {
|
||||
static void copy(List src, int srcStart,
|
||||
List dst, int dstStart, int count) {
|
||||
static void copy(List src, int srcStart, List dst, int dstStart, int count) {
|
||||
if (srcStart < dstStart) {
|
||||
for (int i = srcStart + count - 1, j = dstStart + count - 1;
|
||||
i >= srcStart; i--, j--) {
|
||||
i >= srcStart;
|
||||
i--, j--) {
|
||||
dst[j] = src[i];
|
||||
}
|
||||
} else {
|
||||
|
|
|
@ -40,13 +40,11 @@ class _InvocationMirror implements Invocation {
|
|||
void _setMemberNameAndType() {
|
||||
if (_functionName.startsWith("get:")) {
|
||||
_type = _GETTER;
|
||||
_memberName =
|
||||
new internal.Symbol.unvalidated(_functionName.substring(4));
|
||||
_memberName = new internal.Symbol.unvalidated(_functionName.substring(4));
|
||||
} else if (_functionName.startsWith("set:")) {
|
||||
_type = _SETTER;
|
||||
_memberName =
|
||||
new internal.Symbol.unvalidated(
|
||||
_functionName.substring(4) + "=");
|
||||
new internal.Symbol.unvalidated(_functionName.substring(4) + "=");
|
||||
} else {
|
||||
_type = _isSuperInvocation ? (_SUPER << _CALL_SHIFT) | _METHOD : _METHOD;
|
||||
_memberName = new internal.Symbol.unvalidated(_functionName);
|
||||
|
@ -76,7 +74,7 @@ class _InvocationMirror implements Invocation {
|
|||
|
||||
Map<Symbol, dynamic> get namedArguments {
|
||||
if (_namedArguments == null) {
|
||||
int numArguments = _argumentsDescriptor[0] - 1; // Exclude receiver.
|
||||
int numArguments = _argumentsDescriptor[0] - 1; // Exclude receiver.
|
||||
int numPositionalArguments = _argumentsDescriptor[1] - 1;
|
||||
int numNamedArguments = numArguments - numPositionalArguments;
|
||||
if (numNamedArguments == 0) {
|
||||
|
@ -84,10 +82,9 @@ class _InvocationMirror implements Invocation {
|
|||
}
|
||||
_namedArguments = new Map<Symbol, dynamic>();
|
||||
for (int i = 0; i < numNamedArguments; i++) {
|
||||
String arg_name = _argumentsDescriptor[2 + 2*i];
|
||||
var arg_value = _arguments[_argumentsDescriptor[3 + 2*i]];
|
||||
_namedArguments[new internal.Symbol.unvalidated(arg_name)] =
|
||||
arg_value;
|
||||
String arg_name = _argumentsDescriptor[2 + 2 * i];
|
||||
var arg_value = _arguments[_argumentsDescriptor[3 + 2 * i]];
|
||||
_namedArguments[new internal.Symbol.unvalidated(arg_name)] = arg_value;
|
||||
}
|
||||
_namedArguments = new Map.unmodifiable(_namedArguments);
|
||||
}
|
||||
|
@ -122,18 +119,12 @@ class _InvocationMirror implements Invocation {
|
|||
return (_type & _TYPE_MASK) == _SETTER;
|
||||
}
|
||||
|
||||
_InvocationMirror(this._functionName,
|
||||
this._argumentsDescriptor,
|
||||
this._arguments,
|
||||
this._isSuperInvocation);
|
||||
_InvocationMirror(this._functionName, this._argumentsDescriptor,
|
||||
this._arguments, this._isSuperInvocation);
|
||||
|
||||
static _allocateInvocationMirror(String functionName,
|
||||
List argumentsDescriptor,
|
||||
List arguments,
|
||||
bool isSuperInvocation) {
|
||||
return new _InvocationMirror(functionName,
|
||||
argumentsDescriptor,
|
||||
arguments,
|
||||
isSuperInvocation);
|
||||
List argumentsDescriptor, List arguments, bool isSuperInvocation) {
|
||||
return new _InvocationMirror(
|
||||
functionName, argumentsDescriptor, arguments, isSuperInvocation);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -5,21 +5,26 @@
|
|||
import "dart:collection" show HashMap;
|
||||
import "dart:_internal" hide Symbol;
|
||||
|
||||
@patch class ReceivePort {
|
||||
@patch factory ReceivePort() = _ReceivePortImpl;
|
||||
@patch
|
||||
class ReceivePort {
|
||||
@patch
|
||||
factory ReceivePort() = _ReceivePortImpl;
|
||||
|
||||
@patch factory ReceivePort.fromRawReceivePort(RawReceivePort rawPort) =
|
||||
@patch
|
||||
factory ReceivePort.fromRawReceivePort(RawReceivePort rawPort) =
|
||||
_ReceivePortImpl.fromRawReceivePort;
|
||||
}
|
||||
|
||||
@patch class Capability {
|
||||
@patch factory Capability() = _CapabilityImpl;
|
||||
@patch
|
||||
class Capability {
|
||||
@patch
|
||||
factory Capability() = _CapabilityImpl;
|
||||
}
|
||||
|
||||
class _CapabilityImpl implements Capability {
|
||||
factory _CapabilityImpl() native "CapabilityImpl_factory";
|
||||
|
||||
bool operator==(var other) {
|
||||
bool operator ==(var other) {
|
||||
return (other is _CapabilityImpl) && _equals(other);
|
||||
}
|
||||
|
||||
|
@ -31,7 +36,8 @@ class _CapabilityImpl implements Capability {
|
|||
_get_hashcode() native "CapabilityImpl_get_hashcode";
|
||||
}
|
||||
|
||||
@patch class RawReceivePort {
|
||||
@patch
|
||||
class RawReceivePort {
|
||||
/**
|
||||
* Opens a long-lived port for receiving messages.
|
||||
*
|
||||
|
@ -39,7 +45,8 @@ class _CapabilityImpl implements Capability {
|
|||
* can not be paused. The data-handler must be set before the first
|
||||
* event is received.
|
||||
*/
|
||||
@patch factory RawReceivePort([void handler(event)]) {
|
||||
@patch
|
||||
factory RawReceivePort([void handler(event)]) {
|
||||
_RawReceivePortImpl result = new _RawReceivePortImpl();
|
||||
result.handler = handler;
|
||||
return result;
|
||||
|
@ -59,13 +66,9 @@ class _ReceivePortImpl extends Stream implements ReceivePort {
|
|||
}
|
||||
|
||||
StreamSubscription listen(void onData(var message),
|
||||
{ Function onError,
|
||||
void onDone(),
|
||||
bool cancelOnError }) {
|
||||
{Function onError, void onDone(), bool cancelOnError}) {
|
||||
return _controller.stream.listen(onData,
|
||||
onError: onError,
|
||||
onDone: onDone,
|
||||
cancelOnError: cancelOnError);
|
||||
onError: onError, onDone: onDone, cancelOnError: cancelOnError);
|
||||
}
|
||||
|
||||
close() {
|
||||
|
@ -121,7 +124,7 @@ class _RawReceivePortImpl implements RawReceivePort {
|
|||
return _get_sendport();
|
||||
}
|
||||
|
||||
bool operator==(var other) {
|
||||
bool operator ==(var other) {
|
||||
return (other is _RawReceivePortImpl) &&
|
||||
(this._get_id() == other._get_id());
|
||||
}
|
||||
|
@ -167,17 +170,17 @@ class _RawReceivePortImpl implements RawReceivePort {
|
|||
|
||||
return new HashMap();
|
||||
}
|
||||
|
||||
static final Map _handlerMap = _initHandlerMap();
|
||||
}
|
||||
|
||||
|
||||
class _SendPortImpl implements SendPort {
|
||||
/*--- public interface ---*/
|
||||
void send(var message) {
|
||||
_sendInternal(message);
|
||||
}
|
||||
|
||||
bool operator==(var other) {
|
||||
bool operator ==(var other) {
|
||||
return (other is _SendPortImpl) && (this._get_id() == other._get_id());
|
||||
}
|
||||
|
||||
|
@ -202,31 +205,32 @@ typedef _BinaryFunction(args, message);
|
|||
* initial message. Defers execution of the entry point until the
|
||||
* isolate is in the message loop.
|
||||
*/
|
||||
void _startMainIsolate(Function entryPoint,
|
||||
List<String> args) {
|
||||
_startIsolate(null, // no parent port
|
||||
entryPoint,
|
||||
args,
|
||||
null, // no message
|
||||
true, // isSpawnUri
|
||||
null, // no control port
|
||||
null); // no capabilities
|
||||
void _startMainIsolate(Function entryPoint, List<String> args) {
|
||||
_startIsolate(
|
||||
null, // no parent port
|
||||
entryPoint,
|
||||
args,
|
||||
null, // no message
|
||||
true, // isSpawnUri
|
||||
null, // no control port
|
||||
null); // no capabilities
|
||||
}
|
||||
|
||||
/**
|
||||
* Takes the real entry point as argument and invokes it with the initial
|
||||
* message.
|
||||
*/
|
||||
void _startIsolate(SendPort parentPort,
|
||||
Function entryPoint,
|
||||
List<String> args,
|
||||
var message,
|
||||
bool isSpawnUri,
|
||||
RawReceivePort controlPort,
|
||||
List capabilities) {
|
||||
void _startIsolate(
|
||||
SendPort parentPort,
|
||||
Function entryPoint,
|
||||
List<String> args,
|
||||
var message,
|
||||
bool isSpawnUri,
|
||||
RawReceivePort controlPort,
|
||||
List capabilities) {
|
||||
// The control port (aka the main isolate port) does not handle any messages.
|
||||
if (controlPort != null) {
|
||||
controlPort.handler = (_) {}; // Nobody home on the control port.
|
||||
controlPort.handler = (_) {}; // Nobody home on the control port.
|
||||
}
|
||||
|
||||
if (parentPort != null) {
|
||||
|
@ -268,13 +272,16 @@ void _startIsolate(SendPort parentPort,
|
|||
port.sendPort.send(null);
|
||||
}
|
||||
|
||||
@patch class Isolate {
|
||||
@patch
|
||||
class Isolate {
|
||||
static final _currentIsolate = _getCurrentIsolate();
|
||||
static final _rootUri = _getCurrentRootUri();
|
||||
|
||||
@patch static Isolate get current => _currentIsolate;
|
||||
@patch
|
||||
static Isolate get current => _currentIsolate;
|
||||
|
||||
@patch static Future<Uri> get packageRoot {
|
||||
@patch
|
||||
static Future<Uri> get packageRoot {
|
||||
var hook = VMLibraryHooks.packageRootUriFuture;
|
||||
if (hook == null) {
|
||||
throw new UnsupportedError("Isolate.packageRoot");
|
||||
|
@ -282,7 +289,8 @@ void _startIsolate(SendPort parentPort,
|
|||
return hook();
|
||||
}
|
||||
|
||||
@patch static Future<Uri> get packageConfig {
|
||||
@patch
|
||||
static Future<Uri> get packageConfig {
|
||||
var hook = VMLibraryHooks.packageConfigUriFuture;
|
||||
if (hook == null) {
|
||||
throw new UnsupportedError("Isolate.packageConfig");
|
||||
|
@ -290,7 +298,8 @@ void _startIsolate(SendPort parentPort,
|
|||
return hook();
|
||||
}
|
||||
|
||||
@patch static Future<Uri> resolvePackageUri(Uri packageUri) {
|
||||
@patch
|
||||
static Future<Uri> resolvePackageUri(Uri packageUri) {
|
||||
var hook = VMLibraryHooks.resolvePackageUriFuture;
|
||||
if (hook == null) {
|
||||
throw new UnsupportedError("Isolate.resolvePackageUri");
|
||||
|
@ -303,10 +312,12 @@ void _startIsolate(SendPort parentPort,
|
|||
(VMLibraryHooks.packageConfigUriFuture != null) &&
|
||||
(VMLibraryHooks.resolvePackageUriFuture != null);
|
||||
|
||||
@patch static Future<Isolate> spawn(
|
||||
void entryPoint(message), var message,
|
||||
{bool paused: false, bool errorsAreFatal,
|
||||
SendPort onExit, SendPort onError}) async {
|
||||
@patch
|
||||
static Future<Isolate> spawn(void entryPoint(message), var message,
|
||||
{bool paused: false,
|
||||
bool errorsAreFatal,
|
||||
SendPort onExit,
|
||||
SendPort onError}) async {
|
||||
// `paused` isn't handled yet.
|
||||
RawReceivePort readyPort;
|
||||
try {
|
||||
|
@ -334,8 +345,7 @@ void _startIsolate(SendPort parentPort,
|
|||
}
|
||||
|
||||
_spawnFunction(readyPort.sendPort, script.toString(), entryPoint, message,
|
||||
paused, errorsAreFatal, onExit, onError,
|
||||
packageRoot, packageConfig);
|
||||
paused, errorsAreFatal, onExit, onError, packageRoot, packageConfig);
|
||||
return await _spawnCommon(readyPort);
|
||||
} catch (e, st) {
|
||||
if (readyPort != null) {
|
||||
|
@ -345,17 +355,17 @@ void _startIsolate(SendPort parentPort,
|
|||
}
|
||||
}
|
||||
|
||||
@patch static Future<Isolate> spawnUri(
|
||||
Uri uri, List<String> args, var message,
|
||||
@patch
|
||||
static Future<Isolate> spawnUri(Uri uri, List<String> args, var message,
|
||||
{bool paused: false,
|
||||
SendPort onExit,
|
||||
SendPort onError,
|
||||
bool errorsAreFatal,
|
||||
bool checked,
|
||||
Map<String, String> environment,
|
||||
Uri packageRoot,
|
||||
Uri packageConfig,
|
||||
bool automaticPackageResolution: false}) async {
|
||||
SendPort onExit,
|
||||
SendPort onError,
|
||||
bool errorsAreFatal,
|
||||
bool checked,
|
||||
Map<String, String> environment,
|
||||
Uri packageRoot,
|
||||
Uri packageConfig,
|
||||
bool automaticPackageResolution: false}) async {
|
||||
RawReceivePort readyPort;
|
||||
if (environment != null) {
|
||||
throw new UnimplementedError("environment");
|
||||
|
@ -365,18 +375,18 @@ void _startIsolate(SendPort parentPort,
|
|||
if (automaticPackageResolution) {
|
||||
if (packageRoot != null) {
|
||||
throw new ArgumentError("Cannot simultaneously request "
|
||||
"automaticPackageResolution and specify a"
|
||||
"packageRoot.");
|
||||
"automaticPackageResolution and specify a"
|
||||
"packageRoot.");
|
||||
}
|
||||
if (packageConfig != null) {
|
||||
throw new ArgumentError("Cannot simultaneously request "
|
||||
"automaticPackageResolution and specify a"
|
||||
"packageConfig.");
|
||||
"automaticPackageResolution and specify a"
|
||||
"packageConfig.");
|
||||
}
|
||||
} else {
|
||||
if ((packageRoot != null) && (packageConfig != null)) {
|
||||
throw new ArgumentError("Cannot simultaneously specify a "
|
||||
"packageRoot and a packageConfig.");
|
||||
"packageRoot and a packageConfig.");
|
||||
}
|
||||
}
|
||||
try {
|
||||
|
@ -413,12 +423,20 @@ void _startIsolate(SendPort parentPort,
|
|||
var packageRootString = packageRoot?.toString();
|
||||
var packageConfigString = packageConfig?.toString();
|
||||
|
||||
_spawnUri(readyPort.sendPort, spawnedUri.toString(),
|
||||
args, message,
|
||||
paused, onExit, onError,
|
||||
errorsAreFatal, checked,
|
||||
null, /* environment */
|
||||
packageRootString, packageConfigString);
|
||||
_spawnUri(
|
||||
readyPort.sendPort,
|
||||
spawnedUri.toString(),
|
||||
args,
|
||||
message,
|
||||
paused,
|
||||
onExit,
|
||||
onError,
|
||||
errorsAreFatal,
|
||||
checked,
|
||||
null,
|
||||
/* environment */
|
||||
packageRootString,
|
||||
packageConfigString);
|
||||
return await _spawnCommon(readyPort);
|
||||
} catch (e, st) {
|
||||
if (readyPort != null) {
|
||||
|
@ -436,8 +454,8 @@ void _startIsolate(SendPort parentPort,
|
|||
SendPort controlPort = readyMessage[0];
|
||||
List capabilities = readyMessage[1];
|
||||
completer.complete(new Isolate(controlPort,
|
||||
pauseCapability: capabilities[0],
|
||||
terminateCapability: capabilities[1]));
|
||||
pauseCapability: capabilities[0],
|
||||
terminateCapability: capabilities[1]));
|
||||
} else if (readyMessage is String) {
|
||||
// We encountered an error while starting the new isolate.
|
||||
completer.completeError(new IsolateSpawnException(
|
||||
|
@ -465,110 +483,127 @@ void _startIsolate(SendPort parentPort,
|
|||
static const _DEL_ERROR = 8;
|
||||
static const _ERROR_FATAL = 9;
|
||||
|
||||
static void _spawnFunction(
|
||||
SendPort readyPort,
|
||||
String uri,
|
||||
Function topLevelFunction,
|
||||
var message,
|
||||
bool paused,
|
||||
bool errorsAreFatal,
|
||||
SendPort onExit,
|
||||
SendPort onError,
|
||||
String packageRoot,
|
||||
String packageConfig) native "Isolate_spawnFunction";
|
||||
|
||||
static void _spawnFunction(SendPort readyPort, String uri,
|
||||
Function topLevelFunction,
|
||||
var message, bool paused, bool errorsAreFatal,
|
||||
SendPort onExit, SendPort onError,
|
||||
String packageRoot, String packageConfig)
|
||||
native "Isolate_spawnFunction";
|
||||
|
||||
static void _spawnUri(SendPort readyPort, String uri,
|
||||
List<String> args, var message,
|
||||
bool paused, SendPort onExit, SendPort onError,
|
||||
bool errorsAreFatal, bool checked,
|
||||
List environment,
|
||||
String packageRoot, String packageConfig)
|
||||
native "Isolate_spawnUri";
|
||||
static void _spawnUri(
|
||||
SendPort readyPort,
|
||||
String uri,
|
||||
List<String> args,
|
||||
var message,
|
||||
bool paused,
|
||||
SendPort onExit,
|
||||
SendPort onError,
|
||||
bool errorsAreFatal,
|
||||
bool checked,
|
||||
List environment,
|
||||
String packageRoot,
|
||||
String packageConfig) native "Isolate_spawnUri";
|
||||
|
||||
static void _sendOOB(port, msg) native "Isolate_sendOOB";
|
||||
|
||||
@patch void _pause(Capability resumeCapability) {
|
||||
@patch
|
||||
void _pause(Capability resumeCapability) {
|
||||
var msg = new List(4)
|
||||
..[0] = 0 // Make room for OOB message type.
|
||||
..[1] = _PAUSE
|
||||
..[2] = pauseCapability
|
||||
..[3] = resumeCapability;
|
||||
..[0] = 0 // Make room for OOB message type.
|
||||
..[1] = _PAUSE
|
||||
..[2] = pauseCapability
|
||||
..[3] = resumeCapability;
|
||||
_sendOOB(controlPort, msg);
|
||||
}
|
||||
|
||||
@patch void resume(Capability resumeCapability) {
|
||||
@patch
|
||||
void resume(Capability resumeCapability) {
|
||||
var msg = new List(4)
|
||||
..[0] = 0 // Make room for OOB message type.
|
||||
..[1] = _RESUME
|
||||
..[2] = pauseCapability
|
||||
..[3] = resumeCapability;
|
||||
..[0] = 0 // Make room for OOB message type.
|
||||
..[1] = _RESUME
|
||||
..[2] = pauseCapability
|
||||
..[3] = resumeCapability;
|
||||
_sendOOB(controlPort, msg);
|
||||
}
|
||||
|
||||
@patch void addOnExitListener(SendPort responsePort,
|
||||
{Object response}) {
|
||||
@patch
|
||||
void addOnExitListener(SendPort responsePort, {Object response}) {
|
||||
var msg = new List(4)
|
||||
..[0] = 0 // Make room for OOB message type.
|
||||
..[1] = _ADD_EXIT
|
||||
..[2] = responsePort
|
||||
..[3] = response;
|
||||
..[0] = 0 // Make room for OOB message type.
|
||||
..[1] = _ADD_EXIT
|
||||
..[2] = responsePort
|
||||
..[3] = response;
|
||||
_sendOOB(controlPort, msg);
|
||||
}
|
||||
|
||||
@patch void removeOnExitListener(SendPort responsePort) {
|
||||
@patch
|
||||
void removeOnExitListener(SendPort responsePort) {
|
||||
var msg = new List(3)
|
||||
..[0] = 0 // Make room for OOB message type.
|
||||
..[1] = _DEL_EXIT
|
||||
..[2] = responsePort;
|
||||
..[0] = 0 // Make room for OOB message type.
|
||||
..[1] = _DEL_EXIT
|
||||
..[2] = responsePort;
|
||||
_sendOOB(controlPort, msg);
|
||||
}
|
||||
|
||||
@patch void setErrorsFatal(bool errorsAreFatal) {
|
||||
@patch
|
||||
void setErrorsFatal(bool errorsAreFatal) {
|
||||
var msg = new List(4)
|
||||
..[0] = 0 // Make room for OOB message type.
|
||||
..[0] = 0 // Make room for OOB message type.
|
||||
..[1] = _ERROR_FATAL
|
||||
..[2] = terminateCapability
|
||||
..[3] = errorsAreFatal;
|
||||
_sendOOB(controlPort, msg);
|
||||
}
|
||||
|
||||
@patch void kill({int priority: BEFORE_NEXT_EVENT}) {
|
||||
@patch
|
||||
void kill({int priority: BEFORE_NEXT_EVENT}) {
|
||||
var msg = new List(4)
|
||||
..[0] = 0 // Make room for OOB message type.
|
||||
..[1] = _KILL
|
||||
..[2] = terminateCapability
|
||||
..[3] = priority;
|
||||
..[0] = 0 // Make room for OOB message type.
|
||||
..[1] = _KILL
|
||||
..[2] = terminateCapability
|
||||
..[3] = priority;
|
||||
_sendOOB(controlPort, msg);
|
||||
}
|
||||
|
||||
@patch void ping(SendPort responsePort, {Object response,
|
||||
int priority: IMMEDIATE}) {
|
||||
@patch
|
||||
void ping(SendPort responsePort, {Object response, int priority: IMMEDIATE}) {
|
||||
var msg = new List(5)
|
||||
..[0] = 0 // Make room for OOM message type.
|
||||
..[1] = _PING
|
||||
..[2] = responsePort
|
||||
..[3] = priority
|
||||
..[4] = response;
|
||||
..[0] = 0 // Make room for OOM message type.
|
||||
..[1] = _PING
|
||||
..[2] = responsePort
|
||||
..[3] = priority
|
||||
..[4] = response;
|
||||
_sendOOB(controlPort, msg);
|
||||
}
|
||||
|
||||
@patch void addErrorListener(SendPort port) {
|
||||
@patch
|
||||
void addErrorListener(SendPort port) {
|
||||
var msg = new List(3)
|
||||
..[0] = 0 // Make room for OOB message type.
|
||||
..[1] = _ADD_ERROR
|
||||
..[2] = port;
|
||||
..[0] = 0 // Make room for OOB message type.
|
||||
..[1] = _ADD_ERROR
|
||||
..[2] = port;
|
||||
_sendOOB(controlPort, msg);
|
||||
}
|
||||
|
||||
@patch void removeErrorListener(SendPort port) {
|
||||
@patch
|
||||
void removeErrorListener(SendPort port) {
|
||||
var msg = new List(3)
|
||||
..[0] = 0 // Make room for OOB message type.
|
||||
..[1] = _DEL_ERROR
|
||||
..[2] = port;
|
||||
..[0] = 0 // Make room for OOB message type.
|
||||
..[1] = _DEL_ERROR
|
||||
..[2] = port;
|
||||
_sendOOB(controlPort, msg);
|
||||
}
|
||||
|
||||
static Isolate _getCurrentIsolate() {
|
||||
List portAndCapabilities = _getPortAndCapabilitiesOfCurrentIsolate();
|
||||
return new Isolate(portAndCapabilities[0],
|
||||
pauseCapability: portAndCapabilities[1],
|
||||
terminateCapability: portAndCapabilities[2]);
|
||||
pauseCapability: portAndCapabilities[1],
|
||||
terminateCapability: portAndCapabilities[2]);
|
||||
}
|
||||
|
||||
static List _getPortAndCapabilitiesOfCurrentIsolate()
|
||||
|
@ -582,6 +617,5 @@ void _startIsolate(SendPort parentPort,
|
|||
}
|
||||
}
|
||||
|
||||
static String _getCurrentRootUriStr()
|
||||
native "Isolate_getCurrentRootUriStr";
|
||||
static String _getCurrentRootUriStr() native "Isolate_getCurrentRootUriStr";
|
||||
}
|
||||
|
|
|
@ -2,7 +2,8 @@
|
|||
// for details. All rights reserved. Use of this source code is governed by a
|
||||
// BSD-style license that can be found in the LICENSE file.
|
||||
|
||||
@patch class Map<K, V> {
|
||||
@patch
|
||||
class Map<K, V> {
|
||||
// Factory constructing a Map from a parser generated Map literal.
|
||||
// [elements] contains n key-value pairs.
|
||||
// The keys are at position 2*n and are already type checked by the parser
|
||||
|
@ -17,9 +18,11 @@
|
|||
return map;
|
||||
}
|
||||
|
||||
@patch factory Map.unmodifiable(Map other) {
|
||||
@patch
|
||||
factory Map.unmodifiable(Map other) {
|
||||
return new UnmodifiableMapView<K, V>(new Map.from(other));
|
||||
}
|
||||
|
||||
@patch factory Map() = LinkedHashMap<K, V>;
|
||||
@patch
|
||||
factory Map() = LinkedHashMap<K, V>;
|
||||
}
|
||||
|
|
|
@ -8,7 +8,8 @@ import "dart:typed_data";
|
|||
|
||||
// If [x] is an [int] and [exponent] is a non-negative [int], the result is
|
||||
// an [int], otherwise the result is a [double].
|
||||
@patch num pow(num x, num exponent) {
|
||||
@patch
|
||||
num pow(num x, num exponent) {
|
||||
if ((x is int) && (exponent is int) && (exponent >= 0)) {
|
||||
return _intPow(x, exponent);
|
||||
}
|
||||
|
@ -17,7 +18,7 @@ import "dart:typed_data";
|
|||
|
||||
double _doublePow(double base, double exponent) {
|
||||
if (exponent == 0.0) {
|
||||
return 1.0; // ECMA-262 15.8.2.13
|
||||
return 1.0; // ECMA-262 15.8.2.13
|
||||
}
|
||||
// Speed up simple cases.
|
||||
if (exponent == 1.0) return base;
|
||||
|
@ -56,16 +57,26 @@ int _intPow(int base, int exponent) {
|
|||
return result;
|
||||
}
|
||||
|
||||
@patch double atan2(num a, num b) => _atan2(a.toDouble(), b.toDouble());
|
||||
@patch double sin(num x) => _sin(x.toDouble());
|
||||
@patch double cos(num x) => _cos(x.toDouble());
|
||||
@patch double tan(num x) => _tan(x.toDouble());
|
||||
@patch double acos(num x) => _acos(x.toDouble());
|
||||
@patch double asin(num x) => _asin(x.toDouble());
|
||||
@patch double atan(num x) => _atan(x.toDouble());
|
||||
@patch double sqrt(num x) => _sqrt(x.toDouble());
|
||||
@patch double exp(num x) => _exp(x.toDouble());
|
||||
@patch double log(num x) => _log(x.toDouble());
|
||||
@patch
|
||||
double atan2(num a, num b) => _atan2(a.toDouble(), b.toDouble());
|
||||
@patch
|
||||
double sin(num x) => _sin(x.toDouble());
|
||||
@patch
|
||||
double cos(num x) => _cos(x.toDouble());
|
||||
@patch
|
||||
double tan(num x) => _tan(x.toDouble());
|
||||
@patch
|
||||
double acos(num x) => _acos(x.toDouble());
|
||||
@patch
|
||||
double asin(num x) => _asin(x.toDouble());
|
||||
@patch
|
||||
double atan(num x) => _atan(x.toDouble());
|
||||
@patch
|
||||
double sqrt(num x) => _sqrt(x.toDouble());
|
||||
@patch
|
||||
double exp(num x) => _exp(x.toDouble());
|
||||
@patch
|
||||
double log(num x) => _log(x.toDouble());
|
||||
|
||||
double _atan2(double a, double b) native "Math_atan2";
|
||||
double _sin(double x) native "Math_sin";
|
||||
|
@ -78,30 +89,31 @@ double _sqrt(double x) native "Math_sqrt";
|
|||
double _exp(double x) native "Math_exp";
|
||||
double _log(double x) native "Math_log";
|
||||
|
||||
|
||||
// TODO(iposva): Handle patch methods within a patch class correctly.
|
||||
@patch class Random {
|
||||
|
||||
@patch factory Random([int seed]) {
|
||||
@patch
|
||||
class Random {
|
||||
@patch
|
||||
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).._nextState()
|
||||
.._nextState()
|
||||
.._nextState()
|
||||
.._nextState();
|
||||
return new _Random._withState(state)
|
||||
.._nextState()
|
||||
.._nextState()
|
||||
.._nextState()
|
||||
.._nextState();
|
||||
}
|
||||
|
||||
@patch factory Random.secure() {
|
||||
@patch
|
||||
factory Random.secure() {
|
||||
return new _SecureRandom();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
class _Random implements Random {
|
||||
// Internal state of the random number generator.
|
||||
final Uint32List _state;
|
||||
static const _kSTATE_LO = 0;
|
||||
static const _kSTATE_HI = 1; // Unused in Dart code.
|
||||
static const _kSTATE_HI = 1; // Unused in Dart code.
|
||||
|
||||
_Random._withState(this._state);
|
||||
|
||||
|
@ -122,8 +134,8 @@ class _Random implements Random {
|
|||
int nextInt(int max) {
|
||||
const limit = 0x3FFFFFFF;
|
||||
if ((max <= 0) || ((max > limit) && (max > _POW2_32))) {
|
||||
throw new RangeError.range(max, 1, _POW2_32, "max",
|
||||
"Must be positive and <= 2^32");
|
||||
throw new RangeError.range(
|
||||
max, 1, _POW2_32, "max", "Must be positive and <= 2^32");
|
||||
}
|
||||
if ((max & -max) == max) {
|
||||
// Fast case for powers of two.
|
||||
|
@ -173,7 +185,6 @@ class _Random implements Random {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
class _SecureRandom implements Random {
|
||||
_SecureRandom() {
|
||||
// Throw early in constructor if entropy source is not hooked up.
|
||||
|
@ -188,7 +199,7 @@ class _SecureRandom implements Random {
|
|||
max, 1, _POW2_32, "max", "Must be positive and <= 2^32");
|
||||
final byteCount = ((max - 1).bitLength + 7) >> 3;
|
||||
if (byteCount == 0) {
|
||||
return 0; // Not random if max == 1.
|
||||
return 0; // Not random if max == 1.
|
||||
}
|
||||
var rnd;
|
||||
var result;
|
||||
|
@ -211,4 +222,3 @@ class _SecureRandom implements Random {
|
|||
static const _POW2_32 = 1 << 32;
|
||||
static const _POW2_53_D = 1.0 * (1 << 53);
|
||||
}
|
||||
|
||||
|
|
|
@ -9,7 +9,8 @@ import "dart:_internal" as internal;
|
|||
/**
|
||||
* Returns a [MirrorSystem] for the current isolate.
|
||||
*/
|
||||
@patch MirrorSystem currentMirrorSystem() {
|
||||
@patch
|
||||
MirrorSystem currentMirrorSystem() {
|
||||
return _Mirrors.currentMirrorSystem();
|
||||
}
|
||||
|
||||
|
@ -19,7 +20,8 @@ import "dart:_internal" as internal;
|
|||
* This only works if this mirror system is associated with the
|
||||
* current running isolate.
|
||||
*/
|
||||
@patch InstanceMirror reflect(Object reflectee) {
|
||||
@patch
|
||||
InstanceMirror reflect(Object reflectee) {
|
||||
return _Mirrors.reflect(reflectee);
|
||||
}
|
||||
|
||||
|
@ -29,16 +31,20 @@ import "dart:_internal" as internal;
|
|||
*
|
||||
* This only works with objects local to the current isolate.
|
||||
*/
|
||||
@patch ClassMirror reflectClass(Type key) {
|
||||
@patch
|
||||
ClassMirror reflectClass(Type key) {
|
||||
return _Mirrors.reflectClass(key);
|
||||
}
|
||||
|
||||
@patch TypeMirror reflectType(Type key, [List<Type> typeArguments]) {
|
||||
@patch
|
||||
TypeMirror reflectType(Type key, [List<Type> typeArguments]) {
|
||||
return _Mirrors.reflectType(key, typeArguments);
|
||||
}
|
||||
|
||||
@patch class MirrorSystem {
|
||||
@patch LibraryMirror findLibrary(Symbol libraryName) {
|
||||
@patch
|
||||
class MirrorSystem {
|
||||
@patch
|
||||
LibraryMirror findLibrary(Symbol libraryName) {
|
||||
var candidates =
|
||||
libraries.values.where((lib) => lib.simpleName == libraryName);
|
||||
if (candidates.length == 1) {
|
||||
|
@ -47,16 +53,18 @@ import "dart:_internal" as internal;
|
|||
if (candidates.length > 1) {
|
||||
var uris = candidates.map((lib) => lib.uri.toString()).toList();
|
||||
throw new Exception("There are multiple libraries named "
|
||||
"'${getName(libraryName)}': $uris");
|
||||
"'${getName(libraryName)}': $uris");
|
||||
}
|
||||
throw new Exception("There is no library named '${getName(libraryName)}'");
|
||||
}
|
||||
|
||||
@patch static String getName(Symbol symbol) {
|
||||
@patch
|
||||
static String getName(Symbol symbol) {
|
||||
return internal.Symbol.getUnmangledName(symbol);
|
||||
}
|
||||
|
||||
@patch static Symbol getSymbol(String name, [LibraryMirror library]) {
|
||||
@patch
|
||||
static Symbol getSymbol(String name, [LibraryMirror library]) {
|
||||
if ((library != null && library is! _LocalLibraryMirror) ||
|
||||
((name.length > 0) && (name[0] == '_') && (library == null))) {
|
||||
throw new ArgumentError(library);
|
||||
|
|
|
@ -4,7 +4,8 @@
|
|||
|
||||
// Dart core library.
|
||||
|
||||
@patch class Null {
|
||||
@patch
|
||||
class Null {
|
||||
static const _HASH_CODE = 2011; // The year Dart was announced and a prime.
|
||||
|
||||
@patch
|
||||
|
|
|
@ -2,10 +2,11 @@
|
|||
// for details. All rights reserved. Use of this source code is governed by a
|
||||
// BSD-style license that can be found in the LICENSE file.
|
||||
|
||||
@patch class Object {
|
||||
|
||||
@patch
|
||||
class Object {
|
||||
// The VM has its own implementation of equals.
|
||||
@patch bool operator ==(other) native "Object_equals";
|
||||
@patch
|
||||
bool operator ==(other) native "Object_equals";
|
||||
|
||||
// Helpers used to implement hashCode. If a hashCode is used, we remember it
|
||||
// in a weak table in the VM. A new hashCode value is calculated using a
|
||||
|
@ -29,29 +30,30 @@
|
|||
return result;
|
||||
}
|
||||
|
||||
@patch int get hashCode => _objectHashCode(this);
|
||||
@patch
|
||||
int get hashCode => _objectHashCode(this);
|
||||
int get _identityHashCode => _objectHashCode(this);
|
||||
|
||||
@patch String toString() native "Object_toString";
|
||||
@patch
|
||||
String toString() native "Object_toString";
|
||||
// A statically dispatched version of Object.toString.
|
||||
static String _toString(obj) native "Object_toString";
|
||||
|
||||
_noSuchMethod(bool isMethod,
|
||||
String memberName,
|
||||
int type,
|
||||
List arguments,
|
||||
Map<String, dynamic> namedArguments)
|
||||
native "Object_noSuchMethod";
|
||||
_noSuchMethod(bool isMethod, String memberName, int type, List arguments,
|
||||
Map<String, dynamic> namedArguments) native "Object_noSuchMethod";
|
||||
|
||||
@patch dynamic noSuchMethod(Invocation invocation) {
|
||||
return _noSuchMethod(invocation.isMethod,
|
||||
internal.Symbol.getName(invocation.memberName),
|
||||
invocation._type,
|
||||
invocation.positionalArguments,
|
||||
_symbolMapToStringMap(invocation.namedArguments));
|
||||
@patch
|
||||
dynamic noSuchMethod(Invocation invocation) {
|
||||
return _noSuchMethod(
|
||||
invocation.isMethod,
|
||||
internal.Symbol.getName(invocation.memberName),
|
||||
invocation._type,
|
||||
invocation.positionalArguments,
|
||||
_symbolMapToStringMap(invocation.namedArguments));
|
||||
}
|
||||
|
||||
@patch Type get runtimeType native "Object_runtimeType";
|
||||
@patch
|
||||
Type get runtimeType native "Object_runtimeType";
|
||||
|
||||
static bool _haveSameRuntimeType(a, b) native "Object_haveSameRuntimeType";
|
||||
|
||||
|
|
|
@ -8,7 +8,8 @@ import 'dart:core' hide Symbol;
|
|||
// string is a line, but it may contain "\n" characters.
|
||||
typedef void _PrintClosure(String line);
|
||||
|
||||
@patch void printToConsole(String line) {
|
||||
@patch
|
||||
void printToConsole(String line) {
|
||||
_printClosure(line);
|
||||
}
|
||||
|
||||
|
|
|
@ -2,11 +2,14 @@
|
|||
// for details. All rights reserved. Use of this source code is governed by a
|
||||
// BSD-style license that can be found in the LICENSE file.
|
||||
|
||||
@patch class UserTag {
|
||||
@patch factory UserTag(String label) {
|
||||
@patch
|
||||
class UserTag {
|
||||
@patch
|
||||
factory UserTag(String label) {
|
||||
return new _UserTag(label);
|
||||
}
|
||||
@patch static UserTag get defaultTag => _getDefaultTag();
|
||||
@patch
|
||||
static UserTag get defaultTag => _getDefaultTag();
|
||||
}
|
||||
|
||||
class _UserTag implements UserTag {
|
||||
|
@ -15,7 +18,8 @@ class _UserTag implements UserTag {
|
|||
UserTag makeCurrent() native "UserTag_makeCurrent";
|
||||
}
|
||||
|
||||
@patch UserTag getCurrentTag() => _getCurrentTag();
|
||||
@patch
|
||||
UserTag getCurrentTag() => _getCurrentTag();
|
||||
UserTag _getCurrentTag() native "Profiler_getCurrentTag";
|
||||
|
||||
UserTag _getDefaultTag() native "UserTag_defaultTag";
|
||||
|
|
|
@ -2,12 +2,12 @@
|
|||
// for details. All rights reserved. Use of this source code is governed by a
|
||||
// BSD-style license that can be found in the LICENSE file.
|
||||
|
||||
@patch class RegExp {
|
||||
@patch factory RegExp(String source,
|
||||
{bool multiLine: false,
|
||||
bool caseSensitive: true}) {
|
||||
_RegExpHashKey key = new _RegExpHashKey(
|
||||
source, multiLine, caseSensitive);
|
||||
@patch
|
||||
class RegExp {
|
||||
@patch
|
||||
factory RegExp(String source,
|
||||
{bool multiLine: false, bool caseSensitive: true}) {
|
||||
_RegExpHashKey key = new _RegExpHashKey(source, multiLine, caseSensitive);
|
||||
_RegExpHashValue value = _cache[key];
|
||||
|
||||
if (value == null) {
|
||||
|
@ -19,8 +19,7 @@
|
|||
|
||||
value = new _RegExpHashValue(
|
||||
new _RegExp(source,
|
||||
multiLine: multiLine,
|
||||
caseSensitive: caseSensitive),
|
||||
multiLine: multiLine, caseSensitive: caseSensitive),
|
||||
key);
|
||||
_cache[key] = value;
|
||||
} else {
|
||||
|
@ -51,7 +50,6 @@
|
|||
new LinkedList<_RegExpHashKey>();
|
||||
}
|
||||
|
||||
|
||||
// Represents both a key in the regular expression cache as well as its
|
||||
// corresponding entry in the LRU list.
|
||||
class _RegExpHashKey extends LinkedListEntry<_RegExpHashKey> {
|
||||
|
@ -62,14 +60,13 @@ class _RegExpHashKey extends LinkedListEntry<_RegExpHashKey> {
|
|||
_RegExpHashKey(this.pattern, this.multiLine, this.caseSensitive);
|
||||
|
||||
int get hashCode => pattern.hashCode;
|
||||
bool operator==(_RegExpHashKey that) {
|
||||
bool operator ==(_RegExpHashKey that) {
|
||||
return (this.pattern == that.pattern) &&
|
||||
(this.multiLine == that.multiLine) &&
|
||||
(this.caseSensitive == that.caseSensitive);
|
||||
(this.multiLine == that.multiLine) &&
|
||||
(this.caseSensitive == that.caseSensitive);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Represents a value in the regular expression cache. Contains a pointer
|
||||
// back to the key in order to access the corresponding LRU entry.
|
||||
class _RegExpHashValue {
|
||||
|
@ -79,7 +76,6 @@ class _RegExpHashValue {
|
|||
_RegExpHashValue(this.regexp, this.key);
|
||||
}
|
||||
|
||||
|
||||
class _RegExpMatch implements Match {
|
||||
_RegExpMatch(this._regexp, this.input, this._match);
|
||||
|
||||
|
@ -129,12 +125,10 @@ class _RegExpMatch implements Match {
|
|||
static const int _MATCH_PAIR = 2;
|
||||
}
|
||||
|
||||
|
||||
class _RegExp implements RegExp {
|
||||
factory _RegExp(
|
||||
String pattern,
|
||||
factory _RegExp(String pattern,
|
||||
{bool multiLine: false,
|
||||
bool caseSensitive: true}) native "RegExp_factory";
|
||||
bool caseSensitive: true}) native "RegExp_factory";
|
||||
|
||||
Match firstMatch(String str) {
|
||||
if (str is! String) throw new ArgumentError(str);
|
||||
|
@ -199,18 +193,18 @@ class _RegExp implements RegExp {
|
|||
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, // '0' - '7'
|
||||
0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // '8' - '9'
|
||||
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, // '0' - '7'
|
||||
0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // '8' - '9'
|
||||
|
||||
0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, // 'A' - 'G'
|
||||
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, // 'H' - 'O'
|
||||
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, // 'P' - 'W'
|
||||
0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0xff, // 'X' - 'Z', '_'
|
||||
0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, // 'A' - 'G'
|
||||
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, // 'H' - 'O'
|
||||
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, // 'P' - 'W'
|
||||
0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0xff, // 'X' - 'Z', '_'
|
||||
|
||||
0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, // 'a' - 'g'
|
||||
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, // 'h' - 'o'
|
||||
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, // 'p' - 'w'
|
||||
0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, // 'x' - 'z'
|
||||
0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, // 'a' - 'g'
|
||||
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, // 'h' - 'o'
|
||||
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, // 'p' - 'w'
|
||||
0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, // 'x' - 'z'
|
||||
// Latin-1 range
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
|
@ -233,8 +227,7 @@ class _RegExp implements RegExp {
|
|||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
];
|
||||
|
||||
List _ExecuteMatch(String str, int start_index)
|
||||
native "RegExp_ExecuteMatch";
|
||||
List _ExecuteMatch(String str, int start_index) native "RegExp_ExecuteMatch";
|
||||
|
||||
List _ExecuteMatchSticky(String str, int start_index)
|
||||
native "RegExp_ExecuteMatchSticky";
|
||||
|
@ -261,7 +254,7 @@ class _AllMatchesIterator implements Iterator<Match> {
|
|||
Match get current => _current;
|
||||
|
||||
bool moveNext() {
|
||||
if (_re == null) return false; // Cleared after a failed match.
|
||||
if (_re == null) return false; // Cleared after a failed match.
|
||||
if (_nextIndex <= _str.length) {
|
||||
var match = _re._ExecuteMatch(_str, _nextIndex);
|
||||
if (match != null) {
|
||||
|
|
|
@ -2,8 +2,10 @@
|
|||
// for details. All rights reserved. Use of this source code is governed by a
|
||||
// BSD-style license that can be found in the LICENSE file.
|
||||
|
||||
@patch class _AsyncRun {
|
||||
@patch static void _scheduleImmediate(void callback()) {
|
||||
@patch
|
||||
class _AsyncRun {
|
||||
@patch
|
||||
static void _scheduleImmediate(void callback()) {
|
||||
if (_ScheduleImmediate._closure == null) {
|
||||
throw new UnsupportedError("Microtasks are not supported");
|
||||
}
|
||||
|
|
|
@ -6,4 +6,3 @@
|
|||
class _StackTrace implements StackTrace {
|
||||
// toString() is overridden on the C++ side.
|
||||
}
|
||||
|
||||
|
|
|
@ -4,15 +4,18 @@
|
|||
|
||||
// A VM patch of the stopwatch part of dart:core.
|
||||
|
||||
@patch class Stopwatch {
|
||||
@patch static void _initTicker() {
|
||||
@patch
|
||||
class Stopwatch {
|
||||
@patch
|
||||
static void _initTicker() {
|
||||
if (_frequency == null) {
|
||||
_frequency = _computeFrequency();
|
||||
}
|
||||
}
|
||||
|
||||
// Returns the current clock tick.
|
||||
@patch static int _now() native "Stopwatch_now";
|
||||
@patch
|
||||
static int _now() native "Stopwatch_now";
|
||||
|
||||
// Returns the frequency of clock ticks in Hz.
|
||||
static int _computeFrequency() native "Stopwatch_frequency";
|
||||
|
|
|
@ -4,7 +4,8 @@
|
|||
|
||||
import 'dart:typed_data' show Uint16List;
|
||||
|
||||
@patch class StringBuffer {
|
||||
@patch
|
||||
class StringBuffer {
|
||||
static const int _BUFFER_SIZE = 64;
|
||||
static const int _PARTS_TO_COMPACT = 128;
|
||||
static const int _PARTS_TO_COMPACT_SIZE_LIMIT = _PARTS_TO_COMPACT * 8;
|
||||
|
@ -50,20 +51,24 @@ import 'dart:typed_data' show Uint16List;
|
|||
int _bufferCodeUnitMagnitude = 0;
|
||||
|
||||
/// Creates the string buffer with an initial content.
|
||||
@patch StringBuffer([Object content = ""]) {
|
||||
@patch
|
||||
StringBuffer([Object content = ""]) {
|
||||
write(content);
|
||||
}
|
||||
|
||||
@patch int get length => _partsCodeUnits + _bufferPosition;
|
||||
@patch
|
||||
int get length => _partsCodeUnits + _bufferPosition;
|
||||
|
||||
@patch void write(Object obj) {
|
||||
@patch
|
||||
void write(Object obj) {
|
||||
String str = '$obj';
|
||||
if (str.isEmpty) return;
|
||||
_consumeBuffer();
|
||||
_addPart(str);
|
||||
}
|
||||
|
||||
@patch void writeCharCode(int charCode) {
|
||||
@patch
|
||||
void writeCharCode(int charCode) {
|
||||
if (charCode <= 0xFFFF) {
|
||||
if (charCode < 0) {
|
||||
throw new RangeError.range(charCode, 0, 0x10FFFF);
|
||||
|
@ -83,7 +88,8 @@ import 'dart:typed_data' show Uint16List;
|
|||
}
|
||||
}
|
||||
|
||||
@patch void writeAll(Iterable objects, [String separator = ""]) {
|
||||
@patch
|
||||
void writeAll(Iterable objects, [String separator = ""]) {
|
||||
Iterator iterator = objects.iterator;
|
||||
if (!iterator.moveNext()) return;
|
||||
if (separator.isEmpty) {
|
||||
|
@ -99,23 +105,26 @@ import 'dart:typed_data' show Uint16List;
|
|||
}
|
||||
}
|
||||
|
||||
@patch void writeln([Object obj = ""]) {
|
||||
@patch
|
||||
void writeln([Object obj = ""]) {
|
||||
write(obj);
|
||||
write("\n");
|
||||
}
|
||||
|
||||
/** Makes the buffer empty. */
|
||||
@patch void clear() {
|
||||
@patch
|
||||
void clear() {
|
||||
_parts = null;
|
||||
_partsCodeUnits = _bufferPosition = _bufferCodeUnitMagnitude = 0;
|
||||
}
|
||||
|
||||
/** Returns the contents of buffer as a string. */
|
||||
@patch String toString() {
|
||||
@patch
|
||||
String toString() {
|
||||
_consumeBuffer();
|
||||
return (_partsCodeUnits == 0) ?
|
||||
"" :
|
||||
_StringBase._concatRange(_parts, 0, _parts.length);
|
||||
return (_partsCodeUnits == 0)
|
||||
? ""
|
||||
: _StringBase._concatRange(_parts, 0, _parts.length);
|
||||
}
|
||||
|
||||
/** Ensures that the buffer has enough capacity to add n code units. */
|
||||
|
@ -169,9 +178,9 @@ import 'dart:typed_data' show Uint16List;
|
|||
if (_partsCodeUnitsSinceCompaction < _PARTS_TO_COMPACT_SIZE_LIMIT) {
|
||||
String compacted = _StringBase._concatRange(
|
||||
_parts,
|
||||
_partsCompactionIndex, // Start
|
||||
_partsCompactionIndex + _PARTS_TO_COMPACT // End
|
||||
);
|
||||
_partsCompactionIndex, // Start
|
||||
_partsCompactionIndex + _PARTS_TO_COMPACT // End
|
||||
);
|
||||
_parts.length = _parts.length - _PARTS_TO_COMPACT;
|
||||
_parts.add(compacted);
|
||||
}
|
||||
|
|
|
@ -7,42 +7,48 @@ const int _maxLatin1 = 0xff;
|
|||
const int _maxUtf16 = 0xffff;
|
||||
const int _maxUnicode = 0x10ffff;
|
||||
|
||||
@patch class String {
|
||||
@patch factory String.fromCharCodes(Iterable<int> charCodes,
|
||||
[int start = 0, int end]) {
|
||||
if (charCodes is! Iterable) throw new ArgumentError.value(charCodes, "charCodes");
|
||||
@patch
|
||||
class String {
|
||||
@patch
|
||||
factory String.fromCharCodes(Iterable<int> charCodes,
|
||||
[int start = 0, int end]) {
|
||||
if (charCodes is! Iterable)
|
||||
throw new ArgumentError.value(charCodes, "charCodes");
|
||||
if (start is! int) throw new ArgumentError.value(start, "start");
|
||||
if (end != null && end is! int) throw new ArgumentError.value(end, "end");
|
||||
return _StringBase.createFromCharCodes(charCodes, start, end, null);
|
||||
}
|
||||
|
||||
@patch factory String.fromCharCode(int charCode) {
|
||||
@patch
|
||||
factory String.fromCharCode(int charCode) {
|
||||
if (charCode >= 0) {
|
||||
if (charCode <= 0xff) {
|
||||
return _OneByteString._allocate(1).._setAt(0, charCode);
|
||||
}
|
||||
if (charCode <= 0xffff) {
|
||||
return _StringBase._createFromCodePoints(new _List(1)..[0] = charCode,
|
||||
0, 1);
|
||||
return _StringBase._createFromCodePoints(
|
||||
new _List(1)..[0] = charCode, 0, 1);
|
||||
}
|
||||
if (charCode <= 0x10ffff) {
|
||||
var low = 0xDC00 | (charCode & 0x3ff);
|
||||
int bits = charCode - 0x10000;
|
||||
var high = 0xD800 | (bits >> 10);
|
||||
return _StringBase._createFromCodePoints(new _List(2)..[0] = high
|
||||
..[1] = low,
|
||||
0, 2);
|
||||
return _StringBase._createFromCodePoints(
|
||||
new _List(2)
|
||||
..[0] = high
|
||||
..[1] = low,
|
||||
0,
|
||||
2);
|
||||
}
|
||||
}
|
||||
throw new RangeError.range(charCode, 0, 0x10ffff);
|
||||
}
|
||||
|
||||
@patch const factory String.fromEnvironment(String name,
|
||||
{String defaultValue})
|
||||
@patch
|
||||
const factory String.fromEnvironment(String name, {String defaultValue})
|
||||
native "String_fromEnvironment";
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* [_StringBase] contains common methods used by concrete String
|
||||
* implementations, e.g., _OneByteString.
|
||||
|
@ -79,8 +85,7 @@ abstract class _StringBase {
|
|||
static const int _maxJoinReplaceOneByteStringLength = 500;
|
||||
|
||||
factory _StringBase._uninstantiable() {
|
||||
throw new UnsupportedError(
|
||||
"_StringBase can't be instaniated");
|
||||
throw new UnsupportedError("_StringBase can't be instaniated");
|
||||
}
|
||||
|
||||
int get hashCode native "String_getHashCode";
|
||||
|
@ -89,7 +94,7 @@ abstract class _StringBase {
|
|||
// Alternatively return false and override it on one-byte string classes.
|
||||
int id = ClassID.getID(this);
|
||||
return id == ClassID.cidOneByteString ||
|
||||
id == ClassID.cidExternalOneByteString;
|
||||
id == ClassID.cidExternalOneByteString;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -102,9 +107,8 @@ abstract class _StringBase {
|
|||
* The [limit] is an upper limit on the character codes in the iterable.
|
||||
* It's `null` if unknown.
|
||||
*/
|
||||
static String createFromCharCodes(Iterable<int> charCodes,
|
||||
int start, int end,
|
||||
int limit) {
|
||||
static String createFromCharCodes(
|
||||
Iterable<int> charCodes, int start, int end, int limit) {
|
||||
if (start == null) throw new ArgumentError.notNull("start");
|
||||
if (charCodes == null) throw new ArgumentError(charCodes);
|
||||
// TODO(srdjan): Also skip copying of wide typed arrays.
|
||||
|
@ -152,14 +156,14 @@ abstract class _StringBase {
|
|||
return bits;
|
||||
}
|
||||
|
||||
static String _createStringFromIterable(Iterable<int> charCodes,
|
||||
int start, int end) {
|
||||
static String _createStringFromIterable(
|
||||
Iterable<int> charCodes, int start, int end) {
|
||||
// Treat charCodes as Iterable.
|
||||
if (charCodes is EfficientLengthIterable) {
|
||||
int length = charCodes.length;
|
||||
end = RangeError.checkValidRange(start, end, length);
|
||||
List charCodeList = new List.from(charCodes.take(end).skip(start),
|
||||
growable: false);
|
||||
List charCodeList =
|
||||
new List.from(charCodes.take(end).skip(start), growable: false);
|
||||
return createFromCharCodes(charCodeList, 0, charCodeList.length, null);
|
||||
}
|
||||
// Don't know length of iterable, so iterate and see if all the values
|
||||
|
@ -172,7 +176,7 @@ abstract class _StringBase {
|
|||
}
|
||||
}
|
||||
List charCodeList;
|
||||
int bits = 0; // Bitwise-or of all char codes in list.
|
||||
int bits = 0; // Bitwise-or of all char codes in list.
|
||||
if (end == null) {
|
||||
var list = [];
|
||||
while (it.moveNext()) {
|
||||
|
@ -222,7 +226,7 @@ abstract class _StringBase {
|
|||
|
||||
String operator [](int index) native "String_charAt";
|
||||
|
||||
int codeUnitAt(int index); // Implemented in the subclasses.
|
||||
int codeUnitAt(int index); // Implemented in the subclasses.
|
||||
|
||||
int get length native "String_getLength";
|
||||
|
||||
|
@ -242,8 +246,7 @@ abstract class _StringBase {
|
|||
if (identical(this, other)) {
|
||||
return true;
|
||||
}
|
||||
if ((other is! String) ||
|
||||
(this.length != other.length)) {
|
||||
if ((other is! String) || (this.length != other.length)) {
|
||||
return false;
|
||||
}
|
||||
final len = this.length;
|
||||
|
@ -389,10 +392,10 @@ abstract class _StringBase {
|
|||
// Checks for one-byte whitespaces only.
|
||||
static bool _isOneByteWhitespace(int codeUnit) {
|
||||
if (codeUnit <= 32) {
|
||||
return ((codeUnit == 32) || // Space.
|
||||
((codeUnit <= 13) && (codeUnit >= 9))); // CR, LF, TAB, etc.
|
||||
return ((codeUnit == 32) || // Space.
|
||||
((codeUnit <= 13) && (codeUnit >= 9))); // CR, LF, TAB, etc.
|
||||
}
|
||||
return (codeUnit == 0x85) || (codeUnit == 0xA0); // NEL, NBSP.
|
||||
return (codeUnit == 0x85) || (codeUnit == 0xA0); // NEL, NBSP.
|
||||
}
|
||||
|
||||
// Characters with Whitespace property (Unicode 6.2).
|
||||
|
@ -412,21 +415,18 @@ abstract class _StringBase {
|
|||
// BOM: 0xFEFF
|
||||
static bool _isTwoByteWhitespace(int codeUnit) {
|
||||
if (codeUnit <= 32) {
|
||||
return (codeUnit == 32) ||
|
||||
((codeUnit <= 13) && (codeUnit >= 9));
|
||||
return (codeUnit == 32) || ((codeUnit <= 13) && (codeUnit >= 9));
|
||||
}
|
||||
if (codeUnit < 0x85) return false;
|
||||
if ((codeUnit == 0x85) || (codeUnit == 0xA0)) return true;
|
||||
return (codeUnit <= 0x200A)
|
||||
? ((codeUnit == 0x1680) ||
|
||||
(codeUnit == 0x180E) ||
|
||||
(0x2000 <= codeUnit))
|
||||
: ((codeUnit == 0x2028) ||
|
||||
(codeUnit == 0x2029) ||
|
||||
(codeUnit == 0x202F) ||
|
||||
(codeUnit == 0x205F) ||
|
||||
(codeUnit == 0x3000) ||
|
||||
(codeUnit == 0xFEFF));
|
||||
? ((codeUnit == 0x1680) || (codeUnit == 0x180E) || (0x2000 <= codeUnit))
|
||||
: ((codeUnit == 0x2028) ||
|
||||
(codeUnit == 0x2029) ||
|
||||
(codeUnit == 0x202F) ||
|
||||
(codeUnit == 0x205F) ||
|
||||
(codeUnit == 0x3000) ||
|
||||
(codeUnit == 0xFEFF));
|
||||
}
|
||||
|
||||
int _firstNonWhitespace() {
|
||||
|
@ -505,7 +505,7 @@ abstract class _StringBase {
|
|||
return _substringUnchecked(0, last + 1);
|
||||
}
|
||||
|
||||
String operator*(int times) {
|
||||
String operator *(int times) {
|
||||
if (times <= 0) return "";
|
||||
if (times == 1) return this;
|
||||
StringBuffer buffer = new StringBuffer(this);
|
||||
|
@ -546,9 +546,8 @@ abstract class _StringBase {
|
|||
return pattern.allMatches(this.substring(startIndex)).isNotEmpty;
|
||||
}
|
||||
|
||||
String replaceFirst(Pattern pattern,
|
||||
String replacement,
|
||||
[int startIndex = 0]) {
|
||||
String replaceFirst(Pattern pattern, String replacement,
|
||||
[int startIndex = 0]) {
|
||||
if (pattern is! Pattern) {
|
||||
throw new ArgumentError("${pattern} is not a Pattern");
|
||||
}
|
||||
|
@ -559,9 +558,9 @@ abstract class _StringBase {
|
|||
throw new ArgumentError("${startIndex} is not an int");
|
||||
}
|
||||
RangeError.checkValueInInterval(startIndex, 0, this.length, "startIndex");
|
||||
Iterator iterator =
|
||||
startIndex == 0 ? pattern.allMatches(this).iterator
|
||||
: pattern.allMatches(this, startIndex).iterator;
|
||||
Iterator iterator = startIndex == 0
|
||||
? pattern.allMatches(this).iterator
|
||||
: pattern.allMatches(this, startIndex).iterator;
|
||||
if (!iterator.moveNext()) return this;
|
||||
Match match = iterator.current;
|
||||
return replaceRange(match.start, match.end, replacement);
|
||||
|
@ -586,8 +585,8 @@ abstract class _StringBase {
|
|||
_addReplaceSlice(slices, 0, start);
|
||||
if (replacement.length > 0) slices.add(replacement);
|
||||
_addReplaceSlice(slices, end, length);
|
||||
return _joinReplaceAllResult(this, slices, totalLength,
|
||||
replacementIsOneByte);
|
||||
return _joinReplaceAllResult(
|
||||
this, slices, totalLength, replacementIsOneByte);
|
||||
}
|
||||
|
||||
static int _addReplaceSlice(List matches, int start, int end) {
|
||||
|
@ -632,17 +631,15 @@ abstract class _StringBase {
|
|||
// TODO(lrn): Is there a cut-off point, or is runtime always faster?
|
||||
return _joinReplaceAllOneByteResult(this, matches, length);
|
||||
}
|
||||
return _joinReplaceAllResult(this, matches, length,
|
||||
replacementIsOneByte);
|
||||
return _joinReplaceAllResult(this, matches, length, replacementIsOneByte);
|
||||
}
|
||||
|
||||
/**
|
||||
* As [_joinReplaceAllResult], but knowing that the result
|
||||
* is always a [_OneByteString].
|
||||
*/
|
||||
static String _joinReplaceAllOneByteResult(String base,
|
||||
List matches,
|
||||
int length) {
|
||||
static String _joinReplaceAllOneByteResult(
|
||||
String base, List matches, int length) {
|
||||
_OneByteString result = _OneByteString._allocate(length);
|
||||
int writeIndex = 0;
|
||||
for (int i = 0; i < matches.length; i++) {
|
||||
|
@ -689,8 +686,9 @@ abstract class _StringBase {
|
|||
* If they are, then we have to check the base string slices to know
|
||||
* whether the result must be a one-byte string.
|
||||
*/
|
||||
static String _joinReplaceAllResult(String base, List matches, int length,
|
||||
bool replacementStringsAreOneByte)
|
||||
static String
|
||||
_joinReplaceAllResult(String base, List matches, int length,
|
||||
bool replacementStringsAreOneByte)
|
||||
native "StringBase_joinReplaceAllResult";
|
||||
|
||||
String replaceAllMapped(Pattern pattern, String replace(Match match)) {
|
||||
|
@ -716,12 +714,12 @@ abstract class _StringBase {
|
|||
this._isOneByte) {
|
||||
return _joinReplaceAllOneByteResult(this, matches, length);
|
||||
}
|
||||
return _joinReplaceAllResult(this, matches, length,
|
||||
replacementStringsAreOneByte);
|
||||
return _joinReplaceAllResult(
|
||||
this, matches, length, replacementStringsAreOneByte);
|
||||
}
|
||||
|
||||
String replaceFirstMapped(Pattern pattern, String replace(Match match),
|
||||
[int startIndex = 0]) {
|
||||
[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");
|
||||
|
@ -737,8 +735,8 @@ abstract class _StringBase {
|
|||
static String _matchString(Match match) => match[0];
|
||||
static String _stringIdentity(String string) => string;
|
||||
|
||||
String _splitMapJoinEmptyString(String onMatch(Match match),
|
||||
String onNonMatch(String nonMatch)) {
|
||||
String _splitMapJoinEmptyString(
|
||||
String onMatch(Match match), String onNonMatch(String nonMatch)) {
|
||||
// Pattern is the empty string.
|
||||
StringBuffer buffer = new StringBuffer();
|
||||
int length = this.length;
|
||||
|
@ -767,8 +765,7 @@ abstract class _StringBase {
|
|||
}
|
||||
|
||||
String splitMapJoin(Pattern pattern,
|
||||
{String onMatch(Match match),
|
||||
String onNonMatch(String nonMatch)}) {
|
||||
{String onMatch(Match match), String onNonMatch(String nonMatch)}) {
|
||||
if (pattern is! Pattern) {
|
||||
throw new ArgumentError("${pattern} is not a Pattern");
|
||||
}
|
||||
|
@ -887,7 +884,7 @@ abstract class _StringBase {
|
|||
}
|
||||
int endIndex = match.end;
|
||||
if (startIndex == endIndex && endIndex == previousIndex) {
|
||||
++startIndex; // empty match, advance and restart
|
||||
++startIndex; // empty match, advance and restart
|
||||
continue;
|
||||
}
|
||||
result.add(this.substring(previousIndex, match.start));
|
||||
|
@ -919,9 +916,7 @@ abstract class _StringBase {
|
|||
native "String_concatRange";
|
||||
}
|
||||
|
||||
|
||||
class _OneByteString extends _StringBase implements String {
|
||||
|
||||
factory _OneByteString._uninstantiable() {
|
||||
throw new UnsupportedError(
|
||||
"_OneByteString can only be allocated by the VM");
|
||||
|
@ -1018,14 +1013,14 @@ class _OneByteString extends _StringBase implements String {
|
|||
return super.contains(pattern, start);
|
||||
}
|
||||
|
||||
String operator*(int times) {
|
||||
String operator *(int times) {
|
||||
if (times <= 0) return "";
|
||||
if (times == 1) return this;
|
||||
int length = this.length;
|
||||
if (this.isEmpty) return this; // Don't clone empty string.
|
||||
if (this.isEmpty) return this; // Don't clone empty string.
|
||||
_OneByteString result = _OneByteString._allocate(length * times);
|
||||
int index = 0;
|
||||
for (int i = 0; i < times; i ++) {
|
||||
for (int i = 0; i < times; i++) {
|
||||
for (int j = 0; j < length; j++) {
|
||||
result._setAt(index++, this.codeUnitAt(j));
|
||||
}
|
||||
|
@ -1193,10 +1188,8 @@ class _OneByteString extends _StringBase implements String {
|
|||
// set using _setAt.
|
||||
static _OneByteString _allocate(int length) native "OneByteString_allocate";
|
||||
|
||||
|
||||
static _OneByteString _allocateFromOneByteList(List<int> list,
|
||||
int start, int end)
|
||||
native "OneByteString_allocateFromOneByteList";
|
||||
static _OneByteString _allocateFromOneByteList(List<int> list, int start,
|
||||
int end) native "OneByteString_allocateFromOneByteList";
|
||||
|
||||
// This is internal helper method. Code point value must be a valid
|
||||
// Latin1 value (0..0xFF), index must be valid.
|
||||
|
@ -1220,7 +1213,6 @@ class _OneByteString extends _StringBase implements String {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
class _TwoByteString extends _StringBase implements String {
|
||||
factory _TwoByteString._uninstantiable() {
|
||||
throw new UnsupportedError(
|
||||
|
@ -1241,7 +1233,6 @@ class _TwoByteString extends _StringBase implements String {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
class _ExternalOneByteString extends _StringBase implements String {
|
||||
factory _ExternalOneByteString._uninstantiable() {
|
||||
throw new UnsupportedError(
|
||||
|
@ -1261,7 +1252,6 @@ class _ExternalOneByteString extends _StringBase implements String {
|
|||
static int _getCid() native "ExternalOneByteString_getCid";
|
||||
}
|
||||
|
||||
|
||||
class _ExternalTwoByteString extends _StringBase implements String {
|
||||
factory _ExternalTwoByteString._uninstantiable() {
|
||||
throw new UnsupportedError(
|
||||
|
@ -1279,12 +1269,11 @@ class _ExternalTwoByteString extends _StringBase implements String {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
class _StringMatch implements Match {
|
||||
const _StringMatch(this.start, this.input, this.pattern);
|
||||
|
||||
int get end => start + pattern.length;
|
||||
String operator[](int g) => group(g);
|
||||
String operator [](int g) => group(g);
|
||||
int get groupCount => 0;
|
||||
|
||||
String group(int group) {
|
||||
|
@ -1307,7 +1296,6 @@ class _StringMatch implements Match {
|
|||
final String pattern;
|
||||
}
|
||||
|
||||
|
||||
class _StringAllMatchesIterable extends Iterable<Match> {
|
||||
final String _input;
|
||||
final String _pattern;
|
||||
|
|
|
@ -4,11 +4,13 @@
|
|||
|
||||
import 'dart:core' hide Symbol;
|
||||
|
||||
@patch class Symbol {
|
||||
@patch const Symbol(String name)
|
||||
: this._name = name;
|
||||
@patch
|
||||
class Symbol {
|
||||
@patch
|
||||
const Symbol(String name) : this._name = name;
|
||||
|
||||
@patch toString() => 'Symbol("${getUnmangledName(this)}")';
|
||||
@patch
|
||||
toString() => 'Symbol("${getUnmangledName(this)}")';
|
||||
|
||||
static getUnmangledName(Symbol symbol) {
|
||||
String string = Symbol.getName(symbol);
|
||||
|
@ -54,7 +56,8 @@ import 'dart:core' hide Symbol;
|
|||
return result.toString();
|
||||
}
|
||||
|
||||
@patch int get hashCode {
|
||||
@patch
|
||||
int get hashCode {
|
||||
const arbitraryPrime = 664597;
|
||||
return 0x1fffffff & (arbitraryPrime * _name.hashCode);
|
||||
}
|
||||
|
|
|
@ -2,33 +2,29 @@
|
|||
// for details. All rights reserved. Use of this source code is governed by a
|
||||
// BSD-style license that can be found in the LICENSE file.
|
||||
|
||||
@patch bool _isDartStreamEnabled() native "Timeline_isDartStreamEnabled";
|
||||
@patch
|
||||
bool _isDartStreamEnabled() native "Timeline_isDartStreamEnabled";
|
||||
|
||||
@patch int _getTraceClock() native "Timeline_getTraceClock";
|
||||
@patch
|
||||
int _getTraceClock() native "Timeline_getTraceClock";
|
||||
|
||||
@patch int _getThreadCpuClock() native "Timeline_getThreadCpuClock";
|
||||
@patch
|
||||
int _getThreadCpuClock() native "Timeline_getThreadCpuClock";
|
||||
|
||||
@patch int _getNextAsyncId() native "Timeline_getNextAsyncId";
|
||||
@patch
|
||||
int _getNextAsyncId() native "Timeline_getNextAsyncId";
|
||||
|
||||
@patch int _getIsolateNum() native "Timeline_getIsolateNum";
|
||||
@patch
|
||||
int _getIsolateNum() native "Timeline_getIsolateNum";
|
||||
|
||||
@patch void _reportTaskEvent(
|
||||
int start,
|
||||
int taskId,
|
||||
String phase,
|
||||
String category,
|
||||
String name,
|
||||
String argumentsAsJson) native "Timeline_reportTaskEvent";
|
||||
@patch
|
||||
void _reportTaskEvent(int start, int taskId, String phase, String category,
|
||||
String name, String argumentsAsJson) native "Timeline_reportTaskEvent";
|
||||
|
||||
@patch void _reportCompleteEvent(
|
||||
int start,
|
||||
int startCpu,
|
||||
String category,
|
||||
String name,
|
||||
String argumentsAsJson) native "Timeline_reportCompleteEvent";
|
||||
@patch
|
||||
void _reportCompleteEvent(int start, int startCpu, String category, String name,
|
||||
String argumentsAsJson) native "Timeline_reportCompleteEvent";
|
||||
|
||||
@patch void _reportInstantEvent(
|
||||
int start,
|
||||
String category,
|
||||
String name,
|
||||
String argumentsAsJson) native "Timeline_reportInstantEvent";
|
||||
@patch
|
||||
void _reportInstantEvent(int start, String category, String name,
|
||||
String argumentsAsJson) native "Timeline_reportInstantEvent";
|
||||
|
|
|
@ -16,8 +16,7 @@ class _TimerHeap {
|
|||
List<_Timer> _list;
|
||||
int _used = 0;
|
||||
|
||||
_TimerHeap([int initSize = 7])
|
||||
: _list = new List<_Timer>(initSize);
|
||||
_TimerHeap([int initSize = 7]) : _list = new List<_Timer>(initSize);
|
||||
|
||||
bool get isEmpty => _used == 0;
|
||||
|
||||
|
@ -140,13 +139,12 @@ class _Timer implements Timer {
|
|||
|
||||
static bool _handlingCallbacks = false;
|
||||
|
||||
Function _callback; // Closure to call when timer fires. null if canceled.
|
||||
int _wakeupTime; // Expiration time.
|
||||
final int _milliSeconds; // Duration specified at creation.
|
||||
final bool _repeating; // Indicates periodic timers.
|
||||
var _indexOrNext; // Index if part of the TimerHeap, link otherwise.
|
||||
int _id; // Incrementing id to enable sorting of timers with same expiry.
|
||||
|
||||
Function _callback; // Closure to call when timer fires. null if canceled.
|
||||
int _wakeupTime; // Expiration time.
|
||||
final int _milliSeconds; // Duration specified at creation.
|
||||
final bool _repeating; // Indicates periodic timers.
|
||||
var _indexOrNext; // Index if part of the TimerHeap, link otherwise.
|
||||
int _id; // Incrementing id to enable sorting of timers with same expiry.
|
||||
|
||||
// Get the next available id. We accept collisions and reordering when the
|
||||
// _idCount overflows and the timers expire at the same millisecond.
|
||||
|
@ -156,16 +154,12 @@ class _Timer implements Timer {
|
|||
return result;
|
||||
}
|
||||
|
||||
_Timer._internal(
|
||||
this._callback, this._wakeupTime, this._milliSeconds, this._repeating)
|
||||
: _id = _nextId();
|
||||
|
||||
_Timer._internal(this._callback,
|
||||
this._wakeupTime,
|
||||
this._milliSeconds,
|
||||
this._repeating) : _id = _nextId();
|
||||
|
||||
|
||||
static Timer _createTimer(void callback(Timer timer),
|
||||
int milliSeconds,
|
||||
bool repeating) {
|
||||
static Timer _createTimer(
|
||||
void callback(Timer timer), int milliSeconds, bool repeating) {
|
||||
// Negative timeouts are treated as if 0 timeout.
|
||||
if (milliSeconds < 0) {
|
||||
milliSeconds = 0;
|
||||
|
@ -177,40 +171,32 @@ class _Timer implements Timer {
|
|||
int now = VMLibraryHooks.timerMillisecondClock();
|
||||
int wakeupTime = (milliSeconds == 0) ? now : (now + 1 + milliSeconds);
|
||||
|
||||
_Timer timer = new _Timer._internal(callback,
|
||||
wakeupTime,
|
||||
milliSeconds,
|
||||
repeating);
|
||||
_Timer timer =
|
||||
new _Timer._internal(callback, wakeupTime, milliSeconds, repeating);
|
||||
// Enqueue this newly created timer in the appropriate structure and
|
||||
// notify if necessary.
|
||||
timer._enqueue();
|
||||
return timer;
|
||||
}
|
||||
|
||||
|
||||
factory _Timer(int milliSeconds, void callback(Timer timer)) {
|
||||
return _createTimer(callback, milliSeconds, false);
|
||||
}
|
||||
|
||||
|
||||
factory _Timer.periodic(int milliSeconds, void callback(Timer timer)) {
|
||||
return _createTimer(callback, milliSeconds, true);
|
||||
}
|
||||
|
||||
|
||||
bool get _isInHeap => _indexOrNext is int;
|
||||
|
||||
|
||||
int _compareTo(_Timer other) {
|
||||
int c = _wakeupTime - other._wakeupTime;
|
||||
if (c != 0) return c;
|
||||
return _id - other._id;
|
||||
}
|
||||
|
||||
|
||||
bool get isActive => _callback != null;
|
||||
|
||||
|
||||
// Cancels a set timer. The timer is removed from the timer heap if it is a
|
||||
// non-zero timer. Zero timers are kept in the list as they need to consume
|
||||
// the corresponding pending message.
|
||||
|
@ -226,7 +212,6 @@ class _Timer implements Timer {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
void _advanceWakeupTime() {
|
||||
// Recalculate the next wakeup time. For repeating timers with a 0 timeout
|
||||
// the next wakeup time is now.
|
||||
|
@ -238,7 +223,6 @@ class _Timer implements Timer {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
// Adds a timer to the heap or timer list. Timers with the same wakeup time
|
||||
// are enqueued in order and notified in FIFO order.
|
||||
void _enqueue() {
|
||||
|
@ -260,7 +244,6 @@ class _Timer implements Timer {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
// Enqeue one message for each zero timer. To be able to distinguish from
|
||||
// EventHandler messages we send a _ZERO_EVENT instead of a _TIMEOUT_EVENT.
|
||||
static void _notifyZeroHandler() {
|
||||
|
@ -270,7 +253,6 @@ class _Timer implements Timer {
|
|||
_sendPort.send(_ZERO_EVENT);
|
||||
}
|
||||
|
||||
|
||||
// Handle the notification of a zero timer. Make sure to also execute non-zero
|
||||
// timers with a lower expiration time.
|
||||
static List _queueFromZeroEvent() {
|
||||
|
@ -291,7 +273,6 @@ class _Timer implements Timer {
|
|||
return pendingTimers;
|
||||
}
|
||||
|
||||
|
||||
static void _notifyEventHandler() {
|
||||
if (_handlingCallbacks) {
|
||||
// While we are already handling callbacks we will not notify the event
|
||||
|
@ -324,7 +305,6 @@ class _Timer implements Timer {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
static List _queueFromTimeoutEvent() {
|
||||
var pendingTimers = new List();
|
||||
if (_firstZeroTimer != null) {
|
||||
|
@ -352,7 +332,6 @@ class _Timer implements Timer {
|
|||
return pendingTimers;
|
||||
}
|
||||
|
||||
|
||||
static void _runTimers(List pendingTimers) {
|
||||
// If there are no pending timers currently reset the id space before we
|
||||
// have a chance to enqueue new timers.
|
||||
|
@ -402,7 +381,6 @@ class _Timer implements Timer {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
static void _handleMessage(msg) {
|
||||
var pendingTimers;
|
||||
if (msg == _ZERO_EVENT) {
|
||||
|
@ -410,7 +388,7 @@ class _Timer implements Timer {
|
|||
assert(pendingTimers.length > 0);
|
||||
} else {
|
||||
assert(msg == _TIMEOUT_EVENT);
|
||||
_scheduledWakeupTime = null; // Consumed the last scheduled wakeup now.
|
||||
_scheduledWakeupTime = null; // Consumed the last scheduled wakeup now.
|
||||
pendingTimers = _queueFromTimeoutEvent();
|
||||
}
|
||||
_runTimers(pendingTimers);
|
||||
|
@ -419,7 +397,6 @@ class _Timer implements Timer {
|
|||
_notifyEventHandler();
|
||||
}
|
||||
|
||||
|
||||
// Tell the event handler to wake this isolate at a specific time.
|
||||
static void _scheduleWakeup(int wakeupTime) {
|
||||
if (_sendPort == null) {
|
||||
|
@ -429,7 +406,6 @@ class _Timer implements Timer {
|
|||
_scheduledWakeupTime = wakeupTime;
|
||||
}
|
||||
|
||||
|
||||
// Cancel pending wakeups in the event handler.
|
||||
static void _cancelWakeup() {
|
||||
assert(_sendPort != null);
|
||||
|
@ -437,7 +413,6 @@ class _Timer implements Timer {
|
|||
_scheduledWakeupTime = null;
|
||||
}
|
||||
|
||||
|
||||
// Create a receive port and register a message handler for the timer
|
||||
// events.
|
||||
static void _createTimerHandler() {
|
||||
|
@ -448,7 +423,6 @@ class _Timer implements Timer {
|
|||
_scheduledWakeupTime = null;
|
||||
}
|
||||
|
||||
|
||||
static void _shutdownTimerHandler() {
|
||||
_receivePort.close();
|
||||
_receivePort = null;
|
||||
|
@ -456,11 +430,9 @@ class _Timer implements Timer {
|
|||
_scheduledWakeupTime = null;
|
||||
}
|
||||
|
||||
|
||||
// The Timer factory registered with the dart:async library by the embedder.
|
||||
static Timer _factory(int milliSeconds,
|
||||
void callback(Timer timer),
|
||||
bool repeating) {
|
||||
static Timer _factory(
|
||||
int milliSeconds, void callback(Timer timer), bool repeating) {
|
||||
if (repeating) {
|
||||
return new _Timer.periodic(milliSeconds, callback);
|
||||
}
|
||||
|
@ -468,7 +440,6 @@ class _Timer implements Timer {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
_setupHooks() {
|
||||
VMLibraryHooks.timerFactory = _Timer._factory;
|
||||
}
|
||||
|
|
|
@ -4,8 +4,10 @@
|
|||
|
||||
import 'dart:_internal' hide Symbol;
|
||||
|
||||
@patch class Timer {
|
||||
@patch static Timer _createTimer(Duration duration, void callback()) {
|
||||
@patch
|
||||
class Timer {
|
||||
@patch
|
||||
static Timer _createTimer(Duration duration, void callback()) {
|
||||
// TODO(iposva): Remove _TimerFactory and use VMLibraryHooks exclusively.
|
||||
if (_TimerFactory._factory == null) {
|
||||
_TimerFactory._factory = VMLibraryHooks.timerFactory;
|
||||
|
@ -15,11 +17,14 @@ import 'dart:_internal' hide Symbol;
|
|||
}
|
||||
int milliseconds = duration.inMilliseconds;
|
||||
if (milliseconds < 0) milliseconds = 0;
|
||||
return _TimerFactory._factory(milliseconds, (_) { callback(); }, false);
|
||||
return _TimerFactory._factory(milliseconds, (_) {
|
||||
callback();
|
||||
}, false);
|
||||
}
|
||||
|
||||
@patch static Timer _createPeriodicTimer(Duration duration,
|
||||
void callback(Timer timer)) {
|
||||
@patch
|
||||
static Timer _createPeriodicTimer(
|
||||
Duration duration, void callback(Timer timer)) {
|
||||
// TODO(iposva): Remove _TimerFactory and use VMLibraryHooks exclusively.
|
||||
if (_TimerFactory._factory == null) {
|
||||
_TimerFactory._factory = VMLibraryHooks.timerFactory;
|
||||
|
@ -33,9 +38,8 @@ import 'dart:_internal' hide Symbol;
|
|||
}
|
||||
}
|
||||
|
||||
typedef Timer _TimerFactoryClosure(int milliseconds,
|
||||
void callback(Timer timer),
|
||||
bool repeating);
|
||||
typedef Timer _TimerFactoryClosure(
|
||||
int milliseconds, void callback(Timer timer), bool repeating);
|
||||
|
||||
// Warning: Dartium sets _TimerFactory._factory instead of setting things up
|
||||
// through VMLibraryHooks.timerFactory.
|
||||
|
|
|
@ -10,21 +10,16 @@ abstract class _AbstractType implements Type {
|
|||
}
|
||||
|
||||
// Equivalent of RawType.
|
||||
class _Type extends _AbstractType {
|
||||
}
|
||||
class _Type extends _AbstractType {}
|
||||
|
||||
// Equivalent of RawTypeRef.
|
||||
class _TypeRef extends _AbstractType {
|
||||
}
|
||||
class _TypeRef extends _AbstractType {}
|
||||
|
||||
// Equivalent of RawTypeParameter.
|
||||
class _TypeParameter extends _AbstractType {
|
||||
}
|
||||
class _TypeParameter extends _AbstractType {}
|
||||
|
||||
// Equivalent of RawBoundedType.
|
||||
class _BoundedType extends _AbstractType {
|
||||
}
|
||||
class _BoundedType extends _AbstractType {}
|
||||
|
||||
// Equivalent of RawMixinAppType.
|
||||
class _MixinAppType extends _AbstractType {
|
||||
}
|
||||
class _MixinAppType extends _AbstractType {}
|
||||
|
|
|
@ -13,21 +13,24 @@ Uri _unsupportedUriBase() {
|
|||
// value for Uri.base.
|
||||
_UriBaseClosure _uriBaseClosure = _unsupportedUriBase;
|
||||
|
||||
@patch class Uri {
|
||||
@patch static Uri get base => _uriBaseClosure();
|
||||
@patch
|
||||
class Uri {
|
||||
@patch
|
||||
static Uri get base => _uriBaseClosure();
|
||||
}
|
||||
|
||||
@patch class _Uri {
|
||||
@patch
|
||||
class _Uri {
|
||||
static final bool _isWindowsCached = _isWindowsPlatform;
|
||||
|
||||
static bool get _isWindowsPlatform native "Uri_isWindowsPlatform";
|
||||
|
||||
@patch static bool get _isWindows => _isWindowsCached;
|
||||
@patch
|
||||
static bool get _isWindows => _isWindowsCached;
|
||||
|
||||
@patch static String _uriEncode(List<int> canonicalTable,
|
||||
String text,
|
||||
Encoding encoding,
|
||||
bool spaceToPlus) {
|
||||
@patch
|
||||
static String _uriEncode(List<int> canonicalTable, String text,
|
||||
Encoding encoding, bool spaceToPlus) {
|
||||
// First check if the text will be changed by encoding.
|
||||
int i = 0;
|
||||
if (identical(encoding, UTF8) ||
|
||||
|
@ -63,9 +66,10 @@ _UriBaseClosure _uriBaseClosure = _unsupportedUriBase;
|
|||
result.writeCharCode(_PLUS);
|
||||
} else {
|
||||
const String hexDigits = '0123456789ABCDEF';
|
||||
result..writeCharCode(_PERCENT)
|
||||
..writeCharCode(hexDigits.codeUnitAt(byte >> 4))
|
||||
..writeCharCode(hexDigits.codeUnitAt(byte & 0x0f));
|
||||
result
|
||||
..writeCharCode(_PERCENT)
|
||||
..writeCharCode(hexDigits.codeUnitAt(byte >> 4))
|
||||
..writeCharCode(hexDigits.codeUnitAt(byte & 0x0f));
|
||||
}
|
||||
}
|
||||
return result.toString();
|
||||
|
|
|
@ -2,9 +2,11 @@
|
|||
// for details. All rights reserved. Use of this source code is governed by a
|
||||
// BSD-style license that can be found in the LICENSE file.
|
||||
|
||||
@patch class Asset {
|
||||
@patch
|
||||
class Asset {
|
||||
/// Call to request assets from the embedder.
|
||||
@patch static HashMap<String, Asset> request() {
|
||||
@patch
|
||||
static HashMap<String, Asset> request() {
|
||||
HashMap<String, Asset> assets = new HashMap<String, Asset>();
|
||||
Uint8List tarBytes = _requestAssets();
|
||||
if (tarBytes == null) {
|
||||
|
@ -21,18 +23,26 @@
|
|||
|
||||
List _decodeAssets(Uint8List data) native "VMService_DecodeAssets";
|
||||
|
||||
@patch bool sendIsolateServiceMessage(SendPort sp, List m)
|
||||
@patch
|
||||
bool sendIsolateServiceMessage(SendPort sp, List m)
|
||||
native "VMService_SendIsolateServiceMessage";
|
||||
@patch void sendRootServiceMessage(List m)
|
||||
native "VMService_SendRootServiceMessage";
|
||||
@patch void sendObjectRootServiceMessage(List m)
|
||||
@patch
|
||||
void sendRootServiceMessage(List m) native "VMService_SendRootServiceMessage";
|
||||
@patch
|
||||
void sendObjectRootServiceMessage(List m)
|
||||
native "VMService_SendObjectRootServiceMessage";
|
||||
@patch void _onStart() native "VMService_OnStart";
|
||||
@patch void _onExit() native "VMService_OnExit";
|
||||
@patch void onServerAddressChange(String address)
|
||||
@patch
|
||||
void _onStart() native "VMService_OnStart";
|
||||
@patch
|
||||
void _onExit() native "VMService_OnExit";
|
||||
@patch
|
||||
void onServerAddressChange(String address)
|
||||
native "VMService_OnServerAddressChange";
|
||||
@patch bool _vmListenStream(String streamId) native "VMService_ListenStream";
|
||||
@patch void _vmCancelStream(String streamId) native "VMService_CancelStream";
|
||||
@patch Uint8List _requestAssets() native "VMService_RequestAssets";
|
||||
@patch void _spawnUriNotify(obj, String token)
|
||||
native "VMService_spawnUriNotify";
|
||||
@patch
|
||||
bool _vmListenStream(String streamId) native "VMService_ListenStream";
|
||||
@patch
|
||||
void _vmCancelStream(String streamId) native "VMService_CancelStream";
|
||||
@patch
|
||||
Uint8List _requestAssets() native "VMService_RequestAssets";
|
||||
@patch
|
||||
void _spawnUriNotify(obj, String token) native "VMService_spawnUriNotify";
|
||||
|
|
|
@ -138,7 +138,6 @@ class PauseInterruptedEvent implements M.PauseInterruptedEvent {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
class PausePostRequestEvent implements M.PausePostRequestEvent {
|
||||
final DateTime timestamp;
|
||||
final M.IsolateRef isolate;
|
||||
|
@ -152,7 +151,6 @@ class PausePostRequestEvent implements M.PausePostRequestEvent {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
class PauseExceptionEvent implements M.PauseExceptionEvent {
|
||||
final DateTime timestamp;
|
||||
final M.IsolateRef isolate;
|
||||
|
@ -319,11 +317,8 @@ M.Event createEventFromServiceEvent(S.ServiceEvent event) {
|
|||
case S.ServiceEvent.kPauseExit:
|
||||
return new PauseExitEvent(event.timestamp, event.isolate);
|
||||
case S.ServiceEvent.kPausePostRequest:
|
||||
return new PausePostRequestEvent(
|
||||
event.timestamp,
|
||||
event.isolate,
|
||||
event.topFrame,
|
||||
event.atAsyncSuspension);
|
||||
return new PausePostRequestEvent(event.timestamp, event.isolate,
|
||||
event.topFrame, event.atAsyncSuspension);
|
||||
case S.ServiceEvent.kPauseBreakpoint:
|
||||
return new PauseBreakpointEvent(
|
||||
event.timestamp,
|
||||
|
|
|
@ -314,30 +314,29 @@ class MergedObjectVertex {
|
|||
var cids = _graph._cids;
|
||||
var size = 0;
|
||||
var sibling = _id;
|
||||
while (sibling != SENTINEL &&
|
||||
cids[sibling] == cids[_id]) {
|
||||
while (sibling != SENTINEL && cids[sibling] == cids[_id]) {
|
||||
size += _graph._shallowSizes[sibling];
|
||||
sibling = _graph._mergedDomNext[sibling];
|
||||
}
|
||||
return size;
|
||||
}
|
||||
|
||||
int get retainedSize {
|
||||
var cids = _graph._cids;
|
||||
var size = 0;
|
||||
var sibling = _id;
|
||||
while (sibling != SENTINEL &&
|
||||
cids[sibling] == cids[_id]) {
|
||||
while (sibling != SENTINEL && cids[sibling] == cids[_id]) {
|
||||
size += _graph._retainedSizes[sibling];
|
||||
sibling = _graph._mergedDomNext[sibling];
|
||||
}
|
||||
return size;
|
||||
}
|
||||
|
||||
int get instanceCount {
|
||||
var cids = _graph._cids;
|
||||
var count = 0;
|
||||
var sibling = _id;
|
||||
while (sibling != SENTINEL &&
|
||||
cids[sibling] == cids[_id]) {
|
||||
while (sibling != SENTINEL && cids[sibling] == cids[_id]) {
|
||||
count++;
|
||||
sibling = _graph._mergedDomNext[sibling];
|
||||
}
|
||||
|
@ -354,8 +353,7 @@ class MergedObjectVertex {
|
|||
// Walk the list of children and look for the representative objects, i.e.
|
||||
// the first sibling of each cid.
|
||||
while (child != SENTINEL) {
|
||||
if (prev == SENTINEL ||
|
||||
cids[prev] != cids[child]) {
|
||||
if (prev == SENTINEL || cids[prev] != cids[child]) {
|
||||
domChildren.add(new MergedObjectVertex._(child, _graph));
|
||||
}
|
||||
prev = child;
|
||||
|
@ -502,9 +500,9 @@ class ObjectGraph {
|
|||
|
||||
int _kObjectAlignment;
|
||||
int _kStackCid;
|
||||
int _N; // Objects in the snapshot.
|
||||
int _Nconnected; // Objects reachable from root.
|
||||
int _E; // References in the snapshot.
|
||||
int _N; // Objects in the snapshot.
|
||||
int _Nconnected; // Objects reachable from root.
|
||||
int _E; // References in the snapshot.
|
||||
int _size;
|
||||
|
||||
// Indexed by node id, with id 0 representing invalid/uninitialized.
|
||||
|
@ -694,8 +692,8 @@ class ObjectGraph {
|
|||
var startSuccIndex = firstSuccs[i];
|
||||
var limitSuccIndex = firstSuccs[i + 1];
|
||||
for (var succIndex = startSuccIndex;
|
||||
succIndex < limitSuccIndex;
|
||||
succIndex++) {
|
||||
succIndex < limitSuccIndex;
|
||||
succIndex++) {
|
||||
succs[succIndex] = SENTINEL;
|
||||
}
|
||||
}
|
||||
|
@ -942,7 +940,7 @@ class ObjectGraph {
|
|||
retainedSizes[doms[v]] += retainedSizes[v];
|
||||
}
|
||||
|
||||
assert(retainedSizes[ROOT] == size); // Root retains everything.
|
||||
assert(retainedSizes[ROOT] == size); // Root retains everything.
|
||||
|
||||
_retainedSizes = retainedSizes;
|
||||
_size = size;
|
||||
|
@ -967,16 +965,16 @@ class ObjectGraph {
|
|||
|
||||
// Merge the given lists according to the given key in ascending order.
|
||||
// Returns the head of the merged list.
|
||||
static int _mergeSorted(int head1, int head2,
|
||||
Uint32List next, Uint16List key) {
|
||||
static int _mergeSorted(
|
||||
int head1, int head2, Uint32List next, Uint16List key) {
|
||||
var head = head1;
|
||||
var beforeInsert = SENTINEL;
|
||||
var afterInsert = head1;
|
||||
var startInsert = head2;
|
||||
|
||||
while (startInsert != SENTINEL) {
|
||||
while ((afterInsert != SENTINEL) &&
|
||||
(key[afterInsert] <= key[startInsert])) {
|
||||
while (
|
||||
(afterInsert != SENTINEL) && (key[afterInsert] <= key[startInsert])) {
|
||||
beforeInsert = afterInsert;
|
||||
afterInsert = next[beforeInsert];
|
||||
}
|
||||
|
@ -1019,8 +1017,7 @@ class ObjectGraph {
|
|||
int head1 = head;
|
||||
int slow = head;
|
||||
int fast = head;
|
||||
while (next[fast] != SENTINEL &&
|
||||
next[next[fast]] != SENTINEL) {
|
||||
while (next[fast] != SENTINEL && next[next[fast]] != SENTINEL) {
|
||||
slow = next[slow];
|
||||
fast = next[next[fast]];
|
||||
}
|
||||
|
@ -1058,8 +1055,7 @@ class ObjectGraph {
|
|||
int cid = cids[parent1];
|
||||
int slow = parent1;
|
||||
int fast = parent1;
|
||||
while (next[fast] != end &&
|
||||
next[next[fast]] != end) {
|
||||
while (next[fast] != end && next[next[fast]] != end) {
|
||||
slow = next[slow];
|
||||
fast = next[next[fast]];
|
||||
}
|
||||
|
@ -1095,8 +1091,7 @@ class ObjectGraph {
|
|||
|
||||
// Find next sibling with a different cid.
|
||||
var after = child;
|
||||
while (after != SENTINEL &&
|
||||
cids[after] == cids[child]) {
|
||||
while (after != SENTINEL && cids[after] == cids[child]) {
|
||||
after = next[after];
|
||||
}
|
||||
|
||||
|
|
|
@ -29,7 +29,7 @@ final _portsRepository = new PortsRepository();
|
|||
final _scriptRepository = new ScriptRepository();
|
||||
final _singleTargetCacheRepository = new SingleTargetCacheRepository();
|
||||
final _stronglyReachangleInstancesRepository =
|
||||
new StronglyReachableInstancesRepository();
|
||||
new StronglyReachableInstancesRepository();
|
||||
final _subtypeTestCacheRepository = new SubtypeTestCacheRepository();
|
||||
final _topRetainingInstancesRepository = new TopRetainingInstancesRepository();
|
||||
final _typeArgumentsRepository = new TypeArgumentsRepository();
|
||||
|
|
|
@ -253,8 +253,7 @@ abstract class Command extends _CommandBase {
|
|||
toString() => 'Command(${name})';
|
||||
}
|
||||
|
||||
abstract class CommandException implements Exception {
|
||||
}
|
||||
abstract class CommandException implements Exception {}
|
||||
|
||||
class AmbiguousCommandException extends CommandException {
|
||||
AmbiguousCommandException(this.command, this.matches);
|
||||
|
@ -264,8 +263,8 @@ class AmbiguousCommandException extends CommandException {
|
|||
|
||||
@override
|
||||
String toString() {
|
||||
List<String> matchNames = matches.map(
|
||||
(Command command) => '${command.fullName}').toList();
|
||||
List<String> matchNames =
|
||||
matches.map((Command command) => '${command.fullName}').toList();
|
||||
return "Command '$command' is ambiguous: $matchNames";
|
||||
}
|
||||
}
|
||||
|
|
|
@ -209,8 +209,7 @@ class DownCommand extends DebuggerCommand {
|
|||
debugger.downFrame(count);
|
||||
debugger.console.print('frame = ${debugger.currentFrame}');
|
||||
} catch (e) {
|
||||
debugger.console.print(
|
||||
'frame must be in range [${e.start}..${e.end-1}]');
|
||||
debugger.console.print('frame must be in range [${e.start}..${e.end-1}]');
|
||||
}
|
||||
return new Future.value(null);
|
||||
}
|
||||
|
@ -244,8 +243,7 @@ class UpCommand extends DebuggerCommand {
|
|||
debugger.upFrame(count);
|
||||
debugger.console.print('frame = ${debugger.currentFrame}');
|
||||
} on RangeError catch (e) {
|
||||
debugger.console.print(
|
||||
'frame must be in range [${e.start}..${e.end-1}]');
|
||||
debugger.console.print('frame must be in range [${e.start}..${e.end-1}]');
|
||||
}
|
||||
return new Future.value(null);
|
||||
}
|
||||
|
@ -281,8 +279,7 @@ class FrameCommand extends DebuggerCommand {
|
|||
debugger.currentFrame = frame;
|
||||
debugger.console.print('frame = ${debugger.currentFrame}');
|
||||
} on RangeError catch (e) {
|
||||
debugger.console.print(
|
||||
'frame must be in range [${e.start}..${e.end-1}]');
|
||||
debugger.console.print('frame must be in range [${e.start}..${e.end-1}]');
|
||||
}
|
||||
return new Future.value(null);
|
||||
}
|
||||
|
@ -418,12 +415,12 @@ class RewindCommand extends DebuggerCommand {
|
|||
debugger.console.print('rewind expects 0 or 1 argument');
|
||||
return;
|
||||
} else if (count < 1 || count > debugger.stackDepth) {
|
||||
debugger.console.print(
|
||||
'frame must be in range [1..${debugger.stackDepth - 1}]');
|
||||
debugger.console
|
||||
.print('frame must be in range [1..${debugger.stackDepth - 1}]');
|
||||
return;
|
||||
}
|
||||
await debugger.rewind(count);
|
||||
} on S.ServerRpcException catch(e) {
|
||||
} on S.ServerRpcException catch (e) {
|
||||
if (e.code == S.ServerRpcException.kCannotResume) {
|
||||
debugger.console.printRed(e.data['details']);
|
||||
} else {
|
||||
|
@ -434,8 +431,7 @@ class RewindCommand extends DebuggerCommand {
|
|||
|
||||
String helpShort = 'Rewind the stack to a previous frame';
|
||||
|
||||
String helpLong =
|
||||
'Rewind the stack to a previous frame.\n'
|
||||
String helpLong = 'Rewind the stack to a previous frame.\n'
|
||||
'\n'
|
||||
'Syntax: rewind\n'
|
||||
' rewind <count>\n';
|
||||
|
@ -454,7 +450,7 @@ class ReloadCommand extends DebuggerCommand {
|
|||
await debugger.isolate.reloadSources();
|
||||
debugger.console.print('reload complete');
|
||||
await debugger.refreshStack();
|
||||
} on S.ServerRpcException catch(e) {
|
||||
} on S.ServerRpcException catch (e) {
|
||||
if (e.code == S.ServerRpcException.kIsolateReloadBarred ||
|
||||
e.code == S.ServerRpcException.kIsolateReloadFailed ||
|
||||
e.code == S.ServerRpcException.kIsolateIsReloading) {
|
||||
|
@ -467,8 +463,7 @@ class ReloadCommand extends DebuggerCommand {
|
|||
|
||||
String helpShort = 'Reload the sources for the current isolate';
|
||||
|
||||
String helpLong =
|
||||
'Reload the sources for the current isolate.\n'
|
||||
String helpLong = 'Reload the sources for the current isolate.\n'
|
||||
'\n'
|
||||
'Syntax: reload\n';
|
||||
}
|
||||
|
@ -1833,24 +1828,18 @@ class ObservatoryDebugger extends Debugger {
|
|||
console.printBold('\$ $command');
|
||||
return cmd.runCommand(command).then((_) {
|
||||
lastCommand = command;
|
||||
}).catchError(
|
||||
(e, s) {
|
||||
console.printRed('Unable to execute command because the connection '
|
||||
'to the VM has been closed');
|
||||
}, test: (e) => e is S.NetworkRpcException
|
||||
).catchError(
|
||||
(e, s) {
|
||||
console.printRed(e.toString());
|
||||
}, test: (e) => e is CommandException
|
||||
).catchError(
|
||||
(e, s) {
|
||||
if (s != null) {
|
||||
console.printRed('Internal error: $e\n$s');
|
||||
} else {
|
||||
console.printRed('Internal error: $e\n');
|
||||
}
|
||||
}).catchError((e, s) {
|
||||
console.printRed('Unable to execute command because the connection '
|
||||
'to the VM has been closed');
|
||||
}, test: (e) => e is S.NetworkRpcException).catchError((e, s) {
|
||||
console.printRed(e.toString());
|
||||
}, test: (e) => e is CommandException).catchError((e, s) {
|
||||
if (s != null) {
|
||||
console.printRed('Internal error: $e\n$s');
|
||||
} else {
|
||||
console.printRed('Internal error: $e\n');
|
||||
}
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
String historyPrev(String command) {
|
||||
|
@ -2417,10 +2406,9 @@ class DebuggerFrameElement extends HtmlElement implements Renderable {
|
|||
bool _expanded = false;
|
||||
|
||||
void setCurrent(bool value) {
|
||||
Future load =
|
||||
(_frame.function != null) ?
|
||||
_frame.function.load() :
|
||||
new Future.value(null);
|
||||
Future load = (_frame.function != null)
|
||||
? _frame.function.load()
|
||||
: new Future.value(null);
|
||||
load.then((func) {
|
||||
_current = value;
|
||||
if (_current) {
|
||||
|
@ -2480,8 +2468,7 @@ class DebuggerFrameElement extends HtmlElement implements Renderable {
|
|||
}
|
||||
if (_frame.kind == M.FrameKind.asyncSuspensionMarker) {
|
||||
final content = <Element>[
|
||||
new SpanElement()
|
||||
..children = _createMarkerHeader(_frame.marker)
|
||||
new SpanElement()..children = _createMarkerHeader(_frame.marker)
|
||||
];
|
||||
children = content;
|
||||
return;
|
||||
|
@ -2603,7 +2590,7 @@ class DebuggerFrameElement extends HtmlElement implements Renderable {
|
|||
new DivElement()
|
||||
..classes = ['frameSummary']
|
||||
..children = content
|
||||
];
|
||||
];
|
||||
}
|
||||
|
||||
List<Element> _createHeader() {
|
||||
|
@ -2657,8 +2644,7 @@ class DebuggerFrameElement extends HtmlElement implements Renderable {
|
|||
return frame.function == null;
|
||||
}
|
||||
return (newFrame.function.id == _frame.function.id &&
|
||||
newFrame.location.script.id ==
|
||||
frame.location.script.id);
|
||||
newFrame.location.script.id == frame.location.script.id);
|
||||
}
|
||||
|
||||
void updateFrame(S.Frame newFrame) {
|
||||
|
|
|
@ -140,9 +140,7 @@ class HeapSnapshotElement extends HtmlElement implements Renderable {
|
|||
|
||||
Future _refresh() async {
|
||||
_progress = null;
|
||||
_progressStream = _snapshots.get(isolate,
|
||||
roots: _roots,
|
||||
gc: true);
|
||||
_progressStream = _snapshots.get(isolate, roots: _roots, gc: true);
|
||||
_r.dirty();
|
||||
_progressStream.listen((e) {
|
||||
_progress = e.progress;
|
||||
|
@ -281,14 +279,13 @@ class HeapSnapshotElement extends HtmlElement implements Renderable {
|
|||
]);
|
||||
break;
|
||||
case HeapSnapshotTreeMode.mergedDominatorTree:
|
||||
_tree = new VirtualTreeElement(
|
||||
_createMergedDominator, _updateMergedDominator,
|
||||
_getChildrenMergedDominator,
|
||||
_tree = new VirtualTreeElement(_createMergedDominator,
|
||||
_updateMergedDominator, _getChildrenMergedDominator,
|
||||
items: _getChildrenMergedDominator(_snapshot.mergedDominatorTree),
|
||||
queue: _r.queue);
|
||||
_tree.expand(_snapshot.mergedDominatorTree);
|
||||
final text = 'A heap dominator tree, where siblings with the same class'
|
||||
' have been merged into a single node.';
|
||||
' have been merged into a single node.';
|
||||
report.addAll([
|
||||
new DivElement()
|
||||
..classes = ['content-centered-big', 'explanation']
|
||||
|
@ -376,6 +373,7 @@ class HeapSnapshotElement extends HtmlElement implements Renderable {
|
|||
.where((child) => child.retainedSize >= kMinRetainedSize)
|
||||
.take(kMaxChildren);
|
||||
}
|
||||
|
||||
static _getChildrenMergedDominator(M.HeapSnapshotMergedDominatorNode node) {
|
||||
final list = node.children.toList();
|
||||
list.sort((a, b) => b.retainedSize - a.retainedSize);
|
||||
|
@ -414,8 +412,7 @@ class HeapSnapshotElement extends HtmlElement implements Renderable {
|
|||
wrapper
|
||||
..text = ''
|
||||
..children = [
|
||||
new AnchorElement(href: Uris.debugger(isolate))
|
||||
..text = 'stack frames'
|
||||
new AnchorElement(href: Uris.debugger(isolate))..text = 'stack frames'
|
||||
];
|
||||
} else {
|
||||
node.object.then((object) {
|
||||
|
@ -445,8 +442,7 @@ class HeapSnapshotElement extends HtmlElement implements Renderable {
|
|||
wrapper
|
||||
..text = ''
|
||||
..children = [
|
||||
new AnchorElement(href: Uris.debugger(isolate))
|
||||
..text = 'stack frames'
|
||||
new AnchorElement(href: Uris.debugger(isolate))..text = 'stack frames'
|
||||
];
|
||||
} else {
|
||||
node.klass.then((klass) {
|
||||
|
|
|
@ -340,8 +340,7 @@ class IsolateViewElement extends HtmlElement implements Renderable {
|
|||
..classes = ['memberValue']
|
||||
..children = [
|
||||
new CurlyBlockElement(queue: _r.queue)
|
||||
..content = threads
|
||||
.map(_populateThreadInfo)
|
||||
..content = threads.map(_populateThreadInfo)
|
||||
]
|
||||
]
|
||||
],
|
||||
|
@ -368,8 +367,7 @@ class IsolateViewElement extends HtmlElement implements Renderable {
|
|||
return new DivElement()
|
||||
..classes = ['indent']
|
||||
..children = [
|
||||
new SpanElement()
|
||||
..text = '${t.id} ',
|
||||
new SpanElement()..text = '${t.id} ',
|
||||
new CurlyBlockElement(queue: _r.queue)
|
||||
..content = [
|
||||
new DivElement()
|
||||
|
@ -379,10 +377,9 @@ class IsolateViewElement extends HtmlElement implements Renderable {
|
|||
..classes = ['indent']
|
||||
..title = '${t.memoryHighWatermark}B'
|
||||
..text =
|
||||
'native memory usage high watermark ${Utils.formatSize(t.memoryHighWatermark)}',
|
||||
'native memory usage high watermark ${Utils.formatSize(t.memoryHighWatermark)}',
|
||||
new DivElement()
|
||||
..children = t.zones
|
||||
.map((z) => new DivElement()
|
||||
..children = t.zones.map((z) => new DivElement()
|
||||
..classes = ['indent']
|
||||
..children = [
|
||||
new DivElement()
|
||||
|
@ -391,8 +388,7 @@ class IsolateViewElement extends HtmlElement implements Renderable {
|
|||
..children = [
|
||||
// TODO(bkonyi): zones will always be empty. See
|
||||
// issue #28885.
|
||||
new SpanElement()
|
||||
..text = 'zone ${index++} ',
|
||||
new SpanElement()..text = 'zone ${index++} ',
|
||||
new CurlyBlockElement(queue: _r.queue)
|
||||
..content = [
|
||||
new DivElement()
|
||||
|
@ -407,27 +403,25 @@ class IsolateViewElement extends HtmlElement implements Renderable {
|
|||
new SpanElement()
|
||||
..classes = ['memberValue']
|
||||
..title = '${z.used}B'
|
||||
..text =
|
||||
Utils.formatSize(z.used)
|
||||
..text = Utils.formatSize(z.used)
|
||||
],
|
||||
new DivElement()
|
||||
..classes = ['memberItem']
|
||||
..children = [
|
||||
new SpanElement()
|
||||
..classes = ['memberName']
|
||||
..text = 'capacity',
|
||||
new SpanElement()
|
||||
..classes = ['memberValue']
|
||||
..title = '${z.capacity}B'
|
||||
..text =
|
||||
Utils.formatSize(z.capacity)
|
||||
new SpanElement()
|
||||
..classes = ['memberName']
|
||||
..text = 'capacity',
|
||||
new SpanElement()
|
||||
..classes = ['memberValue']
|
||||
..title = '${z.capacity}B'
|
||||
..text = Utils.formatSize(z.capacity)
|
||||
]
|
||||
]
|
||||
]
|
||||
]
|
||||
]
|
||||
]
|
||||
)]
|
||||
])
|
||||
]
|
||||
];
|
||||
}
|
||||
|
||||
|
|
|
@ -8,7 +8,10 @@ import 'package:observatory/models.dart' as M;
|
|||
import 'package:observatory/src/elements/helpers/rendering_scheduler.dart';
|
||||
import 'package:observatory/src/elements/helpers/tag.dart';
|
||||
|
||||
enum ProfileTreeMode { code, function, }
|
||||
enum ProfileTreeMode {
|
||||
code,
|
||||
function,
|
||||
}
|
||||
|
||||
class StackTraceTreeConfigChangedEvent {
|
||||
final StackTraceTreeConfigElement element;
|
||||
|
@ -185,8 +188,7 @@ class StackTraceTreeConfigElement extends HtmlElement implements Renderable {
|
|||
_r.dirty();
|
||||
})
|
||||
..onChange.map(_toEvent).listen(_triggerModeChange),
|
||||
new SpanElement()
|
||||
..text = ' $modeDescription'
|
||||
new SpanElement()..text = ' $modeDescription'
|
||||
];
|
||||
}
|
||||
|
||||
|
@ -215,8 +217,7 @@ class StackTraceTreeConfigElement extends HtmlElement implements Renderable {
|
|||
_r.dirty();
|
||||
})
|
||||
..onChange.map(_toEvent).listen(_triggerDirectionChange),
|
||||
new SpanElement()
|
||||
..text = ' $directionDescription'
|
||||
new SpanElement()..text = ' $directionDescription'
|
||||
];
|
||||
}
|
||||
|
||||
|
|
|
@ -99,8 +99,9 @@ class VMConnectElement extends HtmlElement implements Renderable {
|
|||
..children = _targets.list().map((target) {
|
||||
final ObservatoryApplication app =
|
||||
ObservatoryApplication.app;
|
||||
final bool current = (app != null) ?
|
||||
app.isConnectedVMTarget(target) : false;
|
||||
final bool current = (app != null)
|
||||
? app.isConnectedVMTarget(target)
|
||||
: false;
|
||||
return new LIElement()
|
||||
..children = [
|
||||
new VMConnectTargetElement(target,
|
||||
|
|
|
@ -213,7 +213,6 @@ class VMViewElement extends HtmlElement implements Renderable {
|
|||
..classes = ['memberValue']
|
||||
..text = '${_vm.heapAllocationCount}'
|
||||
],
|
||||
|
||||
new BRElement(),
|
||||
new DivElement()
|
||||
..classes = ['memberItem']
|
||||
|
|
|
@ -4,11 +4,7 @@
|
|||
|
||||
part of models;
|
||||
|
||||
enum FrameKind {
|
||||
regular,
|
||||
asyncCausal,
|
||||
asyncSuspensionMarker
|
||||
}
|
||||
enum FrameKind { regular, asyncCausal, asyncSuspensionMarker }
|
||||
|
||||
abstract class Frame {
|
||||
FrameKind get kind;
|
||||
|
|
|
@ -30,8 +30,6 @@ abstract class HeapSnapshotLoadingProgress {
|
|||
}
|
||||
|
||||
abstract class HeapSnapshotRepository {
|
||||
Stream<HeapSnapshotLoadingProgressEvent> get(
|
||||
IsolateRef isolate,
|
||||
{HeapSnapshotRoots roots: HeapSnapshotRoots.vm,
|
||||
bool gc: false});
|
||||
Stream<HeapSnapshotLoadingProgressEvent> get(IsolateRef isolate,
|
||||
{HeapSnapshotRoots roots: HeapSnapshotRoots.vm, bool gc: false});
|
||||
}
|
||||
|
|
|
@ -100,10 +100,8 @@ class HeapSnapshotLoadingProgress extends M.HeapSnapshotLoadingProgress {
|
|||
}
|
||||
|
||||
class HeapSnapshotRepository implements M.HeapSnapshotRepository {
|
||||
Stream<HeapSnapshotLoadingProgressEvent> get(
|
||||
M.IsolateRef i,
|
||||
{M.HeapSnapshotRoots roots: M.HeapSnapshotRoots.vm,
|
||||
bool gc: false}) {
|
||||
Stream<HeapSnapshotLoadingProgressEvent> get(M.IsolateRef i,
|
||||
{M.HeapSnapshotRoots roots: M.HeapSnapshotRoots.vm, bool gc: false}) {
|
||||
S.Isolate isolate = i as S.Isolate;
|
||||
assert(isolate != null);
|
||||
assert(gc != null);
|
||||
|
|
|
@ -31,12 +31,12 @@ main() {
|
|||
test('elements created', () async {
|
||||
final completer = new Completer<AllocationProfileMock>();
|
||||
final repo = new AllocationProfileRepositoryMock(
|
||||
getter: expectAsync((M.IsolateRef i, bool gc, bool reset) {
|
||||
expect(i, equals(isolate));
|
||||
expect(gc, isFalse);
|
||||
expect(reset, isFalse);
|
||||
return completer.future;
|
||||
}, count: 1));
|
||||
getter: expectAsync((M.IsolateRef i, bool gc, bool reset) {
|
||||
expect(i, equals(isolate));
|
||||
expect(gc, isFalse);
|
||||
expect(reset, isFalse);
|
||||
return completer.future;
|
||||
}, count: 1));
|
||||
final e = new AllocationProfileElement(vm, isolate, events, notif, repo);
|
||||
document.body.append(e);
|
||||
await e.onRendered.first;
|
||||
|
@ -54,35 +54,37 @@ main() {
|
|||
final completer = new Completer<AllocationProfileMock>();
|
||||
int step = 0;
|
||||
final repo = new AllocationProfileRepositoryMock(
|
||||
getter: expectAsync((M.IsolateRef i, bool gc, bool reset) {
|
||||
expect(i, equals(isolate));
|
||||
switch (step) {
|
||||
case 0:
|
||||
expect(gc, isFalse);
|
||||
expect(reset, isFalse);
|
||||
break;
|
||||
case 1:
|
||||
expect(gc, isFalse);
|
||||
expect(reset, isTrue);
|
||||
break;
|
||||
case 2:
|
||||
expect(gc, isTrue);
|
||||
expect(reset, isFalse);
|
||||
break;
|
||||
case 3:
|
||||
expect(gc, isFalse);
|
||||
expect(reset, isFalse);
|
||||
break;
|
||||
}
|
||||
step++;
|
||||
return completer.future;
|
||||
}, count: 4));
|
||||
getter: expectAsync((M.IsolateRef i, bool gc, bool reset) {
|
||||
expect(i, equals(isolate));
|
||||
switch (step) {
|
||||
case 0:
|
||||
expect(gc, isFalse);
|
||||
expect(reset, isFalse);
|
||||
break;
|
||||
case 1:
|
||||
expect(gc, isFalse);
|
||||
expect(reset, isTrue);
|
||||
break;
|
||||
case 2:
|
||||
expect(gc, isTrue);
|
||||
expect(reset, isFalse);
|
||||
break;
|
||||
case 3:
|
||||
expect(gc, isFalse);
|
||||
expect(reset, isFalse);
|
||||
break;
|
||||
}
|
||||
step++;
|
||||
return completer.future;
|
||||
}, count: 4));
|
||||
final e = new AllocationProfileElement(vm, isolate, events, notif, repo);
|
||||
document.body.append(e);
|
||||
await e.onRendered.first;
|
||||
completer.complete(const AllocationProfileMock());
|
||||
await e.onRendered.first;
|
||||
e.querySelectorAll(rTag).sublist(1, 4)
|
||||
e
|
||||
.querySelectorAll(rTag)
|
||||
.sublist(1, 4)
|
||||
.forEach((NavRefreshElement e) => e.refresh());
|
||||
e.remove();
|
||||
await e.onRendered.first;
|
||||
|
@ -93,13 +95,13 @@ main() {
|
|||
final completer = new Completer<AllocationProfileMock>();
|
||||
int count = 0;
|
||||
final repo = new AllocationProfileRepositoryMock(
|
||||
getter: expectAsync((M.IsolateRef i, bool gc, bool reset) {
|
||||
expect(i, equals(isolate));
|
||||
expect(gc, isFalse);
|
||||
expect(reset, isFalse);
|
||||
count++;
|
||||
return completer.future;
|
||||
}, count: 2));
|
||||
getter: expectAsync((M.IsolateRef i, bool gc, bool reset) {
|
||||
expect(i, equals(isolate));
|
||||
expect(gc, isFalse);
|
||||
expect(reset, isFalse);
|
||||
count++;
|
||||
return completer.future;
|
||||
}, count: 2));
|
||||
final e = new AllocationProfileElement(vm, isolate, events, notif, repo);
|
||||
document.body.append(e);
|
||||
await e.onRendered.first;
|
||||
|
@ -112,11 +114,11 @@ main() {
|
|||
expect(count, equals(2));
|
||||
// shouldn't trigger
|
||||
events.add(new GCEventMock(isolate: new IsolateRefMock(id: 'another')));
|
||||
await (() async {} ());
|
||||
await (() async {}());
|
||||
e.querySelector('input[type=\'checkbox\']').click();
|
||||
// shouldn't trigger
|
||||
events.add(new GCEventMock(isolate: isolate));
|
||||
await (() async {} ());
|
||||
await (() async {}());
|
||||
e.remove();
|
||||
await e.onRendered.first;
|
||||
expect(e.children.length, isZero, reason: 'is empty');
|
||||
|
@ -126,22 +128,24 @@ main() {
|
|||
const clazz2 = const ClassRefMock(name: 'class2');
|
||||
const clazz3 = const ClassRefMock(name: 'class3');
|
||||
const profile = const AllocationProfileMock(members: const [
|
||||
const ClassHeapStatsMock(clazz: clazz2, newSpace: const AllocationsMock(
|
||||
accumulated: const AllocationCountMock(bytes: 10)
|
||||
)),
|
||||
const ClassHeapStatsMock(
|
||||
clazz: clazz2,
|
||||
newSpace: const AllocationsMock(
|
||||
accumulated: const AllocationCountMock(bytes: 10))),
|
||||
const ClassHeapStatsMock(clazz: clazz3),
|
||||
const ClassHeapStatsMock(clazz: clazz1, newSpace: const AllocationsMock(
|
||||
accumulated: const AllocationCountMock(bytes: 5)
|
||||
))
|
||||
const ClassHeapStatsMock(
|
||||
clazz: clazz1,
|
||||
newSpace: const AllocationsMock(
|
||||
accumulated: const AllocationCountMock(bytes: 5)))
|
||||
]);
|
||||
final completer = new Completer<AllocationProfileMock>();
|
||||
final repo = new AllocationProfileRepositoryMock(
|
||||
getter: expectAsync((M.IsolateRef i, bool gc, bool reset) {
|
||||
expect(i, equals(isolate));
|
||||
expect(gc, isFalse);
|
||||
expect(reset, isFalse);
|
||||
return completer.future;
|
||||
}, count: 1));
|
||||
getter: expectAsync((M.IsolateRef i, bool gc, bool reset) {
|
||||
expect(i, equals(isolate));
|
||||
expect(gc, isFalse);
|
||||
expect(reset, isFalse);
|
||||
return completer.future;
|
||||
}, count: 1));
|
||||
final e = new AllocationProfileElement(vm, isolate, events, notif, repo);
|
||||
document.body.append(e);
|
||||
await e.onRendered.first;
|
||||
|
|
|
@ -19,8 +19,8 @@ main() {
|
|||
|
||||
group('instantiation', () {
|
||||
test('default', () {
|
||||
final e = new ClassTreeElement(vm, isolate, events, notifications,
|
||||
new ClassRepositoryMock());
|
||||
final e = new ClassTreeElement(
|
||||
vm, isolate, events, notifications, new ClassRepositoryMock());
|
||||
expect(e, isNotNull, reason: 'element correctly created');
|
||||
});
|
||||
});
|
||||
|
@ -31,13 +31,17 @@ main() {
|
|||
const child1_id = 'c1-id';
|
||||
const child2 = const ClassMock(id: child2_id);
|
||||
const child1_1 = const ClassMock(id: child1_1_id);
|
||||
const child1 = const ClassMock(id: child1_id,
|
||||
subclasses: const [child1_1]);
|
||||
const object = const ClassMock(id: 'o-id',
|
||||
subclasses: const [child1, child2]);
|
||||
const child1 =
|
||||
const ClassMock(id: child1_id, subclasses: const [child1_1]);
|
||||
const object =
|
||||
const ClassMock(id: 'o-id', subclasses: const [child1, child2]);
|
||||
const ids = const [child1_id, child1_1_id, child2_id];
|
||||
bool rendered = false;
|
||||
final e = new ClassTreeElement(vm, isolate, events, notifications,
|
||||
final e = new ClassTreeElement(
|
||||
vm,
|
||||
isolate,
|
||||
events,
|
||||
notifications,
|
||||
new ClassRepositoryMock(
|
||||
object: expectAsync((i) async {
|
||||
expect(i, equals(isolate));
|
||||
|
@ -48,10 +52,14 @@ main() {
|
|||
expect(i, equals(isolate));
|
||||
expect(ids.contains(id), isTrue);
|
||||
switch (id) {
|
||||
case child1_id: return child1;
|
||||
case child1_1_id: return child1_1;
|
||||
case child2_id: return child2;
|
||||
default: return null;
|
||||
case child1_id:
|
||||
return child1;
|
||||
case child1_1_id:
|
||||
return child1_1;
|
||||
case child2_id:
|
||||
return child2;
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
}, count: 3)));
|
||||
document.body.append(e);
|
||||
|
|
|
@ -28,23 +28,20 @@ main() {
|
|||
final instances = new InstanceRepositoryMock();
|
||||
test('instantiation', () {
|
||||
final e = new ContextViewElement(vm, isolate, context, events, notifs,
|
||||
contexts, retainedSizes, reachableSizes,
|
||||
inbounds, paths, instances);
|
||||
contexts, retainedSizes, reachableSizes, inbounds, paths, instances);
|
||||
expect(e, isNotNull, reason: 'element correctly created');
|
||||
expect(e.isolate, equals(isolate));
|
||||
expect(e.context, equals(context));
|
||||
});
|
||||
test('elements created after attachment', () async {
|
||||
final contexts = new ContextRepositoryMock(
|
||||
getter: expectAsync((i, id) async {
|
||||
expect(i, equals(isolate));
|
||||
expect(id, equals(context.id));
|
||||
return context;
|
||||
}, count: 1)
|
||||
);
|
||||
getter: expectAsync((i, id) async {
|
||||
expect(i, equals(isolate));
|
||||
expect(id, equals(context.id));
|
||||
return context;
|
||||
}, count: 1));
|
||||
final e = new ContextViewElement(vm, isolate, context, events, notifs,
|
||||
contexts, retainedSizes, reachableSizes,
|
||||
inbounds, paths, instances);
|
||||
contexts, retainedSizes, reachableSizes, inbounds, paths, instances);
|
||||
document.body.append(e);
|
||||
await e.onRendered.first;
|
||||
expect(e.children.length, isNonZero, reason: 'has elements');
|
||||
|
|
|
@ -29,18 +29,16 @@ main() {
|
|||
expect(e, isNotNull, reason: 'element correctly created');
|
||||
});
|
||||
test('elements created', () async {
|
||||
final controller
|
||||
= new StreamController<M.SampleProfileLoadingProgressEvent>.broadcast();
|
||||
final profiles = new IsolateSampleProfileRepositoryMock(
|
||||
getter: (M.IsolateRef i, M.SampleProfileTag t, bool clear,
|
||||
bool forceFetch) {
|
||||
expect(i, equals(isolate));
|
||||
expect(t, isNotNull);
|
||||
expect(clear, isFalse);
|
||||
expect(forceFetch, isFalse);
|
||||
return controller.stream;
|
||||
}
|
||||
);
|
||||
final controller =
|
||||
new StreamController<M.SampleProfileLoadingProgressEvent>.broadcast();
|
||||
final profiles = new IsolateSampleProfileRepositoryMock(getter:
|
||||
(M.IsolateRef i, M.SampleProfileTag t, bool clear, bool forceFetch) {
|
||||
expect(i, equals(isolate));
|
||||
expect(t, isNotNull);
|
||||
expect(clear, isFalse);
|
||||
expect(forceFetch, isFalse);
|
||||
return controller.stream;
|
||||
});
|
||||
final e = new CpuProfileElement(vm, isolate, events, notifs, profiles);
|
||||
document.body.append(e);
|
||||
await e.onRendered.first;
|
||||
|
@ -49,25 +47,19 @@ main() {
|
|||
expect(e.querySelectorAll(cTag).length, isZero);
|
||||
expect(e.querySelectorAll(tTag).length, isZero);
|
||||
controller.add(new SampleProfileLoadingProgressEventMock(
|
||||
progress: new SampleProfileLoadingProgressMock(
|
||||
status: M.SampleProfileLoadingStatus.fetching
|
||||
)
|
||||
));
|
||||
progress: new SampleProfileLoadingProgressMock(
|
||||
status: M.SampleProfileLoadingStatus.fetching)));
|
||||
await e.onRendered.first;
|
||||
expect(e.querySelectorAll(sTag).length, equals(1));
|
||||
expect(e.querySelectorAll(cTag).length, isZero);
|
||||
expect(e.querySelectorAll(tTag).length, isZero);
|
||||
controller.add(new SampleProfileLoadingProgressEventMock(
|
||||
progress: new SampleProfileLoadingProgressMock(
|
||||
status: M.SampleProfileLoadingStatus.loading
|
||||
)
|
||||
));
|
||||
progress: new SampleProfileLoadingProgressMock(
|
||||
status: M.SampleProfileLoadingStatus.loading)));
|
||||
controller.add(new SampleProfileLoadingProgressEventMock(
|
||||
progress: new SampleProfileLoadingProgressMock(
|
||||
status: M.SampleProfileLoadingStatus.loaded,
|
||||
profile: new SampleProfileMock()
|
||||
)
|
||||
));
|
||||
progress: new SampleProfileLoadingProgressMock(
|
||||
status: M.SampleProfileLoadingStatus.loaded,
|
||||
profile: new SampleProfileMock())));
|
||||
controller.close();
|
||||
await e.onRendered.first;
|
||||
expect(e.querySelectorAll(sTag).length, equals(1));
|
||||
|
|
|
@ -29,18 +29,16 @@ main() {
|
|||
expect(e, isNotNull, reason: 'element correctly created');
|
||||
});
|
||||
test('elements created', () async {
|
||||
final controller
|
||||
= new StreamController<M.SampleProfileLoadingProgressEvent>.broadcast();
|
||||
final profiles = new IsolateSampleProfileRepositoryMock(
|
||||
getter: (M.IsolateRef i, M.SampleProfileTag t, bool clear,
|
||||
bool forceFetch) {
|
||||
expect(i, equals(isolate));
|
||||
expect(t, isNotNull);
|
||||
expect(clear, isFalse);
|
||||
expect(forceFetch, isFalse);
|
||||
return controller.stream;
|
||||
}
|
||||
);
|
||||
final controller =
|
||||
new StreamController<M.SampleProfileLoadingProgressEvent>.broadcast();
|
||||
final profiles = new IsolateSampleProfileRepositoryMock(getter:
|
||||
(M.IsolateRef i, M.SampleProfileTag t, bool clear, bool forceFetch) {
|
||||
expect(i, equals(isolate));
|
||||
expect(t, isNotNull);
|
||||
expect(clear, isFalse);
|
||||
expect(forceFetch, isFalse);
|
||||
return controller.stream;
|
||||
});
|
||||
final e = new CpuProfileTableElement(vm, isolate, events, notifs, profiles);
|
||||
document.body.append(e);
|
||||
await e.onRendered.first;
|
||||
|
@ -49,25 +47,19 @@ main() {
|
|||
expect(e.querySelectorAll(cTag).length, isZero);
|
||||
expect(e.querySelectorAll(tTag).length, isZero);
|
||||
controller.add(new SampleProfileLoadingProgressEventMock(
|
||||
progress: new SampleProfileLoadingProgressMock(
|
||||
status: M.SampleProfileLoadingStatus.fetching
|
||||
)
|
||||
));
|
||||
progress: new SampleProfileLoadingProgressMock(
|
||||
status: M.SampleProfileLoadingStatus.fetching)));
|
||||
await e.onRendered.first;
|
||||
expect(e.querySelectorAll(sTag).length, equals(1));
|
||||
expect(e.querySelectorAll(cTag).length, isZero);
|
||||
expect(e.querySelectorAll(tTag).length, isZero);
|
||||
controller.add(new SampleProfileLoadingProgressEventMock(
|
||||
progress: new SampleProfileLoadingProgressMock(
|
||||
status: M.SampleProfileLoadingStatus.loading
|
||||
)
|
||||
));
|
||||
progress: new SampleProfileLoadingProgressMock(
|
||||
status: M.SampleProfileLoadingStatus.loading)));
|
||||
controller.add(new SampleProfileLoadingProgressEventMock(
|
||||
progress: new SampleProfileLoadingProgressMock(
|
||||
status: M.SampleProfileLoadingStatus.loaded,
|
||||
profile: new SampleProfileMock()
|
||||
)
|
||||
));
|
||||
progress: new SampleProfileLoadingProgressMock(
|
||||
status: M.SampleProfileLoadingStatus.loaded,
|
||||
profile: new SampleProfileMock())));
|
||||
controller.close();
|
||||
await e.onRendered.first;
|
||||
expect(e.querySelectorAll(sTag).length, equals(1));
|
||||
|
|
|
@ -23,15 +23,13 @@ main() {
|
|||
expect(e.disabled, isFalse);
|
||||
});
|
||||
test('not expanded / not disabled', () {
|
||||
final e = new CurlyBlockElement(expanded: false,
|
||||
disabled: false);
|
||||
final e = new CurlyBlockElement(expanded: false, disabled: false);
|
||||
expect(e, isNotNull, reason: 'element correctly created');
|
||||
expect(e.expanded, isFalse);
|
||||
expect(e.disabled, isFalse);
|
||||
});
|
||||
test('not expanded / disabled', () {
|
||||
final e = new CurlyBlockElement(expanded: false,
|
||||
disabled: true);
|
||||
final e = new CurlyBlockElement(expanded: false, disabled: true);
|
||||
expect(e, isNotNull, reason: 'element correctly created');
|
||||
expect(e.expanded, isFalse);
|
||||
expect(e.disabled, isTrue);
|
||||
|
@ -72,8 +70,7 @@ main() {
|
|||
expect(e.children.length, isZero, reason: 'is empty');
|
||||
document.body.append(e);
|
||||
await e.onRendered.first;
|
||||
expect(e.children.length, isNonZero,
|
||||
reason: 'has elements');
|
||||
expect(e.children.length, isNonZero, reason: 'has elements');
|
||||
e.remove();
|
||||
await e.onRendered.first;
|
||||
expect(e.children.length, isZero, reason: 'is empty');
|
||||
|
@ -155,7 +152,7 @@ main() {
|
|||
await e.onRendered.first;
|
||||
});
|
||||
test('fires on toggle', () async {
|
||||
e.onToggle.listen(expectAsync((CurlyBlockToggleEvent event){
|
||||
e.onToggle.listen(expectAsync((CurlyBlockToggleEvent event) {
|
||||
expect(event, isNotNull);
|
||||
expect(event.control, equals(e));
|
||||
}, count: 1));
|
||||
|
@ -163,7 +160,7 @@ main() {
|
|||
await e.onRendered.first;
|
||||
});
|
||||
test('fires on manual toggle', () async {
|
||||
e.onToggle.listen(expectAsync((CurlyBlockToggleEvent event){
|
||||
e.onToggle.listen(expectAsync((CurlyBlockToggleEvent event) {
|
||||
expect(event, isNotNull);
|
||||
expect(event.control, equals(e));
|
||||
}, count: 1));
|
||||
|
@ -171,7 +168,7 @@ main() {
|
|||
await e.onRendered.first;
|
||||
});
|
||||
test('does not fire if setting same expanded value', () async {
|
||||
e.onToggle.listen(expectAsync((_){}, count: 0));
|
||||
e.onToggle.listen(expectAsync((_) {}, count: 0));
|
||||
e.expanded = e.expanded;
|
||||
await e.onRendered.first;
|
||||
});
|
||||
|
|
|
@ -22,10 +22,9 @@ main() {
|
|||
await e.onRendered.first;
|
||||
expect(e.children.length, isNonZero, reason: 'has elements');
|
||||
expect(e.innerHtml.contains(ref.message), isTrue,
|
||||
reason: 'no message in the component');
|
||||
reason: 'no message in the component');
|
||||
e.remove();
|
||||
await e.onRendered.first;
|
||||
expect(e.children.length, isZero,
|
||||
reason: 'is empty');
|
||||
expect(e.children.length, isZero, reason: 'is empty');
|
||||
});
|
||||
}
|
||||
|
|
|
@ -16,8 +16,8 @@ main() {
|
|||
|
||||
const isolate = const IsolateRefMock();
|
||||
const field = const FieldRefMock();
|
||||
const declaredType = const InstanceMock(kind: M.InstanceKind.type,
|
||||
name: 'CustomObject');
|
||||
const declaredType =
|
||||
const InstanceMock(kind: M.InstanceKind.type, name: 'CustomObject');
|
||||
const field_non_dynamic = const FieldRefMock(declaredType: declaredType);
|
||||
final repository = new InstanceRepositoryMock();
|
||||
test('instantiation', () {
|
||||
|
|
|
@ -18,9 +18,8 @@ main() {
|
|||
|
||||
group('instantiation', () {
|
||||
test('default', () {
|
||||
final e = new FlagListElement(vm, events,
|
||||
new FlagsRepositoryMock(),
|
||||
notifications);
|
||||
final e = new FlagListElement(
|
||||
vm, events, new FlagsRepositoryMock(), notifications);
|
||||
expect(e, isNotNull, reason: 'element correctly created');
|
||||
});
|
||||
});
|
||||
|
@ -43,8 +42,8 @@ main() {
|
|||
expect(e.children.length, isNonZero, reason: 'has elements');
|
||||
expect(e.querySelectorAll(nTag).length, equals(1));
|
||||
expect(e.querySelectorAll('.flag').length, equals(flags.length));
|
||||
expect(e.querySelectorAll('.flag.modified').length,
|
||||
equals(modified.length));
|
||||
expect(
|
||||
e.querySelectorAll('.flag.modified').length, equals(modified.length));
|
||||
expect(e.querySelectorAll('.flag.unmodified').length,
|
||||
equals(unmodifed.length));
|
||||
expect(e.querySelectorAll('.flag').length, equals(flags.length));
|
||||
|
|
|
@ -23,8 +23,8 @@ main() {
|
|||
expect(e.message, equals(''), reason: 'message should be empty');
|
||||
});
|
||||
test('message', () {
|
||||
final GeneralErrorElement e = new GeneralErrorElement(notifications,
|
||||
message: message);
|
||||
final GeneralErrorElement e =
|
||||
new GeneralErrorElement(notifications, message: message);
|
||||
expect(e, isNotNull, reason: 'element correctly created');
|
||||
expect(e.message, isNotNull, reason: 'message should not be null');
|
||||
expect(e.message, equals(message), reason: 'message should be the same');
|
||||
|
@ -49,8 +49,7 @@ main() {
|
|||
reason: 'should not contain');
|
||||
e.message = message;
|
||||
await e.onRendered.first;
|
||||
expect(e.innerHtml.contains(message), isTrue,
|
||||
reason: 'should contain');
|
||||
expect(e.innerHtml.contains(message), isTrue, reason: 'should contain');
|
||||
e.message = '';
|
||||
await e.onRendered.first;
|
||||
expect(e.innerHtml.contains(message), isFalse,
|
||||
|
|
|
@ -22,44 +22,37 @@ main() {
|
|||
final snapshots = new HeapSnapshotRepositoryMock();
|
||||
final instances = new InstanceRepositoryMock();
|
||||
test('instantiation', () {
|
||||
final e = new HeapSnapshotElement(vm, isolate, events, notifs, snapshots,
|
||||
instances);
|
||||
final e = new HeapSnapshotElement(
|
||||
vm, isolate, events, notifs, snapshots, instances);
|
||||
expect(e, isNotNull, reason: 'element correctly created');
|
||||
});
|
||||
test('elements created', () async {
|
||||
final controller
|
||||
= new StreamController<M.HeapSnapshotLoadingProgressEvent>.broadcast();
|
||||
final snapshots = new HeapSnapshotRepositoryMock(
|
||||
getter: (M.IsolateRef i, bool gc) {
|
||||
expect(i, equals(isolate));
|
||||
expect(gc, isFalse);
|
||||
return controller.stream;
|
||||
}
|
||||
);
|
||||
final e = new HeapSnapshotElement(vm, isolate, events, notifs, snapshots,
|
||||
instances);
|
||||
final controller =
|
||||
new StreamController<M.HeapSnapshotLoadingProgressEvent>.broadcast();
|
||||
final snapshots =
|
||||
new HeapSnapshotRepositoryMock(getter: (M.IsolateRef i, bool gc) {
|
||||
expect(i, equals(isolate));
|
||||
expect(gc, isFalse);
|
||||
return controller.stream;
|
||||
});
|
||||
final e = new HeapSnapshotElement(
|
||||
vm, isolate, events, notifs, snapshots, instances);
|
||||
document.body.append(e);
|
||||
await e.onRendered.first;
|
||||
expect(e.children.length, isNonZero, reason: 'has elements');
|
||||
expect(e.querySelectorAll(tTag).length, isZero);
|
||||
controller.add(const HeapSnapshotLoadingProgressEventMock(
|
||||
progress: const HeapSnapshotLoadingProgressMock(
|
||||
status: M.HeapSnapshotLoadingStatus.fetching
|
||||
)
|
||||
));
|
||||
progress: const HeapSnapshotLoadingProgressMock(
|
||||
status: M.HeapSnapshotLoadingStatus.fetching)));
|
||||
await e.onRendered.first;
|
||||
expect(e.querySelectorAll(tTag).length, isZero);
|
||||
controller.add(const HeapSnapshotLoadingProgressEventMock(
|
||||
progress: const HeapSnapshotLoadingProgressMock(
|
||||
status: M.HeapSnapshotLoadingStatus.loading
|
||||
)
|
||||
));
|
||||
progress: const HeapSnapshotLoadingProgressMock(
|
||||
status: M.HeapSnapshotLoadingStatus.loading)));
|
||||
controller.add(new HeapSnapshotLoadingProgressEventMock(
|
||||
progress: new HeapSnapshotLoadingProgressMock(
|
||||
status: M.HeapSnapshotLoadingStatus.loaded,
|
||||
snapshot: new HeapSnapshotMock(timestamp: new DateTime.now())
|
||||
)
|
||||
));
|
||||
progress: new HeapSnapshotLoadingProgressMock(
|
||||
status: M.HeapSnapshotLoadingStatus.loaded,
|
||||
snapshot: new HeapSnapshotMock(timestamp: new DateTime.now()))));
|
||||
controller.close();
|
||||
await e.onRendered.first;
|
||||
expect(e.querySelectorAll(tTag).length, equals(1));
|
||||
|
|
|
@ -28,23 +28,20 @@ main() {
|
|||
final instances = new InstanceRepositoryMock();
|
||||
test('instantiation', () {
|
||||
final e = new ICDataViewElement(vm, isolate, icdata, events, notifs,
|
||||
icdatas, retainedSizes, reachableSizes,
|
||||
inbounds, paths, instances);
|
||||
icdatas, retainedSizes, reachableSizes, inbounds, paths, instances);
|
||||
expect(e, isNotNull, reason: 'element correctly created');
|
||||
expect(e.isolate, equals(isolate));
|
||||
expect(e.icdata, equals(icdata));
|
||||
});
|
||||
test('elements created after attachment', () async {
|
||||
final icdatas = new ICDataRepositoryMock(
|
||||
getter: expectAsync((i, id) async {
|
||||
expect(i, equals(isolate));
|
||||
expect(id, equals(icdata.id));
|
||||
return icdata;
|
||||
}, count: 1)
|
||||
);
|
||||
getter: expectAsync((i, id) async {
|
||||
expect(i, equals(isolate));
|
||||
expect(id, equals(icdata.id));
|
||||
return icdata;
|
||||
}, count: 1));
|
||||
final e = new ICDataViewElement(vm, isolate, icdata, events, notifs,
|
||||
icdatas, retainedSizes, reachableSizes,
|
||||
inbounds, paths, instances);
|
||||
icdatas, retainedSizes, reachableSizes, inbounds, paths, instances);
|
||||
document.body.append(e);
|
||||
await e.onRendered.first;
|
||||
expect(e.children.length, isNonZero, reason: 'has elements');
|
||||
|
|
|
@ -21,29 +21,27 @@ main() {
|
|||
final inbounds = new InboundReferencesRepositoryMock();
|
||||
final instances = new InstanceRepositoryMock();
|
||||
test('instantiation', () {
|
||||
final e = new InboundReferencesElement(isolate, object, inbounds,
|
||||
instances);
|
||||
final e =
|
||||
new InboundReferencesElement(isolate, object, inbounds, instances);
|
||||
expect(e, isNotNull, reason: 'element correctly created');
|
||||
expect(e.isolate, equals(isolate));
|
||||
expect(e.object, equals(object));
|
||||
});
|
||||
test('elements created after attachment', () async {
|
||||
const source = const InstanceRefMock(id: 'source-id', name: 'source_name');
|
||||
const references = const InboundReferencesMock(elements: const [
|
||||
const InboundReferenceMock(source: source)
|
||||
]);
|
||||
const references = const InboundReferencesMock(
|
||||
elements: const [const InboundReferenceMock(source: source)]);
|
||||
bool invoked = false;
|
||||
final inbounds = new InboundReferencesRepositoryMock(
|
||||
getter: expectAsync((i, id) async {
|
||||
expect(i, equals(isolate));
|
||||
expect(id, equals(object.id));
|
||||
invoked = true;
|
||||
return references;
|
||||
}, count: 1)
|
||||
);
|
||||
getter: expectAsync((i, id) async {
|
||||
expect(i, equals(isolate));
|
||||
expect(id, equals(object.id));
|
||||
invoked = true;
|
||||
return references;
|
||||
}, count: 1));
|
||||
final instances = new InstanceRepositoryMock();
|
||||
final e = new InboundReferencesElement(isolate, object, inbounds,
|
||||
instances);
|
||||
final e =
|
||||
new InboundReferencesElement(isolate, object, inbounds, instances);
|
||||
document.body.append(e);
|
||||
await e.onRendered.first;
|
||||
expect(invoked, isFalse);
|
||||
|
|
|
@ -17,39 +17,41 @@ main() {
|
|||
NotificationRepositoryMock notifications;
|
||||
Uri uri;
|
||||
const vm = const VMMock(isolates: const [
|
||||
const IsolateMock(id: 'i-1-id'), const IsolateMock(id: 'i-2-id')
|
||||
const IsolateMock(id: 'i-1-id'),
|
||||
const IsolateMock(id: 'i-2-id')
|
||||
]);
|
||||
const missing = 'missing-id';
|
||||
setUp(() {
|
||||
events = new EventRepositoryMock();
|
||||
notifications = new NotificationRepositoryMock();
|
||||
uri = new Uri(path: 'path');
|
||||
uri = new Uri(path: 'path');
|
||||
});
|
||||
test('instantiation', () {
|
||||
final e = new IsolateReconnectElement(vm, events, notifications, missing,
|
||||
uri);
|
||||
final e =
|
||||
new IsolateReconnectElement(vm, events, notifications, missing, uri);
|
||||
expect(e, isNotNull, reason: 'element correctly created');
|
||||
expect(e.vm, equals(vm));
|
||||
expect(e.missing, equals(missing));
|
||||
expect(e.uri, equals(uri));
|
||||
});
|
||||
test('elements created after attachment', () async {
|
||||
final e = new IsolateReconnectElement(vm, events, notifications, missing,
|
||||
uri);
|
||||
final e =
|
||||
new IsolateReconnectElement(vm, events, notifications, missing, uri);
|
||||
document.body.append(e);
|
||||
await e.onRendered.first;
|
||||
expect(e.children.length, isNonZero, reason: 'has elements');
|
||||
expect(e.querySelector(nTag), isNotNull, reason: 'has notifications');
|
||||
expect(e.querySelectorAll('.isolate-link').length,
|
||||
equals(vm.isolates.length), reason: 'has links');
|
||||
expect(
|
||||
e.querySelectorAll('.isolate-link').length, equals(vm.isolates.length),
|
||||
reason: 'has links');
|
||||
e.remove();
|
||||
await e.onRendered.first;
|
||||
expect(e.children.length, isZero, reason: 'is empty');
|
||||
});
|
||||
group('updates', () {
|
||||
test('are correctly listen', () async {
|
||||
final e = new IsolateReconnectElement(vm, events, notifications, missing,
|
||||
uri);
|
||||
final e =
|
||||
new IsolateReconnectElement(vm, events, notifications, missing, uri);
|
||||
expect(events.onVMUpdateHasListener, isFalse);
|
||||
document.body.append(e);
|
||||
await e.onRendered.first;
|
||||
|
@ -59,11 +61,12 @@ main() {
|
|||
expect(events.onVMUpdateHasListener, isFalse);
|
||||
});
|
||||
test('have effects', () async {
|
||||
final e = new IsolateReconnectElement(vm, events, notifications, missing,
|
||||
uri);
|
||||
final e =
|
||||
new IsolateReconnectElement(vm, events, notifications, missing, uri);
|
||||
const vm2 = const VMMock(isolates: const [
|
||||
const IsolateMock(id: 'i-1-id'), const IsolateMock(id: 'i-2-id'),
|
||||
const IsolateMock(id: 'i-3-id')
|
||||
const IsolateMock(id: 'i-1-id'),
|
||||
const IsolateMock(id: 'i-2-id'),
|
||||
const IsolateMock(id: 'i-3-id')
|
||||
]);
|
||||
document.body.append(e);
|
||||
await e.onRendered.first;
|
||||
|
|
|
@ -27,26 +27,41 @@ main() {
|
|||
final paths = new RetainingPathRepositoryMock();
|
||||
final instances = new InstanceRepositoryMock();
|
||||
test('instantiation', () {
|
||||
final e = new MegamorphicCacheViewElement(vm, isolate, cache, events,
|
||||
notifs, caches, retainedSizes,
|
||||
reachableSizes, inbounds, paths,
|
||||
instances);
|
||||
final e = new MegamorphicCacheViewElement(
|
||||
vm,
|
||||
isolate,
|
||||
cache,
|
||||
events,
|
||||
notifs,
|
||||
caches,
|
||||
retainedSizes,
|
||||
reachableSizes,
|
||||
inbounds,
|
||||
paths,
|
||||
instances);
|
||||
expect(e, isNotNull, reason: 'element correctly created');
|
||||
expect(e.isolate, equals(isolate));
|
||||
expect(e.cache, equals(cache));
|
||||
});
|
||||
test('elements created after attachment', () async {
|
||||
final caches = new MegamorphicCacheRepositoryMock(
|
||||
getter: expectAsync((i, id) async {
|
||||
expect(i, equals(isolate));
|
||||
expect(id, equals(cache.id));
|
||||
return cache;
|
||||
}, count: 1)
|
||||
);
|
||||
final e = new MegamorphicCacheViewElement(vm, isolate, cache, events,
|
||||
notifs, caches, retainedSizes,
|
||||
reachableSizes, inbounds, paths,
|
||||
instances);
|
||||
getter: expectAsync((i, id) async {
|
||||
expect(i, equals(isolate));
|
||||
expect(id, equals(cache.id));
|
||||
return cache;
|
||||
}, count: 1));
|
||||
final e = new MegamorphicCacheViewElement(
|
||||
vm,
|
||||
isolate,
|
||||
cache,
|
||||
events,
|
||||
notifs,
|
||||
caches,
|
||||
retainedSizes,
|
||||
reachableSizes,
|
||||
inbounds,
|
||||
paths,
|
||||
instances);
|
||||
document.body.append(e);
|
||||
await e.onRendered.first;
|
||||
expect(e.children.length, isNonZero, reason: 'has elements');
|
||||
|
|
|
@ -11,13 +11,14 @@ class AllocationProfileMock implements M.AllocationProfile {
|
|||
final M.HeapSpace oldSpace;
|
||||
final Iterable<M.ClassHeapStats> members;
|
||||
|
||||
const AllocationProfileMock({this.lastServiceGC, this.lastAccumulatorReset,
|
||||
this.newSpace: const HeapSpaceMock(),
|
||||
this.oldSpace: const HeapSpaceMock(),
|
||||
this.members: const []});
|
||||
const AllocationProfileMock(
|
||||
{this.lastServiceGC,
|
||||
this.lastAccumulatorReset,
|
||||
this.newSpace: const HeapSpaceMock(),
|
||||
this.oldSpace: const HeapSpaceMock(),
|
||||
this.members: const []});
|
||||
}
|
||||
|
||||
|
||||
class ClassHeapStatsMock implements M.ClassHeapStats {
|
||||
final M.ClassRef clazz;
|
||||
final M.Allocations newSpace;
|
||||
|
@ -25,18 +26,21 @@ class ClassHeapStatsMock implements M.ClassHeapStats {
|
|||
final int promotedInstances;
|
||||
final int promotedBytes;
|
||||
|
||||
const ClassHeapStatsMock({this.clazz: const ClassRefMock(),
|
||||
this.newSpace: const AllocationsMock(),
|
||||
this.oldSpace: const AllocationsMock(),
|
||||
this.promotedInstances: 0, this.promotedBytes: 0});
|
||||
const ClassHeapStatsMock(
|
||||
{this.clazz: const ClassRefMock(),
|
||||
this.newSpace: const AllocationsMock(),
|
||||
this.oldSpace: const AllocationsMock(),
|
||||
this.promotedInstances: 0,
|
||||
this.promotedBytes: 0});
|
||||
}
|
||||
|
||||
class AllocationsMock implements M.Allocations {
|
||||
final M.AllocationCount accumulated;
|
||||
final M.AllocationCount current;
|
||||
|
||||
const AllocationsMock({this.accumulated: const AllocationCountMock(),
|
||||
this.current: const AllocationCountMock()});
|
||||
const AllocationsMock(
|
||||
{this.accumulated: const AllocationCountMock(),
|
||||
this.current: const AllocationCountMock()});
|
||||
}
|
||||
|
||||
class AllocationCountMock implements M.AllocationCount {
|
||||
|
|
|
@ -34,12 +34,27 @@ class ClassMock implements M.Class {
|
|||
final bool hasAllocations;
|
||||
bool get hasNoAllocations => !hasAllocations;
|
||||
final bool traceAllocations;
|
||||
const ClassMock({this.id: 'c-id', this.name: 'c-name', this.vmName: 'c-name',
|
||||
this.clazz, this.size, this.error, this.isAbstract: false,
|
||||
this.isConst: false, this.isPatch: false, this.library,
|
||||
this.location, this.superclass, this.superType,
|
||||
this.interfaces: const [], this.fields: const [],
|
||||
this.functions: const [], this.mixin,
|
||||
this.subclasses: const [], this.hasAllocations: false,
|
||||
this.newSpace, this.oldSpace, this.traceAllocations: false});
|
||||
const ClassMock(
|
||||
{this.id: 'c-id',
|
||||
this.name: 'c-name',
|
||||
this.vmName: 'c-name',
|
||||
this.clazz,
|
||||
this.size,
|
||||
this.error,
|
||||
this.isAbstract: false,
|
||||
this.isConst: false,
|
||||
this.isPatch: false,
|
||||
this.library,
|
||||
this.location,
|
||||
this.superclass,
|
||||
this.superType,
|
||||
this.interfaces: const [],
|
||||
this.fields: const [],
|
||||
this.functions: const [],
|
||||
this.mixin,
|
||||
this.subclasses: const [],
|
||||
this.hasAllocations: false,
|
||||
this.newSpace,
|
||||
this.oldSpace,
|
||||
this.traceAllocations: false});
|
||||
}
|
||||
|
|
|
@ -10,7 +10,7 @@ class CodeRefMock implements M.CodeRef {
|
|||
final M.CodeKind kind;
|
||||
final bool isOptimized;
|
||||
|
||||
const CodeRefMock({this.id, this.name, this.kind, this.isOptimized: false });
|
||||
const CodeRefMock({this.id, this.name, this.kind, this.isOptimized: false});
|
||||
}
|
||||
|
||||
class CodeMock implements M.Code {
|
||||
|
@ -25,10 +25,15 @@ class CodeMock implements M.Code {
|
|||
final M.ObjectPoolRef objectPool;
|
||||
final Iterable<M.FunctionRef> inlinedFunctions;
|
||||
|
||||
const CodeMock({this.id: 'code-id', this.name: 'code-name',
|
||||
this.vmName: 'code-vmName', this.clazz, this.size,
|
||||
this.kind: M.CodeKind.dart, this.isOptimized: false,
|
||||
this.function: const FunctionRefMock(),
|
||||
this.objectPool: const ObjectPoolRefMock(),
|
||||
this.inlinedFunctions: const []});
|
||||
const CodeMock(
|
||||
{this.id: 'code-id',
|
||||
this.name: 'code-name',
|
||||
this.vmName: 'code-vmName',
|
||||
this.clazz,
|
||||
this.size,
|
||||
this.kind: M.CodeKind.dart,
|
||||
this.isOptimized: false,
|
||||
this.function: const FunctionRefMock(),
|
||||
this.objectPool: const ObjectPoolRefMock(),
|
||||
this.inlinedFunctions: const []});
|
||||
}
|
||||
|
|
|
@ -20,14 +20,19 @@ class ContextMock implements M.Context {
|
|||
final M.Context parentContext;
|
||||
final Iterable<M.ContextElement> variables;
|
||||
|
||||
const ContextMock({this.id: 'context-id', this.vmName: 'context-vmName',
|
||||
this.clazz: const ClassMock(), this.size: 0, this.length,
|
||||
this.parentContext, this.variables: const []});
|
||||
const ContextMock(
|
||||
{this.id: 'context-id',
|
||||
this.vmName: 'context-vmName',
|
||||
this.clazz: const ClassMock(),
|
||||
this.size: 0,
|
||||
this.length,
|
||||
this.parentContext,
|
||||
this.variables: const []});
|
||||
}
|
||||
|
||||
class ContextElementMock implements M.ContextElement {
|
||||
final GuardedMock<M.InstanceRef> value;
|
||||
|
||||
const ContextElementMock({this.value: const GuardedMock.fromValue(
|
||||
const InstanceRefMock())});
|
||||
const ContextElementMock(
|
||||
{this.value: const GuardedMock.fromValue(const InstanceRefMock())});
|
||||
}
|
||||
|
|
|
@ -9,9 +9,10 @@ class ErrorRefMock implements M.ErrorRef {
|
|||
final M.ErrorKind kind;
|
||||
final String message;
|
||||
|
||||
const ErrorRefMock({this.id: 'error-ref',
|
||||
this.kind: M.ErrorKind.internalError,
|
||||
this.message: 'Error Message'});
|
||||
const ErrorRefMock(
|
||||
{this.id: 'error-ref',
|
||||
this.kind: M.ErrorKind.internalError,
|
||||
this.message: 'Error Message'});
|
||||
}
|
||||
|
||||
class ErrorMock implements M.Error {
|
||||
|
@ -22,8 +23,11 @@ class ErrorMock implements M.Error {
|
|||
final M.ErrorKind kind;
|
||||
final String message;
|
||||
|
||||
const ErrorMock({this.id: 'error-id', this.vmName: 'error-vmName',
|
||||
this.clazz: const ClassMock(), this.size: 0,
|
||||
this.kind: M.ErrorKind.internalError,
|
||||
this.message: 'Error Message'});
|
||||
const ErrorMock(
|
||||
{this.id: 'error-id',
|
||||
this.vmName: 'error-vmName',
|
||||
this.clazz: const ClassMock(),
|
||||
this.size: 0,
|
||||
this.kind: M.ErrorKind.internalError,
|
||||
this.message: 'Error Message'});
|
||||
}
|
||||
|
|
|
@ -9,54 +9,64 @@ class VMUpdateEventMock implements M.VMUpdateEvent {
|
|||
final DateTime timestamp;
|
||||
const VMUpdateEventMock({this.timestamp, this.vm});
|
||||
}
|
||||
|
||||
class IsolateStartEventMock implements M.IsolateStartEvent {
|
||||
final DateTime timestamp;
|
||||
final M.IsolateRef isolate;
|
||||
const IsolateStartEventMock({this.timestamp, this.isolate});
|
||||
}
|
||||
|
||||
class IsolateRunnableEventMock implements M.IsolateRunnableEvent {
|
||||
final DateTime timestamp;
|
||||
final M.IsolateRef isolate;
|
||||
const IsolateRunnableEventMock({this.timestamp, this.isolate});
|
||||
}
|
||||
|
||||
class IsolateExitEventMock implements M.IsolateExitEvent {
|
||||
final DateTime timestamp;
|
||||
final M.IsolateRef isolate;
|
||||
const IsolateExitEventMock({this.timestamp, this.isolate});
|
||||
}
|
||||
|
||||
class IsolateUpdateEventMock implements M.IsolateUpdateEvent {
|
||||
final DateTime timestamp;
|
||||
final M.IsolateRef isolate;
|
||||
const IsolateUpdateEventMock({this.timestamp, this.isolate});
|
||||
}
|
||||
|
||||
class IsolateRealodEventMock implements M.IsolateReloadEvent {
|
||||
final DateTime timestamp;
|
||||
final M.IsolateRef isolate;
|
||||
final M.Error error;
|
||||
const IsolateRealodEventMock({this.timestamp, this.isolate, this.error});
|
||||
}
|
||||
|
||||
class ServiceExtensionAddedEventMock implements M.ServiceExtensionAddedEvent {
|
||||
final DateTime timestamp;
|
||||
final M.IsolateRef isolate;
|
||||
final String extensionRPC;
|
||||
const ServiceExtensionAddedEventMock({this.extensionRPC, this.isolate,
|
||||
this.timestamp});
|
||||
const ServiceExtensionAddedEventMock(
|
||||
{this.extensionRPC, this.isolate, this.timestamp});
|
||||
}
|
||||
|
||||
class DebuggerSettingsUpdateEventMock implements M.PauseStartEvent {
|
||||
final DateTime timestamp;
|
||||
final M.IsolateRef isolate;
|
||||
const DebuggerSettingsUpdateEventMock({this.isolate, this.timestamp});
|
||||
}
|
||||
|
||||
class PauseStartEventMock implements M.PauseStartEvent {
|
||||
final DateTime timestamp;
|
||||
final M.IsolateRef isolate;
|
||||
const PauseStartEventMock({this.isolate, this.timestamp});
|
||||
}
|
||||
|
||||
class PauseExitEventMock implements M.PauseExitEvent {
|
||||
final DateTime timestamp;
|
||||
final M.IsolateRef isolate;
|
||||
const PauseExitEventMock({this.isolate, this.timestamp});
|
||||
}
|
||||
|
||||
class PauseBreakpointEventMock implements M.PauseBreakpointEvent {
|
||||
final DateTime timestamp;
|
||||
final M.IsolateRef isolate;
|
||||
|
@ -64,83 +74,100 @@ class PauseBreakpointEventMock implements M.PauseBreakpointEvent {
|
|||
final List<M.Breakpoint> pauseBreakpoints;
|
||||
final M.Frame topFrame;
|
||||
final bool atAsyncSuspension;
|
||||
const PauseBreakpointEventMock({this.timestamp, this.isolate, this.breakpoint,
|
||||
this.pauseBreakpoints, this.topFrame, this.atAsyncSuspension});
|
||||
const PauseBreakpointEventMock(
|
||||
{this.timestamp,
|
||||
this.isolate,
|
||||
this.breakpoint,
|
||||
this.pauseBreakpoints,
|
||||
this.topFrame,
|
||||
this.atAsyncSuspension});
|
||||
}
|
||||
|
||||
class PauseInterruptedEventMock implements M.PauseInterruptedEvent {
|
||||
final DateTime timestamp;
|
||||
final M.IsolateRef isolate;
|
||||
final M.Frame topFrame;
|
||||
final bool atAsyncSuspension;
|
||||
const PauseInterruptedEventMock({this.timestamp, this.isolate, this.topFrame,
|
||||
this.atAsyncSuspension});
|
||||
const PauseInterruptedEventMock(
|
||||
{this.timestamp, this.isolate, this.topFrame, this.atAsyncSuspension});
|
||||
}
|
||||
|
||||
class PauseExceptionEventMock implements M.PauseExceptionEvent {
|
||||
final DateTime timestamp;
|
||||
final M.IsolateRef isolate;
|
||||
final M.Frame topFrame;
|
||||
final M.InstanceRef exception;
|
||||
const PauseExceptionEventMock({this.timestamp, this.isolate, this.topFrame,
|
||||
this.exception});
|
||||
const PauseExceptionEventMock(
|
||||
{this.timestamp, this.isolate, this.topFrame, this.exception});
|
||||
}
|
||||
|
||||
class ResumeEventMock implements M.ResumeEvent {
|
||||
final DateTime timestamp;
|
||||
final M.IsolateRef isolate;
|
||||
final M.Frame topFrame;
|
||||
const ResumeEventMock({this.timestamp, this.isolate, this.topFrame});
|
||||
}
|
||||
|
||||
class BreakpointAddedEventMock implements M.BreakpointAddedEvent {
|
||||
final DateTime timestamp;
|
||||
final M.IsolateRef isolate;
|
||||
final M.Breakpoint breakpoint;
|
||||
const BreakpointAddedEventMock({this.timestamp, this.isolate,
|
||||
this.breakpoint});
|
||||
const BreakpointAddedEventMock(
|
||||
{this.timestamp, this.isolate, this.breakpoint});
|
||||
}
|
||||
|
||||
class BreakpointResolvedEventMock implements M.BreakpointResolvedEvent {
|
||||
final DateTime timestamp;
|
||||
final M.IsolateRef isolate;
|
||||
final M.Breakpoint breakpoint;
|
||||
const BreakpointResolvedEventMock({this.timestamp, this.isolate,
|
||||
this.breakpoint});
|
||||
const BreakpointResolvedEventMock(
|
||||
{this.timestamp, this.isolate, this.breakpoint});
|
||||
}
|
||||
|
||||
class BreakpointRemovedEventMock implements M.BreakpointRemovedEvent {
|
||||
final DateTime timestamp;
|
||||
final M.IsolateRef isolate;
|
||||
final M.Breakpoint breakpoint;
|
||||
const BreakpointRemovedEventMock({this.timestamp, this.isolate,
|
||||
this.breakpoint});
|
||||
const BreakpointRemovedEventMock(
|
||||
{this.timestamp, this.isolate, this.breakpoint});
|
||||
}
|
||||
|
||||
class InspectEventMock implements M.InspectEvent {
|
||||
final DateTime timestamp;
|
||||
final M.IsolateRef isolate;
|
||||
final M.InstanceRef inspectee;
|
||||
const InspectEventMock({this.timestamp, this.isolate, this.inspectee});
|
||||
}
|
||||
|
||||
class NoneEventMock implements M.NoneEvent {
|
||||
final DateTime timestamp;
|
||||
final M.IsolateRef isolate;
|
||||
const NoneEventMock({this.timestamp, this.isolate});
|
||||
}
|
||||
|
||||
class GCEventMock implements M.GCEvent {
|
||||
final DateTime timestamp;
|
||||
final M.IsolateRef isolate;
|
||||
const GCEventMock({this.timestamp, this.isolate});
|
||||
}
|
||||
|
||||
class ExtensionEventMock implements M.ExtensionEvent {
|
||||
final DateTime timestamp;
|
||||
final M.IsolateRef isolate;
|
||||
final String extensionKind;
|
||||
final M.ExtensionData extensionData;
|
||||
const ExtensionEventMock({this.timestamp, this.isolate, this.extensionKind,
|
||||
this.extensionData});
|
||||
const ExtensionEventMock(
|
||||
{this.timestamp, this.isolate, this.extensionKind, this.extensionData});
|
||||
}
|
||||
|
||||
class TimelineEventsEventMock implements M.TimelineEventsEvent {
|
||||
final DateTime timestamp;
|
||||
final M.IsolateRef isolate;
|
||||
final List<M.TimelineEvent> timelineEvents;
|
||||
const TimelineEventsEventMock({this.timestamp, this.isolate,
|
||||
this.timelineEvents});
|
||||
const TimelineEventsEventMock(
|
||||
{this.timestamp, this.isolate, this.timelineEvents});
|
||||
}
|
||||
|
||||
class ConnectionClockedEventMock implements M.ConnectionClosedEvent {
|
||||
final DateTime timestamp;
|
||||
final String reason;
|
||||
|
|
|
@ -13,9 +13,12 @@ class FieldRefMock implements M.FieldRef {
|
|||
final bool isFinal;
|
||||
final bool isStatic;
|
||||
|
||||
const FieldRefMock({this.id: 'field-id', this.name: 'field-name',
|
||||
this.dartOwner,
|
||||
this.declaredType: const InstanceRefMock(name: 'dynamic'),
|
||||
this.isConst: false,
|
||||
this.isFinal: false, this.isStatic: false});
|
||||
const FieldRefMock(
|
||||
{this.id: 'field-id',
|
||||
this.name: 'field-name',
|
||||
this.dartOwner,
|
||||
this.declaredType: const InstanceRefMock(name: 'dynamic'),
|
||||
this.isConst: false,
|
||||
this.isFinal: false,
|
||||
this.isStatic: false});
|
||||
}
|
||||
|
|
|
@ -12,8 +12,13 @@ class FunctionRefMock implements M.FunctionRef {
|
|||
final bool isConst;
|
||||
final M.FunctionKind kind;
|
||||
|
||||
const FunctionRefMock({this.id, this.name, this.dartOwner,
|
||||
this.isStatic : false, this.isConst : false, this.kind});
|
||||
const FunctionRefMock(
|
||||
{this.id,
|
||||
this.name,
|
||||
this.dartOwner,
|
||||
this.isStatic: false,
|
||||
this.isConst: false,
|
||||
this.kind});
|
||||
}
|
||||
|
||||
class FunctionMock implements M.Function {
|
||||
|
@ -38,11 +43,27 @@ class FunctionMock implements M.Function {
|
|||
final bool isRecognized;
|
||||
final bool isNative;
|
||||
final String vmName;
|
||||
const FunctionMock({this.id, this.name, this.clazz, this.size, this.dartOwner,
|
||||
this.isStatic : false, this.isConst : false, this.kind, this.location,
|
||||
this.code, this.unoptimizedCode, this.field, this.usageCounter: 0,
|
||||
this.icDataArray: const InstanceRefMock(), this.deoptimizations: 0,
|
||||
this.isOptimizable: false, this.isInlinable: false,
|
||||
this.hasIntrinsic: false, this.isRecognized: false, this.isNative: false,
|
||||
this.vmName: 'function-vm-name',});
|
||||
const FunctionMock({
|
||||
this.id,
|
||||
this.name,
|
||||
this.clazz,
|
||||
this.size,
|
||||
this.dartOwner,
|
||||
this.isStatic: false,
|
||||
this.isConst: false,
|
||||
this.kind,
|
||||
this.location,
|
||||
this.code,
|
||||
this.unoptimizedCode,
|
||||
this.field,
|
||||
this.usageCounter: 0,
|
||||
this.icDataArray: const InstanceRefMock(),
|
||||
this.deoptimizations: 0,
|
||||
this.isOptimizable: false,
|
||||
this.isInlinable: false,
|
||||
this.hasIntrinsic: false,
|
||||
this.isRecognized: false,
|
||||
this.isNative: false,
|
||||
this.vmName: 'function-vm-name',
|
||||
});
|
||||
}
|
||||
|
|
|
@ -10,9 +10,7 @@ class GuardedMock<T> implements M.Guarded {
|
|||
final T asValue;
|
||||
final M.Sentinel asSentinel;
|
||||
|
||||
const GuardedMock.fromValue(this.asValue)
|
||||
: asSentinel = null;
|
||||
const GuardedMock.fromValue(this.asValue) : asSentinel = null;
|
||||
|
||||
const GuardedMock.fromSentinel(this.asSentinel)
|
||||
: asValue = null;
|
||||
const GuardedMock.fromSentinel(this.asSentinel) : asValue = null;
|
||||
}
|
||||
|
|
|
@ -12,8 +12,11 @@ class HeapSnapshotMock implements M.HeapSnapshot {
|
|||
final M.HeapSnapshotDominatorNode dominatorTree;
|
||||
final Iterable<M.HeapSnapshotClassReferences> classReferences;
|
||||
|
||||
const HeapSnapshotMock({this.timestamp, this.objects: 0,
|
||||
this.references: 0, this.size: 0,
|
||||
const HeapSnapshotMock(
|
||||
{this.timestamp,
|
||||
this.objects: 0,
|
||||
this.references: 0,
|
||||
this.size: 0,
|
||||
this.dominatorTree: const HeapSnapshotDominatorNodeMock(),
|
||||
this.classReferences: const []});
|
||||
}
|
||||
|
@ -24,9 +27,11 @@ class HeapSnapshotDominatorNodeMock implements M.HeapSnapshotDominatorNode {
|
|||
final Future<M.ObjectRef> object;
|
||||
final Iterable<M.HeapSnapshotDominatorNode> children;
|
||||
|
||||
const HeapSnapshotDominatorNodeMock({this.shallowSize: 1,
|
||||
this.retainedSize: 1,
|
||||
this.object, this.children: const []});
|
||||
const HeapSnapshotDominatorNodeMock(
|
||||
{this.shallowSize: 1,
|
||||
this.retainedSize: 1,
|
||||
this.object,
|
||||
this.children: const []});
|
||||
}
|
||||
|
||||
class HeapSnapshotClassReferencesMock implements M.HeapSnapshotClassReferences {
|
||||
|
@ -37,11 +42,13 @@ class HeapSnapshotClassReferencesMock implements M.HeapSnapshotClassReferences {
|
|||
final Iterable<M.HeapSnapshotClassInbound> inbounds;
|
||||
final Iterable<M.HeapSnapshotClassOutbound> outbounds;
|
||||
|
||||
const HeapSnapshotClassReferencesMock({this.clazz: const ClassRefMock(),
|
||||
this.instances: 1, this.shallowSize: 1,
|
||||
this.retainedSize: 2,
|
||||
this.inbounds: const [],
|
||||
this.outbounds: const []});
|
||||
const HeapSnapshotClassReferencesMock(
|
||||
{this.clazz: const ClassRefMock(),
|
||||
this.instances: 1,
|
||||
this.shallowSize: 1,
|
||||
this.retainedSize: 2,
|
||||
this.inbounds: const [],
|
||||
this.outbounds: const []});
|
||||
}
|
||||
|
||||
class HeapSnapshotClassInboundMock implements M.HeapSnapshotClassInbound {
|
||||
|
@ -50,9 +57,11 @@ class HeapSnapshotClassInboundMock implements M.HeapSnapshotClassInbound {
|
|||
final int shallowSize;
|
||||
final int retainedSize;
|
||||
|
||||
const HeapSnapshotClassInboundMock({this.source: const ClassRefMock(),
|
||||
this.count: 1, this.shallowSize: 1,
|
||||
this.retainedSize: 2});
|
||||
const HeapSnapshotClassInboundMock(
|
||||
{this.source: const ClassRefMock(),
|
||||
this.count: 1,
|
||||
this.shallowSize: 1,
|
||||
this.retainedSize: 2});
|
||||
}
|
||||
|
||||
class HeapSnapshotClassOutboundMock implements M.HeapSnapshotClassOutbound {
|
||||
|
@ -60,7 +69,9 @@ class HeapSnapshotClassOutboundMock implements M.HeapSnapshotClassOutbound {
|
|||
final int count;
|
||||
final int shallowSize;
|
||||
final int retainedSize;
|
||||
const HeapSnapshotClassOutboundMock({this.target: const ClassRefMock(),
|
||||
this.count: 1, this.shallowSize: 1,
|
||||
this.retainedSize: 2});
|
||||
const HeapSnapshotClassOutboundMock(
|
||||
{this.target: const ClassRefMock(),
|
||||
this.count: 1,
|
||||
this.shallowSize: 1,
|
||||
this.retainedSize: 2});
|
||||
}
|
||||
|
|
|
@ -12,9 +12,12 @@ class HeapSpaceMock implements M.HeapSpace {
|
|||
final Duration avgCollectionTime;
|
||||
final Duration totalCollectionTime;
|
||||
final Duration avgCollectionPeriod;
|
||||
const HeapSpaceMock({this.used: 0, this.capacity: 1, this.collections: 0,
|
||||
this.external: 1,
|
||||
this.avgCollectionTime: const Duration(),
|
||||
this.totalCollectionTime: const Duration(),
|
||||
this.avgCollectionPeriod: const Duration()});
|
||||
const HeapSpaceMock(
|
||||
{this.used: 0,
|
||||
this.capacity: 1,
|
||||
this.collections: 0,
|
||||
this.external: 1,
|
||||
this.avgCollectionTime: const Duration(),
|
||||
this.totalCollectionTime: const Duration(),
|
||||
this.avgCollectionPeriod: const Duration()});
|
||||
}
|
||||
|
|
|
@ -21,8 +21,13 @@ class ICDataMock implements M.ICData {
|
|||
final M.InstanceRef argumentsDescriptor;
|
||||
final M.InstanceRef entries;
|
||||
|
||||
const ICDataMock({this.id: 'icdata-id', this.vmName: 'icdata-vmName',
|
||||
this.clazz: const ClassRefMock(), this.size: 0,
|
||||
this.selector, this.dartOwner, this.argumentsDescriptor,
|
||||
this.entries});
|
||||
const ICDataMock(
|
||||
{this.id: 'icdata-id',
|
||||
this.vmName: 'icdata-vmName',
|
||||
this.clazz: const ClassRefMock(),
|
||||
this.size: 0,
|
||||
this.selector,
|
||||
this.dartOwner,
|
||||
this.argumentsDescriptor,
|
||||
this.entries});
|
||||
}
|
||||
|
|
|
@ -16,7 +16,9 @@ class InboundReferenceMock implements M.InboundReference {
|
|||
final int parentListIndex;
|
||||
final int parentWordOffset;
|
||||
|
||||
const InboundReferenceMock({this.source: const InstanceRefMock(),
|
||||
this.parentField, this.parentListIndex,
|
||||
this.parentWordOffset});
|
||||
const InboundReferenceMock(
|
||||
{this.source: const InstanceRefMock(),
|
||||
this.parentField,
|
||||
this.parentListIndex,
|
||||
this.parentWordOffset});
|
||||
}
|
||||
|
|
|
@ -18,12 +18,19 @@ class InstanceRefMock implements M.InstanceRef {
|
|||
final M.FunctionRef closureFunction;
|
||||
final M.ContextRef closureContext;
|
||||
|
||||
const InstanceRefMock({this.id: 'instance-id', this.name: 'instance-name',
|
||||
this.kind: M.InstanceKind.vNull, this.clazz,
|
||||
this.valueAsString: 'null',
|
||||
this.valueAsStringIsTruncated, this.length,
|
||||
this.typeClass, this.parameterizedClass, this.pattern,
|
||||
this.closureFunction, this.closureContext});
|
||||
const InstanceRefMock(
|
||||
{this.id: 'instance-id',
|
||||
this.name: 'instance-name',
|
||||
this.kind: M.InstanceKind.vNull,
|
||||
this.clazz,
|
||||
this.valueAsString: 'null',
|
||||
this.valueAsStringIsTruncated,
|
||||
this.length,
|
||||
this.typeClass,
|
||||
this.parameterizedClass,
|
||||
this.pattern,
|
||||
this.closureFunction,
|
||||
this.closureContext});
|
||||
}
|
||||
|
||||
class InstanceMock implements M.Instance {
|
||||
|
@ -65,20 +72,42 @@ class InstanceMock implements M.Instance {
|
|||
final M.InstanceRef oneByteBytecode;
|
||||
final M.InstanceRef twoByteBytecode;
|
||||
|
||||
const InstanceMock({this.id: 'instance-id', this.name: 'instance-name',
|
||||
this.vmName: 'instance-vmName',
|
||||
this.kind: M.InstanceKind.vNull,
|
||||
this.clazz: const ClassRefMock(), this.size: 0,
|
||||
this.valueAsString: 'null', this.valueAsStringIsTruncated,
|
||||
this.length, this.typeClass, this.parameterizedClass,
|
||||
this.pattern, this.closureFunction, this.closureContext,
|
||||
this.offset, this.count, this.typedElements, this.fields,
|
||||
this.nativeFields, this.elements, this.associations,
|
||||
this.key, this.value, this.referent, this.typeArguments,
|
||||
this.parameterIndex, this.targetType, this.bound,
|
||||
this.activationBreakpoint, this.isCaseSensitive,
|
||||
this.isMultiLine, this.oneByteFunction,
|
||||
this.twoByteFunction, this.externalOneByteFunction,
|
||||
this.externalTwoByteFunction, this.oneByteBytecode,
|
||||
this.twoByteBytecode});
|
||||
const InstanceMock(
|
||||
{this.id: 'instance-id',
|
||||
this.name: 'instance-name',
|
||||
this.vmName: 'instance-vmName',
|
||||
this.kind: M.InstanceKind.vNull,
|
||||
this.clazz: const ClassRefMock(),
|
||||
this.size: 0,
|
||||
this.valueAsString: 'null',
|
||||
this.valueAsStringIsTruncated,
|
||||
this.length,
|
||||
this.typeClass,
|
||||
this.parameterizedClass,
|
||||
this.pattern,
|
||||
this.closureFunction,
|
||||
this.closureContext,
|
||||
this.offset,
|
||||
this.count,
|
||||
this.typedElements,
|
||||
this.fields,
|
||||
this.nativeFields,
|
||||
this.elements,
|
||||
this.associations,
|
||||
this.key,
|
||||
this.value,
|
||||
this.referent,
|
||||
this.typeArguments,
|
||||
this.parameterIndex,
|
||||
this.targetType,
|
||||
this.bound,
|
||||
this.activationBreakpoint,
|
||||
this.isCaseSensitive,
|
||||
this.isMultiLine,
|
||||
this.oneByteFunction,
|
||||
this.twoByteFunction,
|
||||
this.externalOneByteFunction,
|
||||
this.externalTwoByteFunction,
|
||||
this.oneByteBytecode,
|
||||
this.twoByteBytecode});
|
||||
}
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue