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

Side by Side Diff: runtime/vm/parser.cc

Issue 15689013: - Modify dart_api.h to be a proper C API. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 years, 6 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
« no previous file with comments | « runtime/vm/dart_api_message.cc ('k') | runtime/vm/snapshot_test.cc » ('j') | 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) 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 #include "vm/parser.h" 5 #include "vm/parser.h"
6 6
7 #include "lib/invocation_mirror.h" 7 #include "lib/invocation_mirror.h"
8 #include "vm/bigint_operations.h" 8 #include "vm/bigint_operations.h"
9 #include "vm/class_finalizer.h" 9 #include "vm/class_finalizer.h"
10 #include "vm/compiler.h" 10 #include "vm/compiler.h"
(...skipping 4214 matching lines...) Expand 10 before | Expand all | Expand 10 after
4225 4225
4226 4226
4227 4227
4228 RawObject* Parser::CallLibraryTagHandler(Dart_LibraryTag tag, 4228 RawObject* Parser::CallLibraryTagHandler(Dart_LibraryTag tag,
4229 intptr_t token_pos, 4229 intptr_t token_pos,
4230 const String& url) { 4230 const String& url) {
4231 Isolate* isolate = Isolate::Current(); 4231 Isolate* isolate = Isolate::Current();
4232 Dart_LibraryTagHandler handler = isolate->library_tag_handler(); 4232 Dart_LibraryTagHandler handler = isolate->library_tag_handler();
4233 if (handler == NULL) { 4233 if (handler == NULL) {
4234 if (url.StartsWith(Symbols::DartScheme())) { 4234 if (url.StartsWith(Symbols::DartScheme())) {
4235 if (tag == kCanonicalizeUrl) { 4235 if (tag == Dart_kCanonicalizeUrl) {
4236 return url.raw(); 4236 return url.raw();
4237 } 4237 }
4238 return Object::null(); 4238 return Object::null();
4239 } 4239 }
4240 ErrorMsg(token_pos, "no library handler registered"); 4240 ErrorMsg(token_pos, "no library handler registered");
4241 } 4241 }
4242 Dart_Handle result = handler(tag, 4242 Dart_Handle result = handler(tag,
4243 Api::NewHandle(isolate, library_.raw()), 4243 Api::NewHandle(isolate, library_.raw()),
4244 Api::NewHandle(isolate, url.raw())); 4244 Api::NewHandle(isolate, url.raw()));
4245 if (Dart_IsError(result)) { 4245 if (Dart_IsError(result)) {
4246 // In case of an error we append an explanatory error message to the 4246 // In case of an error we append an explanatory error message to the
4247 // error obtained from the library tag handler. 4247 // error obtained from the library tag handler.
4248 Error& prev_error = Error::Handle(); 4248 Error& prev_error = Error::Handle();
4249 prev_error ^= Api::UnwrapHandle(result); 4249 prev_error ^= Api::UnwrapHandle(result);
4250 AppendErrorMsg(prev_error, token_pos, "library handler failed"); 4250 AppendErrorMsg(prev_error, token_pos, "library handler failed");
4251 } 4251 }
4252 if (tag == kCanonicalizeUrl) { 4252 if (tag == Dart_kCanonicalizeUrl) {
4253 if (!Dart_IsString(result)) { 4253 if (!Dart_IsString(result)) {
4254 ErrorMsg(token_pos, "library handler failed URI canonicalization"); 4254 ErrorMsg(token_pos, "library handler failed URI canonicalization");
4255 } 4255 }
4256 } 4256 }
4257 return Api::UnwrapHandle(result); 4257 return Api::UnwrapHandle(result);
4258 } 4258 }
4259 4259
4260 4260
4261 void Parser::ParseLibraryName() { 4261 void Parser::ParseLibraryName() {
4262 ASSERT(CurrentToken() == Token::kLIBRARY); 4262 ASSERT(CurrentToken() == Token::kLIBRARY);
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
4333 show_names = Array::MakeArray(show_list); 4333 show_names = Array::MakeArray(show_list);
4334 } 4334 }
4335 if (hide_list.Length() > 0) { 4335 if (hide_list.Length() > 0) {
4336 hide_names = Array::MakeArray(hide_list); 4336 hide_names = Array::MakeArray(hide_list);
4337 } 4337 }
4338 } 4338 }
4339 ExpectSemicolon(); 4339 ExpectSemicolon();
4340 4340
4341 // Canonicalize library URL. 4341 // Canonicalize library URL.
4342 const String& canon_url = String::CheckedHandle( 4342 const String& canon_url = String::CheckedHandle(
4343 CallLibraryTagHandler(kCanonicalizeUrl, import_pos, url)); 4343 CallLibraryTagHandler(Dart_kCanonicalizeUrl, import_pos, url));
4344 // Lookup the library URL. 4344 // Lookup the library URL.
4345 Library& library = Library::Handle(Library::LookupLibrary(canon_url)); 4345 Library& library = Library::Handle(Library::LookupLibrary(canon_url));
4346 if (library.IsNull()) { 4346 if (library.IsNull()) {
4347 // Call the library tag handler to load the library. 4347 // Call the library tag handler to load the library.
4348 CallLibraryTagHandler(kImportTag, import_pos, canon_url); 4348 CallLibraryTagHandler(Dart_kImportTag, import_pos, canon_url);
4349 // If the library tag handler succeded without registering the 4349 // If the library tag handler succeded without registering the
4350 // library we create an empty library to import. 4350 // library we create an empty library to import.
4351 library = Library::LookupLibrary(canon_url); 4351 library = Library::LookupLibrary(canon_url);
4352 if (library.IsNull()) { 4352 if (library.IsNull()) {
4353 library = Library::New(canon_url); 4353 library = Library::New(canon_url);
4354 library.Register(); 4354 library.Register();
4355 } 4355 }
4356 } 4356 }
4357 const Namespace& ns = 4357 const Namespace& ns =
4358 Namespace::Handle(Namespace::New(library, show_names, hide_names)); 4358 Namespace::Handle(Namespace::New(library, show_names, hide_names));
(...skipping 27 matching lines...) Expand all
4386 void Parser::ParseLibraryPart() { 4386 void Parser::ParseLibraryPart() {
4387 const intptr_t source_pos = TokenPos(); 4387 const intptr_t source_pos = TokenPos();
4388 ConsumeToken(); // Consume "part". 4388 ConsumeToken(); // Consume "part".
4389 if (CurrentToken() != Token::kSTRING) { 4389 if (CurrentToken() != Token::kSTRING) {
4390 ErrorMsg("url expected"); 4390 ErrorMsg("url expected");
4391 } 4391 }
4392 const String& url = *CurrentLiteral(); 4392 const String& url = *CurrentLiteral();
4393 ConsumeToken(); 4393 ConsumeToken();
4394 ExpectSemicolon(); 4394 ExpectSemicolon();
4395 const String& canon_url = String::CheckedHandle( 4395 const String& canon_url = String::CheckedHandle(
4396 CallLibraryTagHandler(kCanonicalizeUrl, source_pos, url)); 4396 CallLibraryTagHandler(Dart_kCanonicalizeUrl, source_pos, url));
4397 CallLibraryTagHandler(kSourceTag, source_pos, canon_url); 4397 CallLibraryTagHandler(Dart_kSourceTag, source_pos, canon_url);
4398 } 4398 }
4399 4399
4400 4400
4401 void Parser::ParseLibraryDefinition() { 4401 void Parser::ParseLibraryDefinition() {
4402 TRACE_PARSER("ParseLibraryDefinition"); 4402 TRACE_PARSER("ParseLibraryDefinition");
4403 4403
4404 // Handle the script tag. 4404 // Handle the script tag.
4405 if (CurrentToken() == Token::kSCRIPTTAG) { 4405 if (CurrentToken() == Token::kSCRIPTTAG) {
4406 // Nothing to do for script tags except to skip them. 4406 // Nothing to do for script tags except to skip them.
4407 ConsumeToken(); 4407 ConsumeToken();
(...skipping 5551 matching lines...) Expand 10 before | Expand all | Expand 10 after
9959 void Parser::SkipQualIdent() { 9959 void Parser::SkipQualIdent() {
9960 ASSERT(IsIdentifier()); 9960 ASSERT(IsIdentifier());
9961 ConsumeToken(); 9961 ConsumeToken();
9962 if (CurrentToken() == Token::kPERIOD) { 9962 if (CurrentToken() == Token::kPERIOD) {
9963 ConsumeToken(); // Consume the kPERIOD token. 9963 ConsumeToken(); // Consume the kPERIOD token.
9964 ExpectIdentifier("identifier expected after '.'"); 9964 ExpectIdentifier("identifier expected after '.'");
9965 } 9965 }
9966 } 9966 }
9967 9967
9968 } // namespace dart 9968 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/dart_api_message.cc ('k') | runtime/vm/snapshot_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698