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 #include "vm/flags.h" | 6 #include "vm/flags.h" |
7 | 7 |
8 #ifndef DART_PRECOMPILED_RUNTIME | 8 #ifndef DART_PRECOMPILED_RUNTIME |
9 | 9 |
10 #include "lib/invocation_mirror.h" | 10 #include "lib/invocation_mirror.h" |
(...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
228 Report::MessageF(Report::kBailout, Script::Handle(function_.script()), | 228 Report::MessageF(Report::kBailout, Script::Handle(function_.script()), |
229 function_.token_pos(), Report::AtLocation, | 229 function_.token_pos(), Report::AtLocation, |
230 "%s Bailout in %s: %s", origin, | 230 "%s Bailout in %s: %s", origin, |
231 String::Handle(function_.name()).ToCString(), reason); | 231 String::Handle(function_.name()).ToCString(), reason); |
232 UNREACHABLE(); | 232 UNREACHABLE(); |
233 } | 233 } |
234 | 234 |
235 | 235 |
236 kernel::ScopeBuildingResult* ParsedFunction::EnsureKernelScopes() { | 236 kernel::ScopeBuildingResult* ParsedFunction::EnsureKernelScopes() { |
237 if (kernel_scopes_ == NULL) { | 237 if (kernel_scopes_ == NULL) { |
238 intptr_t kernel_offset = function().kernel_offset(); | 238 kernel::TreeNode* node = NULL; |
239 Script& script = Script::Handle(Z, function().script()); | 239 if (function().kernel_function() != NULL) { |
240 kernel::StreamingScopeBuilder builder( | 240 node = static_cast<kernel::TreeNode*>(function().kernel_function()); |
241 this, kernel_offset, script.kernel_data(), script.kernel_data_size()); | 241 } |
242 kernel_scopes_ = builder.BuildScopes(); | 242 |
| 243 intptr_t kernel_offset = -1; |
| 244 const uint8_t* kernel_data = NULL; |
| 245 intptr_t kernel_data_size = 0; |
| 246 if (node != NULL) { |
| 247 kernel::TreeNode* library_node = node; |
| 248 if (node != NULL) { |
| 249 const Function* parent = &function(); |
| 250 while (true) { |
| 251 library_node = |
| 252 static_cast<kernel::TreeNode*>(parent->kernel_function()); |
| 253 while (library_node != NULL && !library_node->IsLibrary()) { |
| 254 if (library_node->IsMember()) { |
| 255 library_node = kernel::Member::Cast(library_node)->parent(); |
| 256 } else if (library_node->IsClass()) { |
| 257 library_node = kernel::Class::Cast(library_node)->parent(); |
| 258 break; |
| 259 } else { |
| 260 library_node = NULL; |
| 261 break; |
| 262 } |
| 263 } |
| 264 if (library_node != NULL) break; |
| 265 parent = &Function::Handle(parent->parent_function()); |
| 266 } |
| 267 } |
| 268 if (library_node != NULL && library_node->IsLibrary()) { |
| 269 kernel::Library* library = kernel::Library::Cast(library_node); |
| 270 kernel_offset = node->kernel_offset(); |
| 271 kernel_data = library->kernel_data(); |
| 272 kernel_data_size = library->kernel_data_size(); |
| 273 } |
| 274 } |
| 275 |
| 276 kernel::StreamingScopeBuilder builder2(this, kernel_offset, kernel_data, |
| 277 kernel_data_size); |
| 278 kernel_scopes_ = builder2.BuildScopes(); |
243 } | 279 } |
244 return kernel_scopes_; | 280 return kernel_scopes_; |
245 } | 281 } |
246 | 282 |
247 | 283 |
248 LocalVariable* ParsedFunction::EnsureExpressionTemp() { | 284 LocalVariable* ParsedFunction::EnsureExpressionTemp() { |
249 if (!has_expression_temp_var()) { | 285 if (!has_expression_temp_var()) { |
250 LocalVariable* temp = | 286 LocalVariable* temp = |
251 new (Z) LocalVariable(function_.token_pos(), function_.token_pos(), | 287 new (Z) LocalVariable(function_.token_pos(), function_.token_pos(), |
252 Symbols::ExprTemp(), Object::dynamic_type()); | 288 Symbols::ExprTemp(), Object::dynamic_type()); |
(...skipping 1368 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1621 &Object::dynamic_type()); | 1657 &Object::dynamic_type()); |
1622 | 1658 |
1623 if (parent.IsImplicitSetterFunction()) { | 1659 if (parent.IsImplicitSetterFunction()) { |
1624 const TokenPosition ident_pos = func.token_pos(); | 1660 const TokenPosition ident_pos = func.token_pos(); |
1625 ASSERT(IsIdentifier()); | 1661 ASSERT(IsIdentifier()); |
1626 params.AddFinalParameter(ident_pos, &Symbols::Value(), | 1662 params.AddFinalParameter(ident_pos, &Symbols::Value(), |
1627 &Object::dynamic_type()); | 1663 &Object::dynamic_type()); |
1628 ASSERT(func.num_fixed_parameters() == 2); // closure, value. | 1664 ASSERT(func.num_fixed_parameters() == 2); // closure, value. |
1629 } else if (!parent.IsGetterFunction() && !parent.IsImplicitGetterFunction()) { | 1665 } else if (!parent.IsGetterFunction() && !parent.IsImplicitGetterFunction()) { |
1630 // NOTE: For the `kernel -> flowgraph` we don't use the parser. | 1666 // NOTE: For the `kernel -> flowgraph` we don't use the parser. |
1631 if (parent.kernel_offset() <= 0) { | 1667 if (parent.kernel_function() == NULL) { |
1632 SkipFunctionPreamble(); | 1668 SkipFunctionPreamble(); |
1633 const bool use_function_type_syntax = false; | 1669 const bool use_function_type_syntax = false; |
1634 const bool allow_explicit_default_values = true; | 1670 const bool allow_explicit_default_values = true; |
1635 const bool evaluate_metadata = false; | 1671 const bool evaluate_metadata = false; |
1636 ParseFormalParameterList(use_function_type_syntax, | 1672 ParseFormalParameterList(use_function_type_syntax, |
1637 allow_explicit_default_values, evaluate_metadata, | 1673 allow_explicit_default_values, evaluate_metadata, |
1638 ¶ms); | 1674 ¶ms); |
1639 FinalizeFormalParameterTypes(¶ms); | 1675 FinalizeFormalParameterTypes(¶ms); |
1640 SetupDefaultsForOptionalParams(params); | 1676 SetupDefaultsForOptionalParams(params); |
1641 } | 1677 } |
(...skipping 13671 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
15313 TokenPosition* start, | 15349 TokenPosition* start, |
15314 TokenPosition* end) { | 15350 TokenPosition* end) { |
15315 UNREACHABLE(); | 15351 UNREACHABLE(); |
15316 return false; | 15352 return false; |
15317 } | 15353 } |
15318 | 15354 |
15319 | 15355 |
15320 } // namespace dart | 15356 } // namespace dart |
15321 | 15357 |
15322 #endif // DART_PRECOMPILED_RUNTIME | 15358 #endif // DART_PRECOMPILED_RUNTIME |
OLD | NEW |