b62b438e8a
For method, getter, and setter invocations with names of methods on Object on expressions with static type `dynamic`, if the invocation cannot possibly be an invocation of noSuchMethod, infer the type of the invocation using the type of the member of Object. This implements the feature spec https://github.com/dart-lang/sdk/commit/472ec7780f1bb38f049d0fcc903a69bfb8ef9133 Fixes https://github.com/dart-lang/sdk/issues/32414 Change-Id: I135156346fe1468561d56a01cf3c5f0efde30739 Reviewed-on: https://dart-review.googlesource.com/56942 Commit-Queue: Kevin Millikin <kmillikin@google.com> Reviewed-by: Dmitry Stefantsov <dmitryas@google.com>
143 lines
4.0 KiB
Dart
143 lines
4.0 KiB
Dart
// Copyright (c) 2018, 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.
|
|
|
|
// Selection of methods used during bootstrapping.
|
|
|
|
// ignore_for_file: native_function_body_in_non_sdk_code
|
|
// ignore_for_file: unused_element, unused_field
|
|
|
|
// -----------------------------------------------------------------
|
|
|
|
void _printString(String s) native "Builtin_PrintString";
|
|
|
|
void _print(arg) {
|
|
_printString(arg.toString());
|
|
}
|
|
|
|
_getPrintClosure() => _print;
|
|
|
|
// -----------------------------------------------------------------
|
|
|
|
typedef void _ScheduleImmediateClosure(void callback());
|
|
|
|
class _ScheduleImmediate {
|
|
static _ScheduleImmediateClosure _closure;
|
|
}
|
|
|
|
void _setScheduleImmediateClosure(_ScheduleImmediateClosure closure) {
|
|
_ScheduleImmediate._closure = closure;
|
|
}
|
|
|
|
// -----------------------------------------------------------------
|
|
|
|
class _NamespaceImpl 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);
|
|
}
|
|
|
|
class _Namespace {
|
|
static void _setupNamespace(var namespace) {
|
|
_NamespaceImpl._setupNamespace(namespace);
|
|
}
|
|
|
|
static _Namespace get _namespace => _NamespaceImpl._namespace;
|
|
|
|
static int get _namespacePointer => _NamespaceImpl._namespacePointer;
|
|
}
|
|
|
|
// -----------------------------------------------------------------
|
|
|
|
// These may be set to different values by the embedder by calling
|
|
// _setStdioFDs when initializing dart:io.
|
|
int _stdinFD = 0;
|
|
int _stdoutFD = 1;
|
|
int _stderrFD = 2;
|
|
|
|
// This is an embedder entrypoint.
|
|
void _setStdioFDs(int stdin, int stdout, int stderr) {
|
|
_stdinFD = stdin;
|
|
_stdoutFD = stdout;
|
|
_stderrFD = stderr;
|
|
}
|
|
|
|
// -----------------------------------------------------------------
|
|
|
|
class VMLibraryHooks {
|
|
// Example: "dart:isolate _Timer._factory"
|
|
static var timerFactory;
|
|
|
|
// Example: "dart:io _EventHandler._sendData"
|
|
static var eventHandlerSendData;
|
|
|
|
// A nullary closure that answers the current clock value in milliseconds.
|
|
// Example: "dart:io _EventHandler._timerMillisecondClock"
|
|
static var timerMillisecondClock;
|
|
|
|
// Implementation of Resource.readAsBytes.
|
|
static var resourceReadAsBytes;
|
|
|
|
// Implementation of package root/map provision.
|
|
static var packageRootString;
|
|
static var packageConfigString;
|
|
static var packageRootUriFuture;
|
|
static var packageConfigUriFuture;
|
|
static var resolvePackageUriFuture;
|
|
|
|
static var _computeScriptUri;
|
|
static var _cachedScript;
|
|
static set platformScript(var f) {
|
|
_computeScriptUri = f;
|
|
_cachedScript = null;
|
|
}
|
|
|
|
static get platformScript {
|
|
if (_cachedScript == null && _computeScriptUri != null) {
|
|
_cachedScript = _computeScriptUri();
|
|
}
|
|
return _cachedScript;
|
|
}
|
|
}
|
|
|
|
String _rawScript;
|
|
Uri _scriptUri() {
|
|
if (_rawScript.startsWith('http:') ||
|
|
_rawScript.startsWith('https:') ||
|
|
_rawScript.startsWith('file:')) {
|
|
return Uri.parse(_rawScript);
|
|
} else {
|
|
return Uri.base.resolveUri(new Uri.file(_rawScript));
|
|
}
|
|
}
|
|
|
|
_setupHooks() {
|
|
VMLibraryHooks.platformScript = _scriptUri;
|
|
}
|
|
|
|
// -----------------------------------------------------------------
|
|
|
|
main() {}
|