Index: runtime/vm/object.cc |
diff --git a/runtime/vm/object.cc b/runtime/vm/object.cc |
index df6fde0d7ba841ad7fb6223f3caf2ec26c7bb876..efb1b71379e62b80fea932e5daaa5538a40ee04e 100644 |
--- a/runtime/vm/object.cc |
+++ b/runtime/vm/object.cc |
@@ -1184,7 +1184,7 @@ RawError* Object::Init(Isolate* isolate) { |
// could expect. Use with caution. |
type ^= Type::New(Object::Handle(zone, cls.raw()), |
TypeArguments::Handle(zone), |
- Token::kNoSourcePos); |
+ TokenDescriptor::kNoSource); |
type.SetIsFinalized(); |
type ^= type.Canonicalize(); |
object_store->set_array_type(type); |
@@ -1585,7 +1585,7 @@ RawError* Object::Init(Isolate* isolate) { |
#define ADD_SET_FIELD(clazz) \ |
field_name = Symbols::New("cid"#clazz); \ |
field = Field::New(field_name, true, false, true, false, cls, \ |
- Type::Handle(Type::IntType()), 0); \ |
+ Type::Handle(Type::IntType()), TokenDescriptor::kMinSource); \ |
value = Smi::New(k##clazz##Cid); \ |
field.SetStaticValue(value, true); \ |
cls.AddField(field); \ |
@@ -1971,7 +1971,7 @@ RawAbstractType* Class::RareType() const { |
const Type& type = Type::Handle(Type::New( |
*this, |
Object::null_type_arguments(), |
- Token::kNoSourcePos)); |
+ TokenDescriptor::kNoSource)); |
return ClassFinalizer::FinalizeType(*this, |
type, |
ClassFinalizer::kCanonicalize); |
@@ -1983,7 +1983,7 @@ RawAbstractType* Class::DeclarationType() const { |
const Type& type = Type::Handle(Type::New( |
*this, |
args, |
- Token::kNoSourcePos)); |
+ TokenDescriptor::kNoSource)); |
return ClassFinalizer::FinalizeType(*this, |
type, |
ClassFinalizer::kCanonicalize); |
@@ -2021,7 +2021,7 @@ RawClass* Class::New() { |
result.set_num_type_arguments(0); |
result.set_num_own_type_arguments(0); |
result.set_num_native_fields(0); |
- result.set_token_pos(Token::kNoSourcePos); |
+ result.set_token_pos(TokenDescriptor::kNoSource); |
result.InitEmptyFields(); |
Isolate::Current()->RegisterClass(result); |
return result.raw(); |
@@ -2621,7 +2621,7 @@ RawFunction* Class::CreateInvocationDispatcher(const String& target_name, |
false, // Not external. |
false, // Not native. |
*this, |
- 0)); // token_pos |
+ TokenDescriptor::kMinSource)); |
ArgumentsDescriptor desc(args_desc); |
invocation.set_num_fixed_parameters(desc.PositionalCount()); |
invocation.SetNumOptionalParameters(desc.NamedCount(), |
@@ -2678,7 +2678,7 @@ RawFunction* Function::CreateMethodExtractor(const String& getter_name) const { |
false, // Not external. |
false, // Not native. |
owner, |
- ClassifyingTokenPositions::kMethodExtractor)); // token_pos |
+ TokenDescriptor::kMethodExtractor)); |
// Initialize signature: receiver is a single fixed parameter. |
const intptr_t kNumParameters = 1; |
@@ -3091,7 +3091,7 @@ RawClass* Class::New(intptr_t index) { |
result.set_num_type_arguments(kUnknownNumTypeArguments); |
result.set_num_own_type_arguments(kUnknownNumTypeArguments); |
result.set_num_native_fields(0); |
- result.set_token_pos(Token::kNoSourcePos); |
+ result.set_token_pos(TokenDescriptor::kNoSource); |
result.InitEmptyFields(); |
Isolate::Current()->RegisterClass(result); |
return result.raw(); |
@@ -3100,7 +3100,7 @@ RawClass* Class::New(intptr_t index) { |
RawClass* Class::New(const String& name, |
const Script& script, |
- intptr_t token_pos) { |
+ TokenDescriptor token_pos) { |
Class& result = Class::Handle(New<Instance>(kIllegalCid)); |
result.set_name(name); |
result.set_script(script); |
@@ -3114,7 +3114,7 @@ RawClass* Class::NewNativeWrapper(const Library& library, |
int field_count) { |
Class& cls = Class::Handle(library.LookupClass(name)); |
if (cls.IsNull()) { |
- cls = New(name, Script::Handle(), Token::kNoSourcePos); |
+ cls = New(name, Script::Handle(), TokenDescriptor::kNoSource); |
cls.SetFields(Object::empty_array()); |
cls.SetFunctions(Object::empty_array()); |
// Set super class to Object. |
@@ -3359,13 +3359,13 @@ void Class::set_script(const Script& value) const { |
} |
-void Class::set_token_pos(intptr_t token_pos) const { |
- ASSERT(!Token::IsClassifying(token_pos)); |
+void Class::set_token_pos(TokenDescriptor token_pos) const { |
+ ASSERT(!TokenDescriptor(token_pos).IsClassifying()); |
StoreNonPointer(&raw_ptr()->token_pos_, token_pos); |
} |
-intptr_t Class::ComputeEndTokenPos() const { |
+TokenDescriptor Class::ComputeEndTokenPos() const { |
// Return the begin token for synthetic classes. |
if (IsMixinApplication() || IsTopLevel()) { |
return token_pos(); |
@@ -3373,21 +3373,22 @@ intptr_t Class::ComputeEndTokenPos() const { |
const Script& scr = Script::Handle(script()); |
ASSERT(!scr.IsNull()); |
const TokenStream& tkns = TokenStream::Handle(scr.tokens()); |
- TokenStream::Iterator tkit( |
- tkns, token_pos(), TokenStream::Iterator::kNoNewlines); |
+ TokenStream::Iterator tkit(tkns, |
+ token_pos().value(), |
+ TokenStream::Iterator::kNoNewlines); |
intptr_t level = 0; |
while (tkit.CurrentTokenKind() != Token::kEOS) { |
if (tkit.CurrentTokenKind() == Token::kLBRACE) { |
level++; |
} else if (tkit.CurrentTokenKind() == Token::kRBRACE) { |
if (--level == 0) { |
- return tkit.CurrentPosition(); |
+ return TokenDescriptor(tkit.CurrentPosition()); |
} |
} |
tkit.Advance(); |
} |
UNREACHABLE(); |
- return 0; |
+ return TokenDescriptor::kNoSource; |
} |
@@ -4246,7 +4247,7 @@ void Class::InsertCanonicalConstant(intptr_t index, |
RawUnresolvedClass* UnresolvedClass::New(const LibraryPrefix& library_prefix, |
const String& ident, |
- intptr_t token_pos) { |
+ TokenDescriptor token_pos) { |
const UnresolvedClass& type = UnresolvedClass::Handle(UnresolvedClass::New()); |
type.set_library_prefix(library_prefix); |
type.set_ident(ident); |
@@ -4264,8 +4265,8 @@ RawUnresolvedClass* UnresolvedClass::New() { |
} |
-void UnresolvedClass::set_token_pos(intptr_t token_pos) const { |
- ASSERT(!Token::IsClassifying(token_pos)); |
+void UnresolvedClass::set_token_pos(TokenDescriptor token_pos) const { |
+ ASSERT(!TokenDescriptor(token_pos).IsClassifying()); |
StoreNonPointer(&raw_ptr()->token_pos_, token_pos); |
} |
@@ -5259,7 +5260,7 @@ RawScript* Function::eval_script() const { |
void Function::set_eval_script(const Script& script) const { |
- ASSERT(token_pos() == 0); |
+ ASSERT(token_pos() == TokenDescriptor::kMinSource); |
ASSERT(raw_ptr()->data_ == Object::null()); |
set_data(script); |
} |
@@ -5409,7 +5410,7 @@ RawFunctionType* Function::SignatureType() const { |
scope_class = Isolate::Current()->object_store()->closure_class(); |
if (IsSignatureFunction()) { |
set_owner(scope_class); |
- set_token_pos(Token::kNoSourcePos); |
+ set_token_pos(TokenDescriptor::kNoSource); |
} |
} |
const TypeArguments& signature_type_arguments = |
@@ -5701,8 +5702,8 @@ void Function::set_recognized_kind(MethodRecognizer::Kind value) const { |
} |
-void Function::set_token_pos(intptr_t token_pos) const { |
- ASSERT(!Token::IsClassifying(token_pos) || IsMethodExtractor()); |
+void Function::set_token_pos(TokenDescriptor token_pos) const { |
+ ASSERT(!TokenDescriptor(token_pos).IsClassifying() || IsMethodExtractor()); |
StoreNonPointer(&raw_ptr()->token_pos_, token_pos); |
} |
@@ -5746,8 +5747,10 @@ bool Function::IsOptimizable() const { |
// Native methods don't need to be optimized. |
return false; |
} |
+ const intptr_t function_length = |
+ end_token_pos().value() - token_pos().value(); |
if (is_optimizable() && (script() != Script::null()) && |
- ((end_token_pos() - token_pos()) < FLAG_huge_method_cutoff_in_tokens)) { |
+ (function_length < FLAG_huge_method_cutoff_in_tokens)) { |
// Additional check needed for implicit getters. |
return (unoptimized_code() == Object::null()) || |
(Code::Handle(unoptimized_code()).Size() < |
@@ -6321,7 +6324,7 @@ RawFunction* Function::New(const String& name, |
bool is_external, |
bool is_native, |
const Object& owner, |
- intptr_t token_pos) { |
+ TokenDescriptor token_pos) { |
ASSERT(!owner.IsNull()); |
const Function& result = Function::Handle(Function::New()); |
result.set_parameter_types(Object::empty_array()); |
@@ -6401,7 +6404,7 @@ RawFunction* Function::Clone(const Class& new_owner) const { |
RawFunction* Function::NewClosureFunction(const String& name, |
const Function& parent, |
- intptr_t token_pos) { |
+ TokenDescriptor token_pos) { |
ASSERT(!parent.IsNull()); |
// Use the owner defining the parent function and not the class containing it. |
const Object& parent_owner = Object::Handle(parent.raw_ptr()->owner_); |
@@ -6422,7 +6425,7 @@ RawFunction* Function::NewClosureFunction(const String& name, |
RawFunction* Function::NewSignatureFunction(const Class& owner, |
- intptr_t token_pos) { |
+ TokenDescriptor token_pos) { |
const Function& result = Function::Handle(Function::New( |
Symbols::AnonymousSignature(), |
RawFunction::kSignatureFunction, |
@@ -6452,7 +6455,7 @@ RawFunction* Function::NewEvalFunction(const Class& owner, |
/* is_external = */ false, |
/* is_native = */ false, |
owner, |
- /* token_pos = */ 0)); |
+ TokenDescriptor::kMinSource)); |
ASSERT(!script.IsNull()); |
result.set_is_debuggable(false); |
result.set_is_visible(true); |
@@ -6743,7 +6746,7 @@ RawClass* Function::origin() const { |
RawScript* Function::script() const { |
- if (token_pos() == 0) { |
+ if (token_pos() == TokenDescriptor::kMinSource) { |
// Testing for position 0 is an optimization that relies on temporary |
// eval functions having token position 0. |
const Script& script = Script::Handle(eval_script()); |
@@ -6846,10 +6849,11 @@ RawString* Function::GetSource() const { |
if (!func_script.HasSource()) { |
// When source is not available, avoid printing the whole token stream and |
// doing expensive position calculations. |
- return stream.GenerateSource(token_pos(), end_token_pos() + 1); |
+ return stream.GenerateSource(token_pos(), |
+ TokenDescriptor(end_token_pos().value() + 1)); |
} |
- const TokenStream::Iterator tkit(stream, end_token_pos()); |
+ const TokenStream::Iterator tkit(stream, end_token_pos().value()); |
intptr_t from_line; |
intptr_t from_col; |
intptr_t to_line; |
@@ -6886,7 +6890,7 @@ int32_t Function::SourceFingerprint() const { |
Script::Handle(script()).tokens()), token_pos()); |
Object& obj = Object::Handle(); |
String& literal = String::Handle(); |
- while (tokens_iterator.CurrentPosition() < end_token_pos()) { |
+ while (tokens_iterator.CurrentPosition() < end_token_pos().value()) { |
uint32_t val = 0; |
obj = tokens_iterator.CurrentToken(); |
if (obj.IsSmi()) { |
@@ -7353,7 +7357,7 @@ RawField* Field::New(const String& name, |
bool is_reflectable, |
const Class& owner, |
const AbstractType& type, |
- intptr_t token_pos) { |
+ TokenDescriptor token_pos) { |
ASSERT(!owner.IsNull()); |
const Field& result = Field::Handle(Field::New()); |
result.set_name(name); |
@@ -7387,7 +7391,7 @@ RawField* Field::NewTopLevel(const String& name, |
bool is_final, |
bool is_const, |
const Object& owner, |
- intptr_t token_pos) { |
+ TokenDescriptor token_pos) { |
ASSERT(!owner.IsNull()); |
const Field& result = Field::Handle(Field::New()); |
result.set_name(name); |
@@ -7986,11 +7990,12 @@ void TokenStream::SetPrivateKey(const String& value) const { |
} |
RawString* TokenStream::GenerateSource() const { |
- return GenerateSource(0, kMaxElements); |
+ return GenerateSource(TokenDescriptor::kMinSource, |
+ TokenDescriptor::kMaxSource); |
} |
-RawString* TokenStream::GenerateSource(intptr_t start_pos, |
- intptr_t end_pos) const { |
+RawString* TokenStream::GenerateSource(TokenDescriptor start_pos, |
+ TokenDescriptor end_pos) const { |
Iterator iterator(*this, start_pos, Iterator::kAllTokens); |
const ExternalTypedData& data = ExternalTypedData::Handle(GetStream()); |
const GrowableObjectArray& literals = |
@@ -8006,7 +8011,8 @@ RawString* TokenStream::GenerateSource(intptr_t start_pos, |
// Current indentation level. |
int indent = 0; |
- while ((curr != Token::kEOS) && (iterator.CurrentPosition() < end_pos)) { |
+ while ((curr != Token::kEOS) && |
+ (iterator.CurrentPosition() < end_pos.value())) { |
// Remember current values for this token. |
obj = iterator.CurrentToken(); |
literal = iterator.MakeLiteralToken(obj); |
@@ -8164,14 +8170,15 @@ RawString* TokenStream::GenerateSource(intptr_t start_pos, |
} |
-intptr_t TokenStream::ComputeSourcePosition(intptr_t tok_pos) const { |
- Iterator iterator(*this, 0, Iterator::kAllTokens); |
- intptr_t src_pos = 0; |
+TokenDescriptor TokenStream::ComputeSourcePosition( |
+ TokenDescriptor tok_pos) const { |
+ Iterator iterator(*this, TokenDescriptor::kMinSource, Iterator::kAllTokens); |
+ TokenDescriptor src_pos = TokenDescriptor::kMinSource; |
Token::Kind kind = iterator.CurrentTokenKind(); |
- while (iterator.CurrentPosition() < tok_pos && kind != Token::kEOS) { |
+ while (iterator.CurrentPosition() < tok_pos.value() && kind != Token::kEOS) { |
iterator.Advance(); |
kind = iterator.CurrentTokenKind(); |
- src_pos += 1; |
+ src_pos.Next(); |
} |
return src_pos; |
} |
@@ -8456,13 +8463,33 @@ TokenStream::Iterator::Iterator(const TokenStream& tokens, |
cur_token_kind_(Token::kILLEGAL), |
cur_token_obj_index_(-1), |
stream_type_(stream_type) { |
- ASSERT(token_pos != Token::kNoSourcePos); |
- if (token_pos >= 0) { |
+ ASSERT(token_pos != TokenDescriptor::kNoSource.value()); |
+ if (TokenDescriptor(token_pos).IsReal()) { |
SetCurrentPosition(token_pos); |
} |
} |
+TokenStream::Iterator::Iterator(const TokenStream& tokens, |
+ TokenDescriptor token_pos, |
+ Iterator::StreamType stream_type) |
+ : tokens_(TokenStream::Handle(tokens.raw())), |
+ data_(ExternalTypedData::Handle(tokens.GetStream())), |
+ stream_(reinterpret_cast<uint8_t*>(data_.DataAddr(0)), data_.Length()), |
+ token_objects_(Array::Handle( |
+ GrowableObjectArray::Handle(tokens.TokenObjects()).data())), |
+ obj_(Object::Handle()), |
+ cur_token_pos_(token_pos.value()), |
+ cur_token_kind_(Token::kILLEGAL), |
+ cur_token_obj_index_(-1), |
+ stream_type_(stream_type) { |
+ ASSERT(token_pos != TokenDescriptor::kNoSource); |
+ if (token_pos.IsReal()) { |
+ SetCurrentPosition(token_pos.value()); |
+ } |
+} |
+ |
+ |
void TokenStream::Iterator::SetStream(const TokenStream& tokens, |
intptr_t token_pos) { |
tokens_ = tokens.raw(); |
@@ -8478,6 +8505,12 @@ void TokenStream::Iterator::SetStream(const TokenStream& tokens, |
} |
+void TokenStream::Iterator::SetStream(const TokenStream& tokens, |
+ TokenDescriptor token_pos) { |
+ SetStream(tokens, token_pos.value()); |
+} |
+ |
+ |
bool TokenStream::Iterator::IsValid() const { |
return !tokens_.IsNull(); |
} |
@@ -8524,6 +8557,11 @@ void TokenStream::Iterator::SetCurrentPosition(intptr_t value) { |
} |
+void TokenStream::Iterator::SetCurrentPosition(TokenDescriptor token_pos) { |
+ SetCurrentPosition(token_pos.value()); |
+} |
+ |
+ |
void TokenStream::Iterator::Advance() { |
intptr_t value; |
do { |
@@ -8759,7 +8797,7 @@ void Script::SetLocationOffset(intptr_t line_offset, |
} |
-void Script::GetTokenLocation(intptr_t token_pos, |
+void Script::GetTokenLocation(TokenDescriptor token_pos, |
intptr_t* line, |
intptr_t* column, |
intptr_t* token_len) const { |
@@ -8779,8 +8817,8 @@ void Script::GetTokenLocation(intptr_t token_pos, |
if (column == NULL) { |
TokenStream::Iterator tkit(tkns, 0, TokenStream::Iterator::kAllTokens); |
intptr_t cur_line = line_offset() + 1; |
- while (tkit.CurrentPosition() < token_pos && |
- tkit.CurrentTokenKind() != Token::kEOS) { |
+ while ((tkit.CurrentPosition() < token_pos.value()) && |
+ (tkit.CurrentTokenKind() != Token::kEOS)) { |
if (tkit.CurrentTokenKind() == Token::kNEWLINE) { |
cur_line++; |
} |
@@ -8789,7 +8827,7 @@ void Script::GetTokenLocation(intptr_t token_pos, |
*line = cur_line; |
} else { |
const String& src = String::Handle(Source()); |
- intptr_t src_pos = tkns.ComputeSourcePosition(token_pos); |
+ TokenDescriptor src_pos = tkns.ComputeSourcePosition(token_pos); |
Scanner scanner(src, Symbols::Empty()); |
scanner.ScanTo(src_pos); |
intptr_t relative_line = scanner.CurrentPosition().line; |
@@ -8811,12 +8849,12 @@ void Script::GetTokenLocation(intptr_t token_pos, |
void Script::TokenRangeAtLine(intptr_t line_number, |
- intptr_t* first_token_index, |
- intptr_t* last_token_index) const { |
+ TokenDescriptor* first_token_index, |
+ TokenDescriptor* last_token_index) const { |
ASSERT(first_token_index != NULL && last_token_index != NULL); |
ASSERT(line_number > 0); |
- *first_token_index = -1; |
- *last_token_index = -1; |
+ *first_token_index = TokenDescriptor::kNoSource; |
+ *last_token_index = TokenDescriptor::kNoSource; |
const TokenStream& tkns = TokenStream::Handle(tokens()); |
line_number -= line_offset(); |
if (line_number < 1) line_number = 1; |
@@ -8841,17 +8879,17 @@ void Script::TokenRangeAtLine(intptr_t line_number, |
tkit.Advance(); |
} |
if (tkit.CurrentTokenKind() != Token::kEOS) { |
- *first_token_index = tkit.CurrentPosition(); |
+ *first_token_index = TokenDescriptor(tkit.CurrentPosition()); |
} |
return; |
} |
- *first_token_index = tkit.CurrentPosition(); |
+ *first_token_index = TokenDescriptor(tkit.CurrentPosition()); |
// We cannot do "CurrentPosition() - 1" for the last token, because we do not |
// know whether the previous token is a simple one or not. |
- intptr_t end_pos = *first_token_index; |
+ TokenDescriptor end_pos = *first_token_index; |
while (tkit.CurrentTokenKind() != Token::kNEWLINE && |
tkit.CurrentTokenKind() != Token::kEOS) { |
- end_pos = tkit.CurrentPosition(); |
+ end_pos = TokenDescriptor(tkit.CurrentPosition()); |
tkit.Advance(); |
} |
*last_token_index = end_pos; |
@@ -9151,7 +9189,7 @@ static void ReportTooManyImports(const Library& lib) { |
const String& url = String::Handle(lib.url()); |
Report::MessageF(Report::kError, |
Script::Handle(lib.LookupScript(url)), |
- Token::kNoSourcePos, |
+ TokenDescriptor::kNoSource, |
Report::AtLocation, |
"too many imports in library '%s'", |
url.ToCString()); |
@@ -9338,7 +9376,7 @@ static RawString* MakeTypeParameterMetaName(const TypeParameter& param) { |
void Library::AddMetadata(const Object& owner, |
const String& name, |
- intptr_t token_pos) const { |
+ TokenDescriptor token_pos) const { |
const String& metaname = String::Handle(Symbols::New(name)); |
const Field& field = Field::Handle( |
Field::NewTopLevel(metaname, |
@@ -9357,7 +9395,7 @@ void Library::AddMetadata(const Object& owner, |
void Library::AddClassMetadata(const Class& cls, |
const Object& tl_owner, |
- intptr_t token_pos) const { |
+ TokenDescriptor token_pos) const { |
// We use the toplevel class as the owner of a class's metadata field because |
// a class's metadata is in scope of the library, not the class. |
AddMetadata(tl_owner, |
@@ -9367,7 +9405,7 @@ void Library::AddClassMetadata(const Class& cls, |
void Library::AddFieldMetadata(const Field& field, |
- intptr_t token_pos) const { |
+ TokenDescriptor token_pos) const { |
AddMetadata(Object::Handle(field.RawOwner()), |
String::Handle(MakeFieldMetaName(field)), |
token_pos); |
@@ -9375,7 +9413,7 @@ void Library::AddFieldMetadata(const Field& field, |
void Library::AddFunctionMetadata(const Function& func, |
- intptr_t token_pos) const { |
+ TokenDescriptor token_pos) const { |
AddMetadata(Object::Handle(func.RawOwner()), |
String::Handle(MakeFunctionMetaName(func)), |
token_pos); |
@@ -9383,7 +9421,7 @@ void Library::AddFunctionMetadata(const Function& func, |
void Library::AddTypeParameterMetadata(const TypeParameter& param, |
- intptr_t token_pos) const { |
+ TokenDescriptor token_pos) const { |
AddMetadata(Class::Handle(param.parameterized_class()), |
String::Handle(MakeTypeParameterMetaName(param)), |
token_pos); |
@@ -9391,7 +9429,7 @@ void Library::AddTypeParameterMetadata(const TypeParameter& param, |
void Library::AddLibraryMetadata(const Object& tl_owner, |
- intptr_t token_pos) const { |
+ TokenDescriptor token_pos) const { |
AddMetadata(tl_owner, Symbols::TopLevel(), token_pos); |
} |
@@ -10840,7 +10878,7 @@ void Namespace::set_metadata_field(const Field& value) const { |
} |
-void Namespace::AddMetadata(const Object& owner, intptr_t token_pos) { |
+void Namespace::AddMetadata(const Object& owner, TokenDescriptor token_pos) { |
ASSERT(Field::Handle(metadata_field()).IsNull()); |
Field& field = Field::Handle(Field::NewTopLevel(Symbols::TopLevel(), |
false, // is_final |
@@ -11424,7 +11462,7 @@ const char* PcDescriptors::ToCString() const { |
iter.PcOffset(), |
KindAsStr(iter.Kind()), |
iter.DeoptId(), |
- iter.TokenPos(), |
+ iter.TokenPos().value(), |
iter.TryIndex()); |
} |
} |
@@ -11438,7 +11476,7 @@ const char* PcDescriptors::ToCString() const { |
iter.PcOffset(), |
KindAsStr(iter.Kind()), |
iter.DeoptId(), |
- iter.TokenPos(), |
+ iter.TokenPos().value(), |
iter.TryIndex()); |
} |
return buffer; |
@@ -11462,7 +11500,7 @@ void PcDescriptors::PrintToJSONObject(JSONObject* jsobj, bool ref) const { |
descriptor.AddProperty("kind", KindAsStr(iter.Kind())); |
descriptor.AddProperty("deoptId", iter.DeoptId()); |
// TODO(turnidge): Use AddLocation instead. |
- descriptor.AddProperty("tokenPos", iter.TokenPos()); |
+ descriptor.AddProperty("tokenPos", iter.TokenPos().value()); |
descriptor.AddProperty("tryIndex", iter.TryIndex()); |
} |
} |
@@ -11593,7 +11631,7 @@ const char* CodeSourceMap::ToCString() const { |
while (iter.MoveNext()) { |
len += OS::SNPrint(NULL, 0, FORMAT, addr_width, |
iter.PcOffset(), |
- iter.TokenPos()); |
+ iter.TokenPos().value()); |
} |
} |
// Allocate the buffer. |
@@ -11604,7 +11642,7 @@ const char* CodeSourceMap::ToCString() const { |
while (iter.MoveNext()) { |
index += OS::SNPrint((buffer + index), (len - index), FORMAT, addr_width, |
iter.PcOffset(), |
- iter.TokenPos()); |
+ iter.TokenPos().value()); |
} |
return buffer; |
#undef FORMAT |
@@ -11794,8 +11832,8 @@ static int PrintVarInfo(char* buffer, int len, |
LocalVarDescriptors::KindToCString(kind), |
index, |
info.scope_id, |
- info.begin_pos, |
- info.end_pos); |
+ static_cast<int>(info.begin_pos.value()), |
+ static_cast<int>(info.end_pos.value())); |
} else if (kind == RawLocalVarDescriptors::kContextVar) { |
return OS::SNPrint(buffer, len, |
"%2" Pd " %-13s level=%-3d index=%-3d" |
@@ -11804,8 +11842,8 @@ static int PrintVarInfo(char* buffer, int len, |
LocalVarDescriptors::KindToCString(kind), |
info.scope_id, |
index, |
- info.begin_pos, |
- info.end_pos, |
+ static_cast<int>(info.begin_pos.value()), |
+ static_cast<int>(info.end_pos.value()), |
var_name.ToCString()); |
} else { |
return OS::SNPrint(buffer, len, |
@@ -11815,8 +11853,8 @@ static int PrintVarInfo(char* buffer, int len, |
LocalVarDescriptors::KindToCString(kind), |
info.scope_id, |
index, |
- info.begin_pos, |
- info.end_pos, |
+ static_cast<int>(info.begin_pos.value()), |
+ static_cast<int>(info.end_pos.value()), |
var_name.ToCString()); |
} |
} |
@@ -11871,8 +11909,8 @@ void LocalVarDescriptors::PrintJSONImpl(JSONStream* stream, |
JSONObject var(&members); |
var.AddProperty("name", var_name.ToCString()); |
var.AddProperty("index", static_cast<intptr_t>(info.index())); |
- var.AddProperty("beginPos", static_cast<intptr_t>(info.begin_pos)); |
- var.AddProperty("endPos", static_cast<intptr_t>(info.end_pos)); |
+ var.AddProperty("beginPos", info.begin_pos.value()); |
+ var.AddProperty("endPos", info.end_pos.value()); |
var.AddProperty("scopeId", static_cast<intptr_t>(info.scope_id)); |
var.AddProperty("kind", KindToCString(info.kind())); |
} |
@@ -12949,7 +12987,7 @@ void ICData::PrintJSONImpl(JSONStream* stream, bool ref) const { |
void ICData::PrintToJSONArray(const JSONArray& jsarray, |
- intptr_t token_pos, |
+ TokenDescriptor token_pos, |
bool is_static_call) const { |
Isolate* isolate = Isolate::Current(); |
Class& cls = Class::Handle(); |
@@ -12957,7 +12995,7 @@ void ICData::PrintToJSONArray(const JSONArray& jsarray, |
JSONObject jsobj(&jsarray); |
jsobj.AddProperty("name", String::Handle(target_name()).ToCString()); |
- jsobj.AddProperty("tokenPos", token_pos); |
+ jsobj.AddProperty("tokenPos", token_pos.value()); |
// TODO(rmacnak): Figure out how to stringify DeoptReasons(). |
// jsobj.AddProperty("deoptReasons", ...); |
@@ -12985,7 +13023,7 @@ void ICData::PrintToJSONArray(const JSONArray& jsarray, |
void ICData::PrintToJSONArrayNew(const JSONArray& jsarray, |
- intptr_t token_pos, |
+ TokenDescriptor token_pos, |
bool is_static_call) const { |
Isolate* isolate = Isolate::Current(); |
Class& cls = Class::Handle(); |
@@ -12993,7 +13031,7 @@ void ICData::PrintToJSONArrayNew(const JSONArray& jsarray, |
JSONObject jsobj(&jsarray); |
jsobj.AddProperty("name", String::Handle(target_name()).ToCString()); |
- jsobj.AddProperty("tokenPos", token_pos); |
+ jsobj.AddProperty("tokenPos", token_pos.value()); |
// TODO(rmacnak): Figure out how to stringify DeoptReasons(). |
// jsobj.AddProperty("deoptReasons", ...); |
@@ -13613,7 +13651,7 @@ RawCode* Code::FindCode(uword pc, int64_t timestamp) { |
} |
-intptr_t Code::GetTokenIndexOfPC(uword pc) const { |
+TokenDescriptor Code::GetTokenIndexOfPC(uword pc) const { |
uword pc_offset = pc - EntryPoint(); |
const PcDescriptors& descriptors = PcDescriptors::Handle(pc_descriptors()); |
PcDescriptors::Iterator iter(descriptors, RawPcDescriptors::kAnyKind); |
@@ -13622,7 +13660,7 @@ intptr_t Code::GetTokenIndexOfPC(uword pc) const { |
return iter.TokenPos(); |
} |
} |
- return -1; |
+ return TokenDescriptor::kNoSource; |
} |
@@ -14120,15 +14158,15 @@ RawContextScope* ContextScope::New(intptr_t num_variables, bool is_implicit) { |
} |
-intptr_t ContextScope::TokenIndexAt(intptr_t scope_index) const { |
- return Smi::Value(VariableDescAddr(scope_index)->token_pos); |
+TokenDescriptor ContextScope::TokenIndexAt(intptr_t scope_index) const { |
+ return TokenDescriptor(Smi::Value(VariableDescAddr(scope_index)->token_pos)); |
} |
void ContextScope::SetTokenIndexAt(intptr_t scope_index, |
- intptr_t token_pos) const { |
+ TokenDescriptor token_pos) const { |
StoreSmi(&VariableDescAddr(scope_index)->token_pos, |
- Smi::New(token_pos)); |
+ Smi::New(token_pos.value())); |
} |
@@ -14219,12 +14257,12 @@ const char* ContextScope::ToCString() const { |
for (int i = 0; i < num_variables(); i++) { |
name = NameAt(i); |
const char* cname = name.ToCString(); |
- intptr_t pos = TokenIndexAt(i); |
+ TokenDescriptor pos = TokenIndexAt(i); |
intptr_t idx = ContextIndexAt(i); |
intptr_t lvl = ContextLevelAt(i); |
char* chars = OS::SCreate(Thread::Current()->zone(), |
"%s\nvar %s token-pos %" Pd " ctx lvl %" Pd " index %" Pd "", |
- prev_cstr, cname, pos, lvl, idx); |
+ prev_cstr, cname, pos.value(), lvl, idx); |
prev_cstr = chars; |
} |
return prev_cstr; |
@@ -14545,7 +14583,7 @@ RawLanguageError* LanguageError::New() { |
RawLanguageError* LanguageError::NewFormattedV(const Error& prev_error, |
const Script& script, |
- intptr_t token_pos, |
+ TokenDescriptor token_pos, |
bool report_after_token, |
Report::Kind kind, |
Heap::Space space, |
@@ -14573,7 +14611,7 @@ RawLanguageError* LanguageError::NewFormattedV(const Error& prev_error, |
RawLanguageError* LanguageError::NewFormatted(const Error& prev_error, |
const Script& script, |
- intptr_t token_pos, |
+ TokenDescriptor token_pos, |
bool report_after_token, |
Report::Kind kind, |
Heap::Space space, |
@@ -14617,8 +14655,8 @@ void LanguageError::set_script(const Script& value) const { |
} |
-void LanguageError::set_token_pos(intptr_t token_pos) const { |
- ASSERT(!Token::IsClassifying(token_pos)); |
+void LanguageError::set_token_pos(TokenDescriptor token_pos) const { |
+ ASSERT(!TokenDescriptor(token_pos).IsClassifying()); |
StoreNonPointer(&raw_ptr()->token_pos_, token_pos); |
} |
@@ -15029,7 +15067,7 @@ RawAbstractType* Instance::GetType() const { |
ASSERT(scope_cls.NumTypeArguments() > 0); |
TypeArguments& type_arguments = TypeArguments::Handle(GetTypeArguments()); |
type = FunctionType::New( |
- scope_cls, type_arguments, signature, Token::kNoSourcePos); |
+ scope_cls, type_arguments, signature, TokenDescriptor::kNoSource); |
type.SetIsFinalized(); |
type ^= type.Canonicalize(); |
return type.raw(); |
@@ -15043,7 +15081,7 @@ RawAbstractType* Instance::GetType() const { |
if (cls.NumTypeArguments() > 0) { |
type_arguments = GetTypeArguments(); |
} |
- type = Type::New(cls, type_arguments, Token::kNoSourcePos); |
+ type = Type::New(cls, type_arguments, TokenDescriptor::kNoSource); |
type.SetIsFinalized(); |
type ^= type.Canonicalize(); |
} |
@@ -15370,8 +15408,8 @@ const char* Instance::ToCString() const { |
if (num_type_arguments > 0) { |
type_arguments = GetTypeArguments(); |
} |
- const Type& type = |
- Type::Handle(Type::New(cls, type_arguments, Token::kNoSourcePos)); |
+ const Type& type = Type::Handle( |
+ Type::New(cls, type_arguments, TokenDescriptor::kNoSource)); |
const String& type_name = String::Handle(type.UserVisibleName()); |
return OS::SCreate(Thread::Current()->zone(), |
"Instance of '%s'", type_name.ToCString()); |
@@ -15510,10 +15548,10 @@ void AbstractType::set_arguments(const TypeArguments& value) const { |
UNREACHABLE(); |
} |
-intptr_t AbstractType::token_pos() const { |
+TokenDescriptor AbstractType::token_pos() const { |
// AbstractType is an abstract class. |
UNREACHABLE(); |
- return -1; |
+ return TokenDescriptor::kNoSource; |
} |
@@ -16106,7 +16144,7 @@ RawType* Type::NewNonParameterizedType(const Class& type_class) { |
const TypeArguments& no_type_arguments = TypeArguments::Handle(); |
type ^= Type::New(Object::Handle(type_class.raw()), |
no_type_arguments, |
- Token::kNoSourcePos); |
+ TokenDescriptor::kNoSource); |
type.SetIsFinalized(); |
type ^= type.Canonicalize(); |
} |
@@ -16564,7 +16602,7 @@ RawType* Type::New(Heap::Space space) { |
RawType* Type::New(const Object& clazz, |
const TypeArguments& arguments, |
- intptr_t token_pos, |
+ TokenDescriptor token_pos, |
Heap::Space space) { |
const Type& result = Type::Handle(Type::New(space)); |
result.set_type_class(clazz); |
@@ -16575,8 +16613,8 @@ RawType* Type::New(const Object& clazz, |
} |
-void Type::set_token_pos(intptr_t token_pos) const { |
- ASSERT(!Token::IsClassifying(token_pos)); |
+void Type::set_token_pos(TokenDescriptor token_pos) const { |
+ ASSERT(!TokenDescriptor(token_pos).IsClassifying()); |
StoreNonPointer(&raw_ptr()->token_pos_, token_pos); |
} |
@@ -16994,10 +17032,8 @@ RawAbstractType* FunctionType::Canonicalize(TrailPtr trail) const { |
// Replace the actual function by a signature function. |
const Function& fun = Function::Handle(zone, signature()); |
if (!fun.IsSignatureFunction()) { |
- Function& sig_fun = |
- Function::Handle(zone, |
- Function::NewSignatureFunction(scope_cls, |
- Token::kNoSourcePos)); |
+ Function& sig_fun = Function::Handle(zone, |
+ Function::NewSignatureFunction(scope_cls, TokenDescriptor::kNoSource)); |
type = fun.result_type(); |
type = type.Canonicalize(trail); |
sig_fun.set_result_type(type); |
@@ -17108,7 +17144,7 @@ RawFunctionType* FunctionType::New(Heap::Space space) { |
RawFunctionType* FunctionType::New(const Class& clazz, |
const TypeArguments& arguments, |
const Function& signature, |
- intptr_t token_pos, |
+ TokenDescriptor token_pos, |
Heap::Space space) { |
const FunctionType& result = FunctionType::Handle(FunctionType::New(space)); |
result.set_scope_class(clazz); |
@@ -17121,8 +17157,8 @@ RawFunctionType* FunctionType::New(const Class& clazz, |
} |
-void FunctionType::set_token_pos(intptr_t token_pos) const { |
- ASSERT(!Token::IsClassifying(token_pos)); |
+void FunctionType::set_token_pos(TokenDescriptor token_pos) const { |
+ ASSERT(!TokenDescriptor(token_pos).IsClassifying()); |
StoreNonPointer(&raw_ptr()->token_pos_, token_pos); |
} |
@@ -17540,7 +17576,7 @@ RawTypeParameter* TypeParameter::New(const Class& parameterized_class, |
intptr_t index, |
const String& name, |
const AbstractType& bound, |
- intptr_t token_pos) { |
+ TokenDescriptor token_pos) { |
const TypeParameter& result = TypeParameter::Handle(TypeParameter::New()); |
result.set_parameterized_class(parameterized_class); |
result.set_index(index); |
@@ -17553,8 +17589,8 @@ RawTypeParameter* TypeParameter::New(const Class& parameterized_class, |
} |
-void TypeParameter::set_token_pos(intptr_t token_pos) const { |
- ASSERT(!Token::IsClassifying(token_pos)); |
+void TypeParameter::set_token_pos(TokenDescriptor token_pos) const { |
+ ASSERT(!TokenDescriptor(token_pos).IsClassifying()); |
StoreNonPointer(&raw_ptr()->token_pos_, token_pos); |
} |
@@ -17831,7 +17867,7 @@ void BoundedType::PrintJSONImpl(JSONStream* stream, bool ref) const { |
} |
-intptr_t MixinAppType::token_pos() const { |
+TokenDescriptor MixinAppType::token_pos() const { |
return AbstractType::Handle(MixinTypeAt(0)).token_pos(); |
} |
@@ -22329,14 +22365,14 @@ static intptr_t PrintOneStacktrace(Zone* zone, |
const Function& function, |
const Code& code, |
intptr_t frame_index) { |
- const intptr_t token_pos = code.GetTokenIndexOfPC(pc); |
+ const TokenDescriptor token_pos = code.GetTokenIndexOfPC(pc); |
const Script& script = Script::Handle(zone, function.script()); |
const String& function_name = |
String::Handle(zone, function.QualifiedUserVisibleName()); |
const String& url = String::Handle(zone, script.url()); |
intptr_t line = -1; |
intptr_t column = -1; |
- if (token_pos >= 0) { |
+ if (token_pos.IsReal()) { |
if (script.HasSource()) { |
script.GetTokenLocation(token_pos, &line, &column); |
} else { |