mirror of
https://github.com/dart-lang/sdk
synced 2024-10-14 11:03:19 +00:00
[standalone] Remove dead Dart 1 loading code.
Change-Id: I5551a40819b1e011cf50fe0dc38c74fe45f81160 Reviewed-on: https://dart-review.googlesource.com/c/85841 Reviewed-by: Siva Annamalai <asiva@google.com> Commit-Queue: Ryan Macnak <rmacnak@google.com>
This commit is contained in:
parent
2a9780fde6
commit
d6373525f7
|
@ -246,30 +246,6 @@ String _resolveScriptUri(String scriptName) {
|
|||
return scriptUri.toString();
|
||||
}
|
||||
|
||||
// Embedder Entrypoint (gen_snapshot):
|
||||
// Resolve relative paths relative to working directory.
|
||||
@pragma("vm:entry-point")
|
||||
String _resolveInWorkingDirectory(String fileName) {
|
||||
if (!_setupCompleted) {
|
||||
_setupHooks();
|
||||
}
|
||||
if (_workingDirectory == null) {
|
||||
throw 'No current working directory set.';
|
||||
}
|
||||
var name = _sanitizeWindowsPath(fileName);
|
||||
|
||||
var uri = Uri.parse(name);
|
||||
if (uri.scheme != '') {
|
||||
throw 'Schemes are not supported when resolving filenames.';
|
||||
}
|
||||
uri = _workingDirectory.resolveUri(uri);
|
||||
|
||||
if (_traceLoading) {
|
||||
_log('Resolved in working directory: $fileName -> $uri');
|
||||
}
|
||||
return uri.toString();
|
||||
}
|
||||
|
||||
// Only used by vm/cc unit tests.
|
||||
Uri _resolvePackageUri(Uri uri) {
|
||||
assert(_packageRoot != null);
|
||||
|
@ -304,22 +280,6 @@ String _filePathFromUri(String userUri) {
|
|||
}
|
||||
}
|
||||
|
||||
// Embedder Entrypoint.
|
||||
@pragma("vm:entry-point")
|
||||
_libraryFilePath(String libraryUri) {
|
||||
if (!_setupCompleted) {
|
||||
_setupHooks();
|
||||
}
|
||||
int index = libraryUri.lastIndexOf('/');
|
||||
var path;
|
||||
if (index == -1) {
|
||||
path = './';
|
||||
} else {
|
||||
path = libraryUri.substring(0, index + 1);
|
||||
}
|
||||
return _filePathFromUri(path);
|
||||
}
|
||||
|
||||
// Register callbacks and hooks with the rest of the core libraries.
|
||||
@pragma("vm:entry-point")
|
||||
_setupHooks() {
|
||||
|
|
|
@ -35,7 +35,6 @@ namespace dart {
|
|||
namespace bin {
|
||||
|
||||
const char* DartUtils::original_working_directory = NULL;
|
||||
CommandLineOptions* DartUtils::url_mapping = NULL;
|
||||
const char* const DartUtils::kDartScheme = "dart:";
|
||||
const char* const DartUtils::kDartExtensionScheme = "dart-ext:";
|
||||
const char* const DartUtils::kAsyncLibURL = "dart:async";
|
||||
|
@ -69,23 +68,6 @@ static bool IsWindowsHost() {
|
|||
#endif // defined(HOST_OS_WINDOWS)
|
||||
}
|
||||
|
||||
const char* DartUtils::MapLibraryUrl(const char* url_string) {
|
||||
ASSERT(url_mapping != NULL);
|
||||
// We need to check if the passed in url is found in the url_mapping array,
|
||||
// in that case use the mapped entry.
|
||||
intptr_t len = strlen(url_string);
|
||||
for (intptr_t idx = 0; idx < url_mapping->count(); idx++) {
|
||||
const char* url_name = url_mapping->GetArgument(idx);
|
||||
if (!strncmp(url_string, url_name, len) && (url_name[len] == ',')) {
|
||||
const char* url_mapped_name = url_name + len + 1;
|
||||
if (strlen(url_mapped_name) != 0) {
|
||||
return url_mapped_name; // Found a mapping for this URL.
|
||||
}
|
||||
}
|
||||
}
|
||||
return NULL; // Did not find a mapping for this URL.
|
||||
}
|
||||
|
||||
int64_t DartUtils::GetIntegerValue(Dart_Handle value_obj) {
|
||||
int64_t value = 0;
|
||||
Dart_Handle result = Dart_IntegerToInt64(value_obj, &value);
|
||||
|
@ -394,23 +376,6 @@ Dart_Handle DartUtils::SetWorkingDirectory() {
|
|||
directory);
|
||||
}
|
||||
|
||||
Dart_Handle DartUtils::ResolveUriInWorkingDirectory(Dart_Handle script_uri) {
|
||||
const int kNumArgs = 1;
|
||||
Dart_Handle dart_args[kNumArgs];
|
||||
dart_args[0] = script_uri;
|
||||
return Dart_Invoke(DartUtils::LookupBuiltinLib(),
|
||||
NewString("_resolveInWorkingDirectory"), kNumArgs,
|
||||
dart_args);
|
||||
}
|
||||
|
||||
Dart_Handle DartUtils::LibraryFilePath(Dart_Handle library_uri) {
|
||||
const int kNumArgs = 1;
|
||||
Dart_Handle dart_args[kNumArgs];
|
||||
dart_args[0] = library_uri;
|
||||
return Dart_Invoke(DartUtils::LookupBuiltinLib(),
|
||||
NewString("_libraryFilePath"), kNumArgs, dart_args);
|
||||
}
|
||||
|
||||
Dart_Handle DartUtils::ResolveScript(Dart_Handle url) {
|
||||
const int kNumArgs = 1;
|
||||
Dart_Handle dart_args[kNumArgs];
|
||||
|
@ -792,17 +757,6 @@ bool DartUtils::SetOriginalWorkingDirectory() {
|
|||
return original_working_directory != nullptr;
|
||||
}
|
||||
|
||||
Dart_Handle DartUtils::GetCanonicalizableWorkingDirectory() {
|
||||
const char* str = DartUtils::original_working_directory;
|
||||
intptr_t len = strlen(str);
|
||||
if ((str[len] == '/') || (IsWindowsHost() && str[len] == '\\')) {
|
||||
return Dart_NewStringFromCString(str);
|
||||
}
|
||||
char* new_str = reinterpret_cast<char*>(Dart_ScopeAllocate(len + 2));
|
||||
snprintf(new_str, (len + 2), "%s%s", str, File::PathSeparator());
|
||||
return Dart_NewStringFromCString(new_str);
|
||||
}
|
||||
|
||||
void DartUtils::SetEnvironment(dart::SimpleHashMap* environment) {
|
||||
environment_ = environment;
|
||||
}
|
||||
|
|
|
@ -214,11 +214,7 @@ class DartUtils {
|
|||
}
|
||||
|
||||
static bool SetOriginalWorkingDirectory();
|
||||
static Dart_Handle GetCanonicalizableWorkingDirectory();
|
||||
|
||||
static const char* MapLibraryUrl(const char* url_string);
|
||||
|
||||
static Dart_Handle ResolveUriInWorkingDirectory(Dart_Handle script_uri);
|
||||
static Dart_Handle ResolveScript(Dart_Handle url);
|
||||
|
||||
enum MagicNumber {
|
||||
|
@ -239,9 +235,6 @@ class DartUtils {
|
|||
// Global state that stores the original working directory..
|
||||
static const char* original_working_directory;
|
||||
|
||||
// Global state that captures the URL mappings specified on the command line.
|
||||
static CommandLineOptions* url_mapping;
|
||||
|
||||
static const char* const kDartScheme;
|
||||
static const char* const kDartExtensionScheme;
|
||||
static const char* const kAsyncLibURL;
|
||||
|
@ -258,8 +251,6 @@ class DartUtils {
|
|||
static const char* const kHttpScheme;
|
||||
static const char* const kVMServiceLibURL;
|
||||
|
||||
static Dart_Handle LibraryFilePath(Dart_Handle library_uri);
|
||||
|
||||
static void SetEnvironment(dart::SimpleHashMap* environment);
|
||||
static Dart_Handle EnvironmentCallback(Dart_Handle name);
|
||||
|
||||
|
@ -585,61 +576,6 @@ class ScopedBlockingCall {
|
|||
DISALLOW_COPY_AND_ASSIGN(ScopedBlockingCall);
|
||||
};
|
||||
|
||||
// Where the argument to the constructor is the handle for an object
|
||||
// implementing List<int>, this class creates a scope in which the memory
|
||||
// backing the list can be accessed.
|
||||
//
|
||||
// Do not make Dart_ API calls while in a ScopedMemBuffer.
|
||||
// Do not call Dart_PropagateError while in a ScopedMemBuffer.
|
||||
class ScopedMemBuffer {
|
||||
public:
|
||||
explicit ScopedMemBuffer(Dart_Handle object) {
|
||||
if (!Dart_IsTypedData(object) && !Dart_IsList(object)) {
|
||||
Dart_ThrowException(
|
||||
DartUtils::NewDartArgumentError("Argument is not a List<int>"));
|
||||
}
|
||||
|
||||
uint8_t* bytes = NULL;
|
||||
intptr_t bytes_len = 0;
|
||||
bool is_typed_data = false;
|
||||
if (Dart_IsTypedData(object)) {
|
||||
is_typed_data = true;
|
||||
Dart_TypedData_Type typ;
|
||||
ThrowIfError(Dart_TypedDataAcquireData(
|
||||
object, &typ, reinterpret_cast<void**>(&bytes), &bytes_len));
|
||||
} else {
|
||||
ASSERT(Dart_IsList(object));
|
||||
ThrowIfError(Dart_ListLength(object, &bytes_len));
|
||||
bytes = Dart_ScopeAllocate(bytes_len);
|
||||
ASSERT(bytes != NULL);
|
||||
ThrowIfError(Dart_ListGetAsBytes(object, 0, bytes, bytes_len));
|
||||
}
|
||||
|
||||
object_ = object;
|
||||
bytes_ = bytes;
|
||||
bytes_len_ = bytes_len;
|
||||
is_typed_data_ = is_typed_data;
|
||||
}
|
||||
|
||||
~ScopedMemBuffer() {
|
||||
if (is_typed_data_) {
|
||||
ThrowIfError(Dart_TypedDataReleaseData(object_));
|
||||
}
|
||||
}
|
||||
|
||||
uint8_t* get() const { return bytes_; }
|
||||
intptr_t length() const { return bytes_len_; }
|
||||
|
||||
private:
|
||||
Dart_Handle object_;
|
||||
uint8_t* bytes_;
|
||||
intptr_t bytes_len_;
|
||||
bool is_typed_data_;
|
||||
|
||||
DISALLOW_ALLOCATION();
|
||||
DISALLOW_COPY_AND_ASSIGN(ScopedMemBuffer);
|
||||
};
|
||||
|
||||
struct MagicNumberData {
|
||||
static const intptr_t kMaxLength = 8;
|
||||
|
||||
|
|
|
@ -147,14 +147,6 @@ BOOL_OPTIONS_LIST(BOOL_OPTION_DEFINITION)
|
|||
#undef BOOL_OPTION_DEFINITION
|
||||
|
||||
DEFINE_ENUM_OPTION(snapshot_kind, SnapshotKind, snapshot_kind);
|
||||
DEFINE_STRING_OPTION_CB(embedder_entry_points_manifest, {
|
||||
Log::PrintErr(
|
||||
"Option --embedder_entry_points_manifest is no longer supported."
|
||||
" Use @pragma(\'vm:entry-point\') instead.\n");
|
||||
exit(kErrorExitCode);
|
||||
});
|
||||
DEFINE_STRING_OPTION_CB(url_mapping,
|
||||
{ DartUtils::url_mapping->AddArgument(value); });
|
||||
DEFINE_CB_OPTION(ProcessEnvironmentOption);
|
||||
|
||||
static bool IsSnapshottingForPrecompilation() {
|
||||
|
@ -173,9 +165,6 @@ static void PrintUsage() {
|
|||
" Where to find packages, that is, package:... imports. \n"
|
||||
"--packages=<packages_file> \n"
|
||||
" Where to find a package spec file \n"
|
||||
"--url_mapping=<mapping> \n"
|
||||
" Uses the URL mapping(s) specified on the command line to load the \n"
|
||||
" libraries. \n"
|
||||
"--dependencies=<output-file> \n"
|
||||
" Generates a Makefile with snapshot output files as targets and all \n"
|
||||
" transitive imports as sources. \n"
|
||||
|
@ -940,10 +929,6 @@ int main(int argc, char** argv) {
|
|||
const int EXTRA_VM_ARGUMENTS = 7;
|
||||
CommandLineOptions vm_options(argc + EXTRA_VM_ARGUMENTS);
|
||||
|
||||
// Initialize the URL mapping array.
|
||||
CommandLineOptions cmdline_url_mapping(argc);
|
||||
DartUtils::url_mapping = &cmdline_url_mapping;
|
||||
|
||||
// When running from the command line we assume that we are optimizing for
|
||||
// throughput, and therefore use a larger new gen semi space size and a faster
|
||||
// new gen growth factor unless others have been specified.
|
||||
|
|
|
@ -54,11 +54,6 @@ def BuildOptions():
|
|||
result.add_option("--packages",
|
||||
action="store", type="string",
|
||||
help="package config file used to reasolve package: imports.")
|
||||
result.add_option("--url_mapping",
|
||||
default=[],
|
||||
action="append",
|
||||
help=("mapping from url to file name, used when generating snapshots " +
|
||||
"E.g.: --url_mapping=fileUri,/path/to/file.dart"))
|
||||
result.add_option("-v", "--verbose",
|
||||
help='Verbose output.',
|
||||
default=False, action="store_true")
|
||||
|
@ -143,11 +138,6 @@ def Main():
|
|||
script_args.append(''.join([ "--isolate_snapshot_instructions=",
|
||||
options.isolate_instructions_output_bin ]))
|
||||
|
||||
# Next setup all url mapping options specified.
|
||||
for url_arg in options.url_mapping:
|
||||
url_mapping_argument = ''.join(["--url_mapping=", url_arg ])
|
||||
script_args.append(url_mapping_argument)
|
||||
|
||||
# Finally append the script name if one is specified.
|
||||
if options.script:
|
||||
script_args.append(options.script)
|
||||
|
|
Loading…
Reference in a new issue