[NNBD/VM] Restructure VM patch files for the NNBD dart sdk split

- Move all VM patch files from the lib directory to
sdk/lib/_internal/vm/lib
- Move all VM patch files from the bin directory to
sdk/lib/_internal/vm/bin
- Fixed paths for above patch files in libraries.yaml file.
- Created copies of these patch files in sdk_nnbd directory
- Cleaned up *.gni files by removing the unused dart patch files lists.

Change-Id: I3109d22f3b729a073a6b40175a0d29162a455830
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/117685
Reviewed-by: Régis Crelier <regis@google.com>
Commit-Queue: Siva Annamalai <asiva@google.com>
This commit is contained in:
asiva 2019-09-19 03:57:30 +00:00 committed by commit-bot@chromium.org
parent 0c23664c8f
commit 7c1821c4aa
165 changed files with 28025 additions and 461 deletions

View file

@ -1,6 +1,3 @@
# Copyright (c) 2017, the Dart project authors. Please see the AUTHORS file
# 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.
# This file contains all dart sources for the dart:_builtin library.
builtin_sources = [ "builtin.dart" ]

View file

@ -2,5 +2,3 @@
# 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.
# This file contains all sources for the dart:cli library.
cli_runtime_dart_files = [ "cli_patch.dart" ]

View file

@ -1,21 +1,3 @@
# Copyright (c) 2017, the Dart project authors. Please see the AUTHORS file
# 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.
# This file contains all sources for the dart:io library.
io_runtime_dart_files = [
"common_patch.dart",
"directory_patch.dart",
"eventhandler_patch.dart",
"file_patch.dart",
"file_system_entity_patch.dart",
"filter_patch.dart",
"io_service_patch.dart",
"namespace_patch.dart",
"platform_patch.dart",
"process_patch.dart",
"socket_patch.dart",
"stdio_patch.dart",
"secure_socket_patch.dart",
"sync_socket_patch.dart",
]

View file

@ -5,10 +5,3 @@
# This file contains all sources for the dart:async library.
async_runtime_cc_files = [ "async.cc" ]
async_runtime_dart_files = [
"async_patch.dart",
"deferred_load_patch.dart",
"schedule_microtask_patch.dart",
"timer_patch.dart",
]

View file

@ -3,10 +3,3 @@
# BSD-style license that can be found in the LICENSE file.
collection_runtime_cc_files = [ "linked_hash_map.cc" ]
collection_runtime_dart_files = [
# collection_patch.dart needs to be the first dart file because it contains
# imports.
"collection_patch.dart",
"compact_hash.dart",
]

View file

@ -24,38 +24,3 @@ core_runtime_cc_files = [
"uri.cc",
"weak_property.cc",
]
core_runtime_dart_files = [
"core_patch.dart",
# The above file needs to be first as it imports required libraries.
"array.dart",
"array_patch.dart",
"bigint_patch.dart",
"bool_patch.dart",
"date_patch.dart",
"double.dart",
"double_patch.dart",
"errors_patch.dart",
"expando_patch.dart",
"function.dart",
"function_patch.dart",
"growable_array.dart",
"identical_patch.dart",
"immutable_map.dart",
"integers.dart",
"integers_patch.dart",
"invocation_mirror_patch.dart",
"lib_prefix.dart",
"map_patch.dart",
"null_patch.dart",
"object_patch.dart",
"regexp_patch.dart",
"stacktrace.dart",
"stopwatch_patch.dart",
"string_buffer_patch.dart",
"string_patch.dart",
"type_patch.dart",
"uri_patch.dart",
"weak_property.dart",
]

View file

@ -8,11 +8,3 @@ developer_runtime_cc_files = [
"profiler.cc",
"timeline.cc",
]
developer_runtime_dart_files = [
# developer.dart needs to be the first dart file because it contains
# imports.
"developer.dart",
"profiler.dart",
"timeline.dart",
]

View file

@ -7,9 +7,3 @@ ffi_runtime_cc_files = [
"ffi.cc",
"ffi_dynamic_library.cc",
]
ffi_runtime_dart_files = [
"ffi_patch.dart",
"ffi_dynamic_library_patch.dart",
"ffi_native_type_patch.dart",
]

View file

@ -4,12 +4,3 @@
# Sources that patch the library "dart:_internal".
internal_runtime_cc_files = [ "class_id.cc" ]
internal_runtime_dart_files = [
"internal_patch.dart",
# The above file needs to be first as it imports required libraries.
"class_id.dart",
"print_patch.dart",
"symbol_patch.dart",
]

View file

@ -4,8 +4,3 @@
# This file contains all sources for the dart:isolate library.
isolate_runtime_cc_files = [ "isolate.cc" ]
isolate_runtime_dart_files = [
"isolate_patch.dart",
"timer_impl.dart",
]

View file

@ -3,5 +3,3 @@
# BSD-style license that can be found in the LICENSE file.
math_runtime_cc_files = [ "math.cc" ]
math_runtime_dart_files = [ "math_patch.dart" ]

View file

@ -7,11 +7,3 @@ mirrors_runtime_cc_files = [
"mirrors.cc",
"mirrors.h",
]
mirrors_runtime_dart_files = [
# mirrors_patch.dart needs to be the first dart file because it contains
# imports.
"mirrors_patch.dart",
"mirrors_impl.dart",
"mirror_reference.dart",
]

View file

@ -7,5 +7,3 @@ typed_data_runtime_cc_files = [
"typed_data.cc",
"simd128.cc",
]
typed_data_runtime_dart_files = [ "typed_data_patch.dart" ]

View file

@ -3,5 +3,3 @@
# BSD-style license that can be found in the LICENSE file.
wasm_runtime_cc_files = [ "wasm.cc" ]
wasm_runtime_dart_files = [ "wasm_patch.dart" ]

View file

