Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(708)

Side by Side Diff: runtime/bin/builtin.h

Issue 14752008: Final step towards loading core library scripts directly from the sources (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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
12 #include "platform/assert.h" 13 #include "platform/assert.h"
13 #include "platform/globals.h" 14 #include "platform/globals.h"
14 15
15 namespace dart { 16 namespace dart {
16 namespace bin { 17 namespace bin {
17 18
18 #define FUNCTION_NAME(name) Builtin_##name 19 #define FUNCTION_NAME(name) Builtin_##name
19 #define REGISTER_FUNCTION(name, count) \ 20 #define REGISTER_FUNCTION(name, count) \
20 { ""#name, FUNCTION_NAME(name), count }, 21 { ""#name, FUNCTION_NAME(name), count },
21 #define DECLARE_FUNCTION(name, count) \ 22 #define DECLARE_FUNCTION(name, count) \
22 extern void FUNCTION_NAME(name)(Dart_NativeArguments args); 23 extern void FUNCTION_NAME(name)(Dart_NativeArguments args);
23 24
24 25
25 class Builtin { 26 class Builtin {
26 public: 27 public:
27 // Note: Changes to this enum should be accompanied with changes to 28 // Note: Changes to this enum should be accompanied with changes to
28 // the builtin_libraries_ array in builtin.cc and builtin_nolib.cc. 29 // the builtin_libraries_ array in builtin.cc and builtin_nolib.cc.
29 enum BuiltinLibraryId { 30 enum BuiltinLibraryId {
30 kBuiltinLibrary = 0, 31 kBuiltinLibrary = 0,
31 kIOLibrary, 32 kIOLibrary,
32 33
33 kInvalidLibrary, 34 kInvalidLibrary,
34 }; 35 };
35 36
37 // Get source corresponding to built in library specified in 'id'.
36 static Dart_Handle Source(BuiltinLibraryId id); 38 static Dart_Handle Source(BuiltinLibraryId id);
39
40 // Get source of part file specified in 'uri'.
41 static Dart_Handle PartSource(BuiltinLibraryId id, const char* part_uri);
42
43 // Setup native resolver method built in library specified in 'id'.
37 static void SetNativeResolver(BuiltinLibraryId id); 44 static void SetNativeResolver(BuiltinLibraryId id);
45
46 // Check if built in library specified in 'id' is already loaded, if not
47 // load it.
38 static Dart_Handle LoadAndCheckLibrary(BuiltinLibraryId id); 48 static Dart_Handle LoadAndCheckLibrary(BuiltinLibraryId id);
39 static void PrintString(FILE* out, Dart_Handle object);
40 49
41 private: 50 private:
51 // Map specified URI to an actual file name from 'source_paths' and read
52 // the file.
53 static Dart_Handle GetSource(const char** source_paths, const char* uri);
54
55 // Native method support.
42 static Dart_NativeFunction NativeLookup(Dart_Handle name, 56 static Dart_NativeFunction NativeLookup(Dart_Handle name,
43 int argument_count); 57 int argument_count);
44 static Dart_NativeFunction BuiltinNativeLookup(Dart_Handle name,
45 int argument_count);
46 58
47 static const char builtin_source_[]; 59 static const char* builtin_source_paths_[];
48 static const char io_source_[]; 60 static const char* io_source_paths_[];
49 static const char io_patch_[]; 61 static const char* io_patch_paths_[];
50 static const char web_source_[];
51 62
52 typedef struct { 63 typedef struct {
53 const char* url_; 64 const char* url_;
54 const char* source_; 65 const char** source_paths_;
55 const char* patch_url_; 66 const char* patch_url_;
56 const char* patch_source_; 67 const char** patch_paths_;
57 bool has_natives_; 68 bool has_natives_;
58 } builtin_lib_props; 69 } builtin_lib_props;
59 static builtin_lib_props builtin_libraries_[]; 70 static builtin_lib_props builtin_libraries_[];
60 71
61 DISALLOW_ALLOCATION(); 72 DISALLOW_ALLOCATION();
62 DISALLOW_IMPLICIT_CONSTRUCTORS(Builtin); 73 DISALLOW_IMPLICIT_CONSTRUCTORS(Builtin);
63 }; 74 };
64 75
65 } // namespace bin 76 } // namespace bin
66 } // namespace dart 77 } // namespace dart
67 78
68 #endif // BIN_BUILTIN_H_ 79 #endif // BIN_BUILTIN_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698