Chromium Code Reviews| 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 #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 "platform/utils.h" | 8 #include "platform/utils.h" |
| 9 #include "vm/bootstrap.h" | 9 #include "vm/bootstrap.h" |
| 10 #include "vm/class_finalizer.h" | 10 #include "vm/class_finalizer.h" |
| (...skipping 4837 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 4848 library_.AddObject(func, accessor_name); | 4848 library_.AddObject(func, accessor_name); |
| 4849 } else { | 4849 } else { |
| 4850 library_.ReplaceObject(func, accessor_name); | 4850 library_.ReplaceObject(func, accessor_name); |
| 4851 } | 4851 } |
| 4852 if (metadata_pos >= 0) { | 4852 if (metadata_pos >= 0) { |
| 4853 library_.AddFunctionMetadata(func, metadata_pos); | 4853 library_.AddFunctionMetadata(func, metadata_pos); |
| 4854 } | 4854 } |
| 4855 } | 4855 } |
| 4856 | 4856 |
| 4857 | 4857 |
| 4858 class DartApiScope : public StackResource { | |
| 4859 public: | |
| 4860 explicit DartApiScope(Isolate* isolate) : StackResource(isolate) { | |
| 4861 Dart_EnterScope(); | |
| 4862 } | |
| 4863 ~DartApiScope() { | |
| 4864 Dart_ExitScope(); | |
| 4865 } | |
| 4866 | |
| 4867 private: | |
| 4868 DISALLOW_COPY_AND_ASSIGN(DartApiScope); | |
| 4869 }; | |
| 4870 | |
| 4858 | 4871 |
| 4859 RawObject* Parser::CallLibraryTagHandler(Dart_LibraryTag tag, | 4872 RawObject* Parser::CallLibraryTagHandler(Dart_LibraryTag tag, |
| 4860 intptr_t token_pos, | 4873 intptr_t token_pos, |
| 4861 const String& url) { | 4874 const String& url) { |
| 4862 Dart_LibraryTagHandler handler = isolate()->library_tag_handler(); | 4875 Dart_LibraryTagHandler handler = isolate()->library_tag_handler(); |
| 4863 if (handler == NULL) { | 4876 if (handler == NULL) { |
| 4864 if (url.StartsWith(Symbols::DartScheme())) { | 4877 if (url.StartsWith(Symbols::DartScheme())) { |
| 4865 if (tag == Dart_kCanonicalizeUrl) { | 4878 if (tag == Dart_kCanonicalizeUrl) { |
| 4866 return url.raw(); | 4879 return url.raw(); |
| 4867 } | 4880 } |
| 4868 return Object::null(); | 4881 return Object::null(); |
| 4869 } | 4882 } |
| 4870 ErrorMsg(token_pos, "no library handler registered"); | 4883 ErrorMsg(token_pos, "no library handler registered"); |
| 4871 } | 4884 } |
| 4872 // Block class finalization attempts when calling into the library | 4885 // Block class finalization attempts when calling into the library |
| 4873 // tag handler. | 4886 // tag handler. |
| 4874 isolate()->BlockClassFinalization(); | 4887 isolate()->BlockClassFinalization(); |
| 4888 DartApiScope api_scope(isolate()); | |
|
hausner
2014/02/05 22:22:56
If this is the only place you anticipate calls to
siva
2014/02/05 23:10:55
The reason I made it a class is because we have so
| |
| 4875 Dart_Handle result = handler(tag, | 4889 Dart_Handle result = handler(tag, |
| 4876 Api::NewHandle(isolate(), library_.raw()), | 4890 Api::NewHandle(isolate(), library_.raw()), |
| 4877 Api::NewHandle(isolate(), url.raw())); | 4891 Api::NewHandle(isolate(), url.raw())); |
| 4878 isolate()->UnblockClassFinalization(); | 4892 isolate()->UnblockClassFinalization(); |
| 4879 if (Dart_IsError(result)) { | 4893 if (Dart_IsError(result)) { |
| 4880 // In case of an error we append an explanatory error message to the | 4894 // In case of an error we append an explanatory error message to the |
| 4881 // error obtained from the library tag handler. | 4895 // error obtained from the library tag handler. |
| 4882 Error& prev_error = Error::Handle(); | 4896 Error& prev_error = Error::Handle(); |
| 4883 prev_error ^= Api::UnwrapHandle(result); | 4897 prev_error ^= Api::UnwrapHandle(result); |
| 4884 AppendErrorMsg(prev_error, token_pos, "library handler failed"); | 4898 AppendErrorMsg(prev_error, token_pos, "library handler failed"); |
| (...skipping 5915 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 10800 void Parser::SkipQualIdent() { | 10814 void Parser::SkipQualIdent() { |
| 10801 ASSERT(IsIdentifier()); | 10815 ASSERT(IsIdentifier()); |
| 10802 ConsumeToken(); | 10816 ConsumeToken(); |
| 10803 if (CurrentToken() == Token::kPERIOD) { | 10817 if (CurrentToken() == Token::kPERIOD) { |
| 10804 ConsumeToken(); // Consume the kPERIOD token. | 10818 ConsumeToken(); // Consume the kPERIOD token. |
| 10805 ExpectIdentifier("identifier expected after '.'"); | 10819 ExpectIdentifier("identifier expected after '.'"); |
| 10806 } | 10820 } |
| 10807 } | 10821 } |
| 10808 | 10822 |
| 10809 } // namespace dart | 10823 } // namespace dart |
| OLD | NEW |