| OLD | NEW |
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 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. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef RUNTIME_BIN_PLATFORM_H_ | 5 #ifndef RUNTIME_BIN_PLATFORM_H_ |
| 6 #define RUNTIME_BIN_PLATFORM_H_ | 6 #define RUNTIME_BIN_PLATFORM_H_ |
| 7 | 7 |
| 8 #include "bin/builtin.h" | 8 #include "bin/builtin.h" |
| 9 #include "platform/globals.h" | 9 #include "platform/globals.h" |
| 10 | 10 |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 56 // strings is Dart_ScopeAllocated. The number of elements in the array is | 56 // strings is Dart_ScopeAllocated. The number of elements in the array is |
| 57 // returned in the count argument. | 57 // returned in the count argument. |
| 58 static char** Environment(intptr_t* count); | 58 static char** Environment(intptr_t* count); |
| 59 | 59 |
| 60 static const char* ResolveExecutablePath(); | 60 static const char* ResolveExecutablePath(); |
| 61 | 61 |
| 62 // Stores the executable name. | 62 // Stores the executable name. |
| 63 static void SetExecutableName(const char* executable_name) { | 63 static void SetExecutableName(const char* executable_name) { |
| 64 executable_name_ = executable_name; | 64 executable_name_ = executable_name; |
| 65 } | 65 } |
| 66 static const char* GetExecutableName() { | 66 static const char* GetExecutableName() { return executable_name_; } |
| 67 return executable_name_; | |
| 68 } | |
| 69 static const char* GetResolvedExecutableName() { | 67 static const char* GetResolvedExecutableName() { |
| 70 if (resolved_executable_name_ == NULL) { | 68 if (resolved_executable_name_ == NULL) { |
| 71 // Try to resolve the executable path using platform specific APIs. | 69 // Try to resolve the executable path using platform specific APIs. |
| 72 const char* resolved_name = Platform::ResolveExecutablePath(); | 70 const char* resolved_name = Platform::ResolveExecutablePath(); |
| 73 if (resolved_name != NULL) { | 71 if (resolved_name != NULL) { |
| 74 resolved_executable_name_ = strdup(resolved_name); | 72 resolved_executable_name_ = strdup(resolved_name); |
| 75 } | 73 } |
| 76 } | 74 } |
| 77 return resolved_executable_name_; | 75 return resolved_executable_name_; |
| 78 } | 76 } |
| 79 | 77 |
| 80 // Stores and gets the flags passed to the executable. | 78 // Stores and gets the flags passed to the executable. |
| 81 static void SetExecutableArguments(int script_index, char** argv) { | 79 static void SetExecutableArguments(int script_index, char** argv) { |
| 82 script_index_ = script_index; | 80 script_index_ = script_index; |
| 83 argv_ = argv; | 81 argv_ = argv; |
| 84 } | 82 } |
| 85 static int GetScriptIndex() { | 83 static int GetScriptIndex() { return script_index_; } |
| 86 return script_index_; | 84 static char** GetArgv() { return argv_; } |
| 87 } | |
| 88 static char** GetArgv() { | |
| 89 return argv_; | |
| 90 } | |
| 91 | 85 |
| 92 static DART_NORETURN void Exit(int exit_code); | 86 static DART_NORETURN void Exit(int exit_code); |
| 93 | 87 |
| 94 private: | 88 private: |
| 95 // The path to the executable. | 89 // The path to the executable. |
| 96 static const char* executable_name_; | 90 static const char* executable_name_; |
| 97 // The path to the resolved executable. | 91 // The path to the resolved executable. |
| 98 static char* resolved_executable_name_; | 92 static char* resolved_executable_name_; |
| 99 | 93 |
| 100 static int script_index_; | 94 static int script_index_; |
| 101 static char** argv_; // VM flags are argv_[1 ... script_index_ - 1] | 95 static char** argv_; // VM flags are argv_[1 ... script_index_ - 1] |
| 102 | 96 |
| 103 DISALLOW_ALLOCATION(); | 97 DISALLOW_ALLOCATION(); |
| 104 DISALLOW_IMPLICIT_CONSTRUCTORS(Platform); | 98 DISALLOW_IMPLICIT_CONSTRUCTORS(Platform); |
| 105 }; | 99 }; |
| 106 | 100 |
| 107 } // namespace bin | 101 } // namespace bin |
| 108 } // namespace dart | 102 } // namespace dart |
| 109 | 103 |
| 110 #endif // RUNTIME_BIN_PLATFORM_H_ | 104 #endif // RUNTIME_BIN_PLATFORM_H_ |
| OLD | NEW |