@ -258,8 +258,7 @@ abstract class _ObjectMirror extends Mirror implements ObjectMirror {
}
}
class _InstanceMirror extends _ObjectMirror
implements InstanceMirror {
class _InstanceMirror extends _ObjectMirror implements InstanceMirror {
_InstanceMirror._(reflectee) : super._(reflectee);
ClassMirror _type;
@ -280,8 +279,7 @@ class _InstanceMirror extends _ObjectMirror
String toString() => 'InstanceMirror on ${Error.safeToString(_reflectee)}';
bool operator ==(other) {
return other is _InstanceMirror &&
identical(_reflectee, other._reflectee);
return other is _InstanceMirror && identical(_reflectee, other._reflectee);
}
int get hashCode {
@ -332,8 +330,7 @@ class _InstanceMirror extends _ObjectMirror
static _computeType(reflectee) native 'InstanceMirror_computeType';
}
class _ClosureMirror extends _InstanceMirror
implements ClosureMirror {
class _ClosureMirror extends _InstanceMirror implements ClosureMirror {
_ClosureMirror._(reflectee) : super._(reflectee);
MethodMirror _function;
@ -358,8 +355,7 @@ abstract class _TypeMirror {
Type get _reflectedType;
}
class _ClassMirror extends _ObjectMirror
implements ClassMirror, _TypeMirror {
class _ClassMirror extends _ObjectMirror implements ClassMirror, _TypeMirror {
final Type _reflectedType;
Symbol _simpleName;
DeclarationMirror _owner;
@ -485,8 +481,7 @@ class _ClassMirror extends _ObjectMirror
var _mixin;
ClassMirror get mixin {
if (_mixin == null) {
Type mixinType =
_nativeMixinInstantiated(_reflectedType, _instantiator);
Type mixinType = _nativeMixinInstantiated(_reflectedType, _instantiator);
if (mixinType == null) {
// The reflectee is not a mixin application.
_mixin = this;
@ -674,8 +669,7 @@ class _ClassMirror extends _ObjectMirror
bool isSubtypeOf(TypeMirror other) {
if (other == currentMirrorSystem().dynamicType) return true;
if (other == currentMirrorSystem().voidType) return false;
return _subtypeTest(
_reflectedType, (other as _TypeMirror)._reflectedType);
return _subtypeTest(_reflectedType, (other as _TypeMirror)._reflectedType);
}
bool isAssignableTo(TypeMirror other) {
@ -739,12 +733,11 @@ class _ClassMirror extends _ObjectMirror
native "ClassMirror_type_arguments";
}
class _FunctionTypeMirror extends _ClassMirror
implements FunctionTypeMirror {
class _FunctionTypeMirror extends _ClassMirror implements FunctionTypeMirror {
final _functionReflectee;
_FunctionTypeMirror._(reflectee, this._functionReflectee, reflectedType)
: super._(reflectee, reflectedType, null, null, false, false, false, false,
false);
: super._(reflectee, reflectedType, null, null, false, false, false,
false, false);
bool get _isAnonymousMixinApplication => false;
@ -803,8 +796,7 @@ class _FunctionTypeMirror extends _ClassMirror
native "FunctionTypeMirror_parameters";
}
abstract class _DeclarationMirror extends Mirror
implements DeclarationMirror {
abstract class _DeclarationMirror extends Mirror implements DeclarationMirror {
final _reflectee;
Symbol _simpleName;
@ -892,8 +884,7 @@ class _TypeVariableMirror extends _DeclarationMirror
bool isSubtypeOf(TypeMirror other) {
if (other == currentMirrorSystem().dynamicType) return true;
if (other == currentMirrorSystem().voidType) return false;
return _subtypeTest(
_reflectedType, (other as _TypeMirror)._reflectedType);
return _subtypeTest(_reflectedType, (other as _TypeMirror)._reflectedType);
}
bool isAssignableTo(TypeMirror other) {
@ -981,9 +972,9 @@ class _TypedefMirror extends _DeclarationMirror
if (_isGenericDeclaration) {
_typeArguments = const <TypeMirror>[];
} else {
_typeArguments = new UnmodifiableListView<TypeMirror>(_ClassMirror
._computeTypeArguments(_reflectedType)
.cast<TypeMirror>());
_typeArguments = new UnmodifiableListView<TypeMirror>(
_ClassMirror._computeTypeArguments(_reflectedType)
.cast<TypeMirror>());
}
}
return _typeArguments;
@ -994,8 +985,7 @@ class _TypedefMirror extends _DeclarationMirror
bool isSubtypeOf(TypeMirror other) {
if (other == currentMirrorSystem().dynamicType) return true;
if (other == currentMirrorSystem().voidType) return false;
return _subtypeTest(
_reflectedType, (other as _TypeMirror)._reflectedType);
return _subtypeTest(_reflectedType, (other as _TypeMirror)._reflectedType);
}
bool isAssignableTo(TypeMirror other) {
@ -1159,14 +1149,13 @@ class _CombinatorMirror extends Mirror implements CombinatorMirror {
bool get isHide => !isShow;
}
class _MethodMirror extends _DeclarationMirror
implements MethodMirror {
class _MethodMirror extends _DeclarationMirror implements MethodMirror {
final Type _instantiator;
final bool isStatic;
final int _kindFlags;
_MethodMirror._(reflectee, String simpleName, this._owner,
this._instantiator, this.isStatic, this._kindFlags)
_MethodMirror._(reflectee, String simpleName, this._owner, this._instantiator,
this.isStatic, this._kindFlags)
: super._(reflectee, _s(simpleName));
static const kAbstract = 0;
@ -1287,8 +1276,7 @@ class _MethodMirror extends _DeclarationMirror
static String _MethodMirror_source(reflectee) native "MethodMirror_source";
}
class _VariableMirror extends _DeclarationMirror
implements VariableMirror {
class _VariableMirror extends _DeclarationMirror implements VariableMirror {
final DeclarationMirror owner;
final bool isStatic;
final bool isFinal;
@ -1328,8 +1316,7 @@ class _VariableMirror extends _DeclarationMirror
native "VariableMirror_type";
}
class _ParameterMirror extends _VariableMirror
implements ParameterMirror {
class _ParameterMirror extends _VariableMirror implements ParameterMirror {
final int _position;
final bool isOptional;
final bool isNamed;
@ -1462,8 +1449,7 @@ class _Mirrors {
static Type _instantiateGenericType(Type key, typeArguments)
native "Mirrors_instantiateGenericType";
static Expando<_ClassMirror> _declarationCache =
new Expando("ClassMirror");
static Expando<_ClassMirror> _declarationCache = new Expando("ClassMirror");
static Expando<TypeMirror> _instantiationCache = new Expando("TypeMirror");
static ClassMirror reflectClass(Type key) {

View file

@ -948,7 +948,9 @@ abstract class _StringBase implements String {
@pragma("vm:entry-point")
class _OneByteString extends _StringBase {
factory _OneByteString._uninstantiable() { throw "Unreachable"; }
factory _OneByteString._uninstantiable() {
throw "Unreachable";
}
@pragma("vm:exact-result-type", "dart:core#_Smi")
int get hashCode native "String_getHashCode";
@ -1254,7 +1256,9 @@ class _OneByteString extends _StringBase {
@pragma("vm:entry-point")
class _TwoByteString extends _StringBase {
factory _TwoByteString._uninstantiable() { throw "Unreachable"; }
factory _TwoByteString._uninstantiable() {
throw "Unreachable";
}
static String _allocateFromTwoByteList(List<int> list, int start, int end)
native "TwoByteString_allocateFromTwoByteList";
@ -1274,7 +1278,9 @@ class _TwoByteString extends _StringBase {
@pragma("vm:entry-point")
class _ExternalOneByteString extends _StringBase {
factory _ExternalOneByteString._uninstantiable() { throw "Unreachable"; }
factory _ExternalOneByteString._uninstantiable() {
throw "Unreachable";
}
bool _isWhitespace(int codeUnit) {
return _StringBase._isOneByteWhitespace(codeUnit);
@ -1290,7 +1296,9 @@ class _ExternalOneByteString extends _StringBase {
@pragma("vm:entry-point")
class _ExternalTwoByteString extends _StringBase {
factory _ExternalTwoByteString._uninstantiable() { throw "Unreachable"; }
factory _ExternalTwoByteString._uninstantiable() {
throw "Unreachable";
}
bool _isWhitespace(int codeUnit) {
return _StringBase._isTwoByteWhitespace(codeUnit);

View file

@ -4,150 +4,150 @@
"vm": {
"libraries": {
"_builtin": {
"uri": "../../runtime/bin/builtin.dart"
"uri": "_internal/vm/bin/builtin.dart"
},
"cli": {
"patches": [
"../../runtime/bin/cli_patch.dart"
"_internal/vm/bin/cli_patch.dart"
],
"uri": "cli/cli.dart"
},
"core": {
"patches": [
"../../runtime/lib/core_patch.dart",
"../../runtime/lib/array.dart",
"../../runtime/lib/array_patch.dart",
"../../runtime/lib/bigint_patch.dart",
"../../runtime/lib/bool_patch.dart",
"../../runtime/lib/date_patch.dart",
"../../runtime/lib/double.dart",
"../../runtime/lib/double_patch.dart",
"../../runtime/lib/errors_patch.dart",
"../../runtime/lib/expando_patch.dart",
"../../runtime/lib/function.dart",
"../../runtime/lib/function_patch.dart",
"../../runtime/lib/growable_array.dart",
"../../runtime/lib/identical_patch.dart",
"../../runtime/lib/immutable_map.dart",
"../../runtime/lib/integers.dart",
"../../runtime/lib/integers_patch.dart",
"../../runtime/lib/invocation_mirror_patch.dart",
"../../runtime/lib/lib_prefix.dart",
"../../runtime/lib/map_patch.dart",
"../../runtime/lib/null_patch.dart",
"../../runtime/lib/object_patch.dart",
"../../runtime/lib/regexp_patch.dart",
"../../runtime/lib/stacktrace.dart",
"../../runtime/lib/stopwatch_patch.dart",
"../../runtime/lib/string_buffer_patch.dart",
"../../runtime/lib/string_patch.dart",
"../../runtime/lib/type_patch.dart",
"../../runtime/lib/uri_patch.dart",
"../../runtime/lib/weak_property.dart"
"_internal/vm/lib/core_patch.dart",
"_internal/vm/lib/array.dart",
"_internal/vm/lib/array_patch.dart",
"_internal/vm/lib/bigint_patch.dart",
"_internal/vm/lib/bool_patch.dart",
"_internal/vm/lib/date_patch.dart",
"_internal/vm/lib/double.dart",
"_internal/vm/lib/double_patch.dart",
"_internal/vm/lib/errors_patch.dart",
"_internal/vm/lib/expando_patch.dart",
"_internal/vm/lib/function.dart",
"_internal/vm/lib/function_patch.dart",
"_internal/vm/lib/growable_array.dart",
"_internal/vm/lib/identical_patch.dart",
"_internal/vm/lib/immutable_map.dart",
"_internal/vm/lib/integers.dart",
"_internal/vm/lib/integers_patch.dart",
"_internal/vm/lib/invocation_mirror_patch.dart",
"_internal/vm/lib/lib_prefix.dart",
"_internal/vm/lib/map_patch.dart",
"_internal/vm/lib/null_patch.dart",
"_internal/vm/lib/object_patch.dart",
"_internal/vm/lib/regexp_patch.dart",
"_internal/vm/lib/stacktrace.dart",
"_internal/vm/lib/stopwatch_patch.dart",
"_internal/vm/lib/string_buffer_patch.dart",
"_internal/vm/lib/string_patch.dart",
"_internal/vm/lib/type_patch.dart",
"_internal/vm/lib/uri_patch.dart",
"_internal/vm/lib/weak_property.dart"
],
"uri": "core/core.dart"
},
"async": {
"patches": [
"../../runtime/lib/async_patch.dart",
"../../runtime/lib/deferred_load_patch.dart",
"../../runtime/lib/schedule_microtask_patch.dart",
"../../runtime/lib/timer_patch.dart"
"_internal/vm/lib/async_patch.dart",
"_internal/vm/lib/deferred_load_patch.dart",
"_internal/vm/lib/schedule_microtask_patch.dart",
"_internal/vm/lib/timer_patch.dart"
],
"uri": "async/async.dart"
},
"collection": {
"patches": [
"../../runtime/lib/collection_patch.dart",
"../../runtime/lib/compact_hash.dart"
"_internal/vm/lib/collection_patch.dart",
"_internal/vm/lib/compact_hash.dart"
],
"uri": "collection/collection.dart"
},
"ffi": {
"patches": [
"../../runtime/lib/ffi_patch.dart",
"../../runtime/lib/ffi_dynamic_library_patch.dart",
"../../runtime/lib/ffi_native_type_patch.dart"
"_internal/vm/lib/ffi_patch.dart",
"_internal/vm/lib/ffi_dynamic_library_patch.dart",
"_internal/vm/lib/ffi_native_type_patch.dart"
],
"uri": "ffi/ffi.dart"
},
"wasm": {
"patches": [
"../../runtime/lib/wasm_patch.dart"
],
"uri": "wasm/wasm.dart"
},
"typed_data": {
"patches": "../../runtime/lib/typed_data_patch.dart",
"patches": "_internal/vm/lib/typed_data_patch.dart",
"uri": "typed_data/typed_data.dart"
},
"nativewrappers": {
"uri": "html/dartium/nativewrappers.dart"
},
"mirrors": {
"patches": [
"_internal/vm/lib/mirrors_patch.dart",
"_internal/vm/lib/mirrors_impl.dart",
"_internal/vm/lib/mirror_reference.dart"
],
"uri": "mirrors/mirrors.dart"
},
"developer": {
"patches": [
"../../runtime/lib/developer.dart",
"../../runtime/lib/profiler.dart",
"../../runtime/lib/timeline.dart"
"_internal/vm/lib/developer.dart",
"_internal/vm/lib/profiler.dart",
"_internal/vm/lib/timeline.dart"
],
"uri": "developer/developer.dart"
},
"isolate": {
"patches": [
"../../runtime/lib/isolate_patch.dart",
"../../runtime/lib/timer_impl.dart"
"_internal/vm/lib/isolate_patch.dart",
"_internal/vm/lib/timer_impl.dart"
],
"uri": "isolate/isolate.dart"
},
"mirrors": {
"patches": [
"../../runtime/lib/mirrors_patch.dart",
"../../runtime/lib/mirrors_impl.dart",
"../../runtime/lib/mirror_reference.dart"
],
"uri": "mirrors/mirrors.dart"
},
"_vmservice": {
"uri": "vmservice/vmservice.dart"
},
"wasm": {
"patches": [
"_internal/vm/lib/wasm_patch.dart"
],
"uri": "wasm/wasm.dart"
},
"io": {
"patches": [
"../../runtime/bin/common_patch.dart",
"../../runtime/bin/directory_patch.dart",
"../../runtime/bin/eventhandler_patch.dart",
"../../runtime/bin/file_patch.dart",
"../../runtime/bin/file_system_entity_patch.dart",
"../../runtime/bin/filter_patch.dart",
"../../runtime/bin/io_service_patch.dart",
"../../runtime/bin/namespace_patch.dart",
"../../runtime/bin/platform_patch.dart",
"../../runtime/bin/process_patch.dart",
"../../runtime/bin/socket_patch.dart",
"../../runtime/bin/stdio_patch.dart",
"../../runtime/bin/secure_socket_patch.dart",
"../../runtime/bin/sync_socket_patch.dart"
"_internal/vm/bin/common_patch.dart",
"_internal/vm/bin/directory_patch.dart",
"_internal/vm/bin/eventhandler_patch.dart",
"_internal/vm/bin/file_patch.dart",
"_internal/vm/bin/file_system_entity_patch.dart",
"_internal/vm/bin/filter_patch.dart",
"_internal/vm/bin/io_service_patch.dart",
"_internal/vm/bin/namespace_patch.dart",
"_internal/vm/bin/platform_patch.dart",
"_internal/vm/bin/process_patch.dart",
"_internal/vm/bin/socket_patch.dart",
"_internal/vm/bin/stdio_patch.dart",
"_internal/vm/bin/secure_socket_patch.dart",
"_internal/vm/bin/sync_socket_patch.dart"
],
"uri": "io/io.dart"
},
"_internal": {
"patches": [
"../../runtime/lib/internal_patch.dart",
"../../runtime/lib/class_id_fasta.dart",
"../../runtime/lib/print_patch.dart",
"../../runtime/lib/symbol_patch.dart",
"_internal/vm/lib/internal_patch.dart",
"_internal/vm/lib/class_id_fasta.dart",
"_internal/vm/lib/print_patch.dart",
"_internal/vm/lib/symbol_patch.dart",
"internal/patch.dart"
],
"uri": "internal/internal.dart"
},
"convert": {
"patches": "../../runtime/lib/convert_patch.dart",
"patches": "_internal/vm/lib/convert_patch.dart",
"uri": "convert/convert.dart"
},
"profiler": {
"uri": "profiler/profiler.dart"
},
"math": {
"patches": "../../runtime/lib/math_patch.dart",
"patches": "_internal/vm/lib/math_patch.dart",
"uri": "math/math.dart"
},
"_http": {
@ -487,4 +487,4 @@
}
}
}
}
}

View file

@ -17,87 +17,87 @@ none:
vm:
libraries:
_builtin:
uri: "../../runtime/bin/builtin.dart"
uri: "_internal/vm/bin/builtin.dart"
_internal:
uri: "internal/internal.dart"
patches:
- "../../runtime/lib/internal_patch.dart"
- "../../runtime/lib/class_id_fasta.dart"
- "../../runtime/lib/print_patch.dart"
- "../../runtime/lib/symbol_patch.dart"
- "_internal/vm/lib/internal_patch.dart"
- "_internal/vm/lib/class_id_fasta.dart"
- "_internal/vm/lib/print_patch.dart"
- "_internal/vm/lib/symbol_patch.dart"
- "internal/patch.dart"
async:
uri: "async/async.dart"
patches:
- "../../runtime/lib/async_patch.dart"
- "../../runtime/lib/deferred_load_patch.dart"
- "../../runtime/lib/schedule_microtask_patch.dart"
- "../../runtime/lib/timer_patch.dart"
- "_internal/vm/lib/async_patch.dart"
- "_internal/vm/lib/deferred_load_patch.dart"
- "_internal/vm/lib/schedule_microtask_patch.dart"
- "_internal/vm/lib/timer_patch.dart"
collection:
uri: "collection/collection.dart"
patches:
- "../../runtime/lib/collection_patch.dart"
- "../../runtime/lib/compact_hash.dart"
- "_internal/vm/lib/collection_patch.dart"
- "_internal/vm/lib/compact_hash.dart"
convert:
uri: "convert/convert.dart"
patches: "../../runtime/lib/convert_patch.dart"
patches: "_internal/vm/lib/convert_patch.dart"
core:
uri: "core/core.dart"
patches:
- "../../runtime/lib/core_patch.dart"
- "../../runtime/lib/array.dart"
- "../../runtime/lib/array_patch.dart"
- "../../runtime/lib/bigint_patch.dart"
- "../../runtime/lib/bool_patch.dart"
- "../../runtime/lib/date_patch.dart"
- "../../runtime/lib/double.dart"
- "../../runtime/lib/double_patch.dart"
- "../../runtime/lib/errors_patch.dart"
- "../../runtime/lib/expando_patch.dart"
- "../../runtime/lib/function.dart"
- "../../runtime/lib/function_patch.dart"
- "../../runtime/lib/growable_array.dart"
- "../../runtime/lib/identical_patch.dart"
- "../../runtime/lib/immutable_map.dart"
- "../../runtime/lib/integers.dart"
- "../../runtime/lib/integers_patch.dart"
- "../../runtime/lib/invocation_mirror_patch.dart"
- "../../runtime/lib/lib_prefix.dart"
- "../../runtime/lib/map_patch.dart"
- "../../runtime/lib/null_patch.dart"
- "../../runtime/lib/object_patch.dart"
- "../../runtime/lib/regexp_patch.dart"
- "../../runtime/lib/stacktrace.dart"
- "../../runtime/lib/stopwatch_patch.dart"
- "../../runtime/lib/string_buffer_patch.dart"
- "../../runtime/lib/string_patch.dart"
- "../../runtime/lib/type_patch.dart"
- "../../runtime/lib/uri_patch.dart"
- "../../runtime/lib/weak_property.dart"
- "_internal/vm/lib/core_patch.dart"
- "_internal/vm/lib/array.dart"
- "_internal/vm/lib/array_patch.dart"
- "_internal/vm/lib/bigint_patch.dart"
- "_internal/vm/lib/bool_patch.dart"
- "_internal/vm/lib/date_patch.dart"
- "_internal/vm/lib/double.dart"
- "_internal/vm/lib/double_patch.dart"
- "_internal/vm/lib/errors_patch.dart"
- "_internal/vm/lib/expando_patch.dart"
- "_internal/vm/lib/function.dart"
- "_internal/vm/lib/function_patch.dart"
- "_internal/vm/lib/growable_array.dart"
- "_internal/vm/lib/identical_patch.dart"
- "_internal/vm/lib/immutable_map.dart"
- "_internal/vm/lib/integers.dart"
- "_internal/vm/lib/integers_patch.dart"
- "_internal/vm/lib/invocation_mirror_patch.dart"
- "_internal/vm/lib/lib_prefix.dart"
- "_internal/vm/lib/map_patch.dart"
- "_internal/vm/lib/null_patch.dart"
- "_internal/vm/lib/object_patch.dart"
- "_internal/vm/lib/regexp_patch.dart"
- "_internal/vm/lib/stacktrace.dart"
- "_internal/vm/lib/stopwatch_patch.dart"
- "_internal/vm/lib/string_buffer_patch.dart"
- "_internal/vm/lib/string_patch.dart"
- "_internal/vm/lib/type_patch.dart"
- "_internal/vm/lib/uri_patch.dart"
- "_internal/vm/lib/weak_property.dart"
developer:
uri: "developer/developer.dart"
patches:
- "../../runtime/lib/developer.dart"
- "../../runtime/lib/profiler.dart"
- "../../runtime/lib/timeline.dart"
- "_internal/vm/lib/developer.dart"
- "_internal/vm/lib/profiler.dart"
- "_internal/vm/lib/timeline.dart"
ffi:
uri: "ffi/ffi.dart"
patches:
- "../../runtime/lib/ffi_patch.dart"
- "../../runtime/lib/ffi_dynamic_library_patch.dart"
- "../../runtime/lib/ffi_native_type_patch.dart"
- "_internal/vm/lib/ffi_patch.dart"
- "_internal/vm/lib/ffi_dynamic_library_patch.dart"
- "_internal/vm/lib/ffi_native_type_patch.dart"
wasm:
uri: "wasm/wasm.dart"
patches:
- "../../runtime/lib/wasm_patch.dart"
- "_internal/vm/lib/wasm_patch.dart"
_http:
uri: "_http/http.dart"
@ -105,37 +105,37 @@ vm:
io:
uri: "io/io.dart"
patches:
- "../../runtime/bin/common_patch.dart"
- "../../runtime/bin/directory_patch.dart"
- "../../runtime/bin/eventhandler_patch.dart"
- "../../runtime/bin/file_patch.dart"
- "../../runtime/bin/file_system_entity_patch.dart"
- "../../runtime/bin/filter_patch.dart"
- "../../runtime/bin/io_service_patch.dart"
- "../../runtime/bin/namespace_patch.dart"
- "../../runtime/bin/platform_patch.dart"
- "../../runtime/bin/process_patch.dart"
- "../../runtime/bin/socket_patch.dart"
- "../../runtime/bin/stdio_patch.dart"
- "../../runtime/bin/secure_socket_patch.dart"
- "../../runtime/bin/sync_socket_patch.dart"
- "_internal/vm/bin/common_patch.dart"
- "_internal/vm/bin/directory_patch.dart"
- "_internal/vm/bin/eventhandler_patch.dart"
- "_internal/vm/bin/file_patch.dart"
- "_internal/vm/bin/file_system_entity_patch.dart"
- "_internal/vm/bin/filter_patch.dart"
- "_internal/vm/bin/io_service_patch.dart"
- "_internal/vm/bin/namespace_patch.dart"
- "_internal/vm/bin/platform_patch.dart"
- "_internal/vm/bin/process_patch.dart"
- "_internal/vm/bin/socket_patch.dart"
- "_internal/vm/bin/stdio_patch.dart"
- "_internal/vm/bin/secure_socket_patch.dart"
- "_internal/vm/bin/sync_socket_patch.dart"
isolate:
uri: "isolate/isolate.dart"
patches:
- "../../runtime/lib/isolate_patch.dart"
- "../../runtime/lib/timer_impl.dart"
- "_internal/vm/lib/isolate_patch.dart"
- "_internal/vm/lib/timer_impl.dart"
math:
uri: "math/math.dart"
patches: "../../runtime/lib/math_patch.dart"
patches: "_internal/vm/lib/math_patch.dart"
mirrors:
uri: "mirrors/mirrors.dart"
patches:
- "../../runtime/lib/mirrors_patch.dart"
- "../../runtime/lib/mirrors_impl.dart"
- "../../runtime/lib/mirror_reference.dart"
- "_internal/vm/lib/mirrors_patch.dart"
- "_internal/vm/lib/mirrors_impl.dart"
- "_internal/vm/lib/mirror_reference.dart"
nativewrappers:
uri: "html/dartium/nativewrappers.dart"
@ -146,11 +146,11 @@ vm:
cli:
uri: "cli/cli.dart"
patches:
- "../../runtime/bin/cli_patch.dart"
- "_internal/vm/bin/cli_patch.dart"
typed_data:
uri: "typed_data/typed_data.dart"
patches: "../../runtime/lib/typed_data_patch.dart"
patches: "_internal/vm/lib/typed_data_patch.dart"
_vmservice:
uri: "vmservice/vmservice.dart"

View file

@ -0,0 +1,347 @@
// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
// 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.
library builtin;
// NOTE: Do not import 'dart:io' in builtin.
import 'dart:async';
import 'dart:collection' hide LinkedList, LinkedListEntry;
import 'dart:_internal' hide Symbol;
import 'dart:isolate';
import 'dart:typed_data';
// Embedder sets this to true if the --trace-loading flag was passed on the
// command line.
bool _traceLoading = false;
// Before handling an embedder entrypoint we finalize the setup of the
// dart:_builtin library.
bool _setupCompleted = false;
// '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());
}
@pragma("vm:entry-point")
_getPrintClosure() => _print;
// Asynchronous loading of resources.
// The embedder forwards loading requests to the service isolate.
// A port for communicating with the service isolate for I/O.
@pragma("vm:entry-point")
SendPort _loadPort;
// The isolateId used to communicate with the service isolate for I/O.
@pragma("vm:entry-point")
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.
// Make a request to the loader. Future will complete with result which is
// either a Uri or a List<int>.
Future<T> _makeLoaderRequest<T>(int tag, String uri) {
assert(_isolateId != null);
if (_loadPort == null) {
throw new UnsupportedError("Service isolate is not available.");
}
Completer completer = new Completer<T>();
RawReceivePort port = new RawReceivePort();
port.handler = (msg) {
// Close the port.
port.close();
completer.complete(msg);
};
_loadPort.send([_traceLoading, _isolateId, tag, port.sendPort, 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
// package imports can be resolved relative to it. The root script is the basis
// for the root library in the VM.
Uri _rootScript;
// The package root set on the command line.
Uri _packageRoot;
// Special handling for Windows paths so that they are compatible with URI
// handling.
// Embedder sets this to true if we are running on Windows.
@pragma("vm:entry-point")
bool _isWindows = false;
// Logging from builtin.dart is prefixed with a '*'.
String _logId = (Isolate.current.hashCode % 0x100000).toRadixString(16);
_log(msg) {
_print("* $_logId $msg");
}
_sanitizeWindowsPath(path) {
// For Windows we need to massage the paths a bit according to
// http://blogs.msdn.com/b/ie/archive/2006/12/06/file-uris-in-windows.aspx
//
// Convert
// C:\one\two\three
// to
// /C:/one/two/three
if (_isWindows == false) {
// Do nothing when not running Windows.
return path;
}
var fixedPath = "${path.replaceAll('\\', '/')}";
if ((path.length > 2) && (path[1] == ':')) {
// Path begins with a drive letter.
return '/$fixedPath';
}
return fixedPath;
}
_trimWindowsPath(path) {
// Convert /X:/ to X:/.
if (_isWindows == false) {
// Do nothing when not running Windows.
return path;
}
if (!path.startsWith('/') || (path.length < 3)) {
return path;
}
// Match '/?:'.
if ((path[0] == '/') && (path[2] == ':')) {
// Remove leading '/'.
return path.substring(1);
}
return path;
}
// Ensure we have a trailing slash character.
_enforceTrailingSlash(uri) {
if (!uri.endsWith('/')) {
return '$uri/';
}
return uri;
}
// Embedder Entrypoint:
// The embedder calls this method with the current working directory.
@pragma("vm:entry-point")
void _setWorkingDirectory(String cwd) {
if (!_setupCompleted) {
_setupHooks();
}
if (_traceLoading) {
_log('Setting working directory: $cwd');
}
_workingDirectory = new Uri.directory(cwd);
if (_traceLoading) {
_log('Working directory URI: $_workingDirectory');
}
}
// Embedder Entrypoint:
// The embedder calls this method with a custom package root.
@pragma("vm:entry-point")
String _setPackageRoot(String packageRoot) {
if (!_setupCompleted) {
_setupHooks();
}
if (_traceLoading) {
_log('Setting package root: $packageRoot');
}
if (packageRoot.startsWith('file:') ||
packageRoot.startsWith('http:') ||
packageRoot.startsWith('https:')) {
packageRoot = _enforceTrailingSlash(packageRoot);
_packageRoot = _workingDirectory.resolve(packageRoot);
} else {
packageRoot = _sanitizeWindowsPath(packageRoot);
packageRoot = _trimWindowsPath(packageRoot);
_packageRoot = _workingDirectory.resolveUri(new Uri.directory(packageRoot));
}
// Now that we have determined the packageRoot value being used, set it
// up for use in Platform.packageRoot. This is only set when the embedder
// sets up the package root. Automatically discovered package root will
// not update the VMLibraryHooks value.
var packageRootStr = _packageRoot.toString();
VMLibraryHooks.packageRootString = packageRootStr;
if (_traceLoading) {
_log('Package root URI: $_packageRoot');
}
return packageRootStr;
}
// Embedder Entrypoint:
@pragma("vm:entry-point")
String _setPackagesMap(String packagesParam) {
if (!_setupCompleted) {
_setupHooks();
}
// First convert the packages parameter from the command line to a URI which
// can be handled by the loader code.
// TODO(iposva): Consider refactoring the common code below which is almost
// shared with resolution of the root script.
if (_traceLoading) {
_log("Resolving packages map: $packagesParam");
}
if (_workingDirectory == null) {
throw 'No current working directory set.';
}
var packagesName = _sanitizeWindowsPath(packagesParam);
var packagesUri = Uri.parse(packagesName);
if (packagesUri.scheme == '') {
// Script does not have a scheme, assume that it is a path,
// resolve it against the working directory.
packagesUri = _workingDirectory.resolveUri(packagesUri);
}
var packagesUriStr = packagesUri.toString();
VMLibraryHooks.packageConfigString = packagesUriStr;
if (_traceLoading) {
_log('Resolved packages map to: $packagesUri');
}
return packagesUriStr;
}
// Resolves the script uri in the current working directory iff the given uri
// did not specify a scheme (e.g. a path to a script file on the command line).
@pragma("vm:entry-point")
String _resolveScriptUri(String scriptName) {
if (_traceLoading) {
_log("Resolving script: $scriptName");
}
if (_workingDirectory == null) {
throw 'No current working directory set.';
}
scriptName = _sanitizeWindowsPath(scriptName);
var scriptUri = Uri.parse(scriptName);
if (scriptUri.scheme == '') {
// Script does not have a scheme, assume that it is a path,
// resolve it against the working directory.
scriptUri = _workingDirectory.resolveUri(scriptUri);
}
// Remember the root script URI so that we can resolve packages based on
// this location.
_rootScript = scriptUri;
if (_traceLoading) {
_log('Resolved entry point to: $_rootScript');
}
return scriptUri.toString();
}
// Only used by vm/cc unit tests.
Uri _resolvePackageUri(Uri uri) {
assert(_packageRoot != null);
return _packageRoot.resolve(uri.path);
}
// Returns either a file path or a URI starting with http[s]:, as a String.
String _filePathFromUri(String userUri) {
var uri = Uri.parse(userUri);
if (_traceLoading) {
_log('Getting file path from: $uri');
}
var path;
switch (uri.scheme) {
case '':
case 'file':
return uri.toFilePath();
case 'package':
return _filePathFromUri(_resolvePackageUri(uri).toString());
case 'data':
case 'http':
case 'https':
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';
}
}
// Register callbacks and hooks with the rest of the core libraries.
@pragma("vm:entry-point")
_setupHooks() {
_setupCompleted = true;
VMLibraryHooks.resourceReadAsBytes = _resourceReadAsBytes;
VMLibraryHooks.packageRootUriFuture = _getPackageRootFuture;
VMLibraryHooks.packageConfigUriFuture = _getPackageConfigFuture;
VMLibraryHooks.resolvePackageUriFuture = _resolvePackageUriFuture;
}
// Handling of Resource class by dispatching to the load port.
Future<List<int>> _resourceReadAsBytes(Uri uri) async {
List response =
await _makeLoaderRequest<List<int>>(_Dart_kResourceLoad, uri.toString());
if (response[4] is String) {
// Throw the error.
throw response[4];
} else {
return response[4];
}
}
// TODO(mfairhurst): remove this
Future<Uri> _getPackageRootFuture() {
if (_traceLoading) {
_log("Request for package root from user code.");
}
// Return null, as the `packages/` directory is not supported in dart 2.
return new Future.value(null);
}
Future<Uri> _getPackageConfigFuture() {
if (_traceLoading) {
_log("Request for package config from user code.");
}
assert(_loadPort != null);
return _makeLoaderRequest<Uri>(_Dart_kGetPackageConfigUri, null);
}
Future<Uri> _resolvePackageUriFuture(Uri packageUri) async {
if (_traceLoading) {
_log("Request for package Uri resolution from user code: $packageUri");
}
if (packageUri.scheme != "package") {
if (_traceLoading) {
_log("Non-package Uri, returning unmodified: $packageUri");
}
// Return the incoming parameter if not passed a package: URI.
return packageUri;
}
var result = await _makeLoaderRequest<Uri>(
_Dart_kResolvePackageUri, packageUri.toString());
if (result is! Uri) {
if (_traceLoading) {
_log("Exception when resolving package URI: $packageUri");
}
result = null;
}
if (_traceLoading) {
_log("Resolved '$packageUri' to '$result'");
}
return result;
}

View file

@ -0,0 +1,8 @@
// Copyright (c) 2017, the Dart project authors. Please see the AUTHORS file
// 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.
import "dart:_internal" show patch;
@patch
void _waitForEvent(int timeoutMillis) native "CLI_WaitForEvent";

View file

@ -0,0 +1,62 @@
// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
// 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.
/// Note: the VM concatenates all patch files into a single patch file. This
/// file is the first patch in "dart:io" which contains all the imports used by
/// patches of that library. We plan to change this when we have a shared front
/// end and simply use parts.
import "dart:_internal" show VMLibraryHooks, patch;
import "dart:async"
show
Completer,
Future,
Stream,
StreamConsumer,
StreamController,
StreamSubscription,
Timer,
Zone,
scheduleMicrotask;
import "dart:collection" show HashMap;
import "dart:convert" show Encoding, utf8;
import "dart:developer" show registerExtension;
import "dart:isolate" show RawReceivePort, ReceivePort, SendPort;
import "dart:math" show min;
import "dart:nativewrappers" show NativeFieldWrapperClass1;
import "dart:typed_data" show Uint8List;
/// These are the additional parts of this patch library:
// part "directory_patch.dart";
// part "eventhandler_patch.dart";
// part "file_patch.dart";
// part "file_system_entity_patch.dart";
// part "filter_patch.dart";
// part "io_service_patch.dart";
// part "platform_patch.dart";
// part "process_patch.dart";
// part "socket_patch.dart";
// part "stdio_patch.dart";
// part "secure_socket_patch.dart";
// part "sync_socket_patch.dart";
@patch
class _IOCrypto {
@patch
static Uint8List getRandomBytes(int count) native "Crypto_GetRandomBytes";
}
@pragma("vm:entry-point", "call")
_setupHooks() {
VMLibraryHooks.eventHandlerSendData = _EventHandler._sendData;
VMLibraryHooks.timerMillisecondClock = _EventHandler._timerMillisecondClock;
}

View file

@ -0,0 +1,71 @@
// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
// 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.
// part of "common_patch.dart";
@patch
class _Directory {
@patch
static _current(_Namespace namespace) native "Directory_Current";
@patch
static _setCurrent(_Namespace namespace, Uint8List rawPath)
native "Directory_SetCurrent";
@patch
static _createTemp(_Namespace namespace, Uint8List rawPath)
native "Directory_CreateTemp";
@patch
static String _systemTemp(_Namespace namespace) native "Directory_SystemTemp";
@patch
static _exists(_Namespace namespace, Uint8List rawPath)
native "Directory_Exists";
@patch
static _create(_Namespace namespace, Uint8List rawPath)
native "Directory_Create";
@patch
static _deleteNative(_Namespace namespace, Uint8List rawPath, bool recursive)
native "Directory_Delete";
@patch
static _rename(_Namespace namespace, Uint8List rawPath, String newPath)
native "Directory_Rename";
@patch
static void _fillWithDirectoryListing(
_Namespace namespace,
List<FileSystemEntity> list,
Uint8List rawPath,
bool recursive,
bool followLinks) native "Directory_FillWithDirectoryListing";
}
@patch
class _AsyncDirectoryListerOps {
@patch
factory _AsyncDirectoryListerOps(int pointer) =>
new _AsyncDirectoryListerOpsImpl(pointer);
}
class _AsyncDirectoryListerOpsImpl extends NativeFieldWrapperClass1
implements _AsyncDirectoryListerOps {
_AsyncDirectoryListerOpsImpl._();
factory _AsyncDirectoryListerOpsImpl(int pointer) =>
new _AsyncDirectoryListerOpsImpl._().._setPointer(pointer);
void _setPointer(int pointer)
native "Directory_SetAsyncDirectoryListerPointer";
int getPointer() native "Directory_GetAsyncDirectoryListerPointer";
}
// Corelib 'Uri.base' implementation.
// Uri.base is susceptible to changes in the current working directory.
Uri _uriBaseClosure() {
var result = _Directory._current(_Namespace._namespace);
if (result is OSError) {
throw new FileSystemException(
"Getting current working directory failed", "", result);
}
return new Uri.directory(result);
}
@pragma("vm:entry-point", "call")
_getUriBaseClosure() => _uriBaseClosure;

View file

@ -0,0 +1,15 @@
// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
// 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.
// part of "common_patch.dart";
@patch
class _EventHandler {
@patch
static void _sendData(Object sender, SendPort sendPort, int data)
native "EventHandler_SendData";
static int _timerMillisecondClock()
native "EventHandler_TimerMillisecondClock";
}

View file

@ -0,0 +1,421 @@
// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
// 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.
// part of "common_patch.dart";
@patch
class _File {
@patch
static _exists(_Namespace namespace, Uint8List rawPath) native "File_Exists";
@patch
static _create(_Namespace namespace, Uint8List rawPath) native "File_Create";
@patch
static _createLink(_Namespace namespace, Uint8List rawPath, String target)
native "File_CreateLink";
@patch
static _linkTarget(_Namespace namespace, Uint8List rawPath)
native "File_LinkTarget";
@patch
static _deleteNative(_Namespace namespace, Uint8List rawPath)
native "File_Delete";
@patch
static _deleteLinkNative(_Namespace namespace, Uint8List rawPath)
native "File_DeleteLink";
@patch
static _rename(_Namespace namespace, Uint8List oldPath, String newPath)
native "File_Rename";
@patch
static _renameLink(_Namespace namespace, Uint8List oldPath, String newPath)
native "File_RenameLink";
@patch
static _copy(_Namespace namespace, Uint8List oldPath, String newPath)
native "File_Copy";
@patch
static _lengthFromPath(_Namespace namespace, Uint8List rawPath)
native "File_LengthFromPath";
@patch
static _lastModified(_Namespace namespace, Uint8List rawPath)
native "File_LastModified";
@patch
static _setLastModified(_Namespace namespace, Uint8List rawPath, int millis)
native "File_SetLastModified";
@patch
static _lastAccessed(_Namespace namespace, Uint8List rawPath)
native "File_LastAccessed";
@patch
static _setLastAccessed(_Namespace namespace, Uint8List rawPath, int millis)
native "File_SetLastAccessed";
@patch
static _open(_Namespace namespace, Uint8List rawPath, 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);
}
@pragma("vm:entry-point")
class _RandomAccessFileOpsImpl extends NativeFieldWrapperClass1
implements _RandomAccessFileOps {
_RandomAccessFileOpsImpl._();
factory _RandomAccessFileOpsImpl(int pointer) =>
new _RandomAccessFileOpsImpl._().._setPointer(pointer);
void _setPointer(int pointer) native "File_SetPointer";
int getPointer() native "File_GetPointer";
int close() native "File_Close";
readByte() native "File_ReadByte";
read(int bytes) native "File_Read";
readInto(List<int> buffer, int start, int end) native "File_ReadInto";
writeByte(int value) native "File_WriteByte";
writeFrom(List<int> buffer, int start, int end) native "File_WriteFrom";
position() native "File_Position";
setPosition(int position) native "File_SetPosition";
truncate(int length) native "File_Truncate";
length() native "File_Length";
flush() native "File_Flush";
lock(int lock, int start, int end) native "File_Lock";
}
class _WatcherPath {
final int pathId;
final String path;
final int events;
int count = 0;
_WatcherPath(this.pathId, this.path, this.events);
}
@patch
class _FileSystemWatcher {
void _pathWatchedEnd();
static int _id;
static final Map<int, _WatcherPath> _idMap = {};
final String _path;
final int _events;
final bool _recursive;
_WatcherPath _watcherPath;
StreamController<FileSystemEvent> _broadcastController;
@patch
static Stream<FileSystemEvent> _watch(
String path, int events, bool recursive) {
if (Platform.isLinux) {
return new _InotifyFileSystemWatcher(path, events, recursive)._stream;
}
if (Platform.isWindows) {
return new _Win32FileSystemWatcher(path, events, recursive)._stream;
}
if (Platform.isMacOS) {
return new _FSEventStreamFileSystemWatcher(path, events, recursive)
._stream;
}
throw new FileSystemException(
"File system watching is not supported on this platform");
}
_FileSystemWatcher._(this._path, this._events, this._recursive) {
if (!isSupported) {
throw new FileSystemException(
"File system watching is not supported on this platform", _path);
}
_broadcastController = new StreamController<FileSystemEvent>.broadcast(
onListen: _listen, onCancel: _cancel);
}
Stream<FileSystemEvent> get _stream => _broadcastController.stream;
void _listen() {
if (_id == null) {
try {
_id = _initWatcher();
_newWatcher();
} catch (e) {
_broadcastController.addError(new FileSystemException(
"Failed to initialize file system entity watcher", null, e));
_broadcastController.close();
return;
}
}
var pathId;
try {
pathId =
_watchPath(_id, _Namespace._namespace, _path, _events, _recursive);
} catch (e) {
_broadcastController
.addError(new FileSystemException("Failed to watch path", _path, e));
_broadcastController.close();
return;
}
if (!_idMap.containsKey(pathId)) {
_idMap[pathId] = new _WatcherPath(pathId, _path, _events);
}
_watcherPath = _idMap[pathId];
_watcherPath.count++;
_pathWatched().pipe(_broadcastController);
}
void _cancel() {
if (_watcherPath != null) {
assert(_watcherPath.count > 0);
_watcherPath.count--;
if (_watcherPath.count == 0) {
_unwatchPath(_id, _watcherPath.pathId);
_pathWatchedEnd();
_idMap.remove(_watcherPath.pathId);
}
_watcherPath = null;
}
if (_idMap.isEmpty && _id != null) {
_closeWatcher(_id);
_doneWatcher();
_id = null;
}
}
// Called when (and after) a new watcher instance is created and available.
void _newWatcher() {}
// Called when a watcher is no longer needed.
void _doneWatcher() {}
// Called when a new path is being watched.
Stream _pathWatched() {}
// Called when a path is no longer being watched.
void _donePathWatched() {}
static _WatcherPath _pathFromPathId(int pathId) {
return _idMap[pathId];
}
static Stream _listenOnSocket(int socketId, int id, int pathId) {
var native = new _NativeSocket.watch(socketId);
var socket = new _RawSocket(native);
return socket.expand((event) {
var stops = [];
var events = [];
var pair = {};
if (event == RawSocketEvent.read) {
String getPath(event) {
var path = _pathFromPathId(event[4]).path;
if (event[2] != null && event[2].isNotEmpty) {
path += Platform.pathSeparator;
path += event[2];
}
return path;
}
bool getIsDir(event) {
if (Platform.isWindows) {
// Windows does not get 'isDir' as part of the event.
return FileSystemEntity.isDirectorySync(getPath(event));
}
return (event[0] & FileSystemEvent._isDir) != 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));
} else {
add(event[4], new FileSystemDeleteEvent._(getPath(event), isDir));
}
}
int eventCount;
do {
eventCount = 0;
for (var event in _readEvents(id, pathId)) {
if (event == null) continue;
eventCount++;
int pathId = event[4];
if (!_idMap.containsKey(pathId)) {
// Path is no longer being wathed.
continue;
}
bool isDir = getIsDir(event);
var path = getPath(event);
if ((event[0] & FileSystemEvent.create) != 0) {
add(event[4], new FileSystemCreateEvent._(path, isDir));
}
if ((event[0] & FileSystemEvent.modify) != 0) {
add(event[4], new FileSystemModifyEvent._(path, isDir, true));
}
if ((event[0] & FileSystemEvent._modifyAttributes) != 0) {
add(event[4], new FileSystemModifyEvent._(path, isDir, false));
}
if ((event[0] & FileSystemEvent.move) != 0) {
int link = event[1];
if (link > 0) {
pair.putIfAbsent(pathId, () => {});
if (pair[pathId].containsKey(link)) {
add(
event[4],
new FileSystemMoveEvent._(
getPath(pair[pathId][link]), isDir, path));
pair[pathId].remove(link);
} else {
pair[pathId][link] = event;
}
} else {
rewriteMove(event, isDir);
}
}
if ((event[0] & FileSystemEvent.delete) != 0) {
add(event[4], new FileSystemDeleteEvent._(path, isDir));
}
if ((event[0] & FileSystemEvent._deleteSelf) != 0) {
add(event[4], new FileSystemDeleteEvent._(path, isDir));
// Signal done event.
stops.add([event[4], null]);
}
}
} while (eventCount > 0);
// Be sure to clear this manually, as the sockets are not read through
// the _NativeSocket interface.
native.available = 0;
for (var map in pair.values) {
for (var event in map.values) {
rewriteMove(event, getIsDir(event));
}
}
} else if (event == RawSocketEvent.closed) {
} else if (event == RawSocketEvent.readClosed) {
} else {
assert(false);
}
events.addAll(stops);
return events;
});
}
@patch
static bool get isSupported native "FileSystemWatcher_IsSupported";
static int _initWatcher() native "FileSystemWatcher_InitWatcher";
static void _closeWatcher(int id) native "FileSystemWatcher_CloseWatcher";
static int _watchPath(int id, _Namespace namespace, String path, int events,
bool recursive) native "FileSystemWatcher_WatchPath";
static void _unwatchPath(int id, int path_id)
native "FileSystemWatcher_UnwatchPath";
static List _readEvents(int id, int path_id)
native "FileSystemWatcher_ReadEvents";
static int _getSocketId(int id, int path_id)
native "FileSystemWatcher_GetSocketId";
}
class _InotifyFileSystemWatcher extends _FileSystemWatcher {
static final Map<int, StreamController> _idMap = {};
static StreamSubscription _subscription;
_InotifyFileSystemWatcher(path, events, recursive)
: super._(path, events, recursive);
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();
}
}
});
}
void _doneWatcher() {
_subscription.cancel();
}
Stream _pathWatched() {
var pathId = _watcherPath.pathId;
if (!_idMap.containsKey(pathId)) {
_idMap[pathId] = new StreamController<FileSystemEvent>.broadcast();
}
return _idMap[pathId].stream;
}
void _pathWatchedEnd() {
var pathId = _watcherPath.pathId;
if (!_idMap.containsKey(pathId)) return;
_idMap[pathId].close();
_idMap.remove(pathId);
}
}
class _Win32FileSystemWatcher extends _FileSystemWatcher {
StreamSubscription _subscription;
StreamController _controller;
_Win32FileSystemWatcher(path, events, recursive)
: super._(path, events, recursive);
Stream _pathWatched() {
var pathId = _watcherPath.pathId;
_controller = new StreamController<FileSystemEvent>();
_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;
}
void _pathWatchedEnd() {
_subscription.cancel();
_controller.close();
}
}
class _FSEventStreamFileSystemWatcher extends _FileSystemWatcher {
StreamSubscription _subscription;
StreamController _controller;
_FSEventStreamFileSystemWatcher(path, events, recursive)
: super._(path, events, recursive);
Stream _pathWatched() {
var pathId = _watcherPath.pathId;
var socketId = _FileSystemWatcher._getSocketId(0, pathId);
_controller = new StreamController<FileSystemEvent>();
_subscription =
_FileSystemWatcher._listenOnSocket(socketId, 0, pathId).listen((event) {
if (event[1] != null) {
_controller.add(event[1]);
} else {
_controller.close();
}
});
return _controller.stream;
}
void _pathWatchedEnd() {
_subscription.cancel();
_controller.close();
}
}
@pragma("vm:entry-point", "call")
Uint8List _makeUint8ListView(Uint8List source, int offsetInBytes, int length) {
return new Uint8List.view(source.buffer, offsetInBytes, length);
}

View file

@ -0,0 +1,24 @@
// Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
// 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.
// part of "common_patch.dart";
@patch
class FileStat {
@patch
static _statSync(_Namespace namespace, String path) native "File_Stat";
}
@patch
class FileSystemEntity {
@patch
static _getTypeNative(_Namespace namespace, Uint8List rawPath,
bool followLinks) native "File_GetType";
@patch
static _identicalNative(_Namespace namespace, String path1, String path2)
native "File_AreIdentical";
@patch
static _resolveSymbolicLinks(_Namespace namespace, Uint8List path)
native "File_ResolveSymbolicLinks";
}

View file

@ -0,0 +1,48 @@
// Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
// 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.
// part of "common_patch.dart";
class _FilterImpl extends NativeFieldWrapperClass1 implements RawZLibFilter {
void process(List<int> data, int start, int end) native "Filter_Process";
List<int> processed({bool flush: true, bool end: false})
native "Filter_Processed";
}
class _ZLibInflateFilter extends _FilterImpl {
_ZLibInflateFilter(int windowBits, List<int> dictionary, bool raw) {
_init(windowBits, dictionary, raw);
}
void _init(int windowBits, List<int> dictionary, bool raw)
native "Filter_CreateZLibInflate";
}
class _ZLibDeflateFilter extends _FilterImpl {
_ZLibDeflateFilter(bool gzip, int level, int windowBits, int memLevel,
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";
}
@patch
class RawZLibFilter {
@patch
static RawZLibFilter _makeZLibDeflateFilter(
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 RawZLibFilter _makeZLibInflateFilter(
int windowBits, List<int> dictionary, bool raw) =>
new _ZLibInflateFilter(windowBits, dictionary, raw);
}

View file

@ -0,0 +1,100 @@
// Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
// 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.
// part of "common_patch.dart";
class _IOServicePorts {
// We limit the number of IO Service ports per isolate so that we don't
// spawn too many threads all at once, which can crash the VM on Windows.
static const int maxPorts = 32;
List<SendPort> _ports = <SendPort>[];
List<SendPort> _freePorts = <SendPort>[];
Map<int, SendPort> _usedPorts = new HashMap<int, SendPort>();
_IOServicePorts();
SendPort _getPort(int forRequestId) {
if (_freePorts.isEmpty && _usedPorts.length < maxPorts) {
final SendPort port = _newServicePort();
_ports.add(port);
_freePorts.add(port);
}
if (!_freePorts.isEmpty) {
final SendPort port = _freePorts.removeLast();
assert(!_usedPorts.containsKey(forRequestId));
_usedPorts[forRequestId] = port;
return port;
}
// We have already allocated the max number of ports. Re-use an
// existing one.
final SendPort port = _ports[forRequestId % maxPorts];
_usedPorts[forRequestId] = port;
return port;
}
void _returnPort(int forRequestId) {
final SendPort port = _usedPorts.remove(forRequestId);
if (!_usedPorts.values.contains(port)) {
_freePorts.add(port);
}
}
static SendPort _newServicePort() native "IOService_NewServicePort";
}
@patch
class _IOService {
static _IOServicePorts _servicePorts = new _IOServicePorts();
static RawReceivePort _receivePort;
static SendPort _replyToPort;
static HashMap<int, Completer> _messageMap = new HashMap<int, Completer>();
static int _id = 0;
@patch
static Future _dispatch(int request, List data) {
int id;
do {
id = _getNextId();
} while (_messageMap.containsKey(id));
final SendPort servicePort = _servicePorts._getPort(id);
_ensureInitialize();
final Completer completer = new Completer();
_messageMap[id] = completer;
try {
servicePort.send([id, _replyToPort, request, data]);
} catch (error) {
_messageMap.remove(id).complete(error);
if (_messageMap.length == 0) {
_finalize();
}
}
return completer.future;
}
static void _ensureInitialize() {
if (_receivePort == null) {
_receivePort = new RawReceivePort();
_replyToPort = _receivePort.sendPort;
_receivePort.handler = (data) {
assert(data is List && data.length == 2);
_messageMap.remove(data[0]).complete(data[1]);
_servicePorts._returnPort(data[0]);
if (_messageMap.length == 0) {
_finalize();
}
};
}
}
static void _finalize() {
_id = 0;
_receivePort.close();
_receivePort = null;
}
static int _getNextId() {
if (_id == 0x7FFFFFFF) _id = 0;
return _id++;
}
}

View file

@ -0,0 +1,48 @@
// Copyright (c) 2017, the Dart project authors. Please see the AUTHORS file
// 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.
@pragma("vm:entry-point")
class _NamespaceImpl extends NativeFieldWrapperClass1 implements _Namespace {
_NamespaceImpl._();
static _NamespaceImpl _create(_NamespaceImpl namespace, var n)
native "Namespace_Create";
static int _getPointer(_NamespaceImpl namespace)
native "Namespace_GetPointer";
static int _getDefault() native "Namespace_GetDefault";
// If the platform supports "namespaces", this method is called by the
// embedder with the platform-specific namespace information.
static _NamespaceImpl _cachedNamespace = null;
static void _setupNamespace(var namespace) {
_cachedNamespace = _create(new _NamespaceImpl._(), namespace);
}
static _NamespaceImpl get _namespace {
if (_cachedNamespace == null) {
// The embedder has not supplied a namespace before one is needed, so
// instead use a safe-ish default value.
_cachedNamespace = _create(new _NamespaceImpl._(), _getDefault());
}
return _cachedNamespace;
}
static int get _namespacePointer => _getPointer(_namespace);
}
@patch
@pragma("vm:entry-point")
class _Namespace {
@patch
@pragma("vm:entry-point", "call")
static void _setupNamespace(var namespace) {
_NamespaceImpl._setupNamespace(namespace);
}
@patch
static _Namespace get _namespace => _NamespaceImpl._namespace;
@patch
static int get _namespacePointer => _NamespaceImpl._namespacePointer;
}

View file

@ -0,0 +1,59 @@
// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
// 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.
// part of "common_patch.dart";
@patch
@pragma("vm:entry-point")
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 _operatingSystemVersion() native "Platform_OperatingSystemVersion";
@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 _localeName() native "Platform_LocaleName";
@patch
static String _packageRoot() => VMLibraryHooks.packageRootString;
@patch
static String _packageConfig() => VMLibraryHooks.packageConfigString;
@patch
static Uri _script() => VMLibraryHooks.platformScript;
// This script singleton is written to by the embedder if applicable.
@pragma("vm:entry-point")
static void set _nativeScript(String path) {
VMLibraryHooks.platformScript = (() {
if (path.startsWith('http:') ||
path.startsWith('https:') ||
path.startsWith('package:') ||
path.startsWith('dart:') ||
path.startsWith('data:') ||
path.startsWith('file:')) {
return Uri.parse(path);
} else {
return Uri.base.resolveUri(new Uri.file(path));
}
});
}
}

Some files were not shown because too many files have changed in this diff Show more