| 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 "vm/bigint_operations.h" | 8 #include "vm/bigint_operations.h" |
| 9 #include "vm/bootstrap.h" |
| 9 #include "vm/class_finalizer.h" | 10 #include "vm/class_finalizer.h" |
| 10 #include "vm/compiler.h" | 11 #include "vm/compiler.h" |
| 11 #include "vm/compiler_stats.h" | 12 #include "vm/compiler_stats.h" |
| 12 #include "vm/dart_api_impl.h" | 13 #include "vm/dart_api_impl.h" |
| 13 #include "vm/dart_entry.h" | 14 #include "vm/dart_entry.h" |
| 14 #include "vm/flags.h" | 15 #include "vm/flags.h" |
| 15 #include "vm/growable_array.h" | 16 #include "vm/growable_array.h" |
| 16 #include "vm/longjump.h" | 17 #include "vm/longjump.h" |
| 17 #include "vm/native_entry.h" | 18 #include "vm/native_entry.h" |
| 18 #include "vm/object.h" | 19 #include "vm/object.h" |
| (...skipping 4983 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5002 } | 5003 } |
| 5003 } | 5004 } |
| 5004 | 5005 |
| 5005 | 5006 |
| 5006 // Builds ReturnNode/NativeBodyNode for a native function. | 5007 // Builds ReturnNode/NativeBodyNode for a native function. |
| 5007 void Parser::ParseNativeFunctionBlock(const ParamList* params, | 5008 void Parser::ParseNativeFunctionBlock(const ParamList* params, |
| 5008 const Function& func) { | 5009 const Function& func) { |
| 5009 func.set_is_native(true); | 5010 func.set_is_native(true); |
| 5010 TRACE_PARSER("ParseNativeFunctionBlock"); | 5011 TRACE_PARSER("ParseNativeFunctionBlock"); |
| 5011 const Class& cls = Class::Handle(func.Owner()); | 5012 const Class& cls = Class::Handle(func.Owner()); |
| 5013 const Library& library = Library::Handle(cls.library()); |
| 5012 ASSERT(func.NumParameters() == params->parameters->length()); | 5014 ASSERT(func.NumParameters() == params->parameters->length()); |
| 5013 | 5015 |
| 5014 // Parse the function name out. | 5016 // Parse the function name out. |
| 5015 const intptr_t native_pos = TokenPos(); | 5017 const intptr_t native_pos = TokenPos(); |
| 5016 const String& native_name = ParseNativeDeclaration(); | 5018 const String& native_name = ParseNativeDeclaration(); |
| 5017 | 5019 |
| 5018 // Now resolve the native function to the corresponding native entrypoint. | 5020 // Now resolve the native function to the corresponding native entrypoint. |
| 5019 const int num_params = NativeArguments::ParameterCountForResolution(func); | 5021 const int num_params = NativeArguments::ParameterCountForResolution(func); |
| 5020 NativeFunction native_function = NativeEntry::ResolveNative( | 5022 NativeFunction native_function = NativeEntry::ResolveNative( |
| 5021 cls, native_name, num_params); | 5023 library, native_name, num_params); |
| 5022 if (native_function == NULL) { | 5024 if (native_function == NULL) { |
| 5023 ErrorMsg(native_pos, "native function '%s' cannot be found", | 5025 ErrorMsg(native_pos, "native function '%s' cannot be found", |
| 5024 native_name.ToCString()); | 5026 native_name.ToCString()); |
| 5025 } | 5027 } |
| 5026 | 5028 |
| 5027 // Now add the NativeBodyNode and return statement. | 5029 // Now add the NativeBodyNode and return statement. |
| 5030 Dart_NativeEntryResolver resolver = library.native_entry_resolver(); |
| 5031 bool is_bootstrap_native = Bootstrap::IsBootstapResolver(resolver); |
| 5028 current_block_->statements->Add( | 5032 current_block_->statements->Add( |
| 5029 new ReturnNode(TokenPos(), | 5033 new ReturnNode(TokenPos(), |
| 5030 new NativeBodyNode(TokenPos(), | 5034 new NativeBodyNode(TokenPos(), |
| 5031 Function::ZoneHandle(func.raw()), | 5035 Function::ZoneHandle(func.raw()), |
| 5032 native_name, | 5036 native_name, |
| 5033 native_function))); | 5037 native_function, |
| 5038 is_bootstrap_native))); |
| 5034 } | 5039 } |
| 5035 | 5040 |
| 5036 | 5041 |
| 5037 LocalVariable* Parser::LookupReceiver(LocalScope* from_scope, bool test_only) { | 5042 LocalVariable* Parser::LookupReceiver(LocalScope* from_scope, bool test_only) { |
| 5038 ASSERT(!current_function().is_static()); | 5043 ASSERT(!current_function().is_static()); |
| 5039 return from_scope->LookupVariable(Symbols::This(), test_only); | 5044 return from_scope->LookupVariable(Symbols::This(), test_only); |
| 5040 } | 5045 } |
| 5041 | 5046 |
| 5042 | 5047 |
| 5043 LocalVariable* Parser::LookupTypeArgumentsParameter(LocalScope* from_scope, | 5048 LocalVariable* Parser::LookupTypeArgumentsParameter(LocalScope* from_scope, |
| (...skipping 5229 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 10273 void Parser::SkipQualIdent() { | 10278 void Parser::SkipQualIdent() { |
| 10274 ASSERT(IsIdentifier()); | 10279 ASSERT(IsIdentifier()); |
| 10275 ConsumeToken(); | 10280 ConsumeToken(); |
| 10276 if (CurrentToken() == Token::kPERIOD) { | 10281 if (CurrentToken() == Token::kPERIOD) { |
| 10277 ConsumeToken(); // Consume the kPERIOD token. | 10282 ConsumeToken(); // Consume the kPERIOD token. |
| 10278 ExpectIdentifier("identifier expected after '.'"); | 10283 ExpectIdentifier("identifier expected after '.'"); |
| 10279 } | 10284 } |
| 10280 } | 10285 } |
| 10281 | 10286 |
| 10282 } // namespace dart | 10287 } // namespace dart |
| OLD | NEW |