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

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

Issue 2628693004: TokenPositions on more nodes when running from Kernel (Closed)
Patch Set: Created 3 years, 11 months 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
OLDNEW
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 "vm/kernel_reader.h" 5 #include "vm/kernel_reader.h"
6 6
7 #include <string.h> 7 #include <string.h>
8 8
9 #include "vm/dart_api_impl.h" 9 #include "vm/dart_api_impl.h"
10 #include "vm/longjump.h" 10 #include "vm/longjump.h"
(...skipping 307 matching lines...) Expand 10 before | Expand all | Expand 10 after
318 kernel_constructor->function()); 318 kernel_constructor->function());
319 319
320 const dart::String& name = H.DartConstructorName(kernel_constructor); 320 const dart::String& name = H.DartConstructorName(kernel_constructor);
321 Function& function = dart::Function::ZoneHandle( 321 Function& function = dart::Function::ZoneHandle(
322 Z, dart::Function::New(name, RawFunction::kConstructor, 322 Z, dart::Function::New(name, RawFunction::kConstructor,
323 false, // is_static 323 false, // is_static
324 kernel_constructor->IsConst(), 324 kernel_constructor->IsConst(),
325 false, // is_abstract 325 false, // is_abstract
326 kernel_constructor->IsExternal(), 326 kernel_constructor->IsExternal(),
327 false, // is_native 327 false, // is_native
328 klass, TokenPosition::kMinSource)); 328 klass, kernel_constructor->position()));
329 function.set_end_token_pos(TokenPosition::kMinSource); 329 function.set_end_token_pos(kernel_constructor->end_position());
330 klass.AddFunction(function); 330 klass.AddFunction(function);
331 function.set_kernel_function(kernel_constructor); 331 function.set_kernel_function(kernel_constructor);
332 function.set_result_type(T.ReceiverType(klass)); 332 function.set_result_type(T.ReceiverType(klass));
333 SetupFunctionParameters(H, T, klass, function, 333 SetupFunctionParameters(H, T, klass, function,
334 kernel_constructor->function(), 334 kernel_constructor->function(),
335 true, // is_method 335 true, // is_method
336 false); // is_closure 336 false); // is_closure
337 } 337 }
338 338
339 for (intptr_t i = 0; i < kernel_klass->procedures().length(); i++) { 339 for (intptr_t i = 0; i < kernel_klass->procedures().length(); i++) {
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
396 } 396 }
397 } 397 }
398 const Object& script_class = 398 const Object& script_class =
399 ClassForScriptAt(owner, kernel_procedure->source_uri_index()); 399 ClassForScriptAt(owner, kernel_procedure->source_uri_index());
400 dart::Function& function = dart::Function::ZoneHandle( 400 dart::Function& function = dart::Function::ZoneHandle(
401 Z, Function::New(name, GetFunctionType(kernel_procedure), 401 Z, Function::New(name, GetFunctionType(kernel_procedure),
402 !is_method, // is_static 402 !is_method, // is_static
403 false, // is_const 403 false, // is_const
404 is_abstract, is_external, 404 is_abstract, is_external,
405 native_name != NULL, // is_native 405 native_name != NULL, // is_native
406 script_class, TokenPosition::kMinSource)); 406 script_class, kernel_procedure->position()));
407 function.set_end_token_pos(TokenPosition::kMinSource); 407 function.set_end_token_pos(kernel_procedure->end_position());
408 owner.AddFunction(function); 408 owner.AddFunction(function);
409 function.set_kernel_function(kernel_procedure); 409 function.set_kernel_function(kernel_procedure);
410 function.set_is_debuggable(false); 410 function.set_is_debuggable(kernel_procedure->function()->debuggable());
411 if (native_name != NULL) { 411 if (native_name != NULL) {
412 function.set_native_name(*native_name); 412 function.set_native_name(*native_name);
413 } 413 }
414 414
415 SetupFunctionParameters(H, T, owner, function, kernel_procedure->function(), 415 SetupFunctionParameters(H, T, owner, function, kernel_procedure->function(),
416 is_method, 416 is_method,
417 false); // is_closure 417 false); // is_closure
418 418
419 if (kernel_klass == NULL) { 419 if (kernel_klass == NULL) {
420 library.AddObject(function, name); 420 library.AddObject(function, name);
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
497 // that are const (not just final) and they have is_const for 497 // that are const (not just final) and they have is_const for
498 // non-static 498 // non-static
499 // fields that are final. 499 // fields that are final.
500 kernel_field->IsStatic() ? kernel_field->IsConst() 500 kernel_field->IsStatic() ? kernel_field->IsConst()
501 : kernel_field->IsFinal(), 501 : kernel_field->IsFinal(),
502 false, // is_abstract 502 false, // is_abstract
503 false, // is_external 503 false, // is_external
504 false, // is_native 504 false, // is_native
505 script_class, kernel_field->position())); 505 script_class, kernel_field->position()));
506 klass.AddFunction(getter); 506 klass.AddFunction(getter);
507 getter.set_end_token_pos(kernel_field->end_position());
507 getter.set_kernel_function(kernel_field); 508 getter.set_kernel_function(kernel_field);
508 getter.set_result_type(AbstractType::Handle(Z, field.type())); 509 getter.set_result_type(AbstractType::Handle(Z, field.type()));
509 getter.set_is_debuggable(false); 510 getter.set_is_debuggable(false);
510 SetupFieldAccessorFunction(klass, getter); 511 SetupFieldAccessorFunction(klass, getter);
511 512
512 if (!kernel_field->IsStatic() && !kernel_field->IsFinal()) { 513 if (!kernel_field->IsStatic() && !kernel_field->IsFinal()) {
513 // Only static fields can be const. 514 // Only static fields can be const.
514 ASSERT(!kernel_field->IsConst()); 515 ASSERT(!kernel_field->IsConst());
515 const dart::String& setter_name = H.DartSetterName(kernel_field->name()); 516 const dart::String& setter_name = H.DartSetterName(kernel_field->name());
516 Function& setter = Function::ZoneHandle( 517 Function& setter = Function::ZoneHandle(
517 Z, Function::New(setter_name, RawFunction::kImplicitSetter, 518 Z, Function::New(setter_name, RawFunction::kImplicitSetter,
518 false, // is_static 519 false, // is_static
519 false, // is_const 520 false, // is_const
520 false, // is_abstract 521 false, // is_abstract
521 false, // is_external 522 false, // is_external
522 false, // is_native 523 false, // is_native
523 script_class, kernel_field->position())); 524 script_class, kernel_field->position()));
524 klass.AddFunction(setter); 525 klass.AddFunction(setter);
526 setter.set_end_token_pos(kernel_field->end_position());
525 setter.set_kernel_function(kernel_field); 527 setter.set_kernel_function(kernel_field);
526 setter.set_result_type(Object::void_type()); 528 setter.set_result_type(Object::void_type());
527 setter.set_is_debuggable(false); 529 setter.set_is_debuggable(false);
528 SetupFieldAccessorFunction(klass, setter); 530 SetupFieldAccessorFunction(klass, setter);
529 } 531 }
530 } 532 }
531 533
532 534
533 void KernelReader::SetupFunctionParameters(TranslationHelper translation_helper, 535 void KernelReader::SetupFunctionParameters(TranslationHelper translation_helper,
534 DartTypeTranslator type_translator, 536 DartTypeTranslator type_translator,
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
632 634
633 dart::Library& KernelReader::LookupLibrary(Library* library) { 635 dart::Library& KernelReader::LookupLibrary(Library* library) {
634 dart::Library* handle = NULL; 636 dart::Library* handle = NULL;
635 if (!libraries_.Lookup(library, &handle)) { 637 if (!libraries_.Lookup(library, &handle)) {
636 const dart::String& url = H.DartSymbol(library->import_uri()); 638 const dart::String& url = H.DartSymbol(library->import_uri());
637 handle = 639 handle =
638 &dart::Library::Handle(Z, dart::Library::LookupLibrary(thread_, url)); 640 &dart::Library::Handle(Z, dart::Library::LookupLibrary(thread_, url));
639 if (handle->IsNull()) { 641 if (handle->IsNull()) {
640 *handle = dart::Library::New(url); 642 *handle = dart::Library::New(url);
641 handle->Register(thread_); 643 handle->Register(thread_);
644 handle->SetName(H.DartSymbol(library->name()));
642 } 645 }
643 ASSERT(!handle->IsNull()); 646 ASSERT(!handle->IsNull());
644 libraries_.Insert(library, handle); 647 libraries_.Insert(library, handle);
645 } 648 }
646 return *handle; 649 return *handle;
647 } 650 }
648 651
649 dart::Class& KernelReader::LookupClass(Class* klass) { 652 dart::Class& KernelReader::LookupClass(Class* klass) {
650 dart::Class* handle = NULL; 653 dart::Class* handle = NULL;
651 if (!classes_.Lookup(klass, &handle)) { 654 if (!classes_.Lookup(klass, &handle)) {
652 dart::Library& library = LookupLibrary(klass->parent()); 655 dart::Library& library = LookupLibrary(klass->parent());
653 const dart::String& name = H.DartClassName(klass); 656 const dart::String& name = H.DartClassName(klass);
654 handle = &dart::Class::Handle(Z, library.LookupClass(name)); 657 handle = &dart::Class::Handle(Z, library.LookupClass(name));
655 if (handle->IsNull()) { 658 if (handle->IsNull()) {
656 // The class needs to have a script because all the functions in the class 659 // The class needs to have a script because all the functions in the class
657 // will inherit it. The predicate Function::IsOptimizable uses the 660 // will inherit it. The predicate Function::IsOptimizable uses the
658 // absence of a script to detect test functions that should not be 661 // absence of a script to detect test functions that should not be
659 // optimized. 662 // optimized.
660 Script& script = ScriptAt(klass->source_uri_index()); 663 Script& script = ScriptAt(klass->source_uri_index());
661 handle = &dart::Class::Handle( 664 handle = &dart::Class::Handle(
662 Z, dart::Class::New(library, name, script, TokenPosition::kNoSource)); 665 Z, dart::Class::New(library, name, script, klass->position()));
663 library.AddClass(*handle); 666 library.AddClass(*handle);
664 } else if (handle->script() == Script::null()) { 667 } else if (handle->script() == Script::null()) {
665 // When bootstrapping we can encounter classes that do not yet have a 668 // When bootstrapping we can encounter classes that do not yet have a
666 // dummy script. 669 // dummy script.
667 Script& script = ScriptAt(klass->source_uri_index()); 670 Script& script = ScriptAt(klass->source_uri_index());
668 handle->set_script(script); 671 handle->set_script(script);
669 } 672 }
670 // Insert the class in the cache before calling ReadPreliminaryClass so 673 // Insert the class in the cache before calling ReadPreliminaryClass so
671 // we do not risk allocating the class again by calling LookupClass 674 // we do not risk allocating the class again by calling LookupClass
672 // recursively from ReadPreliminaryClass for the same class. 675 // recursively from ReadPreliminaryClass for the same class.
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
722 initializer_fun.set_is_debuggable(false); 725 initializer_fun.set_is_debuggable(false);
723 initializer_fun.set_is_reflectable(false); 726 initializer_fun.set_is_reflectable(false);
724 initializer_fun.set_is_inlinable(false); 727 initializer_fun.set_is_inlinable(false);
725 return new (zone) ParsedFunction(thread, initializer_fun); 728 return new (zone) ParsedFunction(thread, initializer_fun);
726 } 729 }
727 730
728 731
729 } // namespace kernel 732 } // namespace kernel
730 } // namespace dart 733 } // namespace dart
731 #endif // !defined(DART_PRECOMPILED_RUNTIME) 734 #endif // !defined(DART_PRECOMPILED_RUNTIME)
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698