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 kernel::TreeNode* node = NULL; | 238 intptr_t kernel_offset = function().kernel_offset(); |
239 if (function().kernel_function() != NULL) { | 239 Script& script = Script::Handle(Z, function().script()); |
240 node = static_cast<kernel::TreeNode*>(function().kernel_function()); | 240 kernel::StreamingScopeBuilder builder( |
241 } | 241 this, kernel_offset, script.kernel_data(), script.kernel_data_size()); |
242 | 242 kernel_scopes_ = builder.BuildScopes(); |
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(); | |
279 } | 243 } |
280 return kernel_scopes_; | 244 return kernel_scopes_; |
281 } | 245 } |
282 | 246 |
283 | 247 |
284 LocalVariable* ParsedFunction::EnsureExpressionTemp() { | 248 LocalVariable* ParsedFunction::EnsureExpressionTemp() { |
285 if (!has_expression_temp_var()) { | 249 if (!has_expression_temp_var()) { |
286 LocalVariable* temp = | 250 LocalVariable* temp = |
287 new (Z) LocalVariable(function_.token_pos(), function_.token_pos(), | 251 new (Z) LocalVariable(function_.token_pos(), function_.token_pos(), |
288 Symbols::ExprTemp(), Object::dynamic_type()); | 252 Symbols::ExprTemp(), Object::dynamic_type()); |
(...skipping 1368 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1657 &Object::dynamic_type()); | 1621 &Object::dynamic_type()); |
1658 | 1622 |
1659 if (parent.IsImplicitSetterFunction()) { | 1623 if (parent.IsImplicitSetterFunction()) { |
1660 const TokenPosition ident_pos = func.token_pos(); | 1624 const TokenPosition ident_pos = func.token_pos(); |
1661 ASSERT(IsIdentifier()); | 1625 ASSERT(IsIdentifier()); |
1662 params.AddFinalParameter(ident_pos, &Symbols::Value(), | 1626 params.AddFinalParameter(ident_pos, &Symbols::Value(), |
1663 &Object::dynamic_type()); | 1627 &Object::dynamic_type()); |
1664 ASSERT(func.num_fixed_parameters() == 2); // closure, value. | 1628 ASSERT(func.num_fixed_parameters() == 2); // closure, value. |
1665 } else if (!parent.IsGetterFunction() && !parent.IsImplicitGetterFunction()) { | 1629 } else if (!parent.IsGetterFunction() && !parent.IsImplicitGetterFunction()) { |
1666 // NOTE: For the `kernel -> flowgraph` we don't use the parser. | 1630 // NOTE: For the `kernel -> flowgraph` we don't use the parser. |
1667 if (parent.kernel_function() == NULL) { | 1631 if (parent.kernel_offset() <= 0) { |
1668 SkipFunctionPreamble(); | 1632 SkipFunctionPreamble(); |
1669 const bool use_function_type_syntax = false; | 1633 const bool use_function_type_syntax = false; |
1670 const bool allow_explicit_default_values = true; | 1634 const bool allow_explicit_default_values = true; |
1671 const bool evaluate_metadata = false; | 1635 const bool evaluate_metadata = false; |
1672 ParseFormalParameterList(use_function_type_syntax, | 1636 ParseFormalParameterList(use_function_type_syntax, |
1673 allow_explicit_default_values, evaluate_metadata, | 1637 allow_explicit_default_values, evaluate_metadata, |
1674 ¶ms); | 1638 ¶ms); |
1675 FinalizeFormalParameterTypes(¶ms); | 1639 FinalizeFormalParameterTypes(¶ms); |
1676 SetupDefaultsForOptionalParams(params); | 1640 SetupDefaultsForOptionalParams(params); |
1677 } | 1641 } |
(...skipping 13671 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
15349 TokenPosition* start, | 15313 TokenPosition* start, |
15350 TokenPosition* end) { | 15314 TokenPosition* end) { |
15351 UNREACHABLE(); | 15315 UNREACHABLE(); |
15352 return false; | 15316 return false; |
15353 } | 15317 } |
15354 | 15318 |
15355 | 15319 |
15356 } // namespace dart | 15320 } // namespace dart |
15357 | 15321 |
15358 #endif // DART_PRECOMPILED_RUNTIME | 15322 #endif // DART_PRECOMPILED_RUNTIME |
OLD | NEW |