OLD | NEW |
1 // Copyright (c) 2015, the Dartino project authors. Please see the AUTHORS file | 1 // Copyright (c) 2015, the Dartino 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.md file. | 3 // BSD-style license that can be found in the LICENSE.md file. |
4 | 4 |
5 #ifndef FLETCH_ENABLE_LIVE_CODING | 5 #ifndef DARTINO_ENABLE_LIVE_CODING |
6 | 6 |
7 #include <stdio.h> | 7 #include <stdio.h> |
8 #include <stdlib.h> | 8 #include <stdlib.h> |
9 #include <ctype.h> | 9 #include <ctype.h> |
10 | 10 |
11 #include "include/fletch_api.h" | 11 #include "include/dartino_api.h" |
12 | 12 |
13 #include "src/shared/flags.h" | 13 #include "src/shared/flags.h" |
14 #include "src/shared/list.h" | 14 #include "src/shared/list.h" |
15 #include "src/shared/utils.h" | 15 #include "src/shared/utils.h" |
16 #include "src/shared/platform.h" | 16 #include "src/shared/platform.h" |
17 | 17 |
18 namespace fletch { | 18 namespace dartino { |
19 | 19 |
20 static bool IsSnapshot(List<uint8> snapshot) { | 20 static bool IsSnapshot(List<uint8> snapshot) { |
21 return snapshot.length() > 2 && snapshot[0] == 0xbe && snapshot[1] == 0xef; | 21 return snapshot.length() > 2 && snapshot[0] == 0xbe && snapshot[1] == 0xef; |
22 } | 22 } |
23 | 23 |
24 static int Main(int argc, char** argv) { | 24 static int Main(int argc, char** argv) { |
25 Flags::ExtractFromCommandLine(&argc, argv); | 25 Flags::ExtractFromCommandLine(&argc, argv); |
26 FletchSetup(); | 26 DartinoSetup(); |
27 | 27 |
28 int program_count = argc - 1; | 28 int program_count = argc - 1; |
29 | 29 |
30 FletchProgram* programs = new FletchProgram[program_count]; | 30 DartinoProgram* programs = new DartinoProgram[program_count]; |
31 | 31 |
32 for (int i = 0; i < program_count; i++) { | 32 for (int i = 0; i < program_count; i++) { |
33 // Handle the arguments. | 33 // Handle the arguments. |
34 const char* input = argv[i + 1]; | 34 const char* input = argv[i + 1]; |
35 List<uint8> bytes = Platform::LoadFile(input); | 35 List<uint8> bytes = Platform::LoadFile(input); |
36 if (!IsSnapshot(bytes)) { | 36 if (!IsSnapshot(bytes)) { |
37 FATAL("The input file is not a fletch snapshot."); | 37 FATAL("The input file is not a dartino snapshot."); |
38 } | 38 } |
39 | 39 |
40 FletchProgram program = FletchLoadSnapshot(bytes.data(), bytes.length()); | 40 DartinoProgram program = DartinoLoadSnapshot(bytes.data(), bytes.length()); |
41 programs[i] = program; | 41 programs[i] = program; |
42 } | 42 } |
43 | 43 |
44 int result = FletchRunMultipleMain(program_count, programs); | 44 int result = DartinoRunMultipleMain(program_count, programs); |
45 | 45 |
46 for (int i = 0; i < program_count; i++) { | 46 for (int i = 0; i < program_count; i++) { |
47 FletchDeleteProgram(programs[i]); | 47 DartinoDeleteProgram(programs[i]); |
48 } | 48 } |
49 | 49 |
50 delete[] programs; | 50 delete[] programs; |
51 | 51 |
52 FletchTearDown(); | 52 DartinoTearDown(); |
53 return result; | 53 return result; |
54 } | 54 } |
55 | 55 |
56 } // namespace fletch | 56 } // namespace dartino |
57 | 57 |
58 // Forward main calls to fletch::Main. | 58 // Forward main calls to dartino::Main. |
59 int main(int argc, char** argv) { return fletch::Main(argc, argv); } | 59 int main(int argc, char** argv) { return dartino::Main(argc, argv); } |
60 | 60 |
61 #endif // !FLETCH_ENABLE_LIVE_CODING | 61 #endif // !DARTINO_ENABLE_LIVE_CODING |
OLD | NEW |