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

Side by Side Diff: runtime/bin/builtin_in.cc

Issue 8571020: Provide better error messages when we fail to build the builtin lib. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 9 years, 1 month 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2011, 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 #include <stdlib.h> 5 #include <stdlib.h>
6 #include <string.h> 6 #include <string.h>
7 7
8 #include "include/dart_api.h" 8 #include "include/dart_api.h"
9 9
10 #include "bin/builtin.h" 10 #include "bin/builtin.h"
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
67 int argument_count_; 67 int argument_count_;
68 } BuiltinEntries[] = { 68 } BuiltinEntries[] = {
69 BUILTIN_NATIVE_LIST(REGISTER_FUNCTION) 69 BUILTIN_NATIVE_LIST(REGISTER_FUNCTION)
70 }; 70 };
71 71
72 72
73 static Dart_NativeFunction native_lookup(Dart_Handle name, 73 static Dart_NativeFunction native_lookup(Dart_Handle name,
74 int argument_count) { 74 int argument_count) {
75 const char* function_name = NULL; 75 const char* function_name = NULL;
76 Dart_Handle result = Dart_StringToCString(name, &function_name); 76 Dart_Handle result = Dart_StringToCString(name, &function_name);
77 ASSERT(!Dart_IsError(result)); 77 DART_CHECK_VALID(result);
78 ASSERT(function_name != NULL); 78 ASSERT(function_name != NULL);
79 int num_entries = sizeof(BuiltinEntries) / sizeof(struct NativeEntries); 79 int num_entries = sizeof(BuiltinEntries) / sizeof(struct NativeEntries);
80 for (int i = 0; i < num_entries; i++) { 80 for (int i = 0; i < num_entries; i++) {
81 struct NativeEntries* entry = &(BuiltinEntries[i]); 81 struct NativeEntries* entry = &(BuiltinEntries[i]);
82 if (!strcmp(function_name, entry->name_)) { 82 if (!strcmp(function_name, entry->name_)) {
83 if (entry->argument_count_ == argument_count) { 83 if (entry->argument_count_ == argument_count) {
84 return reinterpret_cast<Dart_NativeFunction>(entry->function_); 84 return reinterpret_cast<Dart_NativeFunction>(entry->function_);
85 } else { 85 } else {
86 // Wrong number of arguments. 86 // Wrong number of arguments.
87 // TODO(regis): Should we pass a buffer for error reporting? 87 // TODO(regis): Should we pass a buffer for error reporting?
88 return NULL; 88 return NULL;
89 } 89 }
90 } 90 }
91 } 91 }
92 return NULL; 92 return NULL;
93 } 93 }
94 94
95 95
96 void Builtin_LoadLibrary() { 96 void Builtin_LoadLibrary() {
97 Dart_Handle url = Dart_NewString(DartUtils::kBuiltinLibURL); 97 Dart_Handle url = Dart_NewString(DartUtils::kBuiltinLibURL);
98 Dart_Handle result = Dart_LookupLibrary(url); 98 Dart_Handle result = Dart_LookupLibrary(url);
99 if (!Dart_IsError(result)) { 99 if (!Dart_IsError(result)) {
100 // Builtin library already loaded. 100 // Builtin library already loaded.
101 return; 101 return;
102 } 102 }
103 103
104 // Load the library. 104 // Load the library.
105 Dart_Handle source = Dart_NewString(Builtin_source_); 105 Dart_Handle source = Dart_NewString(Builtin_source_);
106 Dart_Handle builtin_lib = Dart_LoadLibrary(url, source); 106 Dart_Handle builtin_lib = Dart_LoadLibrary(url, source);
107 ASSERT(!Dart_IsError(builtin_lib)); 107 DART_CHECK_VALID(builtin_lib);
108 108
109 // Lookup the core libraries and inject the builtin library into them. 109 // Lookup the core libraries and inject the builtin library into them.
110 Dart_Handle core_lib = Dart_LookupLibrary(Dart_NewString("dart:core")); 110 Dart_Handle core_lib = Dart_LookupLibrary(Dart_NewString("dart:core"));
111 ASSERT(!Dart_IsError(core_lib)); 111 DART_CHECK_VALID(core_lib);
112 result = Dart_LibraryImportLibrary(core_lib, builtin_lib); 112 result = Dart_LibraryImportLibrary(core_lib, builtin_lib);
113 ASSERT(!Dart_IsError(result)); 113 DART_CHECK_VALID(result);
114 114
115 Dart_Handle coreimpl_lib = 115 Dart_Handle coreimpl_lib =
116 Dart_LookupLibrary(Dart_NewString("dart:coreimpl")); 116 Dart_LookupLibrary(Dart_NewString("dart:coreimpl"));
117 ASSERT(!Dart_IsError(coreimpl_lib)); 117 DART_CHECK_VALID(coreimpl_lib);
118 result = Dart_LibraryImportLibrary(coreimpl_lib, builtin_lib); 118 result = Dart_LibraryImportLibrary(coreimpl_lib, builtin_lib);
119 ASSERT(!Dart_IsError(result)); 119 DART_CHECK_VALID(result);
120 result = Dart_LibraryImportLibrary(builtin_lib, coreimpl_lib); 120 result = Dart_LibraryImportLibrary(builtin_lib, coreimpl_lib);
121 ASSERT(!Dart_IsError(result)); 121 DART_CHECK_VALID(result);
122 122
123 // Create a native wrapper "EventHandlerNativeWrapper" so that we can add a 123 // Create a native wrapper "EventHandlerNativeWrapper" so that we can add a
124 // native field to store the event handle for implementing all 124 // native field to store the event handle for implementing all
125 // event operations. 125 // event operations.
126 Dart_Handle name = Dart_NewString("EventHandlerNativeWrapper"); 126 Dart_Handle name = Dart_NewString("EventHandlerNativeWrapper");
127 const int kNumEventHandlerFields = 1; 127 const int kNumEventHandlerFields = 1;
128 result = Dart_CreateNativeWrapperClass(builtin_lib, 128 result = Dart_CreateNativeWrapperClass(builtin_lib,
129 name, 129 name,
130 kNumEventHandlerFields); 130 kNumEventHandlerFields);
131 ASSERT(!Dart_IsError(result)); 131 DART_CHECK_VALID(result);
132 } 132 }
133 133
134 134
135 void Builtin_ImportLibrary(Dart_Handle library) { 135 void Builtin_ImportLibrary(Dart_Handle library) {
136 Builtin_LoadLibrary(); 136 Builtin_LoadLibrary();
137 137
138 Dart_Handle url = Dart_NewString(DartUtils::kBuiltinLibURL); 138 Dart_Handle url = Dart_NewString(DartUtils::kBuiltinLibURL);
139 Dart_Handle builtin_lib = Dart_LookupLibrary(url); 139 Dart_Handle builtin_lib = Dart_LookupLibrary(url);
140 ASSERT(!Dart_IsError(builtin_lib)); 140 DART_CHECK_VALID(builtin_lib);
141 Dart_Handle result = Dart_LibraryImportLibrary(library, builtin_lib); 141 Dart_Handle result = Dart_LibraryImportLibrary(library, builtin_lib);
142 ASSERT(!Dart_IsError(result)); 142 DART_CHECK_VALID(result);
143 } 143 }
144 144
145 145
146 void Builtin_SetNativeResolver() { 146 void Builtin_SetNativeResolver() {
147 Dart_Handle url = Dart_NewString(DartUtils::kBuiltinLibURL); 147 Dart_Handle url = Dart_NewString(DartUtils::kBuiltinLibURL);
148 Dart_Handle builtin_lib = Dart_LookupLibrary(url); 148 Dart_Handle builtin_lib = Dart_LookupLibrary(url);
149 ASSERT(!Dart_IsError(builtin_lib)); 149 DART_CHECK_VALID(builtin_lib);
150 Dart_Handle result = Dart_SetNativeResolver(builtin_lib, native_lookup); 150 Dart_Handle result = Dart_SetNativeResolver(builtin_lib, native_lookup);
151 ASSERT(!Dart_IsError(result)); 151 DART_CHECK_VALID(result);
152 } 152 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698