[ddc] Cleanup use of dart library name
Avoid hard coded uses of the name for the SDK runtime library. This unblocks a more consistent name/rename logic for all dart libraries when they are imported. Change-Id: I4599006569ecae81a0526686467e06da9b335fc7 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/385188 Reviewed-by: Sigmund Cherem <sigmund@google.com> Commit-Queue: Nicholas Shahan <nshahan@google.com>
This commit is contained in:
committed by
Commit Queue
parent
c2b99d21c1
commit
39bcea7e76
@@ -6135,13 +6135,18 @@ class ProgramCompiler extends ComputeOnceConstantVisitor<js_ast.Expression>
|
||||
var typeArgs = node.arguments.types;
|
||||
var name = target.name.text;
|
||||
|
||||
if (args.isEmpty && typeArgs.length == 1) {
|
||||
if (name == 'TYPE_REF') {
|
||||
return _emitType(typeArgs.single);
|
||||
if (args.isEmpty) {
|
||||
if (typeArgs.isEmpty && name == 'DART_RUNTIME_LIBRARY') {
|
||||
return _runtimeModule;
|
||||
}
|
||||
if (name == 'LEGACY_TYPE_REF') {
|
||||
return _emitType(
|
||||
typeArgs.single.withDeclaredNullability(Nullability.legacy));
|
||||
if (typeArgs.length == 1) {
|
||||
if (name == 'TYPE_REF') {
|
||||
return _emitType(typeArgs.single);
|
||||
}
|
||||
if (name == 'LEGACY_TYPE_REF') {
|
||||
return _emitType(
|
||||
typeArgs.single.withDeclaredNullability(Nullability.legacy));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -6215,16 +6215,20 @@ class LibraryCompiler extends ComputeOnceConstantVisitor<js_ast.Expression>
|
||||
var typeArgs = node.arguments.types;
|
||||
var name = target.name.text;
|
||||
|
||||
if (args.isEmpty && typeArgs.length == 1) {
|
||||
if (name == 'TYPE_REF') {
|
||||
return _emitType(typeArgs.single);
|
||||
if (args.isEmpty) {
|
||||
if (typeArgs.isEmpty && name == 'DART_RUNTIME_LIBRARY') {
|
||||
return _runtimeModule;
|
||||
}
|
||||
if (name == 'LEGACY_TYPE_REF') {
|
||||
return _emitType(
|
||||
typeArgs.single.withDeclaredNullability(Nullability.legacy));
|
||||
if (typeArgs.length == 1) {
|
||||
if (name == 'TYPE_REF') {
|
||||
return _emitType(typeArgs.single);
|
||||
}
|
||||
if (name == 'LEGACY_TYPE_REF') {
|
||||
return _emitType(
|
||||
typeArgs.single.withDeclaredNullability(Nullability.legacy));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (args.length == 1) {
|
||||
if (name == 'getInterceptor') {
|
||||
var argExpression = args.single.accept(this);
|
||||
|
||||
@@ -9,6 +9,7 @@ import 'dart:async';
|
||||
import 'dart:_debugger' show stackTraceMapper, trackCall;
|
||||
import 'dart:_foreign_helper'
|
||||
show
|
||||
DART_RUNTIME_LIBRARY,
|
||||
JS,
|
||||
JS_CLASS_REF,
|
||||
JS_EMBEDDED_GLOBAL,
|
||||
@@ -182,7 +183,7 @@ final Object global_ = JS('', '''
|
||||
''');
|
||||
|
||||
void trackProfile(bool flag) {
|
||||
JS('', 'dart.__trackProfile = #', flag);
|
||||
JS('', '#.__trackProfile = #', DART_RUNTIME_LIBRARY(), flag);
|
||||
}
|
||||
|
||||
final JsSymbol = JS('', 'Symbol');
|
||||
@@ -208,7 +209,7 @@ final hOP = JS('!', '#.Object.prototype.hasOwnProperty', global_);
|
||||
///
|
||||
/// const my_library = Object.create(dart.library);
|
||||
///
|
||||
Object libraryPrototype = JS('', 'dart.library');
|
||||
Object libraryPrototype = JS('', '#.library', DART_RUNTIME_LIBRARY());
|
||||
|
||||
// TODO(vsm): Remove once this flag we've removed the ability to
|
||||
// whitelist / fallback on the old behavior.
|
||||
|
||||
@@ -7,7 +7,8 @@ library dart._debugger;
|
||||
import 'dart:_foreign_helper' show JS;
|
||||
import 'dart:_interceptors' show JSArray;
|
||||
import 'dart:_js_helper' show InternalMap, jsObjectGetPrototypeOf;
|
||||
import 'dart:_foreign_helper' show JS_GET_FLAG, JS_GET_NAME;
|
||||
import 'dart:_foreign_helper'
|
||||
show DART_RUNTIME_LIBRARY, JS_GET_FLAG, JS_GET_NAME;
|
||||
import 'dart:_js_shared_embedded_names' show JsGetName;
|
||||
import 'dart:_runtime' as dart;
|
||||
import 'dart:core';
|
||||
|
||||
@@ -335,3 +335,8 @@ external String JS_STRING_CONCAT(String a, String b);
|
||||
/// JavaScript.
|
||||
@notNull
|
||||
external Object JS_CLASS_REF(Type type);
|
||||
|
||||
/// Identifier used to access the dart:_runtime library object in the calling
|
||||
/// context.
|
||||
@notNull
|
||||
external Object DART_RUNTIME_LIBRARY();
|
||||
|
||||
@@ -7,7 +7,8 @@ library dart._js_helper;
|
||||
import 'dart:async' show Zone;
|
||||
import 'dart:collection';
|
||||
|
||||
import 'dart:_foreign_helper' show JS, JS_CLASS_REF, JS_GET_FLAG, JSExportName;
|
||||
import 'dart:_foreign_helper'
|
||||
show DART_RUNTIME_LIBRAY, JS, JS_CLASS_REF, JS_GET_FLAG, JSExportName;
|
||||
|
||||
import 'dart:_interceptors';
|
||||
import 'dart:_internal'
|
||||
|
||||
@@ -4,11 +4,6 @@
|
||||
|
||||
part of dart._js_helper;
|
||||
|
||||
// TODO(leafp): Maybe get rid of this? Currently used by the interceptors
|
||||
// library, but that should probably be culled as well.
|
||||
Type? getRuntimeType(object) =>
|
||||
JS('Type|null', 'dart.getReifiedType(#)', object);
|
||||
|
||||
/// Returns the property [index] of the JavaScript array [array].
|
||||
getIndex(array, int index) {
|
||||
assert(isJsArray(array));
|
||||
|
||||
@@ -106,7 +106,8 @@ clearDynamicStats() {
|
||||
|
||||
// We need to set this property while the sdk is only partially initialized
|
||||
// so we cannot use a regular Dart field.
|
||||
bool get _trackProfile => JS<bool>('!', 'dart.__trackProfile');
|
||||
bool get _trackProfile =>
|
||||
JS<bool>('!', '#.__trackProfile', DART_RUNTIME_LIBRARY());
|
||||
|
||||
trackCall(obj) {
|
||||
if (JS<bool>('!', '!#', _trackProfile)) return;
|
||||
|
||||
Reference in New Issue
Block a user