mirror of
https://github.com/dart-lang/sdk
synced 2024-09-05 00:13:50 +00:00
Add various missing argument checks to dart:io natives.
Avoid reflective access to mirrors creating invalid reflectees. Change type checks in embedding API functions to return UnhandledExceptionErrors instead of APIErrors so they are catchable by Dart. Fixes invocation_fuzz_test. Bug: https://github.com/dart-lang/sdk/issues/15274 Bug: https://github.com/dart-lang/sdk/issues/23869 Bug: https://github.com/dart-lang/sdk/issues/37680 Change-Id: Ife3e3cb894c59620b0318e4e08947a3d1d45bab9 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/110620 Commit-Queue: Ryan Macnak <rmacnak@google.com> Reviewed-by: Siva Annamalai <asiva@google.com>
This commit is contained in:
parent
650f32c1b0
commit
d08c203e30
|
@ -42,6 +42,10 @@ static File* GetFile(Dart_NativeArguments args) {
|
|||
Dart_Handle result = Dart_GetNativeInstanceField(
|
||||
dart_this, kFileNativeFieldIndex, reinterpret_cast<intptr_t*>(&file));
|
||||
ASSERT(!Dart_IsError(result));
|
||||
if (file == NULL) {
|
||||
Dart_PropagateError(Dart_NewUnhandledExceptionError(
|
||||
DartUtils::NewInternalError("No native peer")));
|
||||
}
|
||||
return file;
|
||||
}
|
||||
|
||||
|
|
|
@ -119,7 +119,7 @@ Dart_Handle Namespace::GetNativeNamespaceArgument(Dart_NativeArguments args,
|
|||
Namespace** namespc) {
|
||||
Dart_Handle namespc_obj = Dart_GetNativeArgument(args, index);
|
||||
if (Dart_IsError(namespc_obj)) {
|
||||
Dart_PropagateError(namespc_obj);
|
||||
return namespc_obj;
|
||||
}
|
||||
DEBUG_ASSERT(IsNamespace(namespc_obj));
|
||||
|
||||
|
@ -129,6 +129,10 @@ Dart_Handle Namespace::GetNativeNamespaceArgument(Dart_NativeArguments args,
|
|||
if (Dart_IsError(result)) {
|
||||
return result;
|
||||
}
|
||||
if (*namespc == NULL) {
|
||||
return Dart_NewUnhandledExceptionError(
|
||||
DartUtils::NewInternalError("No native peer"));
|
||||
}
|
||||
return Dart_Null();
|
||||
}
|
||||
|
||||
|
|
|
@ -38,12 +38,16 @@ const intptr_t SSLFilter::kApproximateSize =
|
|||
sizeof(SSLFilter) + (2 * SSLFilter::kInternalBIOSize);
|
||||
|
||||
static SSLFilter* GetFilter(Dart_NativeArguments args) {
|
||||
SSLFilter* filter;
|
||||
SSLFilter* filter = NULL;
|
||||
Dart_Handle dart_this = ThrowIfError(Dart_GetNativeArgument(args, 0));
|
||||
ASSERT(Dart_IsInstance(dart_this));
|
||||
ThrowIfError(Dart_GetNativeInstanceField(
|
||||
dart_this, SSLFilter::kSSLFilterNativeFieldIndex,
|
||||
reinterpret_cast<intptr_t*>(&filter)));
|
||||
if (filter == NULL) {
|
||||
Dart_PropagateError(Dart_NewUnhandledExceptionError(
|
||||
DartUtils::NewInternalError("No native peer")));
|
||||
}
|
||||
return filter;
|
||||
}
|
||||
|
||||
|
|
|
@ -14,7 +14,7 @@ class SecureSocket {
|
|||
@patch
|
||||
class _SecureFilter {
|
||||
@patch
|
||||
factory _SecureFilter() => new _SecureFilterImpl();
|
||||
factory _SecureFilter._() => new _SecureFilterImpl._();
|
||||
}
|
||||
|
||||
@patch
|
||||
|
@ -22,7 +22,7 @@ class _SecureFilter {
|
|||
class X509Certificate {
|
||||
@patch
|
||||
@pragma("vm:entry-point")
|
||||
factory X509Certificate._() => new _X509CertificateImpl();
|
||||
factory X509Certificate._() => new _X509CertificateImpl._();
|
||||
}
|
||||
|
||||
class _SecureSocket extends _Socket implements SecureSocket {
|
||||
|
@ -75,7 +75,7 @@ class _SecureFilterImpl extends NativeFieldWrapperClass1
|
|||
@pragma("vm:entry-point")
|
||||
static final int ENCRYPTED_SIZE = 10 * 1024;
|
||||
|
||||
_SecureFilterImpl() {
|
||||
_SecureFilterImpl._() {
|
||||
buffers = new List<_ExternalBuffer>(_RawSecureSocket.bufferCount);
|
||||
for (int i = 0; i < _RawSecureSocket.bufferCount; ++i) {
|
||||
buffers[i] = new _ExternalBuffer(
|
||||
|
@ -206,7 +206,7 @@ class _X509CertificateImpl extends NativeFieldWrapperClass1
|
|||
implements X509Certificate {
|
||||
// The native field must be set manually on a new object, in native code.
|
||||
// This is done by WrappedX509 in secure_socket.cc.
|
||||
_X509CertificateImpl();
|
||||
_X509CertificateImpl._();
|
||||
|
||||
Uint8List _cachedDer;
|
||||
Uint8List get _der native "X509_Der";
|
||||
|
|
|
@ -86,6 +86,10 @@ SSLCertContext* SSLCertContext::GetSecurityContext(Dart_NativeArguments args) {
|
|||
ThrowIfError(Dart_GetNativeInstanceField(
|
||||
dart_this, SSLCertContext::kSecurityContextNativeFieldIndex,
|
||||
reinterpret_cast<intptr_t*>(&context)));
|
||||
if (context == NULL) {
|
||||
Dart_PropagateError(Dart_NewUnhandledExceptionError(
|
||||
DartUtils::NewInternalError("No native peer")));
|
||||
}
|
||||
return context;
|
||||
}
|
||||
|
||||
|
@ -644,6 +648,10 @@ static X509* GetX509Certificate(Dart_NativeArguments args) {
|
|||
ThrowIfError(Dart_GetNativeInstanceField(
|
||||
dart_this, SSLCertContext::kX509NativeFieldIndex,
|
||||
reinterpret_cast<intptr_t*>(&certificate)));
|
||||
if (certificate == NULL) {
|
||||
Dart_PropagateError(Dart_NewUnhandledExceptionError(
|
||||
DartUtils::NewInternalError("No native peer")));
|
||||
}
|
||||
return certificate;
|
||||
}
|
||||
|
||||
|
|
|
@ -1106,6 +1106,10 @@ Socket* Socket::GetSocketIdNativeField(Dart_Handle socket_obj) {
|
|||
Dart_PropagateError(err);
|
||||
}
|
||||
Socket* socket = reinterpret_cast<Socket*>(id);
|
||||
if (socket == NULL) {
|
||||
Dart_PropagateError(Dart_NewUnhandledExceptionError(
|
||||
DartUtils::NewInternalError("No native peer")));
|
||||
}
|
||||
return socket;
|
||||
}
|
||||
|
||||
|
|
|
@ -351,6 +351,10 @@ Dart_Handle SynchronousSocket::GetSocketIdNativeField(
|
|||
return result;
|
||||
}
|
||||
*socket = reinterpret_cast<SynchronousSocket*>(id);
|
||||
if (*socket == NULL) {
|
||||
Dart_PropagateError(Dart_NewUnhandledExceptionError(
|
||||
DartUtils::NewInternalError("No native peer")));
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
|
|
|
@ -91,7 +91,7 @@ class _NativeSynchronousSocket extends _NativeSynchronousSocketNativeWrapper {
|
|||
var address = it.current;
|
||||
var socket = new _NativeSynchronousSocket();
|
||||
socket.localAddress = address;
|
||||
var result = socket.nativeCreateConnectSync(address._in_addr, port);
|
||||
var result = socket._nativeCreateConnectSync(address._in_addr, port);
|
||||
if (result is OSError) {
|
||||
// Keep first error, if present.
|
||||
if (error == null) {
|
||||
|
@ -117,7 +117,7 @@ class _NativeSynchronousSocket extends _NativeSynchronousSocketNativeWrapper {
|
|||
}
|
||||
|
||||
InternetAddress get address => localAddress;
|
||||
int get available => nativeAvailable();
|
||||
int get available => _nativeAvailable();
|
||||
|
||||
int get port {
|
||||
if (localPort != 0) {
|
||||
|
@ -126,7 +126,7 @@ class _NativeSynchronousSocket extends _NativeSynchronousSocketNativeWrapper {
|
|||
if (isClosed) {
|
||||
throw const SocketException.closed();
|
||||
}
|
||||
var result = nativeGetPort();
|
||||
var result = _nativeGetPort();
|
||||
if (result is OSError) {
|
||||
throw result;
|
||||
}
|
||||
|
@ -137,7 +137,7 @@ class _NativeSynchronousSocket extends _NativeSynchronousSocketNativeWrapper {
|
|||
if (isClosed) {
|
||||
throw const SocketException.closed();
|
||||
}
|
||||
var result = nativeGetRemotePeer();
|
||||
var result = _nativeGetRemotePeer();
|
||||
if (result is OSError) {
|
||||
throw result;
|
||||
}
|
||||
|
@ -149,7 +149,7 @@ class _NativeSynchronousSocket extends _NativeSynchronousSocketNativeWrapper {
|
|||
if (isClosed) {
|
||||
throw const SocketException.closed();
|
||||
}
|
||||
var result = nativeGetRemotePeer();
|
||||
var result = _nativeGetRemotePeer();
|
||||
if (result is OSError) {
|
||||
throw result;
|
||||
}
|
||||
|
@ -158,7 +158,7 @@ class _NativeSynchronousSocket extends _NativeSynchronousSocketNativeWrapper {
|
|||
|
||||
void closeSync() {
|
||||
if (!isClosed) {
|
||||
nativeCloseSync();
|
||||
_nativeCloseSync();
|
||||
_SocketResourceInfo.SocketClosed(resourceInfo);
|
||||
isClosed = true;
|
||||
}
|
||||
|
@ -209,7 +209,7 @@ class _NativeSynchronousSocket extends _NativeSynchronousSocketNativeWrapper {
|
|||
if (end == start) {
|
||||
return 0;
|
||||
}
|
||||
var result = nativeReadInto(buffer, start, (end - start));
|
||||
var result = _nativeReadInto(buffer, start, (end - start));
|
||||
if (result is OSError) {
|
||||
throw new SocketException("readIntoSync failed", osError: result);
|
||||
}
|
||||
|
@ -229,7 +229,7 @@ class _NativeSynchronousSocket extends _NativeSynchronousSocketNativeWrapper {
|
|||
if (len == 0) {
|
||||
return null;
|
||||
}
|
||||
var result = nativeRead(len);
|
||||
var result = _nativeRead(len);
|
||||
if (result is OSError) {
|
||||
throw result;
|
||||
}
|
||||
|
@ -275,7 +275,7 @@ class _NativeSynchronousSocket extends _NativeSynchronousSocketNativeWrapper {
|
|||
if (isClosedWrite) {
|
||||
closeSync();
|
||||
} else {
|
||||
nativeShutdownRead();
|
||||
_nativeShutdownRead();
|
||||
}
|
||||
isClosedRead = true;
|
||||
}
|
||||
|
@ -287,7 +287,7 @@ class _NativeSynchronousSocket extends _NativeSynchronousSocketNativeWrapper {
|
|||
if (isClosedRead) {
|
||||
closeSync();
|
||||
} else {
|
||||
nativeShutdownWrite();
|
||||
_nativeShutdownWrite();
|
||||
}
|
||||
isClosedWrite = true;
|
||||
}
|
||||
|
@ -313,7 +313,7 @@ class _NativeSynchronousSocket extends _NativeSynchronousSocketNativeWrapper {
|
|||
|
||||
_BufferAndStart bufferAndStart =
|
||||
_ensureFastAndSerializableByteData(buffer, start, end);
|
||||
var result = nativeWrite(bufferAndStart.buffer, bufferAndStart.start,
|
||||
var result = _nativeWrite(bufferAndStart.buffer, bufferAndStart.start,
|
||||
end - (start - bufferAndStart.start));
|
||||
if (result is OSError) {
|
||||
throw new SocketException("writeFromSync failed", osError: result);
|
||||
|
@ -333,17 +333,17 @@ class _NativeSynchronousSocket extends _NativeSynchronousSocketNativeWrapper {
|
|||
// Native method declarations.
|
||||
static _nativeLookupRequest(host, int type)
|
||||
native "SynchronousSocket_LookupRequest";
|
||||
nativeCreateConnectSync(host, int port)
|
||||
_nativeCreateConnectSync(host, int port)
|
||||
native "SynchronousSocket_CreateConnectSync";
|
||||
nativeAvailable() native "SynchronousSocket_Available";
|
||||
nativeCloseSync() native "SynchronousSocket_CloseSync";
|
||||
int nativeGetPort() native "SynchronousSocket_GetPort";
|
||||
List nativeGetRemotePeer() native "SynchronousSocket_GetRemotePeer";
|
||||
nativeRead(int len) native "SynchronousSocket_Read";
|
||||
nativeReadInto(List<int> buffer, int offset, int bytes)
|
||||
_nativeAvailable() native "SynchronousSocket_Available";
|
||||
_nativeCloseSync() native "SynchronousSocket_CloseSync";
|
||||
int _nativeGetPort() native "SynchronousSocket_GetPort";
|
||||
List _nativeGetRemotePeer() native "SynchronousSocket_GetRemotePeer";
|
||||
_nativeRead(int len) native "SynchronousSocket_Read";
|
||||
_nativeReadInto(List<int> buffer, int offset, int bytes)
|
||||
native "SynchronousSocket_ReadList";
|
||||
nativeShutdownRead() native "SynchronousSocket_ShutdownRead";
|
||||
nativeShutdownWrite() native "SynchronousSocket_ShutdownWrite";
|
||||
nativeWrite(List<int> buffer, int offset, int bytes)
|
||||
_nativeShutdownRead() native "SynchronousSocket_ShutdownRead";
|
||||
_nativeShutdownWrite() native "SynchronousSocket_ShutdownWrite";
|
||||
_nativeWrite(List<int> buffer, int offset, int bytes)
|
||||
native "SynchronousSocket_WriteList";
|
||||
}
|
||||
|
|
|
@ -96,7 +96,7 @@ class _List<E> extends FixedLengthListBase<E> {
|
|||
end = RangeError.checkValidRange(start, end, this.length);
|
||||
int length = end - start;
|
||||
if (length == 0) return <E>[];
|
||||
var result = new _GrowableList<E>.withData(_slice(start, length, false));
|
||||
var result = new _GrowableList<E>._withData(_slice(start, length, false));
|
||||
result._setLength(length);
|
||||
return result;
|
||||
}
|
||||
|
@ -137,11 +137,11 @@ class _List<E> extends FixedLengthListBase<E> {
|
|||
if (length > 0) {
|
||||
var result = _slice(0, length, !growable);
|
||||
if (growable) {
|
||||
result = new _GrowableList<E>.withData(result).._setLength(length);
|
||||
result = new _GrowableList<E>._withData(result).._setLength(length);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
// _GrowableList.withData must not be called with empty list.
|
||||
// _GrowableList._withData must not be called with empty list.
|
||||
return growable ? <E>[] : new List<E>(0);
|
||||
}
|
||||
}
|
||||
|
@ -177,7 +177,7 @@ class _ImmutableList<E> extends UnmodifiableListBase<E> {
|
|||
for (int i = 0; i < length; i++) {
|
||||
list[i] = this[start + i];
|
||||
}
|
||||
var result = new _GrowableList<E>.withData(list);
|
||||
var result = new _GrowableList<E>._withData(list);
|
||||
result._setLength(length);
|
||||
return result;
|
||||
}
|
||||
|
@ -221,7 +221,7 @@ class _ImmutableList<E> extends UnmodifiableListBase<E> {
|
|||
list[i] = this[i];
|
||||
}
|
||||
if (!growable) return list;
|
||||
var result = new _GrowableList<E>.withData(list);
|
||||
var result = new _GrowableList<E>._withData(list);
|
||||
result._setLength(length);
|
||||
return result;
|
||||
}
|
||||
|
|
|
@ -70,7 +70,7 @@ class List<E> {
|
|||
if (elements.isEmpty) {
|
||||
return new _GrowableList<E>(0);
|
||||
}
|
||||
var result = new _GrowableList<E>.withData(elements);
|
||||
var result = new _GrowableList<E>._withData(elements);
|
||||
result._setLength(elements.length);
|
||||
return result;
|
||||
}
|
||||
|
|
|
@ -20,8 +20,7 @@ namespace dart {
|
|||
DEFINE_NATIVE_ENTRY(Double_doubleFromInteger, 0, 2) {
|
||||
ASSERT(
|
||||
TypeArguments::CheckedHandle(zone, arguments->NativeArgAt(0)).IsNull());
|
||||
const Integer& value =
|
||||
Integer::CheckedHandle(zone, arguments->NativeArgAt(1));
|
||||
GET_NON_NULL_NATIVE_ARGUMENT(Integer, value, arguments->NativeArgAt(1));
|
||||
if (FLAG_trace_intrinsified_natives) {
|
||||
OS::PrintErr("Double_doubleFromInteger %s\n", value.ToCString());
|
||||
}
|
||||
|
|
|
@ -85,14 +85,14 @@ class _GrowableList<T> extends ListBase<T> {
|
|||
for (int i = 0; i < length; i++) {
|
||||
list[i] = this[start + i];
|
||||
}
|
||||
var result = new _GrowableList<T>.withData(list);
|
||||
var result = new _GrowableList<T>._withData(list);
|
||||
result._setLength(length);
|
||||
return result;
|
||||
}
|
||||
|
||||
factory _GrowableList(int length) {
|
||||
var data = _allocateData(length);
|
||||
var result = new _GrowableList<T>.withData(data);
|
||||
var result = new _GrowableList<T>._withData(data);
|
||||
if (length > 0) {
|
||||
result._setLength(length);
|
||||
}
|
||||
|
@ -101,11 +101,11 @@ class _GrowableList<T> extends ListBase<T> {
|
|||
|
||||
factory _GrowableList.withCapacity(int capacity) {
|
||||
var data = _allocateData(capacity);
|
||||
return new _GrowableList<T>.withData(data);
|
||||
return new _GrowableList<T>._withData(data);
|
||||
}
|
||||
|
||||
@pragma("vm:exact-result-type", _GrowableList)
|
||||
factory _GrowableList.withData(_List data) native "GrowableList_allocate";
|
||||
factory _GrowableList._withData(_List data) native "GrowableList_allocate";
|
||||
|
||||
@pragma("vm:exact-result-type", "dart:core#_Smi")
|
||||
@pragma("vm:prefer-inline")
|
||||
|
@ -381,7 +381,7 @@ class _GrowableList<T> extends ListBase<T> {
|
|||
list[i] = this[i];
|
||||
}
|
||||
if (!growable) return list;
|
||||
var result = new _GrowableList<T>.withData(list);
|
||||
var result = new _GrowableList<T>._withData(list);
|
||||
result._setLength(length);
|
||||
return result;
|
||||
}
|
||||
|
|
|
@ -30,7 +30,7 @@ namespace dart {
|
|||
static RawInstance* CreateMirror(const String& mirror_class_name,
|
||||
const Array& constructor_arguments) {
|
||||
const Library& mirrors_lib = Library::Handle(Library::MirrorsLibrary());
|
||||
const String& constructor_name = Symbols::Dot();
|
||||
const String& constructor_name = Symbols::DotUnder();
|
||||
|
||||
const Object& result = Object::Handle(DartLibraryCalls::InstanceCreate(
|
||||
mirrors_lib, mirror_class_name, constructor_name, constructor_arguments));
|
||||
|
|
|
@ -68,8 +68,8 @@ List<dynamic> _metadata(reflectee) native 'DeclarationMirror_metadata';
|
|||
bool _subtypeTest(Type a, Type b) native 'TypeMirror_subtypeTest';
|
||||
|
||||
class _LocalMirrorSystem extends MirrorSystem {
|
||||
final TypeMirror dynamicType = new _SpecialTypeMirror('dynamic');
|
||||
final TypeMirror voidType = new _SpecialTypeMirror('void');
|
||||
final TypeMirror dynamicType = new _SpecialTypeMirror._('dynamic');
|
||||
final TypeMirror voidType = new _SpecialTypeMirror._('void');
|
||||
|
||||
var _libraries;
|
||||
Map<Uri, LibraryMirror> get libraries {
|
||||
|
@ -100,7 +100,7 @@ class _LocalMirrorSystem extends MirrorSystem {
|
|||
}
|
||||
|
||||
class _SourceLocation implements SourceLocation {
|
||||
_SourceLocation(uriString, this.line, this.column)
|
||||
_SourceLocation._(uriString, this.line, this.column)
|
||||
: this.sourceUri = Uri.parse(uriString);
|
||||
|
||||
// Line and column positions are 1-origin, or 0 if unknown.
|
||||
|
@ -120,7 +120,7 @@ class _LocalIsolateMirror extends _LocalMirror implements IsolateMirror {
|
|||
final String debugName;
|
||||
final LibraryMirror rootLibrary;
|
||||
|
||||
_LocalIsolateMirror(this.debugName, this.rootLibrary);
|
||||
_LocalIsolateMirror._(this.debugName, this.rootLibrary);
|
||||
|
||||
bool get isCurrent => true;
|
||||
|
||||
|
@ -208,7 +208,7 @@ abstract class _LocalObjectMirror extends _LocalMirror implements ObjectMirror {
|
|||
|
||||
final _reflectee; // May be a MirrorReference or an ordinary object.
|
||||
|
||||
_LocalObjectMirror(this._reflectee);
|
||||
_LocalObjectMirror._(this._reflectee);
|
||||
|
||||
InstanceMirror invoke(Symbol memberName, List positionalArguments,
|
||||
[Map<Symbol, dynamic> namedArguments]) {
|
||||
|
@ -262,7 +262,7 @@ abstract class _LocalObjectMirror extends _LocalMirror implements ObjectMirror {
|
|||
|
||||
class _LocalInstanceMirror extends _LocalObjectMirror
|
||||
implements InstanceMirror {
|
||||
_LocalInstanceMirror(reflectee) : super(reflectee);
|
||||
_LocalInstanceMirror._(reflectee) : super._(reflectee);
|
||||
|
||||
ClassMirror _type;
|
||||
ClassMirror get type {
|
||||
|
@ -336,7 +336,7 @@ class _LocalInstanceMirror extends _LocalObjectMirror
|
|||
|
||||
class _LocalClosureMirror extends _LocalInstanceMirror
|
||||
implements ClosureMirror {
|
||||
_LocalClosureMirror(reflectee) : super(reflectee);
|
||||
_LocalClosureMirror._(reflectee) : super._(reflectee);
|
||||
|
||||
MethodMirror _function;
|
||||
MethodMirror get function {
|
||||
|
@ -377,7 +377,7 @@ class _LocalClassMirror extends _LocalObjectMirror
|
|||
final bool isEnum;
|
||||
Type _instantiator;
|
||||
|
||||
_LocalClassMirror(
|
||||
_LocalClassMirror._(
|
||||
reflectee,
|
||||
reflectedType,
|
||||
String simpleName,
|
||||
|
@ -390,7 +390,7 @@ class _LocalClassMirror extends _LocalObjectMirror
|
|||
: this._simpleName = _s(simpleName),
|
||||
this._reflectedType = reflectedType,
|
||||
this._instantiator = reflectedType,
|
||||
super(reflectee);
|
||||
super._(reflectee);
|
||||
|
||||
bool get hasReflectedType => !_isGenericDeclaration;
|
||||
Type get reflectedType {
|
||||
|
@ -600,7 +600,7 @@ class _LocalClassMirror extends _LocalObjectMirror
|
|||
ClassMirror owner = originalDeclaration;
|
||||
var mirror;
|
||||
for (var i = 0; i < params.length; i += 2) {
|
||||
mirror = new _LocalTypeVariableMirror(params[i + 1], params[i], owner);
|
||||
mirror = new _LocalTypeVariableMirror._(params[i + 1], params[i], owner);
|
||||
_typeVariables.add(mirror);
|
||||
}
|
||||
_typeVariables =
|
||||
|
@ -745,8 +745,8 @@ class _LocalClassMirror extends _LocalObjectMirror
|
|||
class _LocalFunctionTypeMirror extends _LocalClassMirror
|
||||
implements FunctionTypeMirror {
|
||||
final _functionReflectee;
|
||||
_LocalFunctionTypeMirror(reflectee, this._functionReflectee, reflectedType)
|
||||
: super(reflectee, reflectedType, null, null, false, false, false, false,
|
||||
_LocalFunctionTypeMirror._(reflectee, this._functionReflectee, reflectedType)
|
||||
: super._(reflectee, reflectedType, null, null, false, false, false, false,
|
||||
false);
|
||||
|
||||
bool get _isAnonymousMixinApplication => false;
|
||||
|
@ -811,7 +811,7 @@ abstract class _LocalDeclarationMirror extends _LocalMirror
|
|||
final _reflectee;
|
||||
Symbol _simpleName;
|
||||
|
||||
_LocalDeclarationMirror(this._reflectee, this._simpleName);
|
||||
_LocalDeclarationMirror._(this._reflectee, this._simpleName);
|
||||
|
||||
Symbol get simpleName => _simpleName;
|
||||
|
||||
|
@ -846,8 +846,8 @@ abstract class _LocalDeclarationMirror extends _LocalMirror
|
|||
|
||||
class _LocalTypeVariableMirror extends _LocalDeclarationMirror
|
||||
implements TypeVariableMirror, _LocalTypeMirror {
|
||||
_LocalTypeVariableMirror(reflectee, String simpleName, this._owner)
|
||||
: super(reflectee, _s(simpleName));
|
||||
_LocalTypeVariableMirror._(reflectee, String simpleName, this._owner)
|
||||
: super._(reflectee, _s(simpleName));
|
||||
|
||||
DeclarationMirror _owner;
|
||||
DeclarationMirror get owner {
|
||||
|
@ -922,7 +922,7 @@ class _LocalTypedefMirror extends _LocalDeclarationMirror
|
|||
|
||||
_LocalTypedefMirror(reflectee, this._reflectedType, String simpleName,
|
||||
this._isGeneric, this._isGenericDeclaration, this._owner)
|
||||
: super(reflectee, _s(simpleName));
|
||||
: super._(reflectee, _s(simpleName));
|
||||
|
||||
bool get isTopLevel => true;
|
||||
|
||||
|
@ -971,7 +971,7 @@ class _LocalTypedefMirror extends _LocalDeclarationMirror
|
|||
TypedefMirror owner = originalDeclaration;
|
||||
var mirror;
|
||||
for (var i = 0; i < params.length; i += 2) {
|
||||
mirror = new _LocalTypeVariableMirror(params[i + 1], params[i], owner);
|
||||
mirror = new _LocalTypeVariableMirror._(params[i + 1], params[i], owner);
|
||||
_typeVariables.add(mirror);
|
||||
}
|
||||
}
|
||||
|
@ -1025,10 +1025,10 @@ class _LocalLibraryMirror extends _LocalObjectMirror implements LibraryMirror {
|
|||
final Symbol simpleName;
|
||||
final Uri uri;
|
||||
|
||||
_LocalLibraryMirror(reflectee, String simpleName, String url)
|
||||
_LocalLibraryMirror._(reflectee, String simpleName, String url)
|
||||
: this.simpleName = _s(simpleName),
|
||||
this.uri = Uri.parse(url),
|
||||
super(reflectee);
|
||||
super._(reflectee);
|
||||
|
||||
// The simple name and the qualified name are the same for a library.
|
||||
Symbol get qualifiedName => simpleName;
|
||||
|
@ -1108,7 +1108,7 @@ class _LocalLibraryDependencyMirror extends _LocalMirror
|
|||
final bool isDeferred;
|
||||
final List<InstanceMirror> metadata;
|
||||
|
||||
_LocalLibraryDependencyMirror(
|
||||
_LocalLibraryDependencyMirror._(
|
||||
this.sourceLibrary,
|
||||
this._targetMirrorOrPrefix,
|
||||
List<dynamic> mutableCombinators,
|
||||
|
@ -1155,7 +1155,7 @@ class _LocalCombinatorMirror extends _LocalMirror implements CombinatorMirror {
|
|||
final List<Symbol> identifiers;
|
||||
final bool isShow;
|
||||
|
||||
_LocalCombinatorMirror(identifierString, this.isShow)
|
||||
_LocalCombinatorMirror._(identifierString, this.isShow)
|
||||
: this.identifiers =
|
||||
new UnmodifiableListView<Symbol>(<Symbol>[_s(identifierString)]);
|
||||
|
||||
|
@ -1168,9 +1168,9 @@ class _LocalMethodMirror extends _LocalDeclarationMirror
|
|||
final bool isStatic;
|
||||
final int _kindFlags;
|
||||
|
||||
_LocalMethodMirror(reflectee, String simpleName, this._owner,
|
||||
_LocalMethodMirror._(reflectee, String simpleName, this._owner,
|
||||
this._instantiator, this.isStatic, this._kindFlags)
|
||||
: super(reflectee, _s(simpleName));
|
||||
: super._(reflectee, _s(simpleName));
|
||||
|
||||
static const kAbstract = 0;
|
||||
static const kGetter = 1;
|
||||
|
@ -1297,9 +1297,9 @@ class _LocalVariableMirror extends _LocalDeclarationMirror
|
|||
final bool isFinal;
|
||||
final bool isConst;
|
||||
|
||||
_LocalVariableMirror(reflectee, String simpleName, this.owner, this._type,
|
||||
_LocalVariableMirror._(reflectee, String simpleName, this.owner, this._type,
|
||||
this.isStatic, this.isFinal, this.isConst)
|
||||
: super(reflectee, _s(simpleName));
|
||||
: super._(reflectee, _s(simpleName));
|
||||
|
||||
bool get isTopLevel => owner is LibraryMirror;
|
||||
|
||||
|
@ -1338,7 +1338,7 @@ class _LocalParameterMirror extends _LocalVariableMirror
|
|||
final bool isNamed;
|
||||
final List _unmirroredMetadata;
|
||||
|
||||
_LocalParameterMirror(
|
||||
_LocalParameterMirror._(
|
||||
reflectee,
|
||||
String simpleName,
|
||||
DeclarationMirror owner,
|
||||
|
@ -1348,7 +1348,7 @@ class _LocalParameterMirror extends _LocalVariableMirror
|
|||
bool isFinal,
|
||||
this._defaultValueReflectee,
|
||||
this._unmirroredMetadata)
|
||||
: super(
|
||||
: super._(
|
||||
reflectee,
|
||||
simpleName,
|
||||
owner,
|
||||
|
@ -1401,7 +1401,7 @@ class _SpecialTypeMirror extends _LocalMirror
|
|||
implements TypeMirror, DeclarationMirror {
|
||||
final Symbol simpleName;
|
||||
|
||||
_SpecialTypeMirror(String name) : simpleName = _s(name);
|
||||
_SpecialTypeMirror._(String name) : simpleName = _s(name);
|
||||
|
||||
bool get isPrivate => false;
|
||||
bool get isTopLevel => true;
|
||||
|
@ -1454,15 +1454,15 @@ class _Mirrors {
|
|||
// Creates a new local mirror for some Object.
|
||||
static InstanceMirror reflect(Object reflectee) {
|
||||
return reflectee is Function
|
||||
? new _LocalClosureMirror(reflectee)
|
||||
: new _LocalInstanceMirror(reflectee);
|
||||
? new _LocalClosureMirror._(reflectee)
|
||||
: new _LocalInstanceMirror._(reflectee);
|
||||
}
|
||||
|
||||
static ClassMirror makeLocalClassMirror(Type key)
|
||||
static ClassMirror _makeLocalClassMirror(Type key)
|
||||
native "Mirrors_makeLocalClassMirror";
|
||||
static TypeMirror makeLocalTypeMirror(Type key)
|
||||
static TypeMirror _makeLocalTypeMirror(Type key)
|
||||
native "Mirrors_makeLocalTypeMirror";
|
||||
static Type instantiateGenericType(Type key, typeArguments)
|
||||
static Type _instantiateGenericType(Type key, typeArguments)
|
||||
native "Mirrors_instantiateGenericType";
|
||||
|
||||
static Expando<_LocalClassMirror> _declarationCache =
|
||||
|
@ -1472,7 +1472,7 @@ class _Mirrors {
|
|||
static ClassMirror reflectClass(Type key) {
|
||||
var classMirror = _declarationCache[key];
|
||||
if (classMirror == null) {
|
||||
classMirror = makeLocalClassMirror(key);
|
||||
classMirror = _makeLocalClassMirror(key);
|
||||
_declarationCache[key] = classMirror;
|
||||
if (!classMirror._isGeneric) {
|
||||
_instantiationCache[key] = classMirror;
|
||||
|
@ -1487,7 +1487,7 @@ class _Mirrors {
|
|||
}
|
||||
var typeMirror = _instantiationCache[key];
|
||||
if (typeMirror == null) {
|
||||
typeMirror = makeLocalTypeMirror(key);
|
||||
typeMirror = _makeLocalTypeMirror(key);
|
||||
_instantiationCache[key] = typeMirror;
|
||||
if (typeMirror is _LocalClassMirror && !typeMirror._isGeneric) {
|
||||
_declarationCache[key] = typeMirror;
|
||||
|
@ -1501,6 +1501,6 @@ class _Mirrors {
|
|||
throw new ArgumentError.value(typeArguments, 'typeArguments',
|
||||
'Type arguments list cannot be empty.');
|
||||
}
|
||||
return instantiateGenericType(key, typeArguments.toList(growable: false));
|
||||
return _instantiateGenericType(key, typeArguments.toList(growable: false));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -174,7 +174,7 @@ namespace dart {
|
|||
V(_Double, get:isNegative, Double_getIsNegative, 0x3a59e7f4) \
|
||||
V(_Double, _mulFromInteger, Double_mulFromInteger, 0x2017fcf6) \
|
||||
V(_Double, .fromInteger, DoubleFromInteger, 0x6d234f4b) \
|
||||
V(_GrowableList, .withData, GrowableArray_Allocate, 0x28b2138e) \
|
||||
V(_GrowableList, ._withData, GrowableArray_Allocate, 0x28b2138e) \
|
||||
V(_RegExp, _ExecuteMatch, RegExp_ExecuteMatch, 0x380184b1) \
|
||||
V(_RegExp, _ExecuteMatchSticky, RegExp_ExecuteMatchSticky, 0x79b8f955) \
|
||||
V(Object, ==, ObjectEquals, 0x7b32a55a) \
|
||||
|
@ -402,7 +402,7 @@ namespace dart {
|
|||
// result-cid, fingerprint).
|
||||
#define RECOGNIZED_LIST_FACTORY_LIST(V) \
|
||||
V(_ListFactory, _List, ., kArrayCid, 0x2121902f) \
|
||||
V(_GrowableListWithData, _GrowableList, .withData, kGrowableObjectArrayCid, \
|
||||
V(_GrowableListWithData, _GrowableList, ._withData, kGrowableObjectArrayCid, \
|
||||
0x28b2138e) \
|
||||
V(_GrowableListFactory, _GrowableList, ., kGrowableObjectArrayCid, \
|
||||
0x3eed680b) \
|
||||
|
|
|
@ -427,19 +427,40 @@ Dart_Handle Api::NewError(const char* format, ...) {
|
|||
|
||||
va_list args;
|
||||
va_start(args, format);
|
||||
intptr_t len = Utils::VSNPrint(NULL, 0, format, args);
|
||||
char* buffer = OS::VSCreate(Z, format, args);
|
||||
va_end(args);
|
||||
|
||||
char* buffer = Z->Alloc<char>(len + 1);
|
||||
va_list args2;
|
||||
va_start(args2, format);
|
||||
Utils::VSNPrint(buffer, (len + 1), format, args2);
|
||||
va_end(args2);
|
||||
|
||||
const String& message = String::Handle(Z, String::New(buffer));
|
||||
return Api::NewHandle(T, ApiError::New(message));
|
||||
}
|
||||
|
||||
Dart_Handle Api::NewArgumentError(const char* format, ...) {
|
||||
Thread* T = Thread::Current();
|
||||
CHECK_API_SCOPE(T);
|
||||
CHECK_CALLBACK_STATE(T);
|
||||
// Ensure we transition safepoint state to VM if we are not already in
|
||||
// that state.
|
||||
TransitionToVM transition(T);
|
||||
HANDLESCOPE(T);
|
||||
|
||||
va_list args;
|
||||
va_start(args, format);
|
||||
char* buffer = OS::VSCreate(Z, format, args);
|
||||
va_end(args);
|
||||
|
||||
const String& message = String::Handle(Z, String::New(buffer));
|
||||
const Array& arguments = Array::Handle(Z, Array::New(1));
|
||||
arguments.SetAt(0, message);
|
||||
Object& error = Object::Handle(
|
||||
Z, DartLibraryCalls::InstanceCreate(
|
||||
Library::Handle(Z, Library::CoreLibrary()),
|
||||
Symbols::ArgumentError(), Symbols::Dot(), arguments));
|
||||
if (!error.IsError()) {
|
||||
error = UnhandledException::New(Instance::Cast(error), Instance::Handle());
|
||||
}
|
||||
return Api::NewHandle(T, error.raw());
|
||||
}
|
||||
|
||||
void Api::SetupAcquiredError(Isolate* isolate) {
|
||||
ASSERT(isolate != NULL);
|
||||
ApiState* state = isolate->api_state();
|
||||
|
@ -2863,7 +2884,8 @@ DART_EXPORT Dart_Handle Dart_ListLength(Dart_Handle list, intptr_t* len) {
|
|||
// Now check and handle a dart object that implements the List interface.
|
||||
const Instance& instance = Instance::Handle(Z, GetListInstance(Z, obj));
|
||||
if (instance.IsNull()) {
|
||||
return Api::NewError("Object does not implement the List interface");
|
||||
return Api::NewArgumentError(
|
||||
"Object does not implement the List interface");
|
||||
}
|
||||
const String& name = String::Handle(Z, Field::GetterName(Symbols::Length()));
|
||||
const int kTypeArgsLen = 0;
|
||||
|
@ -2873,7 +2895,7 @@ DART_EXPORT Dart_Handle Dart_ListLength(Dart_Handle list, intptr_t* len) {
|
|||
const Function& function =
|
||||
Function::Handle(Z, Resolver::ResolveDynamic(instance, name, args_desc));
|
||||
if (function.IsNull()) {
|
||||
return Api::NewError("List object does not have a 'length' field.");
|
||||
return Api::NewArgumentError("List object does not have a 'length' field.");
|
||||
}
|
||||
|
||||
const Array& args = Array::Handle(Z, Array::New(kNumArgs));
|
||||
|
@ -2924,7 +2946,8 @@ DART_EXPORT Dart_Handle Dart_ListGetAt(Dart_Handle list, intptr_t index) {
|
|||
Send1Arg(instance, Symbols::IndexToken(),
|
||||
Instance::Handle(Z, Integer::New(index))));
|
||||
}
|
||||
return Api::NewError("Object does not implement the 'List' interface");
|
||||
return Api::NewArgumentError(
|
||||
"Object does not implement the 'List' interface");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2980,7 +3003,8 @@ DART_EXPORT Dart_Handle Dart_ListGetRange(Dart_Handle list,
|
|||
return Api::Success();
|
||||
}
|
||||
}
|
||||
return Api::NewError("Object does not implement the 'List' interface");
|
||||
return Api::NewArgumentError(
|
||||
"Object does not implement the 'List' interface");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -3035,7 +3059,8 @@ DART_EXPORT Dart_Handle Dart_ListSetAt(Dart_Handle list,
|
|||
return Api::NewHandle(T, DartEntry::InvokeFunction(function, args));
|
||||
}
|
||||
}
|
||||
return Api::NewError("Object does not implement the 'List' interface");
|
||||
return Api::NewArgumentError(
|
||||
"Object does not implement the 'List' interface");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -3235,7 +3260,8 @@ DART_EXPORT Dart_Handle Dart_ListGetAsBytes(Dart_Handle list,
|
|||
return Api::Success();
|
||||
}
|
||||
}
|
||||
return Api::NewError("Object does not implement the 'List' interface");
|
||||
return Api::NewArgumentError(
|
||||
"Object does not implement the 'List' interface");
|
||||
}
|
||||
|
||||
#define SET_LIST_ELEMENT_AS_BYTES(type, obj, native_array, offset, length) \
|
||||
|
@ -3311,7 +3337,8 @@ DART_EXPORT Dart_Handle Dart_ListSetAsBytes(Dart_Handle list,
|
|||
return Api::Success();
|
||||
}
|
||||
}
|
||||
return Api::NewError("Object does not implement the 'List' interface");
|
||||
return Api::NewArgumentError(
|
||||
"Object does not implement the 'List' interface");
|
||||
}
|
||||
|
||||
// --- Maps ---
|
||||
|
@ -3329,7 +3356,7 @@ DART_EXPORT Dart_Handle Dart_MapGetAt(Dart_Handle map, Dart_Handle key) {
|
|||
return Api::NewHandle(
|
||||
T, Send1Arg(instance, Symbols::IndexToken(), Instance::Cast(key_obj)));
|
||||
}
|
||||
return Api::NewError("Object does not implement the 'Map' interface");
|
||||
return Api::NewArgumentError("Object does not implement the 'Map' interface");
|
||||
}
|
||||
|
||||
DART_EXPORT Dart_Handle Dart_MapContainsKey(Dart_Handle map, Dart_Handle key) {
|
||||
|
@ -3346,7 +3373,7 @@ DART_EXPORT Dart_Handle Dart_MapContainsKey(Dart_Handle map, Dart_Handle key) {
|
|||
T, Send1Arg(instance, String::Handle(Z, String::New("containsKey")),
|
||||
Instance::Cast(key_obj)));
|
||||
}
|
||||
return Api::NewError("Object does not implement the 'Map' interface");
|
||||
return Api::NewArgumentError("Object does not implement the 'Map' interface");
|
||||
}
|
||||
|
||||
DART_EXPORT Dart_Handle Dart_MapKeys(Dart_Handle map) {
|
||||
|
@ -3363,7 +3390,7 @@ DART_EXPORT Dart_Handle Dart_MapKeys(Dart_Handle map) {
|
|||
return Api::NewHandle(T, Send0Arg(Instance::Cast(iterator),
|
||||
String::Handle(String::New("toList"))));
|
||||
}
|
||||
return Api::NewError("Object does not implement the 'Map' interface");
|
||||
return Api::NewArgumentError("Object does not implement the 'Map' interface");
|
||||
}
|
||||
|
||||
// --- Typed Data ---
|
||||
|
@ -4693,7 +4720,7 @@ DART_EXPORT Dart_Handle Dart_GetNativeArguments(
|
|||
case Dart_NativeArgument_kBool:
|
||||
if (!Api::GetNativeBooleanArgument(arguments, arg_index,
|
||||
&(native_value->as_bool))) {
|
||||
return Api::NewError(
|
||||
return Api::NewArgumentError(
|
||||
"%s: expects argument at index %d to be of"
|
||||
" type Boolean.",
|
||||
CURRENT_FUNC, i);
|
||||
|
@ -4703,14 +4730,15 @@ DART_EXPORT Dart_Handle Dart_GetNativeArguments(
|
|||
case Dart_NativeArgument_kInt32: {
|
||||
int64_t value = 0;
|
||||
if (!GetNativeIntegerArgument(arguments, arg_index, &value)) {
|
||||
return Api::NewError(
|
||||
return Api::NewArgumentError(
|
||||
"%s: expects argument at index %d to be of"
|
||||
" type Integer.",
|
||||
CURRENT_FUNC, i);
|
||||
}
|
||||
if (value < INT_MIN || value > INT_MAX) {
|
||||
return Api::NewError("%s: argument value at index %d is out of range",
|
||||
CURRENT_FUNC, i);
|
||||
return Api::NewArgumentError(
|
||||
"%s: argument value at index %d is out of range", CURRENT_FUNC,
|
||||
i);
|
||||
}
|
||||
native_value->as_int32 = static_cast<int32_t>(value);
|
||||
break;
|
||||
|
@ -4719,14 +4747,15 @@ DART_EXPORT Dart_Handle Dart_GetNativeArguments(
|
|||
case Dart_NativeArgument_kUint32: {
|
||||
int64_t value = 0;
|
||||
if (!GetNativeIntegerArgument(arguments, arg_index, &value)) {
|
||||
return Api::NewError(
|
||||
return Api::NewArgumentError(
|
||||
"%s: expects argument at index %d to be of"
|
||||
" type Integer.",
|
||||
CURRENT_FUNC, i);
|
||||
}
|
||||
if (value < 0 || value > UINT_MAX) {
|
||||
return Api::NewError("%s: argument value at index %d is out of range",
|
||||
CURRENT_FUNC, i);
|
||||
return Api::NewArgumentError(
|
||||
"%s: argument value at index %d is out of range", CURRENT_FUNC,
|
||||
i);
|
||||
}
|
||||
native_value->as_uint32 = static_cast<uint32_t>(value);
|
||||
break;
|
||||
|
@ -4735,7 +4764,7 @@ DART_EXPORT Dart_Handle Dart_GetNativeArguments(
|
|||
case Dart_NativeArgument_kInt64: {
|
||||
int64_t value = 0;
|
||||
if (!GetNativeIntegerArgument(arguments, arg_index, &value)) {
|
||||
return Api::NewError(
|
||||
return Api::NewArgumentError(
|
||||
"%s: expects argument at index %d to be of"
|
||||
" type Integer.",
|
||||
CURRENT_FUNC, i);
|
||||
|
@ -4747,7 +4776,7 @@ DART_EXPORT Dart_Handle Dart_GetNativeArguments(
|
|||
case Dart_NativeArgument_kUint64: {
|
||||
uint64_t value = 0;
|
||||
if (!GetNativeUnsignedIntegerArgument(arguments, arg_index, &value)) {
|
||||
return Api::NewError(
|
||||
return Api::NewArgumentError(
|
||||
"%s: expects argument at index %d to be of"
|
||||
" type Integer.",
|
||||
CURRENT_FUNC, i);
|
||||
|
@ -4759,7 +4788,7 @@ DART_EXPORT Dart_Handle Dart_GetNativeArguments(
|
|||
case Dart_NativeArgument_kDouble:
|
||||
if (!GetNativeDoubleArgument(arguments, arg_index,
|
||||
&(native_value->as_double))) {
|
||||
return Api::NewError(
|
||||
return Api::NewArgumentError(
|
||||
"%s: expects argument at index %d to be of"
|
||||
" type Double.",
|
||||
CURRENT_FUNC, i);
|
||||
|
@ -4770,7 +4799,7 @@ DART_EXPORT Dart_Handle Dart_GetNativeArguments(
|
|||
if (!GetNativeStringArgument(arguments, arg_index,
|
||||
&(native_value->as_string.dart_str),
|
||||
&(native_value->as_string.peer))) {
|
||||
return Api::NewError(
|
||||
return Api::NewArgumentError(
|
||||
"%s: expects argument at index %d to be of"
|
||||
" type String.",
|
||||
CURRENT_FUNC, i);
|
||||
|
@ -4796,8 +4825,8 @@ DART_EXPORT Dart_Handle Dart_GetNativeArguments(
|
|||
}
|
||||
|
||||
default:
|
||||
return Api::NewError("%s: invalid argument type %d.", CURRENT_FUNC,
|
||||
arg_type);
|
||||
return Api::NewArgumentError("%s: invalid argument type %d.",
|
||||
CURRENT_FUNC, arg_type);
|
||||
}
|
||||
}
|
||||
return Api::Success();
|
||||
|
@ -4862,7 +4891,7 @@ DART_EXPORT Dart_Handle Dart_GetNativeStringArgument(Dart_NativeArguments args,
|
|||
TransitionNativeToVM transition(arguments->thread());
|
||||
Dart_Handle result = Api::Null();
|
||||
if (!GetNativeStringArgument(arguments, arg_index, &result, peer)) {
|
||||
return Api::NewError(
|
||||
return Api::NewArgumentError(
|
||||
"%s expects argument at %d to be of"
|
||||
" type String.",
|
||||
CURRENT_FUNC, arg_index);
|
||||
|
@ -4880,7 +4909,7 @@ DART_EXPORT Dart_Handle Dart_GetNativeIntegerArgument(Dart_NativeArguments args,
|
|||
CURRENT_FUNC, arguments->NativeArgCount() - 1, index);
|
||||
}
|
||||
if (!GetNativeIntegerArgument(arguments, index, value)) {
|
||||
return Api::NewError(
|
||||
return Api::NewArgumentError(
|
||||
"%s: expects argument at %d to be of"
|
||||
" type Integer.",
|
||||
CURRENT_FUNC, index);
|
||||
|
@ -4898,8 +4927,9 @@ DART_EXPORT Dart_Handle Dart_GetNativeBooleanArgument(Dart_NativeArguments args,
|
|||
CURRENT_FUNC, arguments->NativeArgCount() - 1, index);
|
||||
}
|
||||
if (!Api::GetNativeBooleanArgument(arguments, index, value)) {
|
||||
return Api::NewError("%s: expects argument at %d to be of type Boolean.",
|
||||
CURRENT_FUNC, index);
|
||||
return Api::NewArgumentError(
|
||||
"%s: expects argument at %d to be of type Boolean.", CURRENT_FUNC,
|
||||
index);
|
||||
}
|
||||
return Api::Success();
|
||||
}
|
||||
|
@ -4914,7 +4944,7 @@ DART_EXPORT Dart_Handle Dart_GetNativeDoubleArgument(Dart_NativeArguments args,
|
|||
CURRENT_FUNC, arguments->NativeArgCount() - 1, index);
|
||||
}
|
||||
if (!GetNativeDoubleArgument(arguments, index, value)) {
|
||||
return Api::NewError(
|
||||
return Api::NewArgumentError(
|
||||
"%s: expects argument at %d to be of"
|
||||
" type Double.",
|
||||
CURRENT_FUNC, index);
|
||||
|
|
|
@ -75,13 +75,13 @@ const char* CanonicalFunction(const char* func);
|
|||
const Object& tmp = \
|
||||
Object::Handle(zone, Api::UnwrapHandle((dart_handle))); \
|
||||
if (tmp.IsNull()) { \
|
||||
return Api::NewError("%s expects argument '%s' to be non-null.", \
|
||||
CURRENT_FUNC, #dart_handle); \
|
||||
return Api::NewArgumentError("%s expects argument '%s' to be non-null.", \
|
||||
CURRENT_FUNC, #dart_handle); \
|
||||
} else if (tmp.IsError()) { \
|
||||
return dart_handle; \
|
||||
} \
|
||||
return Api::NewError("%s expects argument '%s' to be of type %s.", \
|
||||
CURRENT_FUNC, #dart_handle, #type); \
|
||||
return Api::NewArgumentError("%s expects argument '%s' to be of type %s.", \
|
||||
CURRENT_FUNC, #dart_handle, #type); \
|
||||
} while (0)
|
||||
|
||||
#define RETURN_NULL_ERROR(parameter) \
|
||||
|
@ -225,6 +225,8 @@ class Api : AllStatic {
|
|||
|
||||
// Generates a handle used to designate an error return.
|
||||
static Dart_Handle NewError(const char* format, ...) PRINTF_ATTRIBUTE(1, 2);
|
||||
static Dart_Handle NewArgumentError(const char* format, ...)
|
||||
PRINTF_ATTRIBUTE(1, 2);
|
||||
|
||||
// Gets a handle to Null.
|
||||
static Dart_Handle Null() { return null_handle_; }
|
||||
|
|
|
@ -4325,9 +4325,8 @@ TEST_CASE(DartAPI_SetField_FunnyValue) {
|
|||
|
||||
// Pass a non-instance handle.
|
||||
result = Dart_SetField(lib, name, lib);
|
||||
EXPECT(Dart_IsError(result));
|
||||
EXPECT_STREQ("Dart_SetField expects argument 'value' to be of type Instance.",
|
||||
Dart_GetError(result));
|
||||
EXPECT_ERROR(
|
||||
result, "Dart_SetField expects argument 'value' to be of type Instance.");
|
||||
|
||||
// Pass an error handle. The error is contagious.
|
||||
result = Dart_SetField(lib, name, Api::NewError("myerror"));
|
||||
|
@ -6017,15 +6016,13 @@ TEST_CASE(DartAPI_LookupLibrary) {
|
|||
EXPECT_VALID(result);
|
||||
|
||||
result = Dart_LookupLibrary(Dart_Null());
|
||||
EXPECT(Dart_IsError(result));
|
||||
EXPECT_STREQ("Dart_LookupLibrary expects argument 'url' to be non-null.",
|
||||
Dart_GetError(result));
|
||||
EXPECT_ERROR(result,
|
||||
"Dart_LookupLibrary expects argument 'url' to be non-null.");
|
||||
|
||||
result = Dart_LookupLibrary(Dart_True());
|
||||
EXPECT(Dart_IsError(result));
|
||||
EXPECT_STREQ(
|
||||
"Dart_LookupLibrary expects argument 'url' to be of type String.",
|
||||
Dart_GetError(result));
|
||||
EXPECT_ERROR(
|
||||
result,
|
||||
"Dart_LookupLibrary expects argument 'url' to be of type String.");
|
||||
|
||||
result = Dart_LookupLibrary(Dart_NewApiError("incoming error"));
|
||||
EXPECT(Dart_IsError(result));
|
||||
|
@ -6033,9 +6030,7 @@ TEST_CASE(DartAPI_LookupLibrary) {
|
|||
|
||||
url = NewString("noodles.dart");
|
||||
result = Dart_LookupLibrary(url);
|
||||
EXPECT(Dart_IsError(result));
|
||||
EXPECT_STREQ("Dart_LookupLibrary: library 'noodles.dart' not found.",
|
||||
Dart_GetError(result));
|
||||
EXPECT_ERROR(result, "Dart_LookupLibrary: library 'noodles.dart' not found.");
|
||||
}
|
||||
|
||||
TEST_CASE(DartAPI_LibraryUrl) {
|
||||
|
@ -6045,15 +6040,13 @@ TEST_CASE(DartAPI_LibraryUrl) {
|
|||
EXPECT_VALID(lib);
|
||||
|
||||
Dart_Handle result = Dart_LibraryUrl(Dart_Null());
|
||||
EXPECT(Dart_IsError(result));
|
||||
EXPECT_STREQ("Dart_LibraryUrl expects argument 'library' to be non-null.",
|
||||
Dart_GetError(result));
|
||||
EXPECT_ERROR(result,
|
||||
"Dart_LibraryUrl expects argument 'library' to be non-null.");
|
||||
|
||||
result = Dart_LibraryUrl(Dart_True());
|
||||
EXPECT(Dart_IsError(result));
|
||||
EXPECT_STREQ(
|
||||
"Dart_LibraryUrl expects argument 'library' to be of type Library.",
|
||||
Dart_GetError(result));
|
||||
EXPECT_ERROR(
|
||||
result,
|
||||
"Dart_LibraryUrl expects argument 'library' to be of type Library.");
|
||||
|
||||
result = Dart_LibraryUrl(error);
|
||||
EXPECT(Dart_IsError(result));
|
||||
|
@ -6115,17 +6108,14 @@ TEST_CASE(DartAPI_SetNativeResolver) {
|
|||
EXPECT_VALID(type);
|
||||
|
||||
result = Dart_SetNativeResolver(Dart_Null(), &MyNativeResolver1, NULL);
|
||||
EXPECT(Dart_IsError(result));
|
||||
EXPECT_STREQ(
|
||||
"Dart_SetNativeResolver expects argument 'library' to be non-null.",
|
||||
Dart_GetError(result));
|
||||
EXPECT_ERROR(
|
||||
result,
|
||||
"Dart_SetNativeResolver expects argument 'library' to be non-null.");
|
||||
|
||||
result = Dart_SetNativeResolver(Dart_True(), &MyNativeResolver1, NULL);
|
||||
EXPECT(Dart_IsError(result));
|
||||
EXPECT_STREQ(
|
||||
"Dart_SetNativeResolver expects argument 'library' to be of "
|
||||
"type Library.",
|
||||
Dart_GetError(result));
|
||||
EXPECT_ERROR(result,
|
||||
"Dart_SetNativeResolver expects argument 'library' to be of "
|
||||
"type Library.");
|
||||
|
||||
result = Dart_SetNativeResolver(error, &MyNativeResolver1, NULL);
|
||||
EXPECT(Dart_IsError(result));
|
||||
|
|
|
@ -94,6 +94,7 @@ class ObjectPointerVisitor;
|
|||
V(DefaultLabel, ":L") \
|
||||
V(DotCreate, "._create") \
|
||||
V(DotRange, ".range") \
|
||||
V(DotUnder, "._") \
|
||||
V(DotValue, ".value") \
|
||||
V(DotWithType, "._withType") \
|
||||
V(Double, "double") \
|
||||
|
@ -330,7 +331,7 @@ class ObjectPointerVisitor;
|
|||
V(_Float64x2List, "_Float64x2List") \
|
||||
V(_GrowableList, "_GrowableList") \
|
||||
V(_GrowableListFactory, "_GrowableList.") \
|
||||
V(_GrowableListWithData, "_GrowableList.withData") \
|
||||
V(_GrowableListWithData, "_GrowableList._withData") \
|
||||
V(_ImmutableList, "_ImmutableList") \
|
||||
V(_Int16ArrayFactory, "Int16List.") \
|
||||
V(_Int16ArrayView, "_Int16ArrayView") \
|
||||
|
|
|
@ -546,7 +546,7 @@ class RawDatagramSocket {
|
|||
@patch
|
||||
class _SecureFilter {
|
||||
@patch
|
||||
factory _SecureFilter() {
|
||||
factory _SecureFilter._() {
|
||||
throw UnsupportedError("_SecureFilter._SecureFilter");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -546,7 +546,7 @@ class RawDatagramSocket {
|
|||
@patch
|
||||
class _SecureFilter {
|
||||
@patch
|
||||
factory _SecureFilter() {
|
||||
factory _SecureFilter._() {
|
||||
throw new UnsupportedError("_SecureFilter._SecureFilter");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -414,7 +414,7 @@ class ZLibEncoder extends Converter<List<int>, List<int>> {
|
|||
if (sink is! ByteConversionSink) {
|
||||
sink = new ByteConversionSink.from(sink);
|
||||
}
|
||||
return new _ZLibEncoderSink(
|
||||
return new _ZLibEncoderSink._(
|
||||
sink, gzip, level, windowBits, memLevel, strategy, dictionary, raw);
|
||||
}
|
||||
}
|
||||
|
@ -476,7 +476,7 @@ class ZLibDecoder extends Converter<List<int>, List<int>> {
|
|||
if (sink is! ByteConversionSink) {
|
||||
sink = new ByteConversionSink.from(sink);
|
||||
}
|
||||
return new _ZLibDecoderSink(sink, windowBits, dictionary, raw);
|
||||
return new _ZLibDecoderSink._(sink, windowBits, dictionary, raw);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -562,7 +562,7 @@ class _BufferSink extends ByteConversionSink {
|
|||
}
|
||||
|
||||
class _ZLibEncoderSink extends _FilterSink {
|
||||
_ZLibEncoderSink(
|
||||
_ZLibEncoderSink._(
|
||||
ByteConversionSink sink,
|
||||
bool gzip,
|
||||
int level,
|
||||
|
@ -578,7 +578,7 @@ class _ZLibEncoderSink extends _FilterSink {
|
|||
}
|
||||
|
||||
class _ZLibDecoderSink extends _FilterSink {
|
||||
_ZLibDecoderSink(
|
||||
_ZLibDecoderSink._(
|
||||
ByteConversionSink sink, int windowBits, List<int> dictionary, bool raw)
|
||||
: super(sink,
|
||||
RawZLibFilter._makeZLibInflateFilter(windowBits, dictionary, raw));
|
||||
|
|
|
@ -460,7 +460,7 @@ class _RawSecureSocket extends Stream<RawSocketEvent>
|
|||
bool _filterPending = false;
|
||||
bool _filterActive = false;
|
||||
|
||||
_SecureFilter _secureFilter = new _SecureFilter();
|
||||
_SecureFilter _secureFilter = new _SecureFilter._();
|
||||
String _selectedProtocol;
|
||||
|
||||
static Future<_RawSecureSocket> connect(
|
||||
|
@ -1226,7 +1226,7 @@ class _ExternalBuffer {
|
|||
}
|
||||
|
||||
abstract class _SecureFilter {
|
||||
external factory _SecureFilter();
|
||||
external factory _SecureFilter._();
|
||||
|
||||
void connect(
|
||||
String hostName,
|
||||
|
|
|
@ -11,6 +11,7 @@ library test.invoke_natives;
|
|||
|
||||
import 'dart:mirrors';
|
||||
import 'dart:async';
|
||||
import 'dart:io';
|
||||
|
||||
// Methods to be skipped, by qualified name.
|
||||
var blacklist = [
|
||||
|
@ -30,22 +31,8 @@ var blacklist = [
|
|||
'dart.developer.debugger',
|
||||
|
||||
// Don't run blocking io calls.
|
||||
new RegExp(r".*Sync$"),
|
||||
|
||||
// These prevent the test from exiting.
|
||||
'dart.io.sleep',
|
||||
'dart._http.HttpServer.HttpServer.listenOn',
|
||||
|
||||
// These either cause the VM to segfault or throw uncatchable API errors.
|
||||
// TODO(15274): Fix them and remove from blacklist.
|
||||
'dart.io.SystemEncoding.decode', // Windows only
|
||||
'dart.io.SystemEncoding.encode', // Windows only
|
||||
|
||||
// These construct an object with an uninitialized native field.
|
||||
// TODO(23869): We could make this safer, but making the failure non-fatal
|
||||
// would we worthless aside from this test.
|
||||
'dart.io.X509Certificate.X509Certificate._',
|
||||
'dart.io._X509Impl._X509Impl',
|
||||
new RegExp(r".*Sync$"),
|
||||
|
||||
// Don't call private methods in dart.async as they may circumvent the zoned
|
||||
// error handling below.
|
||||
|
@ -141,7 +128,8 @@ var testZone;
|
|||
doOneTask() {
|
||||
if (queue.length == 0) {
|
||||
print('Done');
|
||||
return;
|
||||
// Forcibly exit as we likely opened sockets and timers during the fuzzing.
|
||||
exit(0);
|
||||
}
|
||||
|
||||
var task = queue.removeLast();
|
||||
|
|
Loading…
Reference in a new issue