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

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

Issue 8380020: Refactor the dart api a bit: (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 | « runtime/vm/parser.h ('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) 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 "vm/parser.h" 5 #include "vm/parser.h"
6 6
7 #include "vm/bigint_operations.h" 7 #include "vm/bigint_operations.h"
8 #include "vm/class_finalizer.h" 8 #include "vm/class_finalizer.h"
9 #include "vm/compiler.h" 9 #include "vm/compiler.h"
10 #include "vm/compiler_stats.h" 10 #include "vm/compiler_stats.h"
(...skipping 2845 matching lines...) Expand 10 before | Expand all | Expand 10 after
2856 } 2856 }
2857 const String& name = *CurrentLiteral(); 2857 const String& name = *CurrentLiteral();
2858 ConsumeToken(); 2858 ConsumeToken();
2859 ExpectToken(Token::kRPAREN); 2859 ExpectToken(Token::kRPAREN);
2860 ExpectToken(Token::kSEMICOLON); 2860 ExpectToken(Token::kSEMICOLON);
2861 library_.SetName(name); 2861 library_.SetName(name);
2862 } 2862 }
2863 } 2863 }
2864 2864
2865 2865
2866 Dart_Result Parser::CallLibraryTagHandler(Dart_LibraryTag tag, 2866 Dart_Handle Parser::CallLibraryTagHandler(Dart_LibraryTag tag,
2867 intptr_t token_pos, 2867 intptr_t token_pos,
2868 const String& url) { 2868 const String& url) {
2869 Dart_LibraryTagHandler handler = Isolate::Current()->library_tag_handler(); 2869 Dart_LibraryTagHandler handler = Isolate::Current()->library_tag_handler();
2870 if (handler == NULL) { 2870 if (handler == NULL) {
2871 ErrorMsg(token_pos, "no library handler registered"); 2871 ErrorMsg(token_pos, "no library handler registered");
2872 } 2872 }
2873 Dart_Result result = handler(tag, 2873 Dart_Handle result = handler(tag,
2874 Api::NewLocalHandle(library_), 2874 Api::NewLocalHandle(library_),
2875 Api::NewLocalHandle(url)); 2875 Api::NewLocalHandle(url));
2876 if (!Dart_IsValidResult(result)) { 2876 if (!Dart_IsValid(result)) {
2877 ErrorMsg(token_pos, "library handler failed: %s", 2877 ErrorMsg(token_pos, "library handler failed: %s", Dart_GetError(result));
2878 Dart_GetErrorCString(result));
2879 } 2878 }
2880 return result; 2879 return result;
2881 } 2880 }
2882 2881
2883 2882
2884 void Parser::ParseLibraryImport() { 2883 void Parser::ParseLibraryImport() {
2885 while (CurrentToken() == Token::kIMPORT) { 2884 while (CurrentToken() == Token::kIMPORT) {
2886 intptr_t import_pos = token_index_; 2885 intptr_t import_pos = token_index_;
2887 ConsumeToken(); 2886 ConsumeToken();
2888 ExpectToken(Token::kLPAREN); 2887 ExpectToken(Token::kLPAREN);
(...skipping 13 matching lines...) Expand all
2902 ConsumeToken(); 2901 ConsumeToken();
2903 ExpectToken(Token::kCOLON); 2902 ExpectToken(Token::kCOLON);
2904 if (CurrentToken() != Token::kSTRING) { 2903 if (CurrentToken() != Token::kSTRING) {
2905 ErrorMsg("prefix expected"); 2904 ErrorMsg("prefix expected");
2906 } 2905 }
2907 prefix = CurrentLiteral()->raw(); 2906 prefix = CurrentLiteral()->raw();
2908 ConsumeToken(); 2907 ConsumeToken();
2909 } 2908 }
2910 ExpectToken(Token::kRPAREN); 2909 ExpectToken(Token::kRPAREN);
2911 ExpectToken(Token::kSEMICOLON); 2910 ExpectToken(Token::kSEMICOLON);
2912 Dart_Result result = CallLibraryTagHandler(kCanonicalizeUrl, 2911 Dart_Handle handle = CallLibraryTagHandler(kCanonicalizeUrl,
2913 import_pos, 2912 import_pos,
2914 url); 2913 url);
2915 Dart_Handle handle = Dart_GetResult(result);
2916 const String& canon_url = String::CheckedHandle(Api::UnwrapHandle(handle)); 2914 const String& canon_url = String::CheckedHandle(Api::UnwrapHandle(handle));
2917 // Lookup the library URL. 2915 // Lookup the library URL.
2918 Library& library = Library::Handle(Library::LookupLibrary(canon_url)); 2916 Library& library = Library::Handle(Library::LookupLibrary(canon_url));
2919 if (library.IsNull()) { 2917 if (library.IsNull()) {
2920 // Create a new library object and call the library tag handler. 2918 // Create a new library object and call the library tag handler.
2921 library = Library::New(canon_url); 2919 library = Library::New(canon_url);
2922 library.Register(); 2920 library.Register();
2923 // The tag handler expects the importing library as a parameter. 2921 // The tag handler expects the importing library as a parameter.
2924 CallLibraryTagHandler(kImportTag, import_pos, canon_url); 2922 CallLibraryTagHandler(kImportTag, import_pos, canon_url);
2925 } 2923 }
(...skipping 18 matching lines...) Expand all
2944 intptr_t source_pos = token_index_; 2942 intptr_t source_pos = token_index_;
2945 ConsumeToken(); 2943 ConsumeToken();
2946 ExpectToken(Token::kLPAREN); 2944 ExpectToken(Token::kLPAREN);
2947 if (CurrentToken() != Token::kSTRING) { 2945 if (CurrentToken() != Token::kSTRING) {
2948 ErrorMsg("source url expected"); 2946 ErrorMsg("source url expected");
2949 } 2947 }
2950 const String& url = *CurrentLiteral(); 2948 const String& url = *CurrentLiteral();
2951 ConsumeToken(); 2949 ConsumeToken();
2952 ExpectToken(Token::kRPAREN); 2950 ExpectToken(Token::kRPAREN);
2953 ExpectToken(Token::kSEMICOLON); 2951 ExpectToken(Token::kSEMICOLON);
2954 Dart_Result result = CallLibraryTagHandler(kCanonicalizeUrl, 2952 Dart_Handle handle = CallLibraryTagHandler(kCanonicalizeUrl,
2955 source_pos, 2953 source_pos,
2956 url); 2954 url);
2957 Dart_Handle handle = Dart_GetResult(result);
2958 const String& canon_url = String::CheckedHandle(Api::UnwrapHandle(handle)); 2955 const String& canon_url = String::CheckedHandle(Api::UnwrapHandle(handle));
2959 CallLibraryTagHandler(kSourceTag, source_pos, canon_url); 2956 CallLibraryTagHandler(kSourceTag, source_pos, canon_url);
2960 } 2957 }
2961 } 2958 }
2962 2959
2963 2960
2964 void Parser::ParseLibraryDefinition() { 2961 void Parser::ParseLibraryDefinition() {
2965 // Handle the script tag. 2962 // Handle the script tag.
2966 if (CurrentToken() == Token::kSCRIPTTAG) { 2963 if (CurrentToken() == Token::kSCRIPTTAG) {
2967 // Nothing to do for script tags except to skip them. 2964 // Nothing to do for script tags except to skip them.
(...skipping 4026 matching lines...) Expand 10 before | Expand all | Expand 10 after
6994 } 6991 }
6995 6992
6996 6993
6997 void Parser::SkipNestedExpr() { 6994 void Parser::SkipNestedExpr() {
6998 const bool saved_mode = SetAllowFunctionLiterals(true); 6995 const bool saved_mode = SetAllowFunctionLiterals(true);
6999 SkipExpr(); 6996 SkipExpr();
7000 SetAllowFunctionLiterals(saved_mode); 6997 SetAllowFunctionLiterals(saved_mode);
7001 } 6998 }
7002 6999
7003 } // namespace dart 7000 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/parser.h ('k') | runtime/vm/snapshot_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698