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_BUILTIN_H_ | 5 #ifndef BIN_BUILTIN_H_ |
6 #define BIN_BUILTIN_H_ | 6 #define BIN_BUILTIN_H_ |
7 | 7 |
8 #include <stdio.h> | 8 #include <stdio.h> |
9 #include <stdlib.h> | 9 #include <stdlib.h> |
10 | 10 |
11 #include "include/dart_api.h" | 11 #include "include/dart_api.h" |
| 12 #include "platform/assert.h" |
12 #include "platform/globals.h" | 13 #include "platform/globals.h" |
13 | 14 |
14 #ifdef DEBUG | |
15 #define ASSERT(expr) assert(expr) | |
16 #else | |
17 #define ASSERT(expr) USE(expr) | |
18 #endif | |
19 | |
20 #define FATAL(error) \ | |
21 fprintf(stderr, "%s\n", error); \ | |
22 fflush(stderr); \ | |
23 abort(); | |
24 | |
25 #define UNREACHABLE() \ | |
26 FATAL("unreachable code") | |
27 | |
28 #define UNIMPLEMENTED() \ | |
29 FATAL("unimplemented code") | |
30 | |
31 #define FUNCTION_NAME(name) Builtin_##name | 15 #define FUNCTION_NAME(name) Builtin_##name |
32 #define REGISTER_FUNCTION(name, count) \ | 16 #define REGISTER_FUNCTION(name, count) \ |
33 { ""#name, FUNCTION_NAME(name), count }, | 17 { ""#name, FUNCTION_NAME(name), count }, |
34 #define DECLARE_FUNCTION(name, count) \ | 18 #define DECLARE_FUNCTION(name, count) \ |
35 extern void FUNCTION_NAME(name)(Dart_NativeArguments args); | 19 extern void FUNCTION_NAME(name)(Dart_NativeArguments args); |
36 | 20 |
37 | 21 |
38 class Builtin { | 22 class Builtin { |
39 public: | 23 public: |
40 static Dart_Handle Source(); | 24 static Dart_Handle Source(); |
41 static void SetupLibrary(Dart_Handle builtin_lib); | 25 static void SetupLibrary(Dart_Handle builtin_lib); |
42 static void ImportLibrary(Dart_Handle library); | 26 static void ImportLibrary(Dart_Handle library); |
43 static void SetNativeResolver(); | 27 static void SetNativeResolver(); |
44 static void PrintString(FILE* out, Dart_Handle object); | 28 static void PrintString(FILE* out, Dart_Handle object); |
45 | 29 |
46 private: | 30 private: |
47 static Dart_NativeFunction NativeLookup(Dart_Handle name, | 31 static Dart_NativeFunction NativeLookup(Dart_Handle name, |
48 int argument_count); | 32 int argument_count); |
49 | 33 |
50 static const char Builtin_source_[]; | 34 static const char Builtin_source_[]; |
51 | 35 |
52 DISALLOW_ALLOCATION(); | 36 DISALLOW_ALLOCATION(); |
53 DISALLOW_IMPLICIT_CONSTRUCTORS(Builtin); | 37 DISALLOW_IMPLICIT_CONSTRUCTORS(Builtin); |
54 }; | 38 }; |
55 | 39 |
56 | 40 |
57 #endif // BIN_BUILTIN_H_ | 41 #endif // BIN_BUILTIN_H_ |
OLD | NEW |