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 #if !defined(DART_IO_DISABLED) | 5 #if !defined(DART_IO_DISABLED) |
6 | 6 |
7 #include "bin/platform.h" | 7 #include "bin/platform.h" |
8 | 8 |
9 #include "bin/file.h" | 9 #include "bin/file.h" |
10 #include "bin/utils.h" | 10 #include "bin/utils.h" |
(...skipping 22 matching lines...) Expand all Loading... |
33 char hostname[HOSTNAME_LENGTH]; | 33 char hostname[HOSTNAME_LENGTH]; |
34 if (Platform::LocalHostname(hostname, HOSTNAME_LENGTH)) { | 34 if (Platform::LocalHostname(hostname, HOSTNAME_LENGTH)) { |
35 Dart_SetReturnValue(args, DartUtils::NewString(hostname)); | 35 Dart_SetReturnValue(args, DartUtils::NewString(hostname)); |
36 } else { | 36 } else { |
37 Dart_SetReturnValue(args, DartUtils::NewDartOSError()); | 37 Dart_SetReturnValue(args, DartUtils::NewDartOSError()); |
38 } | 38 } |
39 } | 39 } |
40 | 40 |
41 | 41 |
42 void FUNCTION_NAME(Platform_ExecutableName)(Dart_NativeArguments args) { | 42 void FUNCTION_NAME(Platform_ExecutableName)(Dart_NativeArguments args) { |
43 if (Dart_IsPrecompiledRuntime()) { | |
44 // This is a work-around to be able to use most of the existing test suite | |
45 // for precompilation. Many tests do something like Process.run( | |
46 // Platform.executable, some_other_script.dart). But with precompilation | |
47 // the script is already fixed, so the spawned process runs the same script | |
48 // again and we have a fork-bomb. | |
49 Dart_ThrowException(Dart_NewStringFromCString( | |
50 "Platform.executable not supported under precompilation")); | |
51 UNREACHABLE(); | |
52 } | |
53 if (Platform::GetExecutableName() != NULL) { | 43 if (Platform::GetExecutableName() != NULL) { |
54 Dart_SetReturnValue( | 44 Dart_SetReturnValue( |
55 args, Dart_NewStringFromCString(Platform::GetExecutableName())); | 45 args, Dart_NewStringFromCString(Platform::GetExecutableName())); |
56 } else { | 46 } else { |
57 Dart_SetReturnValue(args, Dart_Null()); | 47 Dart_SetReturnValue(args, Dart_Null()); |
58 } | 48 } |
59 } | 49 } |
60 | 50 |
61 | 51 |
62 void FUNCTION_NAME(Platform_ResolvedExecutableName)(Dart_NativeArguments args) { | 52 void FUNCTION_NAME(Platform_ResolvedExecutableName)(Dart_NativeArguments args) { |
63 if (Dart_IsPrecompiledRuntime()) { | |
64 Dart_ThrowException(Dart_NewStringFromCString( | |
65 "Platform.resolvedExecutable not supported under precompilation")); | |
66 UNREACHABLE(); | |
67 } | |
68 | |
69 if (Platform::GetResolvedExecutableName() != NULL) { | 53 if (Platform::GetResolvedExecutableName() != NULL) { |
70 Dart_SetReturnValue( | 54 Dart_SetReturnValue( |
71 args, Dart_NewStringFromCString(Platform::GetResolvedExecutableName())); | 55 args, Dart_NewStringFromCString(Platform::GetResolvedExecutableName())); |
72 } else { | 56 } else { |
73 Dart_SetReturnValue(args, Dart_Null()); | 57 Dart_SetReturnValue(args, Dart_Null()); |
74 } | 58 } |
75 } | 59 } |
76 | 60 |
77 | 61 |
78 void FUNCTION_NAME(Platform_ExecutableArguments)(Dart_NativeArguments args) { | 62 void FUNCTION_NAME(Platform_ExecutableArguments)(Dart_NativeArguments args) { |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
122 | 106 |
123 | 107 |
124 void FUNCTION_NAME(Platform_GetVersion)(Dart_NativeArguments args) { | 108 void FUNCTION_NAME(Platform_GetVersion)(Dart_NativeArguments args) { |
125 Dart_SetReturnValue(args, Dart_NewStringFromCString(Dart_VersionString())); | 109 Dart_SetReturnValue(args, Dart_NewStringFromCString(Dart_VersionString())); |
126 } | 110 } |
127 | 111 |
128 } // namespace bin | 112 } // namespace bin |
129 } // namespace dart | 113 } // namespace dart |
130 | 114 |
131 #endif // !defined(DART_IO_DISABLED) | 115 #endif // !defined(DART_IO_DISABLED) |
OLD | NEW |