| 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 BIN_PLATFORM_H_ | 5 #ifndef BIN_PLATFORM_H_ |
| 6 #define BIN_PLATFORM_H_ | 6 #define BIN_PLATFORM_H_ |
| 7 | 7 |
| 8 #include "bin/builtin.h" | 8 #include "bin/builtin.h" |
| 9 | 9 |
| 10 namespace dart { | 10 namespace dart { |
| (...skipping 30 matching lines...) Expand all Loading... |
| 41 // Stores the executable name. | 41 // Stores the executable name. |
| 42 static void SetExecutableName(const char* executable_name) { | 42 static void SetExecutableName(const char* executable_name) { |
| 43 executable_name_ = executable_name; | 43 executable_name_ = executable_name; |
| 44 } | 44 } |
| 45 static const char* GetExecutableName() { | 45 static const char* GetExecutableName() { |
| 46 return executable_name_; | 46 return executable_name_; |
| 47 } | 47 } |
| 48 static const char* GetResolvedExecutableName() { | 48 static const char* GetResolvedExecutableName() { |
| 49 if (resolved_executable_name_ == NULL) { | 49 if (resolved_executable_name_ == NULL) { |
| 50 // Try to resolve the executable path using platform specific APIs. | 50 // Try to resolve the executable path using platform specific APIs. |
| 51 resolved_executable_name_ = Platform::ResolveExecutablePath(); | 51 resolved_executable_name_ = strdup(Platform::ResolveExecutablePath()); |
| 52 } | 52 } |
| 53 return resolved_executable_name_; | 53 return resolved_executable_name_; |
| 54 } | 54 } |
| 55 | 55 |
| 56 // Stores and gets the flags passed to the executable. | 56 // Stores and gets the flags passed to the executable. |
| 57 static void SetExecutableArguments(int script_index, char** argv) { | 57 static void SetExecutableArguments(int script_index, char** argv) { |
| 58 script_index_ = script_index; | 58 script_index_ = script_index; |
| 59 argv_ = argv; | 59 argv_ = argv; |
| 60 } | 60 } |
| 61 static int GetScriptIndex() { | 61 static int GetScriptIndex() { |
| 62 return script_index_; | 62 return script_index_; |
| 63 } | 63 } |
| 64 static char** GetArgv() { | 64 static char** GetArgv() { |
| 65 return argv_; | 65 return argv_; |
| 66 } | 66 } |
| 67 | 67 |
| 68 static DART_NORETURN void Exit(int exit_code); | 68 static DART_NORETURN void Exit(int exit_code); |
| 69 | 69 |
| 70 private: | 70 private: |
| 71 // The path to the executable. | 71 // The path to the executable. |
| 72 static const char* executable_name_; | 72 static const char* executable_name_; |
| 73 // The path to the resolved executable. | 73 // The path to the resolved executable. |
| 74 static const char* resolved_executable_name_; | 74 static char* resolved_executable_name_; |
| 75 | 75 |
| 76 static int script_index_; | 76 static int script_index_; |
| 77 static char** argv_; // VM flags are argv_[1 ... script_index_ - 1] | 77 static char** argv_; // VM flags are argv_[1 ... script_index_ - 1] |
| 78 | 78 |
| 79 DISALLOW_ALLOCATION(); | 79 DISALLOW_ALLOCATION(); |
| 80 DISALLOW_IMPLICIT_CONSTRUCTORS(Platform); | 80 DISALLOW_IMPLICIT_CONSTRUCTORS(Platform); |
| 81 }; | 81 }; |
| 82 | 82 |
| 83 } // namespace bin | 83 } // namespace bin |
| 84 } // namespace dart | 84 } // namespace dart |
| 85 | 85 |
| 86 #endif // BIN_PLATFORM_H_ | 86 #endif // BIN_PLATFORM_H_ |
| OLD | NEW |