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

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

Issue 1564493002: Make Scanner::kNoSourcePos be a true sentinel value (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 4 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) 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/object.h" 5 #include "vm/object.h"
6 6
7 #include "include/dart_api.h" 7 #include "include/dart_api.h"
8 #include "platform/assert.h" 8 #include "platform/assert.h"
9 #include "vm/assembler.h" 9 #include "vm/assembler.h"
10 #include "vm/cpu.h" 10 #include "vm/cpu.h"
(...skipping 3431 matching lines...) Expand 10 before | Expand all | Expand 10 after
3442 UNREACHABLE(); 3442 UNREACHABLE();
3443 } 3443 }
3444 3444
3445 3445
3446 void Class::set_script(const Script& value) const { 3446 void Class::set_script(const Script& value) const {
3447 StorePointer(&raw_ptr()->script_, value.raw()); 3447 StorePointer(&raw_ptr()->script_, value.raw());
3448 } 3448 }
3449 3449
3450 3450
3451 void Class::set_token_pos(intptr_t token_pos) const { 3451 void Class::set_token_pos(intptr_t token_pos) const {
3452 ASSERT(token_pos >= 0); 3452 ASSERT(Scanner::ValidSourcePosition(token_pos));
hausner 2016/01/05 22:30:50 Can there be classes with kNoSourcePos? Ditto for
Cutch 2016/01/06 15:42:19 When first being constructed (Class::New) we set i
3453 StoreNonPointer(&raw_ptr()->token_pos_, token_pos); 3453 StoreNonPointer(&raw_ptr()->token_pos_, token_pos);
3454 } 3454 }
3455 3455
3456 3456
3457 intptr_t Class::ComputeEndTokenPos() const { 3457 intptr_t Class::ComputeEndTokenPos() const {
3458 // Return the begin token for synthetic classes. 3458 // Return the begin token for synthetic classes.
3459 if (IsSignatureClass() || IsMixinApplication() || IsTopLevel()) { 3459 if (IsSignatureClass() || IsMixinApplication() || IsTopLevel()) {
3460 return token_pos(); 3460 return token_pos();
3461 } 3461 }
3462 const Script& scr = Script::Handle(script()); 3462 const Script& scr = Script::Handle(script());
(...skipping 909 matching lines...) Expand 10 before | Expand all | Expand 10 after
4372 RawUnresolvedClass* UnresolvedClass::New() { 4372 RawUnresolvedClass* UnresolvedClass::New() {
4373 ASSERT(Object::unresolved_class_class() != Class::null()); 4373 ASSERT(Object::unresolved_class_class() != Class::null());
4374 RawObject* raw = Object::Allocate(UnresolvedClass::kClassId, 4374 RawObject* raw = Object::Allocate(UnresolvedClass::kClassId,
4375 UnresolvedClass::InstanceSize(), 4375 UnresolvedClass::InstanceSize(),
4376 Heap::kOld); 4376 Heap::kOld);
4377 return reinterpret_cast<RawUnresolvedClass*>(raw); 4377 return reinterpret_cast<RawUnresolvedClass*>(raw);
4378 } 4378 }
4379 4379
4380 4380
4381 void UnresolvedClass::set_token_pos(intptr_t token_pos) const { 4381 void UnresolvedClass::set_token_pos(intptr_t token_pos) const {
4382 ASSERT(token_pos >= 0); 4382 ASSERT(Scanner::ValidSourcePosition(token_pos));
4383 StoreNonPointer(&raw_ptr()->token_pos_, token_pos); 4383 StoreNonPointer(&raw_ptr()->token_pos_, token_pos);
4384 } 4384 }
4385 4385
4386 4386
4387 void UnresolvedClass::set_ident(const String& ident) const { 4387 void UnresolvedClass::set_ident(const String& ident) const {
4388 StorePointer(&raw_ptr()->ident_, ident.raw()); 4388 StorePointer(&raw_ptr()->ident_, ident.raw());
4389 } 4389 }
4390 4390
4391 4391
4392 void UnresolvedClass::set_library_prefix( 4392 void UnresolvedClass::set_library_prefix(
(...skipping 10172 matching lines...) Expand 10 before | Expand all | Expand 10 after
14565 void LanguageError::set_previous_error(const Error& value) const { 14565 void LanguageError::set_previous_error(const Error& value) const {
14566 StorePointer(&raw_ptr()->previous_error_, value.raw()); 14566 StorePointer(&raw_ptr()->previous_error_, value.raw());
14567 } 14567 }
14568 14568
14569 14569
14570 void LanguageError::set_script(const Script& value) const { 14570 void LanguageError::set_script(const Script& value) const {
14571 StorePointer(&raw_ptr()->script_, value.raw()); 14571 StorePointer(&raw_ptr()->script_, value.raw());
14572 } 14572 }
14573 14573
14574 14574
14575 void LanguageError::set_token_pos(intptr_t value) const { 14575 void LanguageError::set_token_pos(intptr_t token_pos) const {
14576 ASSERT(value >= 0); 14576 ASSERT(Scanner::ValidSourcePosition(token_pos));
14577 StoreNonPointer(&raw_ptr()->token_pos_, value); 14577 StoreNonPointer(&raw_ptr()->token_pos_, token_pos);
14578 } 14578 }
14579 14579
14580 14580
14581 void LanguageError::set_kind(uint8_t value) const { 14581 void LanguageError::set_kind(uint8_t value) const {
14582 StoreNonPointer(&raw_ptr()->kind_, value); 14582 StoreNonPointer(&raw_ptr()->kind_, value);
14583 } 14583 }
14584 14584
14585 14585
14586 void LanguageError::set_message(const String& value) const { 14586 void LanguageError::set_message(const String& value) const {
14587 StorePointer(&raw_ptr()->message_, value.raw()); 14587 StorePointer(&raw_ptr()->message_, value.raw());
(...skipping 1794 matching lines...) Expand 10 before | Expand all | Expand 10 after
16382 const Type& result = Type::Handle(Type::New(space)); 16382 const Type& result = Type::Handle(Type::New(space));
16383 result.set_type_class(clazz); 16383 result.set_type_class(clazz);
16384 result.set_arguments(arguments); 16384 result.set_arguments(arguments);
16385 result.set_token_pos(token_pos); 16385 result.set_token_pos(token_pos);
16386 result.StoreNonPointer(&result.raw_ptr()->type_state_, RawType::kAllocated); 16386 result.StoreNonPointer(&result.raw_ptr()->type_state_, RawType::kAllocated);
16387 return result.raw(); 16387 return result.raw();
16388 } 16388 }
16389 16389
16390 16390
16391 void Type::set_token_pos(intptr_t token_pos) const { 16391 void Type::set_token_pos(intptr_t token_pos) const {
16392 ASSERT(token_pos >= 0); 16392 ASSERT(Scanner::ValidSourcePosition(token_pos));
16393 StoreNonPointer(&raw_ptr()->token_pos_, token_pos); 16393 StoreNonPointer(&raw_ptr()->token_pos_, token_pos);
16394 } 16394 }
16395 16395
16396 16396
16397 void Type::set_type_state(int8_t state) const { 16397 void Type::set_type_state(int8_t state) const {
16398 ASSERT((state >= RawType::kAllocated) && 16398 ASSERT((state >= RawType::kAllocated) &&
16399 (state <= RawType::kFinalizedUninstantiated)); 16399 (state <= RawType::kFinalizedUninstantiated));
16400 StoreNonPointer(&raw_ptr()->type_state_, state); 16400 StoreNonPointer(&raw_ptr()->type_state_, state);
16401 } 16401 }
16402 16402
(...skipping 410 matching lines...) Expand 10 before | Expand all | Expand 10 after
16813 result.set_name(name); 16813 result.set_name(name);
16814 result.set_bound(bound); 16814 result.set_bound(bound);
16815 result.set_token_pos(token_pos); 16815 result.set_token_pos(token_pos);
16816 result.StoreNonPointer(&result.raw_ptr()->type_state_, 16816 result.StoreNonPointer(&result.raw_ptr()->type_state_,
16817 RawTypeParameter::kAllocated); 16817 RawTypeParameter::kAllocated);
16818 return result.raw(); 16818 return result.raw();
16819 } 16819 }
16820 16820
16821 16821
16822 void TypeParameter::set_token_pos(intptr_t token_pos) const { 16822 void TypeParameter::set_token_pos(intptr_t token_pos) const {
16823 ASSERT(token_pos >= 0); 16823 ASSERT(Scanner::ValidSourcePosition(token_pos));
16824 StoreNonPointer(&raw_ptr()->token_pos_, token_pos); 16824 StoreNonPointer(&raw_ptr()->token_pos_, token_pos);
16825 } 16825 }
16826 16826
16827 16827
16828 void TypeParameter::set_type_state(int8_t state) const { 16828 void TypeParameter::set_type_state(int8_t state) const {
16829 ASSERT((state == RawTypeParameter::kAllocated) || 16829 ASSERT((state == RawTypeParameter::kAllocated) ||
16830 (state == RawTypeParameter::kBeingFinalized) || 16830 (state == RawTypeParameter::kBeingFinalized) ||
16831 (state == RawTypeParameter::kFinalizedUninstantiated)); 16831 (state == RawTypeParameter::kFinalizedUninstantiated));
16832 StoreNonPointer(&raw_ptr()->type_state_, state); 16832 StoreNonPointer(&raw_ptr()->type_state_, state);
16833 } 16833 }
(...skipping 4741 matching lines...) Expand 10 before | Expand all | Expand 10 after
21575 const Function& function, 21575 const Function& function,
21576 const Code& code, 21576 const Code& code,
21577 intptr_t frame_index) { 21577 intptr_t frame_index) {
21578 const intptr_t token_pos = code.GetTokenIndexOfPC(pc); 21578 const intptr_t token_pos = code.GetTokenIndexOfPC(pc);
21579 const Script& script = Script::Handle(zone, function.script()); 21579 const Script& script = Script::Handle(zone, function.script());
21580 const String& function_name = 21580 const String& function_name =
21581 String::Handle(zone, function.QualifiedUserVisibleName()); 21581 String::Handle(zone, function.QualifiedUserVisibleName());
21582 const String& url = String::Handle(zone, script.url()); 21582 const String& url = String::Handle(zone, script.url());
21583 intptr_t line = -1; 21583 intptr_t line = -1;
21584 intptr_t column = -1; 21584 intptr_t column = -1;
21585 if (token_pos > 0) { 21585 if (token_pos >= 0) {
21586 if (script.HasSource()) { 21586 if (script.HasSource()) {
21587 script.GetTokenLocation(token_pos, &line, &column); 21587 script.GetTokenLocation(token_pos, &line, &column);
21588 } else { 21588 } else {
21589 script.GetTokenLocation(token_pos, &line, NULL); 21589 script.GetTokenLocation(token_pos, &line, NULL);
21590 } 21590 }
21591 } 21591 }
21592 char* chars = NULL; 21592 char* chars = NULL;
21593 if (column >= 0) { 21593 if (column >= 0) {
21594 chars = OS::SCreate(zone, 21594 chars = OS::SCreate(zone,
21595 "#%-6" Pd " %s (%s:%" Pd ":%" Pd ")\n", 21595 "#%-6" Pd " %s (%s:%" Pd ":%" Pd ")\n",
(...skipping 445 matching lines...) Expand 10 before | Expand all | Expand 10 after
22041 return tag_label.ToCString(); 22041 return tag_label.ToCString();
22042 } 22042 }
22043 22043
22044 22044
22045 void UserTag::PrintJSONImpl(JSONStream* stream, bool ref) const { 22045 void UserTag::PrintJSONImpl(JSONStream* stream, bool ref) const {
22046 Instance::PrintJSONImpl(stream, ref); 22046 Instance::PrintJSONImpl(stream, ref);
22047 } 22047 }
22048 22048
22049 22049
22050 } // namespace dart 22050 } // namespace dart
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698