Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2016, 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 <map> | 5 #include <map> |
| 6 #include <set> | 6 #include <set> |
| 7 #include <string> | 7 #include <string> |
| 8 | 8 |
| 9 #include "vm/kernel_to_il.h" | 9 #include "vm/kernel_to_il.h" |
| 10 | 10 |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 51 } else if ((*outermost_node)->IsConstructor()) { | 51 } else if ((*outermost_node)->IsConstructor()) { |
| 52 parent = Constructor::Cast(*outermost_node)->parent(); | 52 parent = Constructor::Cast(*outermost_node)->parent(); |
| 53 } else if ((*outermost_node)->IsField()) { | 53 } else if ((*outermost_node)->IsField()) { |
| 54 parent = Field::Cast(*outermost_node)->parent(); | 54 parent = Field::Cast(*outermost_node)->parent(); |
| 55 } | 55 } |
| 56 if (parent != NULL && parent->IsClass()) *klass = Class::Cast(parent); | 56 if (parent != NULL && parent->IsClass()) *klass = Class::Cast(parent); |
| 57 } | 57 } |
| 58 } | 58 } |
| 59 | 59 |
| 60 | 60 |
| 61 void ScopeBuilder::EnterScope(TreeNode* node) { | 61 void ScopeBuilder::EnterScope(TreeNode* node, TokenPosition start_position) { |
| 62 scope_ = new (Z) LocalScope(scope_, depth_.function_, depth_.loop_); | 62 scope_ = new (Z) LocalScope(scope_, depth_.function_, depth_.loop_); |
| 63 scope_->set_begin_token_pos(start_position); | |
| 63 result_->scopes.Insert(node, scope_); | 64 result_->scopes.Insert(node, scope_); |
| 64 } | 65 } |
| 65 | 66 |
| 66 | 67 |
| 67 void ScopeBuilder::ExitScope() { | 68 void ScopeBuilder::ExitScope(TokenPosition end_position) { |
| 69 scope_->set_end_token_pos(end_position); | |
| 68 scope_ = scope_->parent(); | 70 scope_ = scope_->parent(); |
| 69 } | 71 } |
| 70 | 72 |
| 71 | 73 |
| 72 LocalVariable* ScopeBuilder::MakeVariable(const dart::String& name, | 74 LocalVariable* ScopeBuilder::MakeVariable(const dart::String& name, |
| 73 const AbstractType& type) { | 75 const AbstractType& type, |
| 74 return new (Z) LocalVariable(TokenPosition::kNoSource, | 76 TokenPosition declaration_pos, |
| 75 TokenPosition::kNoSource, name, type); | 77 TokenPosition token_pos) { |
| 78 return new (Z) LocalVariable(declaration_pos, token_pos, name, type); | |
| 76 } | 79 } |
| 77 | 80 |
| 78 | 81 |
| 79 void ScopeBuilder::AddParameters(FunctionNode* function, intptr_t pos) { | 82 void ScopeBuilder::AddParameters(FunctionNode* function, intptr_t pos) { |
| 80 List<VariableDeclaration>& positional = function->positional_parameters(); | 83 List<VariableDeclaration>& positional = function->positional_parameters(); |
| 81 for (intptr_t i = 0; i < positional.length(); ++i) { | 84 for (intptr_t i = 0; i < positional.length(); ++i) { |
| 82 AddParameter(positional[i], pos++); | 85 AddParameter(positional[i], pos++); |
| 83 } | 86 } |
| 84 List<VariableDeclaration>& named = function->named_parameters(); | 87 List<VariableDeclaration>& named = function->named_parameters(); |
| 85 for (intptr_t i = 0; i < named.length(); ++i) { | 88 for (intptr_t i = 0; i < named.length(); ++i) { |
| 86 AddParameter(named[i], pos++); | 89 AddParameter(named[i], pos++); |
| 87 } | 90 } |
| 88 } | 91 } |
| 89 | 92 |
| 90 | 93 |
| 91 void ScopeBuilder::AddParameter(VariableDeclaration* declaration, | 94 void ScopeBuilder::AddParameter(VariableDeclaration* declaration, |
| 92 intptr_t pos) { | 95 intptr_t pos) { |
| 93 LocalVariable* variable = MakeVariable(H.DartSymbol(declaration->name()), | 96 LocalVariable* variable = MakeVariable(H.DartSymbol(declaration->name()), |
| 94 T.TranslateVariableType(declaration)); | 97 T.TranslateVariableType(declaration), |
| 98 declaration->position()); | |
| 95 if (declaration->IsFinal()) { | 99 if (declaration->IsFinal()) { |
| 96 variable->set_is_final(); | 100 variable->set_is_final(); |
| 97 } | 101 } |
| 98 scope_->InsertParameterAt(pos, variable); | 102 scope_->InsertParameterAt(pos, variable); |
| 99 result_->locals.Insert(declaration, variable); | 103 result_->locals.Insert(declaration, variable); |
| 100 | 104 |
| 101 // The default value may contain 'let' bindings for which the constant | 105 // The default value may contain 'let' bindings for which the constant |
| 102 // evaluator needs scope bindings. | 106 // evaluator needs scope bindings. |
| 103 Expression* defaultValue = declaration->initializer(); | 107 Expression* defaultValue = declaration->initializer(); |
| 104 if (defaultValue != NULL) { | 108 if (defaultValue != NULL) { |
| (...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 230 | 234 |
| 231 | 235 |
| 232 void ScopeBuilder::AddVariable(VariableDeclaration* declaration) { | 236 void ScopeBuilder::AddVariable(VariableDeclaration* declaration) { |
| 233 // In case `declaration->IsConst()` the flow graph building will take care of | 237 // In case `declaration->IsConst()` the flow graph building will take care of |
| 234 // evaluating the constant and setting it via | 238 // evaluating the constant and setting it via |
| 235 // `declaration->SetConstantValue()`. | 239 // `declaration->SetConstantValue()`. |
| 236 const dart::String& name = declaration->name()->is_empty() | 240 const dart::String& name = declaration->name()->is_empty() |
| 237 ? GenerateName(":var", name_index_++) | 241 ? GenerateName(":var", name_index_++) |
| 238 : H.DartSymbol(declaration->name()); | 242 : H.DartSymbol(declaration->name()); |
| 239 LocalVariable* variable = | 243 LocalVariable* variable = |
| 240 MakeVariable(name, T.TranslateVariableType(declaration)); | 244 MakeVariable(name, T.TranslateVariableType(declaration), |
| 245 declaration->position(), declaration->end_position()); | |
| 241 if (declaration->IsFinal()) { | 246 if (declaration->IsFinal()) { |
| 242 variable->set_is_final(); | 247 variable->set_is_final(); |
| 243 } | 248 } |
| 244 scope_->AddVariable(variable); | 249 scope_->AddVariable(variable); |
| 245 result_->locals.Insert(declaration, variable); | 250 result_->locals.Insert(declaration, variable); |
| 246 } | 251 } |
| 247 | 252 |
| 248 | 253 |
| 249 static bool IsStaticInitializer(const Function& function, Zone* zone) { | 254 static bool IsStaticInitializer(const Function& function, Zone* zone) { |
| 250 return (function.kind() == RawFunction::kImplicitStaticFinalGetter) && | 255 return (function.kind() == RawFunction::kImplicitStaticFinalGetter) && |
| (...skipping 29 matching lines...) Expand all Loading... | |
| 280 : NULL; | 285 : NULL; |
| 281 ActiveMemberScope active_member(&active_class_, member); | 286 ActiveMemberScope active_member(&active_class_, member); |
| 282 | 287 |
| 283 | 288 |
| 284 LocalScope* enclosing_scope = NULL; | 289 LocalScope* enclosing_scope = NULL; |
| 285 if (function.IsLocalFunction()) { | 290 if (function.IsLocalFunction()) { |
| 286 enclosing_scope = LocalScope::RestoreOuterScope( | 291 enclosing_scope = LocalScope::RestoreOuterScope( |
| 287 ContextScope::Handle(Z, function.context_scope())); | 292 ContextScope::Handle(Z, function.context_scope())); |
| 288 } | 293 } |
| 289 current_function_scope_ = scope_ = new (Z) LocalScope(enclosing_scope, 0, 0); | 294 current_function_scope_ = scope_ = new (Z) LocalScope(enclosing_scope, 0, 0); |
| 295 scope_->set_begin_token_pos(function.token_pos()); | |
| 296 scope_->set_end_token_pos(function.end_token_pos()); | |
| 290 | 297 |
| 291 LocalVariable* context_var = parsed_function->current_context_var(); | 298 LocalVariable* context_var = parsed_function->current_context_var(); |
| 292 context_var->set_is_forced_stack(); | 299 context_var->set_is_forced_stack(); |
| 293 scope_->AddVariable(context_var); | 300 scope_->AddVariable(context_var); |
| 294 scope_->AddVariable(parsed_function->EnsureExpressionTemp()); | 301 scope_->AddVariable(parsed_function->EnsureExpressionTemp()); |
| 295 | 302 |
| 296 parsed_function->SetNodeSequence( | 303 parsed_function->SetNodeSequence( |
| 297 new SequenceNode(TokenPosition::kNoSource, scope_)); | 304 new SequenceNode(TokenPosition::kNoSource, scope_)); |
| 298 | 305 |
| 299 switch (function.kind()) { | 306 switch (function.kind()) { |
| (...skipping 28 matching lines...) Expand all Loading... | |
| 328 result_->this_variable = variable; | 335 result_->this_variable = variable; |
| 329 | 336 |
| 330 // We visit instance field initializers because they might contain | 337 // We visit instance field initializers because they might contain |
| 331 // [Let] expressions and we need to have a mapping. | 338 // [Let] expressions and we need to have a mapping. |
| 332 if (node_->IsConstructor()) { | 339 if (node_->IsConstructor()) { |
| 333 Class* klass = Class::Cast(Constructor::Cast(node_)->parent()); | 340 Class* klass = Class::Cast(Constructor::Cast(node_)->parent()); |
| 334 | 341 |
| 335 for (intptr_t i = 0; i < klass->fields().length(); i++) { | 342 for (intptr_t i = 0; i < klass->fields().length(); i++) { |
| 336 Field* field = klass->fields()[i]; | 343 Field* field = klass->fields()[i]; |
| 337 if (!field->IsStatic() && (field->initializer() != NULL)) { | 344 if (!field->IsStatic() && (field->initializer() != NULL)) { |
| 338 EnterScope(field); | 345 EnterScope(field, field->position()); |
| 339 field->initializer()->AcceptExpressionVisitor(this); | 346 field->initializer()->AcceptExpressionVisitor(this); |
| 340 ExitScope(); | 347 ExitScope(field->end_position()); |
| 341 } | 348 } |
| 342 } | 349 } |
| 343 } | 350 } |
| 344 } else if (function.IsFactory()) { | 351 } else if (function.IsFactory()) { |
| 345 LocalVariable* variable = MakeVariable( | 352 LocalVariable* variable = MakeVariable( |
| 346 Symbols::TypeArgumentsParameter(), AbstractType::dynamic_type()); | 353 Symbols::TypeArgumentsParameter(), AbstractType::dynamic_type()); |
| 347 scope_->InsertParameterAt(pos++, variable); | 354 scope_->InsertParameterAt(pos++, variable); |
| 348 result_->type_arguments_variable = variable; | 355 result_->type_arguments_variable = variable; |
| 349 } | 356 } |
| 350 AddParameters(node, pos); | 357 AddParameters(node, pos); |
| (...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 448 node->VisitChildren(this); | 455 node->VisitChildren(this); |
| 449 } | 456 } |
| 450 | 457 |
| 451 | 458 |
| 452 void ScopeBuilder::HandleLocalFunction(TreeNode* parent, | 459 void ScopeBuilder::HandleLocalFunction(TreeNode* parent, |
| 453 FunctionNode* function) { | 460 FunctionNode* function) { |
| 454 LocalScope* saved_function_scope = current_function_scope_; | 461 LocalScope* saved_function_scope = current_function_scope_; |
| 455 FunctionNode* saved_function_node = current_function_node_; | 462 FunctionNode* saved_function_node = current_function_node_; |
| 456 ScopeBuilder::DepthState saved_depth_state = depth_; | 463 ScopeBuilder::DepthState saved_depth_state = depth_; |
| 457 depth_ = DepthState(depth_.function_ + 1); | 464 depth_ = DepthState(depth_.function_ + 1); |
| 458 EnterScope(parent); | 465 EnterScope(parent, function->position()); |
| 459 current_function_scope_ = scope_; | 466 current_function_scope_ = scope_; |
| 460 current_function_node_ = function; | 467 current_function_node_ = function; |
| 461 if (depth_.function_ == 1) { | 468 if (depth_.function_ == 1) { |
| 462 FunctionScope function_scope = {function, scope_}; | 469 FunctionScope function_scope = {function, scope_}; |
| 463 result_->function_scopes.Add(function_scope); | 470 result_->function_scopes.Add(function_scope); |
| 464 } | 471 } |
| 465 AddParameters(function); | 472 AddParameters(function); |
| 466 VisitFunctionNode(function); | 473 VisitFunctionNode(function); |
| 467 ExitScope(); | 474 ExitScope(function->end_position()); |
| 468 depth_ = saved_depth_state; | 475 depth_ = saved_depth_state; |
| 469 current_function_scope_ = saved_function_scope; | 476 current_function_scope_ = saved_function_scope; |
| 470 current_function_node_ = saved_function_node; | 477 current_function_node_ = saved_function_node; |
| 471 } | 478 } |
| 472 | 479 |
| 473 | 480 |
| 474 void ScopeBuilder::HandleSpecialLoad(LocalVariable** variable, | 481 void ScopeBuilder::HandleSpecialLoad(LocalVariable** variable, |
| 475 const dart::String& symbol) { | 482 const dart::String& symbol) { |
| 476 if (current_function_scope_->parent() != NULL) { | 483 if (current_function_scope_->parent() != NULL) { |
| 477 // We are building the scope tree of a closure function and saw [node]. We | 484 // We are building the scope tree of a closure function and saw [node]. We |
| (...skipping 14 matching lines...) Expand all Loading... | |
| 492 } | 499 } |
| 493 } | 500 } |
| 494 | 501 |
| 495 | 502 |
| 496 void ScopeBuilder::VisitFunctionExpression(FunctionExpression* node) { | 503 void ScopeBuilder::VisitFunctionExpression(FunctionExpression* node) { |
| 497 HandleLocalFunction(node, node->function()); | 504 HandleLocalFunction(node, node->function()); |
| 498 } | 505 } |
| 499 | 506 |
| 500 | 507 |
| 501 void ScopeBuilder::VisitLet(Let* node) { | 508 void ScopeBuilder::VisitLet(Let* node) { |
| 502 EnterScope(node); | 509 EnterScope(node, node->position()); |
| 503 node->VisitChildren(this); | 510 node->VisitChildren(this); |
| 504 ExitScope(); | 511 ExitScope(node->end_position()); |
| 505 } | 512 } |
| 506 | 513 |
| 507 | 514 |
| 508 void ScopeBuilder::VisitBlock(Block* node) { | 515 void ScopeBuilder::VisitBlock(Block* node) { |
| 509 EnterScope(node); | 516 EnterScope(node, node->position()); |
| 510 node->VisitChildren(this); | 517 node->VisitChildren(this); |
| 511 ExitScope(); | 518 ExitScope(node->end_position()); |
| 512 } | 519 } |
| 513 | 520 |
| 514 | 521 |
| 515 void ScopeBuilder::VisitVariableDeclaration(VariableDeclaration* node) { | 522 void ScopeBuilder::VisitVariableDeclaration(VariableDeclaration* node) { |
| 516 AddVariable(node); | 523 AddVariable(node); |
| 517 node->VisitChildren(this); | 524 node->VisitChildren(this); |
| 518 } | 525 } |
| 519 | 526 |
| 520 | 527 |
| 521 void ScopeBuilder::VisitFunctionDeclaration(FunctionDeclaration* node) { | 528 void ScopeBuilder::VisitFunctionDeclaration(FunctionDeclaration* node) { |
| (...skipping 10 matching lines...) Expand all Loading... | |
| 532 | 539 |
| 533 | 540 |
| 534 void ScopeBuilder::VisitDoStatement(DoStatement* node) { | 541 void ScopeBuilder::VisitDoStatement(DoStatement* node) { |
| 535 ++depth_.loop_; | 542 ++depth_.loop_; |
| 536 node->VisitChildren(this); | 543 node->VisitChildren(this); |
| 537 --depth_.loop_; | 544 --depth_.loop_; |
| 538 } | 545 } |
| 539 | 546 |
| 540 | 547 |
| 541 void ScopeBuilder::VisitForStatement(ForStatement* node) { | 548 void ScopeBuilder::VisitForStatement(ForStatement* node) { |
| 542 EnterScope(node); | 549 EnterScope(node, node->position()); |
| 543 List<VariableDeclaration>& variables = node->variables(); | 550 List<VariableDeclaration>& variables = node->variables(); |
| 544 for (intptr_t i = 0; i < variables.length(); ++i) { | 551 for (intptr_t i = 0; i < variables.length(); ++i) { |
| 545 VisitVariableDeclaration(variables[i]); | 552 VisitVariableDeclaration(variables[i]); |
| 546 } | 553 } |
| 547 ++depth_.loop_; | 554 ++depth_.loop_; |
| 548 if (node->condition() != NULL) { | 555 if (node->condition() != NULL) { |
| 549 node->condition()->AcceptExpressionVisitor(this); | 556 node->condition()->AcceptExpressionVisitor(this); |
| 550 } | 557 } |
| 551 node->body()->AcceptStatementVisitor(this); | 558 node->body()->AcceptStatementVisitor(this); |
| 552 List<Expression>& updates = node->updates(); | 559 List<Expression>& updates = node->updates(); |
| 553 for (intptr_t i = 0; i < updates.length(); ++i) { | 560 for (intptr_t i = 0; i < updates.length(); ++i) { |
| 554 updates[i]->AcceptExpressionVisitor(this); | 561 updates[i]->AcceptExpressionVisitor(this); |
| 555 } | 562 } |
| 556 --depth_.loop_; | 563 --depth_.loop_; |
| 557 ExitScope(); | 564 ExitScope(node->end_position()); |
| 558 } | 565 } |
| 559 | 566 |
| 560 | 567 |
| 561 void ScopeBuilder::VisitForInStatement(ForInStatement* node) { | 568 void ScopeBuilder::VisitForInStatement(ForInStatement* node) { |
| 562 node->iterable()->AcceptExpressionVisitor(this); | 569 node->iterable()->AcceptExpressionVisitor(this); |
| 563 ++depth_.for_in_; | 570 ++depth_.for_in_; |
| 564 AddIteratorVariable(); | 571 AddIteratorVariable(); |
| 565 ++depth_.loop_; | 572 ++depth_.loop_; |
| 566 EnterScope(node); | 573 EnterScope(node, node->position()); |
| 567 VisitVariableDeclaration(node->variable()); | 574 VisitVariableDeclaration(node->variable()); |
| 568 node->body()->AcceptStatementVisitor(this); | 575 node->body()->AcceptStatementVisitor(this); |
| 569 ExitScope(); | 576 ExitScope(node->end_position()); |
| 570 --depth_.loop_; | 577 --depth_.loop_; |
| 571 --depth_.for_in_; | 578 --depth_.for_in_; |
| 572 } | 579 } |
| 573 | 580 |
| 574 | 581 |
| 575 void ScopeBuilder::AddSwitchVariable() { | 582 void ScopeBuilder::AddSwitchVariable() { |
| 576 if ((depth_.function_ == 0) && (result_->switch_variable == NULL)) { | 583 if ((depth_.function_ == 0) && (result_->switch_variable == NULL)) { |
| 577 LocalVariable* variable = | 584 LocalVariable* variable = |
| 578 MakeVariable(Symbols::SwitchExpr(), AbstractType::dynamic_type()); | 585 MakeVariable(Symbols::SwitchExpr(), AbstractType::dynamic_type()); |
| 579 variable->set_is_forced_stack(); | 586 variable->set_is_forced_stack(); |
| (...skipping 25 matching lines...) Expand all Loading... | |
| 605 ++depth_.try_; | 612 ++depth_.try_; |
| 606 AddTryVariables(); | 613 AddTryVariables(); |
| 607 node->body()->AcceptStatementVisitor(this); | 614 node->body()->AcceptStatementVisitor(this); |
| 608 --depth_.try_; | 615 --depth_.try_; |
| 609 | 616 |
| 610 ++depth_.catch_; | 617 ++depth_.catch_; |
| 611 AddCatchVariables(); | 618 AddCatchVariables(); |
| 612 List<Catch>& catches = node->catches(); | 619 List<Catch>& catches = node->catches(); |
| 613 for (intptr_t i = 0; i < catches.length(); ++i) { | 620 for (intptr_t i = 0; i < catches.length(); ++i) { |
| 614 Catch* ketch = catches[i]; | 621 Catch* ketch = catches[i]; |
| 615 EnterScope(ketch); | 622 EnterScope(ketch, ketch->position()); |
| 616 if (ketch->exception() != NULL) { | 623 if (ketch->exception() != NULL) { |
| 617 VisitVariableDeclaration(ketch->exception()); | 624 VisitVariableDeclaration(ketch->exception()); |
| 618 } | 625 } |
| 619 if (ketch->stack_trace() != NULL) { | 626 if (ketch->stack_trace() != NULL) { |
| 620 VisitVariableDeclaration(ketch->stack_trace()); | 627 VisitVariableDeclaration(ketch->stack_trace()); |
| 621 } | 628 } |
| 622 ketch->body()->AcceptStatementVisitor(this); | 629 ketch->body()->AcceptStatementVisitor(this); |
| 623 ExitScope(); | 630 ExitScope(ketch->end_position()); |
| 624 } | 631 } |
| 625 --depth_.catch_; | 632 --depth_.catch_; |
| 626 } | 633 } |
| 627 | 634 |
| 628 | 635 |
| 629 void ScopeBuilder::VisitTryFinally(TryFinally* node) { | 636 void ScopeBuilder::VisitTryFinally(TryFinally* node) { |
| 630 ++depth_.try_; | 637 ++depth_.try_; |
| 631 ++depth_.finally_; | 638 ++depth_.finally_; |
| 632 AddTryVariables(); | 639 AddTryVariables(); |
| 633 node->body()->AcceptStatementVisitor(this); | 640 node->body()->AcceptStatementVisitor(this); |
| (...skipping 1826 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2460 PushArgumentInstr* argument = new (Z) PushArgumentInstr(Pop()); | 2467 PushArgumentInstr* argument = new (Z) PushArgumentInstr(Pop()); |
| 2461 Push(argument); | 2468 Push(argument); |
| 2462 | 2469 |
| 2463 argument->set_temp_index(argument->temp_index() - 1); | 2470 argument->set_temp_index(argument->temp_index() - 1); |
| 2464 ++pending_argument_count_; | 2471 ++pending_argument_count_; |
| 2465 | 2472 |
| 2466 return Fragment(argument); | 2473 return Fragment(argument); |
| 2467 } | 2474 } |
| 2468 | 2475 |
| 2469 | 2476 |
| 2470 Fragment FlowGraphBuilder::Return() { | 2477 Fragment FlowGraphBuilder::Return(TokenPosition position) { |
| 2471 Value* value = Pop(); | 2478 Value* value = Pop(); |
| 2472 ASSERT(stack_ == NULL); | 2479 ASSERT(stack_ == NULL); |
| 2473 ReturnInstr* return_instr = | 2480 ReturnInstr* return_instr = |
| 2474 new (Z) ReturnInstr(TokenPosition::kNoSource, value); | 2481 new (Z) ReturnInstr(TokenPosition::kNoSource, value); |
| 2475 if (exit_collector_ != NULL) exit_collector_->AddExit(return_instr); | 2482 if (exit_collector_ != NULL) exit_collector_->AddExit(return_instr); |
| 2476 return Fragment(return_instr).closed(); | 2483 return Fragment(return_instr).closed(); |
| 2477 } | 2484 } |
| 2478 | 2485 |
| 2479 | 2486 |
| 2480 Fragment FlowGraphBuilder::StaticCall(TokenPosition position, | 2487 Fragment FlowGraphBuilder::StaticCall(TokenPosition position, |
| (...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2575 Value* value = Pop(); | 2582 Value* value = Pop(); |
| 2576 if (value->BindsToConstant()) { | 2583 if (value->BindsToConstant()) { |
| 2577 emit_store_barrier = kNoStoreBarrier; | 2584 emit_store_barrier = kNoStoreBarrier; |
| 2578 } | 2585 } |
| 2579 StoreInstanceFieldInstr* store = new (Z) StoreInstanceFieldInstr( | 2586 StoreInstanceFieldInstr* store = new (Z) StoreInstanceFieldInstr( |
| 2580 offset, Pop(), value, emit_store_barrier, TokenPosition::kNoSource); | 2587 offset, Pop(), value, emit_store_barrier, TokenPosition::kNoSource); |
| 2581 return Fragment(store); | 2588 return Fragment(store); |
| 2582 } | 2589 } |
| 2583 | 2590 |
| 2584 | 2591 |
| 2585 Fragment FlowGraphBuilder::StoreLocal(LocalVariable* variable) { | 2592 Fragment FlowGraphBuilder::StoreLocal(LocalVariable* variable, |
| 2593 TokenPosition position) { | |
| 2586 Fragment instructions; | 2594 Fragment instructions; |
| 2587 if (variable->is_captured()) { | 2595 if (variable->is_captured()) { |
| 2588 LocalVariable* value = MakeTemporary(); | 2596 LocalVariable* value = MakeTemporary(); |
| 2589 instructions += LoadContextAt(variable->owner()->context_level()); | 2597 instructions += LoadContextAt(variable->owner()->context_level()); |
| 2590 instructions += LoadLocal(value); | 2598 instructions += LoadLocal(value); |
| 2591 instructions += | 2599 instructions += |
| 2592 StoreInstanceField(Context::variable_offset(variable->index())); | 2600 StoreInstanceField(Context::variable_offset(variable->index())); |
| 2593 } else { | 2601 } else { |
| 2602 Value* value = Pop(); | |
| 2594 StoreLocalInstr* store = | 2603 StoreLocalInstr* store = |
| 2595 new (Z) StoreLocalInstr(*variable, Pop(), TokenPosition::kNoSource); | 2604 new (Z) StoreLocalInstr(*variable, value, position); |
| 2596 instructions <<= store; | 2605 instructions <<= store; |
| 2597 Push(store); | 2606 Push(store); |
| 2598 } | 2607 } |
| 2599 return instructions; | 2608 return instructions; |
| 2600 } | 2609 } |
| 2601 | 2610 |
| 2602 | 2611 |
| 2603 Fragment FlowGraphBuilder::StoreStaticField(const dart::Field& field) { | 2612 Fragment FlowGraphBuilder::StoreStaticField(const dart::Field& field) { |
| 2604 return Fragment(new (Z) StoreStaticFieldInstr(MayCloneField(Z, field), Pop(), | 2613 return Fragment(new (Z) StoreStaticFieldInstr(MayCloneField(Z, field), Pop(), |
| 2605 TokenPosition::kNoSource)); | 2614 TokenPosition::kNoSource)); |
| 2606 } | 2615 } |
| 2607 | 2616 |
| 2608 | 2617 |
| 2609 Fragment FlowGraphBuilder::StringInterpolate() { | 2618 Fragment FlowGraphBuilder::StringInterpolate(TokenPosition position) { |
| 2610 Value* array = Pop(); | 2619 Value* array = Pop(); |
| 2611 StringInterpolateInstr* interpolate = | 2620 StringInterpolateInstr* interpolate = |
| 2612 new (Z) StringInterpolateInstr(array, TokenPosition::kNoSource); | 2621 new (Z) StringInterpolateInstr(array, position); |
| 2613 Push(interpolate); | 2622 Push(interpolate); |
| 2614 return Fragment(interpolate); | 2623 return Fragment(interpolate); |
| 2615 } | 2624 } |
| 2616 | 2625 |
| 2617 | 2626 |
| 2618 Fragment FlowGraphBuilder::ThrowTypeError() { | 2627 Fragment FlowGraphBuilder::ThrowTypeError() { |
| 2619 const dart::Class& klass = dart::Class::ZoneHandle( | 2628 const dart::Class& klass = dart::Class::ZoneHandle( |
| 2620 Z, dart::Library::LookupCoreClass(Symbols::TypeError())); | 2629 Z, dart::Library::LookupCoreClass(Symbols::TypeError())); |
| 2621 ASSERT(!klass.IsNull()); | 2630 ASSERT(!klass.IsNull()); |
| 2622 const dart::Function& constructor = dart::Function::ZoneHandle( | 2631 const dart::Function& constructor = dart::Function::ZoneHandle( |
| (...skipping 387 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3010 TargetEntryInstr* non_null_entry; | 3019 TargetEntryInstr* non_null_entry; |
| 3011 | 3020 |
| 3012 body += LoadLocal(parameter); | 3021 body += LoadLocal(parameter); |
| 3013 body += BranchIfNull(&null_entry, &non_null_entry); | 3022 body += BranchIfNull(&null_entry, &non_null_entry); |
| 3014 | 3023 |
| 3015 // The argument was `null` and the receiver is not the null class (we only | 3024 // The argument was `null` and the receiver is not the null class (we only |
| 3016 // go into this branch for user-defined == operators) so we can return | 3025 // go into this branch for user-defined == operators) so we can return |
| 3017 // false. | 3026 // false. |
| 3018 Fragment null_fragment(null_entry); | 3027 Fragment null_fragment(null_entry); |
| 3019 null_fragment += Constant(Bool::False()); | 3028 null_fragment += Constant(Bool::False()); |
| 3020 null_fragment += Return(); | 3029 null_fragment += Return(dart_function.end_token_pos()); |
| 3021 | 3030 |
| 3022 body = Fragment(body.entry, non_null_entry); | 3031 body = Fragment(body.entry, non_null_entry); |
| 3023 } | 3032 } |
| 3024 | 3033 |
| 3025 if (dart_function.is_native()) { | 3034 if (dart_function.is_native()) { |
| 3026 body += NativeFunctionBody(function, dart_function); | 3035 body += NativeFunctionBody(function, dart_function); |
| 3027 } else if (function->body() != NULL) { | 3036 } else if (function->body() != NULL) { |
| 3028 body += TranslateStatement(function->body()); | 3037 body += TranslateStatement(function->body()); |
| 3029 } | 3038 } |
| 3030 if (body.is_open()) { | 3039 if (body.is_open()) { |
| 3031 body += NullConstant(); | 3040 body += NullConstant(); |
| 3032 body += Return(); | 3041 body += Return(dart_function.end_token_pos()); |
| 3033 } | 3042 } |
| 3034 | 3043 |
| 3035 // If functions body contains any yield points build switch statement that | 3044 // If functions body contains any yield points build switch statement that |
| 3036 // selects a continuation point based on the value of :await_jump_var. | 3045 // selects a continuation point based on the value of :await_jump_var. |
| 3037 if (!yield_continuations_.is_empty()) { | 3046 if (!yield_continuations_.is_empty()) { |
| 3038 // The code we are building will be executed right after we enter | 3047 // The code we are building will be executed right after we enter |
| 3039 // the function and before any nested contexts are allocated. | 3048 // the function and before any nested contexts are allocated. |
| 3040 // Reset current context_depth_ to match this. | 3049 // Reset current context_depth_ to match this. |
| 3041 intptr_t current_context_depth = context_depth_; | 3050 intptr_t current_context_depth = context_depth_; |
| 3042 context_depth_ = scopes_->yield_jump_variable->owner()->context_level(); | 3051 context_depth_ = scopes_->yield_jump_variable->owner()->context_level(); |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3095 then->set_try_index(yield_continuations_[i].try_index); | 3104 then->set_try_index(yield_continuations_[i].try_index); |
| 3096 | 3105 |
| 3097 // False branch will contain the next comparison. | 3106 // False branch will contain the next comparison. |
| 3098 dispatch = Fragment(dispatch.entry, otherwise); | 3107 dispatch = Fragment(dispatch.entry, otherwise); |
| 3099 block = otherwise; | 3108 block = otherwise; |
| 3100 } | 3109 } |
| 3101 body = dispatch; | 3110 body = dispatch; |
| 3102 | 3111 |
| 3103 context_depth_ = current_context_depth; | 3112 context_depth_ = current_context_depth; |
| 3104 } | 3113 } |
| 3114 | |
| 3105 normal_entry->LinkTo(body.entry); | 3115 normal_entry->LinkTo(body.entry); |
| 3106 | 3116 |
| 3107 // When compiling for OSR, use a depth first search to prune instructions | 3117 // When compiling for OSR, use a depth first search to prune instructions |
| 3108 // unreachable from the OSR entry. Catch entries are always considered | 3118 // unreachable from the OSR entry. Catch entries are always considered |
| 3109 // reachable, even if they become unreachable after OSR. | 3119 // reachable, even if they become unreachable after OSR. |
| 3110 if (osr_id_ != Compiler::kNoOSRDeoptId) { | 3120 if (osr_id_ != Compiler::kNoOSRDeoptId) { |
| 3111 BitVector* block_marks = new (Z) BitVector(Z, next_block_id_); | 3121 BitVector* block_marks = new (Z) BitVector(Z, next_block_id_); |
| 3112 bool found = graph_entry_->PruneUnreachable(graph_entry_, NULL, osr_id_, | 3122 bool found = graph_entry_->PruneUnreachable(graph_entry_, NULL, osr_id_, |
| 3113 block_marks); | 3123 block_marks); |
| 3114 ASSERT(found); | 3124 ASSERT(found); |
| (...skipping 334 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3449 argument_names.SetAt(i, H.DartSymbol(variable->name())); | 3459 argument_names.SetAt(i, H.DartSymbol(variable->name())); |
| 3450 } | 3460 } |
| 3451 } | 3461 } |
| 3452 // Forward them to the target. | 3462 // Forward them to the target. |
| 3453 intptr_t argument_count = positional_argument_count + named_argument_count; | 3463 intptr_t argument_count = positional_argument_count + named_argument_count; |
| 3454 if (!target.is_static()) ++argument_count; | 3464 if (!target.is_static()) ++argument_count; |
| 3455 body += StaticCall(TokenPosition::kNoSource, target, argument_count, | 3465 body += StaticCall(TokenPosition::kNoSource, target, argument_count, |
| 3456 argument_names); | 3466 argument_names); |
| 3457 | 3467 |
| 3458 // Return the result. | 3468 // Return the result. |
| 3459 body += Return(); | 3469 body += Return(kernel_function->end_position()); |
| 3460 | 3470 |
| 3461 return new (Z) FlowGraph(*parsed_function_, graph_entry_, next_block_id_ - 1); | 3471 return new (Z) FlowGraph(*parsed_function_, graph_entry_, next_block_id_ - 1); |
| 3462 } | 3472 } |
| 3463 | 3473 |
| 3464 | 3474 |
| 3465 FlowGraph* FlowGraphBuilder::BuildGraphOfNoSuchMethodDispatcher( | 3475 FlowGraph* FlowGraphBuilder::BuildGraphOfNoSuchMethodDispatcher( |
| 3466 const Function& function) { | 3476 const Function& function) { |
| 3467 // This function is specialized for a receiver class, a method name, and | 3477 // This function is specialized for a receiver class, a method name, and |
| 3468 // the arguments descriptor at a call site. | 3478 // the arguments descriptor at a call site. |
| 3469 | 3479 |
| (...skipping 738 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 4208 } | 4218 } |
| 4209 | 4219 |
| 4210 | 4220 |
| 4211 void FlowGraphBuilder::VisitVariableGet(VariableGet* node) { | 4221 void FlowGraphBuilder::VisitVariableGet(VariableGet* node) { |
| 4212 fragment_ = LoadLocal(LookupVariable(node->variable())); | 4222 fragment_ = LoadLocal(LookupVariable(node->variable())); |
| 4213 } | 4223 } |
| 4214 | 4224 |
| 4215 | 4225 |
| 4216 void FlowGraphBuilder::VisitVariableSet(VariableSet* node) { | 4226 void FlowGraphBuilder::VisitVariableSet(VariableSet* node) { |
| 4217 Fragment instructions = TranslateExpression(node->expression()); | 4227 Fragment instructions = TranslateExpression(node->expression()); |
| 4218 instructions += StoreLocal(LookupVariable(node->variable())); | 4228 instructions += |
| 4229 StoreLocal(LookupVariable(node->variable()), node->position()); | |
| 4219 fragment_ = instructions; | 4230 fragment_ = instructions; |
| 4220 } | 4231 } |
| 4221 | 4232 |
| 4222 | 4233 |
| 4223 void FlowGraphBuilder::VisitStaticGet(StaticGet* node) { | 4234 void FlowGraphBuilder::VisitStaticGet(StaticGet* node) { |
| 4224 Member* target = node->target(); | 4235 Member* target = node->target(); |
| 4225 if (target->IsField()) { | 4236 if (target->IsField()) { |
| 4226 Field* kernel_field = Field::Cast(target); | 4237 Field* kernel_field = Field::Cast(target); |
| 4227 const dart::Field& field = | 4238 const dart::Field& field = |
| 4228 dart::Field::ZoneHandle(Z, H.LookupFieldByKernelField(kernel_field)); | 4239 dart::Field::ZoneHandle(Z, H.LookupFieldByKernelField(kernel_field)); |
| (...skipping 390 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 4619 } | 4630 } |
| 4620 instructions += PushArgument(); // Type arguments. | 4631 instructions += PushArgument(); // Type arguments. |
| 4621 | 4632 |
| 4622 instructions += Constant(type); | 4633 instructions += Constant(type); |
| 4623 instructions += PushArgument(); // Type. | 4634 instructions += PushArgument(); // Type. |
| 4624 | 4635 |
| 4625 instructions += Constant(Bool::False()); | 4636 instructions += Constant(Bool::False()); |
| 4626 instructions += PushArgument(); // Negate?. | 4637 instructions += PushArgument(); // Negate?. |
| 4627 | 4638 |
| 4628 instructions += | 4639 instructions += |
| 4629 InstanceCall(TokenPosition::kNoSource, | 4640 InstanceCall(node->position(), |
| 4630 dart::Library::PrivateCoreLibName(Symbols::_instanceOf()), | 4641 dart::Library::PrivateCoreLibName(Symbols::_instanceOf()), |
| 4631 Token::kIS, 4); | 4642 Token::kIS, 4); |
| 4632 } | 4643 } |
| 4633 | 4644 |
| 4634 fragment_ = instructions; | 4645 fragment_ = instructions; |
| 4635 } | 4646 } |
| 4636 | 4647 |
| 4637 | 4648 |
| 4638 void FlowGraphBuilder::VisitAsExpression(AsExpression* node) { | 4649 void FlowGraphBuilder::VisitAsExpression(AsExpression* node) { |
| 4639 Fragment instructions = TranslateExpression(node->operand()); | 4650 Fragment instructions = TranslateExpression(node->operand()); |
| (...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 4765 LocalVariable* array = MakeTemporary(); | 4776 LocalVariable* array = MakeTemporary(); |
| 4766 | 4777 |
| 4767 for (intptr_t i = 0; i < node->expressions().length(); i++) { | 4778 for (intptr_t i = 0; i < node->expressions().length(); i++) { |
| 4768 instructions += LoadLocal(array); | 4779 instructions += LoadLocal(array); |
| 4769 instructions += IntConstant(i); | 4780 instructions += IntConstant(i); |
| 4770 instructions += TranslateExpression(node->expressions()[i]); | 4781 instructions += TranslateExpression(node->expressions()[i]); |
| 4771 instructions += StoreIndexed(kArrayCid); | 4782 instructions += StoreIndexed(kArrayCid); |
| 4772 instructions += Drop(); | 4783 instructions += Drop(); |
| 4773 } | 4784 } |
| 4774 | 4785 |
| 4775 instructions += StringInterpolate(); | 4786 instructions += StringInterpolate(node->position()); |
| 4776 | 4787 |
| 4777 fragment_ = instructions; | 4788 fragment_ = instructions; |
| 4778 } | 4789 } |
| 4779 | 4790 |
| 4780 | 4791 |
| 4781 void FlowGraphBuilder::VisitListLiteral(ListLiteral* node) { | 4792 void FlowGraphBuilder::VisitListLiteral(ListLiteral* node) { |
| 4782 if (node->is_const()) { | 4793 if (node->is_const()) { |
| 4783 fragment_ = Constant(constant_evaluator_.EvaluateListLiteral(node)); | 4794 fragment_ = Constant(constant_evaluator_.EvaluateListLiteral(node)); |
| 4784 return; | 4795 return; |
| 4785 } | 4796 } |
| (...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 4962 ? NullConstant() | 4973 ? NullConstant() |
| 4963 : TranslateExpression(node->expression()); | 4974 : TranslateExpression(node->expression()); |
| 4964 if (instructions.is_open()) { | 4975 if (instructions.is_open()) { |
| 4965 if (inside_try_finally) { | 4976 if (inside_try_finally) { |
| 4966 ASSERT(scopes_->finally_return_variable != NULL); | 4977 ASSERT(scopes_->finally_return_variable != NULL); |
| 4967 instructions += StoreLocal(scopes_->finally_return_variable); | 4978 instructions += StoreLocal(scopes_->finally_return_variable); |
| 4968 instructions += Drop(); | 4979 instructions += Drop(); |
| 4969 instructions += TranslateFinallyFinalizers(NULL, -1); | 4980 instructions += TranslateFinallyFinalizers(NULL, -1); |
| 4970 if (instructions.is_open()) { | 4981 if (instructions.is_open()) { |
| 4971 instructions += LoadLocal(scopes_->finally_return_variable); | 4982 instructions += LoadLocal(scopes_->finally_return_variable); |
| 4972 instructions += Return(); | 4983 instructions += Return(node->position()); |
| 4973 } | 4984 } |
| 4974 } else { | 4985 } else { |
| 4975 instructions += Return(); | 4986 instructions += Return(node->position()); |
| 4976 } | 4987 } |
| 4977 } else { | 4988 } else { |
| 4978 Pop(); | 4989 Pop(); |
| 4979 } | 4990 } |
| 4980 fragment_ = instructions; | 4991 fragment_ = instructions; |
| 4981 } | 4992 } |
| 4982 | 4993 |
| 4983 | 4994 |
| 4984 void FlowGraphBuilder::VisitExpressionStatement(ExpressionStatement* node) { | 4995 void FlowGraphBuilder::VisitExpressionStatement(ExpressionStatement* node) { |
| 4985 Fragment instructions = TranslateExpression(node->expression()); | 4996 Fragment instructions = TranslateExpression(node->expression()); |
| (...skipping 12 matching lines...) Expand all Loading... | |
| 4998 } else { | 5009 } else { |
| 4999 if (node->IsConst()) { | 5010 if (node->IsConst()) { |
| 5000 const Instance& constant_value = | 5011 const Instance& constant_value = |
| 5001 constant_evaluator_.EvaluateExpression(initializer); | 5012 constant_evaluator_.EvaluateExpression(initializer); |
| 5002 variable->SetConstValue(constant_value); | 5013 variable->SetConstValue(constant_value); |
| 5003 instructions += Constant(constant_value); | 5014 instructions += Constant(constant_value); |
| 5004 } else { | 5015 } else { |
| 5005 instructions += TranslateExpression(initializer); | 5016 instructions += TranslateExpression(initializer); |
| 5006 } | 5017 } |
| 5007 } | 5018 } |
| 5008 instructions += StoreLocal(variable); | 5019 instructions += StoreLocal(variable, variable->token_pos()); |
| 5009 instructions += Drop(); | 5020 instructions += Drop(); |
| 5010 fragment_ = instructions; | 5021 fragment_ = instructions; |
| 5011 } | 5022 } |
| 5012 | 5023 |
| 5013 | 5024 |
| 5014 void FlowGraphBuilder::VisitFunctionDeclaration(FunctionDeclaration* node) { | 5025 void FlowGraphBuilder::VisitFunctionDeclaration(FunctionDeclaration* node) { |
| 5015 Fragment instructions = TranslateFunctionNode(node->function(), node); | 5026 Fragment instructions = TranslateFunctionNode(node->function(), node); |
| 5016 instructions += StoreLocal(LookupVariable(node->variable())); | 5027 instructions += StoreLocal(LookupVariable(node->variable())); |
| 5017 instructions += Drop(); | 5028 instructions += Drop(); |
| 5018 fragment_ = instructions; | 5029 fragment_ = instructions; |
| (...skipping 749 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 5768 | 5779 |
| 5769 continuation = Fragment(continuation.entry, no_error); | 5780 continuation = Fragment(continuation.entry, no_error); |
| 5770 } | 5781 } |
| 5771 | 5782 |
| 5772 fragment_ = continuation; | 5783 fragment_ = continuation; |
| 5773 } | 5784 } |
| 5774 | 5785 |
| 5775 | 5786 |
| 5776 Fragment FlowGraphBuilder::TranslateFunctionNode(FunctionNode* node, | 5787 Fragment FlowGraphBuilder::TranslateFunctionNode(FunctionNode* node, |
| 5777 TreeNode* parent) { | 5788 TreeNode* parent) { |
| 5778 // The VM has a per-isolate table of functions indexed by the enclosing | 5789 // The VM has a per-isolate table of functions indexed by the enclosing |
|
Kevin Millikin (Google)
2017/01/12 13:43:04
This comment (the part about "we don't have token
jensj
2017/01/13 10:14:44
Will do.
| |
| 5779 // function and token position. We don't have token positions, so we've | 5790 // function and token position. We don't have token positions, so we've |
| 5780 // simply numbered the immediately-nested functions with respect to the | 5791 // simply numbered the immediately-nested functions with respect to the |
| 5781 // parent. | 5792 // parent. |
| 5782 Function& function = Function::ZoneHandle(Z); | 5793 Function& function = Function::ZoneHandle(Z); |
| 5783 for (intptr_t i = 0; i < scopes_->function_scopes.length(); ++i) { | 5794 for (intptr_t i = 0; i < scopes_->function_scopes.length(); ++i) { |
| 5784 if (scopes_->function_scopes[i].function != node) continue; | 5795 if (scopes_->function_scopes[i].function != node) continue; |
| 5785 | 5796 |
| 5797 TokenPosition position = node->position(); | |
|
Kevin Millikin (Google)
2017/01/12 13:43:04
Is there any reason not to just continue numbering
jensj
2017/01/13 10:14:44
Numbering them 0, 1, 2 etc is rather weird at it i
| |
| 5798 if (parent->IsFunctionDeclaration()) { | |
| 5799 position = FunctionDeclaration::Cast(parent)->position(); | |
| 5800 } | |
| 5801 if (!position.IsReal()) { | |
| 5802 // Positions has to be unique in regards to the parent. | |
| 5803 // A non-real at this point is probably -1, we cannot blindly use that | |
| 5804 // as others might use it too. Create a new dummy non-real TokenPosition. | |
| 5805 position = TokenPosition(i).ToSynthetic(); | |
| 5806 } | |
| 5807 | |
| 5786 // NOTE: This is not TokenPosition in the general sense! | 5808 // NOTE: This is not TokenPosition in the general sense! |
| 5787 function = I->LookupClosureFunction(parsed_function_->function(), | 5809 function = I->LookupClosureFunction(parsed_function_->function(), position); |
| 5788 TokenPosition(i)); | |
| 5789 if (function.IsNull()) { | 5810 if (function.IsNull()) { |
| 5790 const dart::String* name; | 5811 const dart::String* name; |
| 5791 if (parent->IsFunctionExpression()) { | 5812 if (parent->IsFunctionExpression()) { |
| 5792 name = &Symbols::AnonymousClosure(); | 5813 name = &Symbols::AnonymousClosure(); |
| 5793 } else { | 5814 } else { |
| 5794 ASSERT(parent->IsFunctionDeclaration()); | 5815 ASSERT(parent->IsFunctionDeclaration()); |
| 5795 name = &H.DartSymbol( | 5816 name = &H.DartSymbol( |
| 5796 FunctionDeclaration::Cast(parent)->variable()->name()); | 5817 FunctionDeclaration::Cast(parent)->variable()->name()); |
| 5797 } | 5818 } |
| 5798 // NOTE: This is not TokenPosition in the general sense! | 5819 // NOTE: This is not TokenPosition in the general sense! |
| 5799 function = Function::NewClosureFunction( | 5820 function = Function::NewClosureFunction( |
| 5800 *name, parsed_function_->function(), TokenPosition(i)); | 5821 *name, parsed_function_->function(), position); |
| 5801 function.set_is_debuggable(false); | 5822 function.set_is_debuggable(node->debuggable()); |
| 5823 function.set_end_token_pos(node->end_position()); | |
| 5802 LocalScope* scope = scopes_->function_scopes[i].scope; | 5824 LocalScope* scope = scopes_->function_scopes[i].scope; |
| 5803 const ContextScope& context_scope = | 5825 const ContextScope& context_scope = |
| 5804 ContextScope::Handle(Z, scope->PreserveOuterScope(context_depth_)); | 5826 ContextScope::Handle(Z, scope->PreserveOuterScope(context_depth_)); |
| 5805 function.set_context_scope(context_scope); | 5827 function.set_context_scope(context_scope); |
| 5806 function.set_kernel_function(node); | 5828 function.set_kernel_function(node); |
| 5807 KernelReader::SetupFunctionParameters(H, T, dart::Class::Handle(Z), | 5829 KernelReader::SetupFunctionParameters(H, T, dart::Class::Handle(Z), |
| 5808 function, node, | 5830 function, node, |
| 5809 false, // is_method | 5831 false, // is_method |
| 5810 true); // is_closure | 5832 true); // is_closure |
| 5811 // Finalize function type. | 5833 // Finalize function type. |
| (...skipping 24 matching lines...) Expand all Loading... | |
| 5836 instructions += LoadLocal(parsed_function_->current_context_var()); | 5858 instructions += LoadLocal(parsed_function_->current_context_var()); |
| 5837 instructions += StoreInstanceField(Closure::context_offset()); | 5859 instructions += StoreInstanceField(Closure::context_offset()); |
| 5838 | 5860 |
| 5839 return instructions; | 5861 return instructions; |
| 5840 } | 5862 } |
| 5841 | 5863 |
| 5842 | 5864 |
| 5843 } // namespace kernel | 5865 } // namespace kernel |
| 5844 } // namespace dart | 5866 } // namespace dart |
| 5845 #endif // !defined(DART_PRECOMPILED_RUNTIME) | 5867 #endif // !defined(DART_PRECOMPILED_RUNTIME) |
| OLD | NEW |