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/ast_transformer.h" | 9 #include "vm/ast_transformer.h" |
10 #include "vm/bootstrap.h" | 10 #include "vm/bootstrap.h" |
(...skipping 7321 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7332 parameter->set_invisible(true); | 7332 parameter->set_invisible(true); |
7333 } | 7333 } |
7334 } | 7334 } |
7335 } | 7335 } |
7336 | 7336 |
7337 | 7337 |
7338 // Builds ReturnNode/NativeBodyNode for a native function. | 7338 // Builds ReturnNode/NativeBodyNode for a native function. |
7339 void Parser::ParseNativeFunctionBlock(const ParamList* params, | 7339 void Parser::ParseNativeFunctionBlock(const ParamList* params, |
7340 const Function& func) { | 7340 const Function& func) { |
7341 ASSERT(func.is_native()); | 7341 ASSERT(func.is_native()); |
| 7342 ASSERT(func.NumParameters() == params->parameters->length()); |
7342 TRACE_PARSER("ParseNativeFunctionBlock"); | 7343 TRACE_PARSER("ParseNativeFunctionBlock"); |
7343 const Class& cls = Class::Handle(Z, func.Owner()); | |
7344 const Library& library = Library::Handle(Z, cls.library()); | |
7345 ASSERT(func.NumParameters() == params->parameters->length()); | |
7346 | 7344 |
7347 // Parse the function name out. | 7345 // Parse the function name out. |
7348 const intptr_t native_pos = TokenPos(); | |
7349 const String& native_name = ParseNativeDeclaration(); | 7346 const String& native_name = ParseNativeDeclaration(); |
7350 | 7347 |
7351 // Now resolve the native function to the corresponding native entrypoint. | |
7352 const int num_params = NativeArguments::ParameterCountForResolution(func); | |
7353 bool auto_setup_scope = true; | |
7354 NativeFunction native_function = NativeEntry::ResolveNative( | |
7355 library, native_name, num_params, &auto_setup_scope); | |
7356 if (native_function == NULL) { | |
7357 ReportError(native_pos, | |
7358 "native function '%s' (%" Pd " arguments) cannot be found", | |
7359 native_name.ToCString(), func.NumParameters()); | |
7360 } | |
7361 func.SetIsNativeAutoSetupScope(auto_setup_scope); | |
7362 | |
7363 // Now add the NativeBodyNode and return statement. | 7348 // Now add the NativeBodyNode and return statement. |
7364 Dart_NativeEntryResolver resolver = library.native_entry_resolver(); | |
7365 bool is_bootstrap_native = Bootstrap::IsBootstapResolver(resolver); | |
7366 current_block_->statements->Add(new(Z) ReturnNode( | 7349 current_block_->statements->Add(new(Z) ReturnNode( |
7367 TokenPos(), | 7350 TokenPos(), |
7368 new(Z) NativeBodyNode( | 7351 new(Z) NativeBodyNode( |
7369 TokenPos(), | 7352 TokenPos(), |
7370 Function::ZoneHandle(Z, func.raw()), | 7353 Function::ZoneHandle(Z, func.raw()), |
7371 native_name, | 7354 native_name, |
7372 native_function, | |
7373 current_block_->scope, | 7355 current_block_->scope, |
7374 is_bootstrap_native, | |
7375 FLAG_link_natives_lazily))); | 7356 FLAG_link_natives_lazily))); |
7376 } | 7357 } |
7377 | 7358 |
7378 | 7359 |
7379 LocalVariable* Parser::LookupReceiver(LocalScope* from_scope, bool test_only) { | 7360 LocalVariable* Parser::LookupReceiver(LocalScope* from_scope, bool test_only) { |
7380 ASSERT(!current_function().is_static()); | 7361 ASSERT(!current_function().is_static()); |
7381 return from_scope->LookupVariable(Symbols::This(), test_only); | 7362 return from_scope->LookupVariable(Symbols::This(), test_only); |
7382 } | 7363 } |
7383 | 7364 |
7384 | 7365 |
(...skipping 6967 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
14352 void Parser::SkipQualIdent() { | 14333 void Parser::SkipQualIdent() { |
14353 ASSERT(IsIdentifier()); | 14334 ASSERT(IsIdentifier()); |
14354 ConsumeToken(); | 14335 ConsumeToken(); |
14355 if (CurrentToken() == Token::kPERIOD) { | 14336 if (CurrentToken() == Token::kPERIOD) { |
14356 ConsumeToken(); // Consume the kPERIOD token. | 14337 ConsumeToken(); // Consume the kPERIOD token. |
14357 ExpectIdentifier("identifier expected after '.'"); | 14338 ExpectIdentifier("identifier expected after '.'"); |
14358 } | 14339 } |
14359 } | 14340 } |
14360 | 14341 |
14361 } // namespace dart | 14342 } // namespace dart |
OLD | NEW |