[ VM / CFE ] Removed changes introduced in c7e4a7d333 which allowed for dart:_internal to be imported for tests and updated DartAPI_InvokeNoSuchMethod to not depend on dart:_internal.

Change-Id: Ia861f7ef9eb6de0ee79743592d3517011c66327e
Reviewed-on: https://dart-review.googlesource.com/52266
Reviewed-by: Zach Anderson <zra@google.com>
Commit-Queue: Ben Konyi <bkonyi@google.com>
This commit is contained in:
Ben Konyi 2018-04-24 22:14:48 +00:00 committed by commit-bot@chromium.org
parent 405dd275e9
commit b641826ccf
7 changed files with 7 additions and 58 deletions

View file

@ -22,13 +22,11 @@ class TargetFlags {
final bool syncAsync;
final List<ProgramRoot> programRoots;
final Uri kernelRuntime;
final bool allowDartInternalImport;
TargetFlags(
{this.strongMode: false,
this.treeShake: false,
this.syncAsync: false,
this.allowDartInternalImport: false,
this.programRoots: const <ProgramRoot>[],
this.kernelRuntime});
}

View file

@ -57,16 +57,6 @@ class VmTarget extends Target {
'dart:cli',
];
@override
bool allowPlatformPrivateLibraryAccess(Uri importer, Uri imported) {
if (flags.allowDartInternalImport &&
(imported.scheme == 'dart') &&
(imported.path == '_internal')) {
return true;
}
return super.allowPlatformPrivateLibraryAccess(importer, imported);
}
@override
void performModularTransformationsOnLibraries(
CoreTypes coreTypes, ClassHierarchy hierarchy, List<Library> libraries,

View file

@ -49,14 +49,10 @@ const String platformKernelFile = 'virtual_platform_kernel.dill';
// 1 - Update in-memory file system with in-memory sources (used by tests).
// 2 - Accept last compilation result.
// 3 - APP JIT snapshot training run for kernel_service.
// 4 - Allows for `dart:_internal` to be imported (used by tests).
const int kCompileTag = 0;
const int kUpdateSourcesTag = 1;
const int kAcceptTag = 2;
const int kTrainTag = 3;
const int kAllowDartInternalImportTag = 4;
bool allowDartInternalImport = false;
abstract class Compiler {
final FileSystem fileSystem;
@ -80,16 +76,13 @@ abstract class Compiler {
print("DFE: platformKernelPath: ${platformKernelPath}");
print("DFE: strongMode: ${strongMode}");
print("DFE: syncAsync: ${syncAsync}");
print("DFE: allowDartInternalImport: ${allowDartInternalImport}");
}
options = new CompilerOptions()
..strongMode = strongMode
..fileSystem = fileSystem
..target = new VmTarget(new TargetFlags(
strongMode: strongMode,
syncAsync: syncAsync,
allowDartInternalImport: allowDartInternalImport))
..target = new VmTarget(
new TargetFlags(strongMode: strongMode, syncAsync: syncAsync))
..packagesFileUri = packagesUri
..sdkSummary = platformKernelPath
..verbose = verbose
@ -288,15 +281,6 @@ Future _processLoadRequest(request) async {
}
port.send(new CompilationResult.ok(null).toResponse());
return;
} else if (tag == kAllowDartInternalImportTag) {
compiler = lookupIncrementalCompiler(isolateId);
assert(
lookupIncrementalCompiler(isolateId) == null,
"allowDartInternalImport must be set before creating a compiler"
" instance.");
allowDartInternalImport = true;
port.send(new CompilationResult.ok(null).toResponse());
return;
}
// script should only be null for kUpdateSourcesTag.

View file

@ -5003,7 +5003,6 @@ TEST_CASE(DartAPI_Invoke_Null) {
TEST_CASE(DartAPI_InvokeNoSuchMethod) {
const char* kScriptChars =
"import 'dart:_internal' as _internal;\n"
"class Expect {\n"
" static equals(a, b) {\n"
" if (a != b) {\n"
@ -5014,7 +5013,11 @@ TEST_CASE(DartAPI_InvokeNoSuchMethod) {
"class TestClass {\n"
" static int fld1 = 0;\n"
" void noSuchMethod(Invocation invocation) {\n"
" var name = _internal.Symbol.getName(invocation.memberName);\n"
// This relies on the Symbol.toString() method returning a String of the
// form 'Symbol("name")'. This is to avoid having to import
// dart:_internal just to get access to the name of the symbol.
" var name = invocation.memberName.toString();\n"
" name = name.split('\"')[1];\n"
" if (name == 'fld') {\n"
" Expect.equals(true, invocation.isGetter);\n"
" Expect.equals(false, invocation.isMethod);\n"

View file

@ -48,12 +48,10 @@ const char* KernelIsolate::kName = DART_KERNEL_ISOLATE_NAME;
// 1 - Update in-memory file system with in-memory sources (used by tests).
// 2 - Accept last compilation result.
// 3 - APP JIT snapshot training run for kernel_service.
// 4 - Allows for `dart:_internal` to be imported (used by tests).
const int KernelIsolate::kCompileTag = 0;
const int KernelIsolate::kUpdateSourcesTag = 1;
const int KernelIsolate::kAcceptTag = 2;
const int KernelIsolate::kTrainTag = 3;
const int KernelIsolate::kAllowDartInternalImportTag = 4;
Dart_IsolateCreateCallback KernelIsolate::create_callback_ = NULL;
Monitor* KernelIsolate::monitor_ = new Monitor();
@ -611,23 +609,6 @@ Dart_KernelCompilationResult KernelIsolate::UpdateInMemorySources(
NULL, 0, source_files_count,
source_files, true);
}
Dart_KernelCompilationResult KernelIsolate::AllowDartInternalImport() {
// This must be the main script to be loaded. Wait for Kernel isolate
// to finish initialization.
Dart_Port kernel_port = WaitForKernelPort();
if (kernel_port == ILLEGAL_PORT) {
Dart_KernelCompilationResult result;
result.status = Dart_KernelCompilationStatus_Unknown;
result.error = strdup("Error while initializing Kernel isolate");
return result;
}
KernelCompilationRequest request;
return request.SendAndWaitForResponse(
kAllowDartInternalImportTag, kernel_port, NULL, NULL, 0, 0, NULL, true);
}
#endif // DART_PRECOMPILED_RUNTIME
} // namespace dart

View file

@ -22,7 +22,6 @@ class KernelIsolate : public AllStatic {
static const int kUpdateSourcesTag;
static const int kAcceptTag;
static const int kTrainTag;
static const int kAllowDartInternalImportTag;
static void Run();
@ -45,7 +44,6 @@ class KernelIsolate : public AllStatic {
static Dart_KernelCompilationResult UpdateInMemorySources(
int source_files_count,
Dart_SourceFile source_files[]);
static Dart_KernelCompilationResult AllowDartInternalImport();
protected:
static Monitor* monitor_;

View file

@ -594,11 +594,6 @@ Dart_Handle TestCase::ReloadTestKernel(const void* kernel) {
Dart_Handle TestCase::LoadCoreTestScript(const char* script,
Dart_NativeEntryResolver resolver) {
if (FLAG_use_dart_frontend) {
// Sets a flag in the CFE to not throw an error if `dart:_internal` is
// imported from a non-internal library.
KernelIsolate::AllowDartInternalImport();
}
return LoadTestScript(script, resolver, CORELIB_TEST_URI);
}