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

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

Issue 99373002: Mark native functions when they are created. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 years 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/object_test.cc ('k') | runtime/vm/resolver.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 "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 507 matching lines...) Expand 10 before | Expand all | Expand 10 after
518 } 518 }
519 void Clear() { 519 void Clear() {
520 has_abstract = false; 520 has_abstract = false;
521 has_external = false; 521 has_external = false;
522 has_final = false; 522 has_final = false;
523 has_const = false; 523 has_const = false;
524 has_static = false; 524 has_static = false;
525 has_var = false; 525 has_var = false;
526 has_factory = false; 526 has_factory = false;
527 has_operator = false; 527 has_operator = false;
528 has_native = false;
528 metadata_pos = -1; 529 metadata_pos = -1;
529 operator_token = Token::kILLEGAL; 530 operator_token = Token::kILLEGAL;
530 type = NULL; 531 type = NULL;
531 name_pos = 0; 532 name_pos = 0;
532 name = NULL; 533 name = NULL;
533 redirect_name = NULL; 534 redirect_name = NULL;
534 dict_name = NULL; 535 dict_name = NULL;
535 params.Clear(); 536 params.Clear();
536 kind = RawFunction::kRegularFunction; 537 kind = RawFunction::kRegularFunction;
537 field_ = NULL; 538 field_ = NULL;
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
569 return (dict_name != NULL) ? dict_name : name; 570 return (dict_name != NULL) ? dict_name : name;
570 } 571 }
571 bool has_abstract; 572 bool has_abstract;
572 bool has_external; 573 bool has_external;
573 bool has_final; 574 bool has_final;
574 bool has_const; 575 bool has_const;
575 bool has_static; 576 bool has_static;
576 bool has_var; 577 bool has_var;
577 bool has_factory; 578 bool has_factory;
578 bool has_operator; 579 bool has_operator;
580 bool has_native;
579 intptr_t metadata_pos; 581 intptr_t metadata_pos;
580 Token::Kind operator_token; 582 Token::Kind operator_token;
581 const AbstractType* type; 583 const AbstractType* type;
582 intptr_t name_pos; 584 intptr_t name_pos;
583 intptr_t decl_begin_pos; 585 intptr_t decl_begin_pos;
584 String* name; 586 String* name;
585 // For constructors: NULL or name of redirected to constructor. 587 // For constructors: NULL or name of redirected to constructor.
586 String* redirect_name; 588 String* redirect_name;
587 // dict_name is the name used for the class namespace, if it 589 // dict_name is the name used for the class namespace, if it
588 // differs from 'name'. 590 // differs from 'name'.
(...skipping 978 matching lines...) Expand 10 before | Expand all | Expand 10 after
1567 ParseFormalParameterList(no_explicit_default_values, false, &func_params); 1569 ParseFormalParameterList(no_explicit_default_values, false, &func_params);
1568 1570
1569 // The field 'is_static' has no meaning for signature functions. 1571 // The field 'is_static' has no meaning for signature functions.
1570 const Function& signature_function = Function::Handle( 1572 const Function& signature_function = Function::Handle(
1571 Function::New(*parameter.name, 1573 Function::New(*parameter.name,
1572 RawFunction::kSignatureFunction, 1574 RawFunction::kSignatureFunction,
1573 /* is_static = */ false, 1575 /* is_static = */ false,
1574 /* is_const = */ false, 1576 /* is_const = */ false,
1575 /* is_abstract = */ false, 1577 /* is_abstract = */ false,
1576 /* is_external = */ false, 1578 /* is_external = */ false,
1579 /* is_native = */ false,
1577 current_class(), 1580 current_class(),
1578 parameter.name_pos)); 1581 parameter.name_pos));
1579 signature_function.set_result_type(result_type); 1582 signature_function.set_result_type(result_type);
1580 AddFormalParamsToFunction(&func_params, signature_function); 1583 AddFormalParamsToFunction(&func_params, signature_function);
1581 const String& signature = String::Handle(signature_function.Signature()); 1584 const String& signature = String::Handle(signature_function.Signature());
1582 // Lookup the signature class, i.e. the class whose name is the signature. 1585 // Lookup the signature class, i.e. the class whose name is the signature.
1583 // We only lookup in the current library, but not in its imports, and only 1586 // We only lookup in the current library, but not in its imports, and only
1584 // create a new canonical signature class if it does not exist yet. 1587 // create a new canonical signature class if it does not exist yet.
1585 Class& signature_class = Class::ZoneHandle( 1588 Class& signature_class = Class::ZoneHandle(
1586 library_.LookupLocalClass(signature)); 1589 library_.LookupLocalClass(signature));
(...skipping 1680 matching lines...) Expand 10 before | Expand all | Expand 10 after
3267 "const constructor '%s' may not be native", 3270 "const constructor '%s' may not be native",
3268 method->name->ToCString()); 3271 method->name->ToCString());
3269 } 3272 }
3270 if (method->redirect_name != NULL) { 3273 if (method->redirect_name != NULL) {
3271 ErrorMsg(method->name_pos, 3274 ErrorMsg(method->name_pos,
3272 "Constructor with redirection may not have a function body"); 3275 "Constructor with redirection may not have a function body");
3273 } 3276 }
3274 ParseNativeDeclaration(); 3277 ParseNativeDeclaration();
3275 method_end_pos = TokenPos(); 3278 method_end_pos = TokenPos();
3276 ExpectSemicolon(); 3279 ExpectSemicolon();
3280 method->has_native = true;
3277 } else { 3281 } else {
3278 // We haven't found a method body. Issue error if one is required. 3282 // We haven't found a method body. Issue error if one is required.
3279 const bool must_have_body = 3283 const bool must_have_body =
3280 method->has_static && 3284 method->has_static &&
3281 !method->has_external && 3285 !method->has_external &&
3282 redirection_type.IsNull(); 3286 redirection_type.IsNull();
3283 if (must_have_body) { 3287 if (must_have_body) {
3284 ErrorMsg(method->name_pos, 3288 ErrorMsg(method->name_pos,
3285 "function body expected for method '%s'", 3289 "function body expected for method '%s'",
3286 method->name->ToCString()); 3290 method->name->ToCString());
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
3322 } else { 3326 } else {
3323 function_kind = RawFunction::kRegularFunction; 3327 function_kind = RawFunction::kRegularFunction;
3324 } 3328 }
3325 Function& func = Function::Handle( 3329 Function& func = Function::Handle(
3326 Function::New(*method->name, 3330 Function::New(*method->name,
3327 function_kind, 3331 function_kind,
3328 method->has_static, 3332 method->has_static,
3329 method->has_const, 3333 method->has_const,
3330 method->has_abstract, 3334 method->has_abstract,
3331 method->has_external, 3335 method->has_external,
3336 method->has_native,
3332 current_class(), 3337 current_class(),
3333 method->decl_begin_pos)); 3338 method->decl_begin_pos));
3334 func.set_result_type(*method->type); 3339 func.set_result_type(*method->type);
3335 func.set_end_token_pos(method_end_pos); 3340 func.set_end_token_pos(method_end_pos);
3336 func.set_is_redirecting(is_redirecting); 3341 func.set_is_redirecting(is_redirecting);
3337 if (method->metadata_pos > 0) { 3342 if (method->metadata_pos > 0) {
3338 library_.AddFunctionMetadata(func, method->metadata_pos); 3343 library_.AddFunctionMetadata(func, method->metadata_pos);
3339 } 3344 }
3340 3345
3341 // If this method is a redirecting factory, set the redirection information. 3346 // If this method is a redirecting factory, set the redirection information.
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
3439 if (field->has_static && has_initializer) { 3444 if (field->has_static && has_initializer) {
3440 class_field.set_value(init_value); 3445 class_field.set_value(init_value);
3441 if (!has_simple_literal) { 3446 if (!has_simple_literal) {
3442 String& getter_name = String::Handle(Field::GetterSymbol(*field->name)); 3447 String& getter_name = String::Handle(Field::GetterSymbol(*field->name));
3443 getter = Function::New(getter_name, 3448 getter = Function::New(getter_name,
3444 RawFunction::kImplicitStaticFinalGetter, 3449 RawFunction::kImplicitStaticFinalGetter,
3445 field->has_static, 3450 field->has_static,
3446 field->has_const, 3451 field->has_const,
3447 /* is_abstract = */ false, 3452 /* is_abstract = */ false,
3448 /* is_external = */ false, 3453 /* is_external = */ false,
3454 /* is_native = */ false,
3449 current_class(), 3455 current_class(),
3450 field->name_pos); 3456 field->name_pos);
3451 getter.set_result_type(*field->type); 3457 getter.set_result_type(*field->type);
3452 members->AddFunction(getter); 3458 members->AddFunction(getter);
3453 3459
3454 // Create initializer function for non-const fields. 3460 // Create initializer function for non-const fields.
3455 if (!class_field.is_const()) { 3461 if (!class_field.is_const()) {
3456 const Function& init_function = Function::ZoneHandle( 3462 const Function& init_function = Function::ZoneHandle(
3457 Function::NewStaticInitializer(class_field)); 3463 Function::NewStaticInitializer(class_field));
3458 members->AddFunction(init_function); 3464 members->AddFunction(init_function);
3459 } 3465 }
3460 } 3466 }
3461 } 3467 }
3462 3468
3463 // For instance fields, we create implicit getter and setter methods. 3469 // For instance fields, we create implicit getter and setter methods.
3464 if (!field->has_static) { 3470 if (!field->has_static) {
3465 String& getter_name = String::Handle(Field::GetterSymbol(*field->name)); 3471 String& getter_name = String::Handle(Field::GetterSymbol(*field->name));
3466 getter = Function::New(getter_name, RawFunction::kImplicitGetter, 3472 getter = Function::New(getter_name, RawFunction::kImplicitGetter,
3467 field->has_static, 3473 field->has_static,
3468 field->has_final, 3474 field->has_final,
3469 /* is_abstract = */ false, 3475 /* is_abstract = */ false,
3470 /* is_external = */ false, 3476 /* is_external = */ false,
3477 /* is_native = */ false,
3471 current_class(), 3478 current_class(),
3472 field->name_pos); 3479 field->name_pos);
3473 ParamList params; 3480 ParamList params;
3474 ASSERT(current_class().raw() == getter.Owner()); 3481 ASSERT(current_class().raw() == getter.Owner());
3475 params.AddReceiver(ReceiverType(current_class()), field->name_pos); 3482 params.AddReceiver(ReceiverType(current_class()), field->name_pos);
3476 getter.set_result_type(*field->type); 3483 getter.set_result_type(*field->type);
3477 AddFormalParamsToFunction(&params, getter); 3484 AddFormalParamsToFunction(&params, getter);
3478 members->AddFunction(getter); 3485 members->AddFunction(getter);
3479 if (!field->has_final) { 3486 if (!field->has_final) {
3480 // Build a setter accessor for non-const fields. 3487 // Build a setter accessor for non-const fields.
3481 String& setter_name = String::Handle(Field::SetterSymbol(*field->name)); 3488 String& setter_name = String::Handle(Field::SetterSymbol(*field->name));
3482 setter = Function::New(setter_name, RawFunction::kImplicitSetter, 3489 setter = Function::New(setter_name, RawFunction::kImplicitSetter,
3483 field->has_static, 3490 field->has_static,
3484 field->has_final, 3491 field->has_final,
3485 /* is_abstract = */ false, 3492 /* is_abstract = */ false,
3486 /* is_external = */ false, 3493 /* is_external = */ false,
3494 /* is_native = */ false,
3487 current_class(), 3495 current_class(),
3488 field->name_pos); 3496 field->name_pos);
3489 ParamList params; 3497 ParamList params;
3490 ASSERT(current_class().raw() == setter.Owner()); 3498 ASSERT(current_class().raw() == setter.Owner());
3491 params.AddReceiver(ReceiverType(current_class()), field->name_pos); 3499 params.AddReceiver(ReceiverType(current_class()), field->name_pos);
3492 params.AddFinalParameter(TokenPos(), 3500 params.AddFinalParameter(TokenPos(),
3493 &Symbols::Value(), 3501 &Symbols::Value(),
3494 field->type); 3502 field->type);
3495 setter.set_result_type(Type::Handle(Type::VoidType())); 3503 setter.set_result_type(Type::Handle(Type::VoidType()));
3496 AddFormalParamsToFunction(&params, setter); 3504 AddFormalParamsToFunction(&params, setter);
(...skipping 506 matching lines...) Expand 10 before | Expand all | Expand 10 after
4003 // To indicate that this is an implicit constructor, we set the 4011 // To indicate that this is an implicit constructor, we set the
4004 // token position and end token position of the function 4012 // token position and end token position of the function
4005 // to the token position of the class. 4013 // to the token position of the class.
4006 Function& ctor = Function::Handle( 4014 Function& ctor = Function::Handle(
4007 Function::New(ctor_name, 4015 Function::New(ctor_name,
4008 RawFunction::kConstructor, 4016 RawFunction::kConstructor,
4009 /* is_static = */ false, 4017 /* is_static = */ false,
4010 /* is_const = */ false, 4018 /* is_const = */ false,
4011 /* is_abstract = */ false, 4019 /* is_abstract = */ false,
4012 /* is_external = */ false, 4020 /* is_external = */ false,
4021 /* is_native = */ false,
4013 cls, 4022 cls,
4014 cls.token_pos())); 4023 cls.token_pos()));
4015 ctor.set_end_token_pos(ctor.token_pos()); 4024 ctor.set_end_token_pos(ctor.token_pos());
4016 4025
4017 ParamList params; 4026 ParamList params;
4018 // Add implicit 'this' parameter. 4027 // Add implicit 'this' parameter.
4019 const AbstractType* receiver_type = ReceiverType(cls); 4028 const AbstractType* receiver_type = ReceiverType(cls);
4020 params.AddReceiver(receiver_type, cls.token_pos()); 4029 params.AddReceiver(receiver_type, cls.token_pos());
4021 // Add implicit parameter for construction phase. 4030 // Add implicit parameter for construction phase.
4022 params.AddFinalParameter(cls.token_pos(), 4031 params.AddFinalParameter(cls.token_pos(),
(...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after
4231 ParseFormalParameterList(no_explicit_default_values, false, &func_params); 4240 ParseFormalParameterList(no_explicit_default_values, false, &func_params);
4232 ExpectSemicolon(); 4241 ExpectSemicolon();
4233 // The field 'is_static' has no meaning for signature functions. 4242 // The field 'is_static' has no meaning for signature functions.
4234 Function& signature_function = Function::Handle( 4243 Function& signature_function = Function::Handle(
4235 Function::New(*alias_name, 4244 Function::New(*alias_name,
4236 RawFunction::kSignatureFunction, 4245 RawFunction::kSignatureFunction,
4237 /* is_static = */ false, 4246 /* is_static = */ false,
4238 /* is_const = */ false, 4247 /* is_const = */ false,
4239 /* is_abstract = */ false, 4248 /* is_abstract = */ false,
4240 /* is_external = */ false, 4249 /* is_external = */ false,
4250 /* is_native = */ false,
4241 function_type_alias, 4251 function_type_alias,
4242 alias_name_pos)); 4252 alias_name_pos));
4243 signature_function.set_result_type(result_type); 4253 signature_function.set_result_type(result_type);
4244 AddFormalParamsToFunction(&func_params, signature_function); 4254 AddFormalParamsToFunction(&func_params, signature_function);
4245 4255
4246 // Patch the signature function in the signature class. 4256 // Patch the signature function in the signature class.
4247 function_type_alias.PatchSignatureFunction(signature_function); 4257 function_type_alias.PatchSignatureFunction(signature_function);
4248 4258
4249 const String& signature = String::Handle(signature_function.Signature()); 4259 const String& signature = String::Handle(signature_function.Signature());
4250 if (FLAG_trace_parser) { 4260 if (FLAG_trace_parser) {
(...skipping 313 matching lines...) Expand 10 before | Expand all | Expand 10 after
4564 field.set_value(field_value); 4574 field.set_value(field_value);
4565 if (!has_simple_literal) { 4575 if (!has_simple_literal) {
4566 // Create a static final getter. 4576 // Create a static final getter.
4567 String& getter_name = String::Handle(Field::GetterSymbol(var_name)); 4577 String& getter_name = String::Handle(Field::GetterSymbol(var_name));
4568 getter = Function::New(getter_name, 4578 getter = Function::New(getter_name,
4569 RawFunction::kImplicitStaticFinalGetter, 4579 RawFunction::kImplicitStaticFinalGetter,
4570 is_static, 4580 is_static,
4571 is_const, 4581 is_const,
4572 /* is_abstract = */ false, 4582 /* is_abstract = */ false,
4573 /* is_external = */ false, 4583 /* is_external = */ false,
4584 /* is_native = */ false,
4574 current_class(), 4585 current_class(),
4575 name_pos); 4586 name_pos);
4576 getter.set_result_type(type); 4587 getter.set_result_type(type);
4577 top_level->functions.Add(getter); 4588 top_level->functions.Add(getter);
4578 4589
4579 // Create initializer function. 4590 // Create initializer function.
4580 if (!field.is_const()) { 4591 if (!field.is_const()) {
4581 const Function& init_function = Function::ZoneHandle( 4592 const Function& init_function = Function::ZoneHandle(
4582 Function::NewStaticInitializer(field)); 4593 Function::NewStaticInitializer(field));
4583 top_level->functions.Add(init_function); 4594 top_level->functions.Add(init_function);
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
4644 // A setter named x= may co-exist with a function named x, thus we do 4655 // A setter named x= may co-exist with a function named x, thus we do
4645 // not need to check setters. 4656 // not need to check setters.
4646 4657
4647 CheckToken(Token::kLPAREN); 4658 CheckToken(Token::kLPAREN);
4648 const intptr_t function_pos = TokenPos(); 4659 const intptr_t function_pos = TokenPos();
4649 ParamList params; 4660 ParamList params;
4650 const bool allow_explicit_default_values = true; 4661 const bool allow_explicit_default_values = true;
4651 ParseFormalParameterList(allow_explicit_default_values, false, &params); 4662 ParseFormalParameterList(allow_explicit_default_values, false, &params);
4652 4663
4653 intptr_t function_end_pos = function_pos; 4664 intptr_t function_end_pos = function_pos;
4665 bool is_native = false;
4654 if (is_external) { 4666 if (is_external) {
4655 function_end_pos = TokenPos(); 4667 function_end_pos = TokenPos();
4656 ExpectSemicolon(); 4668 ExpectSemicolon();
4657 } else if (CurrentToken() == Token::kLBRACE) { 4669 } else if (CurrentToken() == Token::kLBRACE) {
4658 SkipBlock(); 4670 SkipBlock();
4659 function_end_pos = TokenPos(); 4671 function_end_pos = TokenPos();
4660 ExpectToken(Token::kRBRACE); 4672 ExpectToken(Token::kRBRACE);
4661 } else if (CurrentToken() == Token::kARROW) { 4673 } else if (CurrentToken() == Token::kARROW) {
4662 ConsumeToken(); 4674 ConsumeToken();
4663 SkipExpr(); 4675 SkipExpr();
4664 function_end_pos = TokenPos(); 4676 function_end_pos = TokenPos();
4665 ExpectSemicolon(); 4677 ExpectSemicolon();
4666 } else if (IsLiteral("native")) { 4678 } else if (IsLiteral("native")) {
4667 ParseNativeDeclaration(); 4679 ParseNativeDeclaration();
4668 function_end_pos = TokenPos(); 4680 function_end_pos = TokenPos();
4669 ExpectSemicolon(); 4681 ExpectSemicolon();
4682 is_native = true;
4670 } else { 4683 } else {
4671 ErrorMsg("function block expected"); 4684 ErrorMsg("function block expected");
4672 } 4685 }
4673 Function& func = Function::Handle( 4686 Function& func = Function::Handle(
4674 Function::New(func_name, 4687 Function::New(func_name,
4675 RawFunction::kRegularFunction, 4688 RawFunction::kRegularFunction,
4676 is_static, 4689 is_static,
4677 /* is_const = */ false, 4690 /* is_const = */ false,
4678 /* is_abstract = */ false, 4691 /* is_abstract = */ false,
4679 is_external, 4692 is_external,
4693 is_native,
4680 current_class(), 4694 current_class(),
4681 decl_begin_pos)); 4695 decl_begin_pos));
4682 func.set_result_type(result_type); 4696 func.set_result_type(result_type);
4683 func.set_end_token_pos(function_end_pos); 4697 func.set_end_token_pos(function_end_pos);
4684 AddFormalParamsToFunction(&params, func); 4698 AddFormalParamsToFunction(&params, func);
4685 top_level->functions.Add(func); 4699 top_level->functions.Add(func);
4686 if (!is_patch) { 4700 if (!is_patch) {
4687 library_.AddObject(func, func_name); 4701 library_.AddObject(func, func_name);
4688 } else { 4702 } else {
4689 library_.ReplaceObject(func, func_name); 4703 library_.ReplaceObject(func, func_name);
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
4774 ErrorMsg(name_pos, "%s for '%s' is already defined", 4788 ErrorMsg(name_pos, "%s for '%s' is already defined",
4775 is_getter ? "getter" : "setter", 4789 is_getter ? "getter" : "setter",
4776 field_name->ToCString()); 4790 field_name->ToCString());
4777 } else if (!found && is_patch) { 4791 } else if (!found && is_patch) {
4778 ErrorMsg(name_pos, "missing %s for '%s' cannot be patched", 4792 ErrorMsg(name_pos, "missing %s for '%s' cannot be patched",
4779 is_getter ? "getter" : "setter", 4793 is_getter ? "getter" : "setter",
4780 field_name->ToCString()); 4794 field_name->ToCString());
4781 } 4795 }
4782 4796
4783 intptr_t accessor_end_pos = accessor_pos; 4797 intptr_t accessor_end_pos = accessor_pos;
4798 bool is_native = false;
4784 if (is_external) { 4799 if (is_external) {
4785 accessor_end_pos = TokenPos(); 4800 accessor_end_pos = TokenPos();
4786 ExpectSemicolon(); 4801 ExpectSemicolon();
4787 } else if (CurrentToken() == Token::kLBRACE) { 4802 } else if (CurrentToken() == Token::kLBRACE) {
4788 SkipBlock(); 4803 SkipBlock();
4789 accessor_end_pos = TokenPos(); 4804 accessor_end_pos = TokenPos();
4790 ExpectToken(Token::kRBRACE); 4805 ExpectToken(Token::kRBRACE);
4791 } else if (CurrentToken() == Token::kARROW) { 4806 } else if (CurrentToken() == Token::kARROW) {
4792 ConsumeToken(); 4807 ConsumeToken();
4793 SkipExpr(); 4808 SkipExpr();
4794 accessor_end_pos = TokenPos(); 4809 accessor_end_pos = TokenPos();
4795 ExpectSemicolon(); 4810 ExpectSemicolon();
4796 } else if (IsLiteral("native")) { 4811 } else if (IsLiteral("native")) {
4797 ParseNativeDeclaration(); 4812 ParseNativeDeclaration();
4798 accessor_end_pos = TokenPos(); 4813 accessor_end_pos = TokenPos();
4799 ExpectSemicolon(); 4814 ExpectSemicolon();
4815 is_native = true;
4800 } else { 4816 } else {
4801 ErrorMsg("function block expected"); 4817 ErrorMsg("function block expected");
4802 } 4818 }
4803 Function& func = Function::Handle( 4819 Function& func = Function::Handle(
4804 Function::New(accessor_name, 4820 Function::New(accessor_name,
4805 is_getter? RawFunction::kGetterFunction : 4821 is_getter ? RawFunction::kGetterFunction :
4806 RawFunction::kSetterFunction, 4822 RawFunction::kSetterFunction,
4807 is_static, 4823 is_static,
4808 /* is_const = */ false, 4824 /* is_const = */ false,
4809 /* is_abstract = */ false, 4825 /* is_abstract = */ false,
4810 is_external, 4826 is_external,
4827 is_native,
4811 current_class(), 4828 current_class(),
4812 decl_begin_pos)); 4829 decl_begin_pos));
4813 func.set_result_type(result_type); 4830 func.set_result_type(result_type);
4814 func.set_end_token_pos(accessor_end_pos); 4831 func.set_end_token_pos(accessor_end_pos);
4815 AddFormalParamsToFunction(&params, func); 4832 AddFormalParamsToFunction(&params, func);
4816 top_level->functions.Add(func); 4833 top_level->functions.Add(func);
4817 if (!is_patch) { 4834 if (!is_patch) {
4818 library_.AddObject(func, accessor_name); 4835 library_.AddObject(func, accessor_name);
4819 } else { 4836 } else {
4820 library_.ReplaceObject(func, accessor_name); 4837 library_.ReplaceObject(func, accessor_name);
(...skipping 459 matching lines...) Expand 10 before | Expand all | Expand 10 after
5280 if (param_desc.is_field_initializer) { 5297 if (param_desc.is_field_initializer) {
5281 parameter->set_invisible(true); 5298 parameter->set_invisible(true);
5282 } 5299 }
5283 } 5300 }
5284 } 5301 }
5285 5302
5286 5303
5287 // Builds ReturnNode/NativeBodyNode for a native function. 5304 // Builds ReturnNode/NativeBodyNode for a native function.
5288 void Parser::ParseNativeFunctionBlock(const ParamList* params, 5305 void Parser::ParseNativeFunctionBlock(const ParamList* params,
5289 const Function& func) { 5306 const Function& func) {
5290 func.set_is_native(true); 5307 ASSERT(func.is_native());
5291 TRACE_PARSER("ParseNativeFunctionBlock"); 5308 TRACE_PARSER("ParseNativeFunctionBlock");
5292 const Class& cls = Class::Handle(func.Owner()); 5309 const Class& cls = Class::Handle(func.Owner());
5293 const Library& library = Library::Handle(cls.library()); 5310 const Library& library = Library::Handle(cls.library());
5294 ASSERT(func.NumParameters() == params->parameters->length()); 5311 ASSERT(func.NumParameters() == params->parameters->length());
5295 5312
5296 // Parse the function name out. 5313 // Parse the function name out.
5297 const intptr_t native_pos = TokenPos(); 5314 const intptr_t native_pos = TokenPos();
5298 const String& native_name = ParseNativeDeclaration(); 5315 const String& native_name = ParseNativeDeclaration();
5299 5316
5300 // Now resolve the native function to the corresponding native entrypoint. 5317 // Now resolve the native function to the corresponding native entrypoint.
(...skipping 5398 matching lines...) Expand 10 before | Expand all | Expand 10 after
10699 void Parser::SkipQualIdent() { 10716 void Parser::SkipQualIdent() {
10700 ASSERT(IsIdentifier()); 10717 ASSERT(IsIdentifier());
10701 ConsumeToken(); 10718 ConsumeToken();
10702 if (CurrentToken() == Token::kPERIOD) { 10719 if (CurrentToken() == Token::kPERIOD) {
10703 ConsumeToken(); // Consume the kPERIOD token. 10720 ConsumeToken(); // Consume the kPERIOD token.
10704 ExpectIdentifier("identifier expected after '.'"); 10721 ExpectIdentifier("identifier expected after '.'");
10705 } 10722 }
10706 } 10723 }
10707 10724
10708 } // namespace dart 10725 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/object_test.cc ('k') | runtime/vm/resolver.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698