Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
dartdev_isolate.h
Go to the documentation of this file.
1// Copyright (c) 2020, the Dart project authors. Please see the AUTHORS file
2// for details. All rights reserved. Use of this source code is governed by a
3// BSD-style license that can be found in the LICENSE file.
4
5#ifndef RUNTIME_BIN_DARTDEV_ISOLATE_H_
6#define RUNTIME_BIN_DARTDEV_ISOLATE_H_
7
8#if !defined(DART_PRECOMPILED_RUNTIME)
9
10#include <memory>
11
12#include "bin/thread.h"
13#include "include/dart_api.h"
15#include "platform/globals.h"
16#include "platform/utils.h"
17
18#define DART_DEV_ISOLATE_NAME "dartdev"
19
20namespace dart {
21namespace bin {
22
23class CommandLineOptions;
24
26 public:
27 // Note: keep in sync with pkg/dartdev/lib/vm_interop_handler.dart
33
34 // Returns true if there does not exist a file at |script_uri| or the URI is
35 // not an HTTP resource.
36 static bool ShouldParseCommand(const char* script_uri);
37
38 static void set_should_run_dart_dev(bool enable) {
39 should_run_dart_dev_ = enable;
40 }
41
42 static void PrintUsageErrorOnRun() {
44 print_usage_error_ = true;
45 }
46
47 static bool should_run_dart_dev() { return should_run_dart_dev_; }
48
49 // Attempts to find the path of the DartDev snapshot.
51
52 // Starts a DartDev instance in a new isolate and runs it to completion.
53 //
54 // Returns true if the VM should run the result in `script`, in which case
55 // `script` and `dart_options` will have been repopulated with the correct
56 // values.
59 char** packages_file,
60 char** script,
61 CommandLineOptions* dart_options);
62
63 protected:
65 public:
67
68 void Run(Dart_IsolateGroupCreateCallback create_isolate,
69 char** package_config_override_,
70 char** script,
71 CommandLineOptions* dart_options);
72
73 DartDev_Result result() const { return result_; }
74
75 private:
76 static void DartDevResultCallback(Dart_Port dest_port_id,
78 static void RunCallback(uword arg);
79 static void ProcessError(const char* msg, int32_t exit_code);
80
81 static DartDev_Result result_;
82 static char** script_;
83 static char** package_config_override_;
84 static std::unique_ptr<char*[], void (*)(char**)> argv_;
85 static intptr_t argc_;
86
87 Dart_IsolateGroupCreateCallback create_isolate_;
88 CommandLineOptions* dart_options_;
89 const char* packages_file_;
90 static Monitor* monitor_;
91
92 DISALLOW_ALLOCATION();
93 };
94
95 private:
96 static Utils::CStringUniquePtr TryResolveArtifactPath(const char* filename);
97
98 static DartDevRunner runner_;
99 static bool should_run_dart_dev_;
100 static bool print_usage_error_;
101
102 DISALLOW_ALLOCATION();
104};
105
106} // namespace bin
107} // namespace dart
108
109#endif // !defined(DART_PRECOMPILED_RUNTIME)
110#endif // RUNTIME_BIN_DARTDEV_ISOLATE_H_
std::unique_ptr< char, decltype(std::free) * > CStringUniquePtr
Definition utils.h:644
void Run(Dart_IsolateGroupCreateCallback create_isolate, char **package_config_override_, char **script, CommandLineOptions *dart_options)
static bool should_run_dart_dev()
static void PrintUsageErrorOnRun()
static void set_should_run_dart_dev(bool enable)
static Utils::CStringUniquePtr TryResolveDartDevSnapshotPath()
static DartDev_Result RunDartDev(Dart_IsolateGroupCreateCallback create_isolate, char **packages_file, char **script, CommandLineOptions *dart_options)
static bool ShouldParseCommand(const char *script_uri)
Dart_Isolate(* Dart_IsolateGroupCreateCallback)(const char *script_uri, const char *main, const char *package_root, const char *package_config, Dart_IsolateFlags *flags, void *isolate_data, char **error)
Definition dart_api.h:653
int64_t Dart_Port
Definition dart_api.h:1524
Win32Message message
uintptr_t uword
Definition globals.h:501
#define DISALLOW_IMPLICIT_CONSTRUCTORS(TypeName)
Definition globals.h:593