| 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 #ifndef VM_OBJECT_H_ | 5 #ifndef VM_OBJECT_H_ |
| 6 #define VM_OBJECT_H_ | 6 #define VM_OBJECT_H_ |
| 7 | 7 |
| 8 #include "include/dart_api.h" | 8 #include "include/dart_api.h" |
| 9 #include "platform/assert.h" | 9 #include "platform/assert.h" |
| 10 #include "platform/utils.h" | 10 #include "platform/utils.h" |
| (...skipping 3255 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3266 virtual int64_t AsInt64Value() const; | 3266 virtual int64_t AsInt64Value() const; |
| 3267 | 3267 |
| 3268 // Returns 0, -1 or 1. | 3268 // Returns 0, -1 or 1. |
| 3269 virtual int CompareWith(const Integer& other) const; | 3269 virtual int CompareWith(const Integer& other) const; |
| 3270 | 3270 |
| 3271 // Return the most compact presentation of an integer. | 3271 // Return the most compact presentation of an integer. |
| 3272 RawInteger* AsInteger() const; | 3272 RawInteger* AsInteger() const; |
| 3273 // Return an integer in the form of a RawBigint. | 3273 // Return an integer in the form of a RawBigint. |
| 3274 RawBigint* AsBigint() const; | 3274 RawBigint* AsBigint() const; |
| 3275 | 3275 |
| 3276 RawInteger* BinaryOp(Token::Kind operation, const Integer& other) const; | 3276 RawInteger* ArithmeticOp(Token::Kind operation, const Integer& other) const; |
| 3277 RawInteger* BitOp(Token::Kind operation, const Integer& other) const; |
| 3277 | 3278 |
| 3278 OBJECT_IMPLEMENTATION(Integer, Number); | 3279 OBJECT_IMPLEMENTATION(Integer, Number); |
| 3279 friend class Class; | 3280 friend class Class; |
| 3280 }; | 3281 }; |
| 3281 | 3282 |
| 3282 | 3283 |
| 3283 class Smi : public Integer { | 3284 class Smi : public Integer { |
| 3284 public: | 3285 public: |
| 3285 static const intptr_t kBits = kSmiBits; | 3286 static const intptr_t kBits = kSmiBits; |
| 3286 static const intptr_t kMaxValue = kSmiMax; | 3287 static const intptr_t kMaxValue = kSmiMax; |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3322 } | 3323 } |
| 3323 | 3324 |
| 3324 static bool IsValid(intptr_t value) { | 3325 static bool IsValid(intptr_t value) { |
| 3325 return (value >= kMinValue) && (value <= kMaxValue); | 3326 return (value >= kMinValue) && (value <= kMaxValue); |
| 3326 } | 3327 } |
| 3327 | 3328 |
| 3328 static bool IsValid64(int64_t value) { | 3329 static bool IsValid64(int64_t value) { |
| 3329 return (value >= kMinValue) && (value <= kMaxValue); | 3330 return (value >= kMinValue) && (value <= kMaxValue); |
| 3330 } | 3331 } |
| 3331 | 3332 |
| 3333 RawInteger* ShiftOp(Token::Kind kind, const Smi& other) const; |
| 3334 |
| 3332 private: | 3335 private: |
| 3333 static intptr_t ValueFromRaw(uword raw_value) { | 3336 static intptr_t ValueFromRaw(uword raw_value) { |
| 3334 intptr_t value = raw_value; | 3337 intptr_t value = raw_value; |
| 3335 ASSERT((value & kSmiTagMask) == kSmiTag); | 3338 ASSERT((value & kSmiTagMask) == kSmiTag); |
| 3336 return (value >> kSmiTagShift); | 3339 return (value >> kSmiTagShift); |
| 3337 } | 3340 } |
| 3338 static cpp_vtable handle_vtable_; | 3341 static cpp_vtable handle_vtable_; |
| 3339 | 3342 |
| 3340 OBJECT_IMPLEMENTATION(Smi, Integer); | 3343 OBJECT_IMPLEMENTATION(Smi, Integer); |
| 3341 friend class Api; // For ValueFromRaw | 3344 friend class Api; // For ValueFromRaw |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3409 static intptr_t InstanceSize() { return 0; } | 3412 static intptr_t InstanceSize() { return 0; } |
| 3410 | 3413 |
| 3411 static intptr_t InstanceSize(intptr_t len) { | 3414 static intptr_t InstanceSize(intptr_t len) { |
| 3412 ASSERT(0 <= len && len <= kMaxElements); | 3415 ASSERT(0 <= len && len <= kMaxElements); |
| 3413 return RoundedAllocationSize(sizeof(RawBigint) + (len * kBytesPerElement)); | 3416 return RoundedAllocationSize(sizeof(RawBigint) + (len * kBytesPerElement)); |
| 3414 } | 3417 } |
| 3415 | 3418 |
| 3416 static RawBigint* New(const String& str, Heap::Space space = Heap::kNew); | 3419 static RawBigint* New(const String& str, Heap::Space space = Heap::kNew); |
| 3417 static RawBigint* New(int64_t value, Heap::Space space = Heap::kNew); | 3420 static RawBigint* New(int64_t value, Heap::Space space = Heap::kNew); |
| 3418 | 3421 |
| 3419 RawBigint* BinaryOp(Token::Kind operation, const Bigint& other) const; | 3422 RawBigint* ArithmeticOp(Token::Kind operation, const Bigint& other) const; |
| 3420 | 3423 |
| 3421 private: | 3424 private: |
| 3422 Chunk GetChunkAt(intptr_t i) const { | 3425 Chunk GetChunkAt(intptr_t i) const { |
| 3423 return *ChunkAddr(i); | 3426 return *ChunkAddr(i); |
| 3424 } | 3427 } |
| 3425 | 3428 |
| 3426 void SetChunkAt(intptr_t i, Chunk newValue) const { | 3429 void SetChunkAt(intptr_t i, Chunk newValue) const { |
| 3427 *ChunkAddr(i) = newValue; | 3430 *ChunkAddr(i) = newValue; |
| 3428 } | 3431 } |
| 3429 | 3432 |
| (...skipping 2220 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5650 if (this->CharAt(i) != str.CharAt(begin_index + i)) { | 5653 if (this->CharAt(i) != str.CharAt(begin_index + i)) { |
| 5651 return false; | 5654 return false; |
| 5652 } | 5655 } |
| 5653 } | 5656 } |
| 5654 return true; | 5657 return true; |
| 5655 } | 5658 } |
| 5656 | 5659 |
| 5657 } // namespace dart | 5660 } // namespace dart |
| 5658 | 5661 |
| 5659 #endif // VM_OBJECT_H_ | 5662 #endif // VM_OBJECT_H_ |
| OLD | NEW |