Chromium Code Reviews| Index: runtime/vm/object.cc |
| diff --git a/runtime/vm/object.cc b/runtime/vm/object.cc |
| index 86bd0b75b5a41a80af1696a8b22783424d70eb19..7e66611bf7135c9044838073fb20180f94cd15b2 100644 |
| --- a/runtime/vm/object.cc |
| +++ b/runtime/vm/object.cc |
| @@ -6072,11 +6072,67 @@ const char* ExceptionHandlers::ToCString() const { |
| } |
| +Code::Comments& Code::Comments::New(intptr_t count) { |
| + Comments* comments; |
| + if (count == 0) { |
| + comments = new Comments(Array::Handle()); |
|
srdjan
2012/05/17 21:30:37
The other option would be to use Array::Empty() in
|
| + } else { |
| + comments = new Comments(Array::Handle( |
| + Array::New(count * kNumberOfEntries))); |
| + } |
| + return *comments; |
| +} |
| + |
| + |
| +intptr_t Code::Comments::Length() const { |
| + return comments_.IsNull() ? 0 : (comments_.Length() / kNumberOfEntries); |
| +} |
| + |
| + |
| +intptr_t Code::Comments::PCOffsetAt(intptr_t idx) const { |
| + return Smi::CheckedHandle( |
| + comments_.At(idx * kNumberOfEntries + kPCOffsetEntry)).Value(); |
| +} |
| + |
| + |
| +void Code::Comments::SetPCOffsetAt(intptr_t idx, intptr_t pc) { |
| + comments_.SetAt(idx * kNumberOfEntries + kPCOffsetEntry, |
| + Smi::Handle(Smi::New(pc))); |
| +} |
| + |
| + |
| +const String& Code::Comments::CommentAt(intptr_t idx) const { |
| + return String::CheckedHandle( |
| + comments_.At(idx * kNumberOfEntries + kCommentEntry)); |
| +} |
| + |
| + |
| +void Code::Comments::SetCommentAt(intptr_t idx, const String& comment) { |
| + comments_.SetAt(idx * kNumberOfEntries + kCommentEntry, comment); |
| +} |
| + |
| + |
| +Code::Comments::Comments(const Array& comments) |
| + : comments_(comments) { |
| +} |
| + |
| + |
| void Code::set_stackmaps(const Array& maps) const { |
| StorePointer(&raw_ptr()->stackmaps_, maps.raw()); |
| } |
| +const Code::Comments& Code::comments() const { |
| + Comments* comments = new Code::Comments(Array::Handle(raw_ptr()->comments_)); |
| + return *comments; |
| +} |
| + |
| + |
| +void Code::set_comments(const Code::Comments& comments) const { |
| + StorePointer(&raw_ptr()->comments_, comments.comments_.raw()); |
| +} |
| + |
| + |
| RawCode* Code::New(int pointer_offsets_length) { |
| const Class& cls = Class::Handle(Object::code_class()); |
| Code& result = Code::Handle(); |