Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
Public Member Functions | Static Public Member Functions | Friends | List of all members
dart::Integer Class Reference

#include <object.h>

Inheritance diagram for dart::Integer:
dart::Number dart::Instance dart::Object dart::Mint dart::Smi

Public Member Functions

virtual bool OperatorEquals (const Instance &other) const
 
virtual bool CanonicalizeEquals (const Instance &other) const
 
virtual uint32_t CanonicalizeHash () const
 
virtual bool Equals (const Instance &other) const
 
virtual ObjectPtr HashCode () const
 
virtual bool IsZero () const
 
virtual bool IsNegative () const
 
virtual double AsDoubleValue () const
 
virtual int64_t AsInt64Value () const
 
virtual int64_t AsTruncatedInt64Value () const
 
virtual uint32_t AsTruncatedUint32Value () const
 
virtual bool FitsIntoSmi () const
 
virtual int CompareWith (const Integer &other) const
 
const char * ToHexCString (Zone *zone) const
 
IntegerPtr AsValidInteger () const
 
IntegerPtr ArithmeticOp (Token::Kind operation, const Integer &other, Heap::Space space=Heap::kNew) const
 
IntegerPtr BitOp (Token::Kind operation, const Integer &other, Heap::Space space=Heap::kNew) const
 
IntegerPtr ShiftOp (Token::Kind operation, const Integer &other, Heap::Space space=Heap::kNew) const
 
- Public Member Functions inherited from dart::Number
StringPtr ToString (Heap::Space space) const
 
- Public Member Functions inherited from dart::Instance
bool IsIdenticalTo (const Instance &other) const
 
intptr_t SizeFromClass () const
 
InstancePtr Canonicalize (Thread *thread) const
 
virtual InstancePtr CanonicalizeLocked (Thread *thread) const
 
virtual void CanonicalizeFieldsLocked (Thread *thread) const
 
InstancePtr CopyShallowToOldSpace (Thread *thread) const
 
ObjectPtr GetField (const Field &field) const
 
void SetField (const Field &field, const Object &value) const
 
AbstractTypePtr GetType (Heap::Space space) const
 
virtual TypeArgumentsPtr GetTypeArguments () const
 
virtual void SetTypeArguments (const TypeArguments &value) const
 
bool IsInstanceOf (const AbstractType &other, const TypeArguments &other_instantiator_type_arguments, const TypeArguments &other_function_type_arguments) const
 
bool IsAssignableTo (const AbstractType &other, const TypeArguments &other_instantiator_type_arguments, const TypeArguments &other_function_type_arguments) const
 
bool IsValidNativeIndex (int index) const
 
intptr_t * NativeFieldsDataAddr () const
 
intptr_t GetNativeField (int index) const
 
void GetNativeFields (uint16_t num_fields, intptr_t *field_values) const
 
void SetNativeFields (uint16_t num_fields, const intptr_t *field_values) const
 
uint16_t NumNativeFields () const
 
void SetNativeField (int index, intptr_t value) const
 
bool IsCallable (Function *function) const
 
ObjectPtr Invoke (const String &selector, const Array &arguments, const Array &argument_names, bool respect_reflectable=true, bool check_is_entrypoint=false) const
 
ObjectPtr InvokeGetter (const String &selector, bool respect_reflectable=true, bool check_is_entrypoint=false) const
 
ObjectPtr InvokeSetter (const String &selector, const Instance &argument, bool respect_reflectable=true, bool check_is_entrypoint=false) const
 
ObjectPtr EvaluateCompiledExpression (const Class &klass, const ExternalTypedData &kernel_buffer, const Array &type_definitions, const Array &arguments, const TypeArguments &type_arguments) const
 
IntegerPtr IdentityHashCode (Thread *thread) const
 
virtual bool IsPointer () const
 
- Public Member Functions inherited from dart::Object
virtual ~Object ()
 
ObjectPtr ptr () const
 
void operator= (ObjectPtr value)
 
bool IsCanonical () const
 
void SetCanonical () const
 
void ClearCanonical () const
 
bool IsImmutable () const
 
void SetImmutable () const
 
void ClearImmutable () const
 
intptr_t GetClassId () const
 
ClassPtr clazz () const
 
 CLASS_LIST_FOR_HANDLES (DEFINE_CLASS_TESTER)
 
bool IsNull () const
 
virtual const char * ToCString () const
 
void PrintJSON (JSONStream *stream, bool ref=true) const
 
virtual void PrintJSONImpl (JSONStream *stream, bool ref) const
 
void PrintImplementationFields (JSONStream *stream) const
 
virtual void PrintImplementationFieldsImpl (const JSONArray &jsarr_fields) const
 
virtual const char * JSONType () const
 
virtual StringPtr DictionaryName () const
 
bool IsNew () const
 
bool IsOld () const
 
bool InVMIsolateHeap () const
 
void Print () const
 

Static Public Member Functions

static IntegerPtr New (const String &str, Heap::Space space=Heap::kNew)
 
static IntegerPtr NewFromUint64 (uint64_t value, Heap::Space space=Heap::kNew)
 
static IntegerPtr NewCanonical (const String &str)
 
static IntegerPtr NewCanonical (int64_t value)
 
static IntegerPtr New (int64_t value, Heap::Space space=Heap::kNew)
 
static bool IsValueInRange (uint64_t value)
 
static int64_t GetInt64Value (const IntegerPtr obj)
 
- Static Public Member Functions inherited from dart::Instance
static bool NullIsAssignableTo (const AbstractType &other)
 
static bool NullIsAssignableTo (const AbstractType &other, const TypeArguments &other_instantiator_type_arguments, const TypeArguments &other_function_type_arguments)
 
static ObjectPtr EvaluateCompiledExpression (Thread *thread, const Object &receiver, const Library &library, const Class &klass, const ExternalTypedData &kernel_buffer, const Array &type_definitions, const Array &param_values, const TypeArguments &type_param_values)
 
static intptr_t UnroundedSize ()
 
static intptr_t InstanceSize ()
 
static InstancePtr New (const Class &cls, Heap::Space space=Heap::kNew)
 
static InstancePtr NewAlreadyFinalized (const Class &cls, Heap::Space space=Heap::kNew)
 
static intptr_t DataOffsetFor (intptr_t cid)
 
static intptr_t ElementSizeFor (intptr_t cid)
 
static intptr_t NextFieldOffset ()
 
static intptr_t NativeFieldsOffset ()
 
- Static Public Member Functions inherited from dart::Object
static ObjectPtr RawCast (ObjectPtr obj)
 
static constexpr bool ContainsCompressedPointers ()
 
static intptr_t tags_offset ()
 
static ObjectHandle ()
 
static ObjectHandle (Zone *zone)
 
static ObjectHandle (ObjectPtr ptr)
 
static ObjectHandle (Zone *zone, ObjectPtr ptr)
 
static ObjectZoneHandle ()
 
static ObjectZoneHandle (Zone *zone)
 
static ObjectZoneHandle (ObjectPtr ptr)
 
static ObjectZoneHandle (Zone *zone, ObjectPtr ptr)
 
static ObjectReadOnlyHandle ()
 
static ObjectPtr null ()
 
static void set_vm_isolate_snapshot_object_table (const Array &table)
 
static ClassPtr class_class ()
 
static ClassPtr dynamic_class ()
 
static ClassPtr void_class ()
 
static ClassPtr type_parameters_class ()
 
static ClassPtr type_arguments_class ()
 
static ClassPtr patch_class_class ()
 
static ClassPtr function_class ()
 
static ClassPtr closure_data_class ()
 
static ClassPtr ffi_trampoline_data_class ()
 
static ClassPtr field_class ()
 
static ClassPtr script_class ()
 
static ClassPtr library_class ()
 
static ClassPtr namespace_class ()
 
static ClassPtr kernel_program_info_class ()
 
static ClassPtr code_class ()
 
static ClassPtr instructions_class ()
 
static ClassPtr instructions_section_class ()
 
static ClassPtr instructions_table_class ()
 
static ClassPtr object_pool_class ()
 
static ClassPtr pc_descriptors_class ()
 
static ClassPtr code_source_map_class ()
 
static ClassPtr compressed_stackmaps_class ()
 
static ClassPtr var_descriptors_class ()
 
static ClassPtr exception_handlers_class ()
 
static ClassPtr context_class ()
 
static ClassPtr context_scope_class ()
 
static ClassPtr sentinel_class ()
 
static ClassPtr api_error_class ()
 
static ClassPtr language_error_class ()
 
static ClassPtr unhandled_exception_class ()
 
static ClassPtr unwind_error_class ()
 
static ClassPtr singletargetcache_class ()
 
static ClassPtr unlinkedcall_class ()
 
static ClassPtr monomorphicsmiablecall_class ()
 
static ClassPtr icdata_class ()
 
static ClassPtr megamorphic_cache_class ()
 
static ClassPtr subtypetestcache_class ()
 
static ClassPtr loadingunit_class ()
 
static ClassPtr weak_serialization_reference_class ()
 
static ClassPtr weak_array_class ()
 
static void InitNullAndBool (IsolateGroup *isolate_group)
 
static void Init (IsolateGroup *isolate_group)
 
static void InitVtables ()
 
static void FinishInit (IsolateGroup *isolate_group)
 
static void FinalizeVMIsolate (IsolateGroup *isolate_group)
 
static void FinalizeReadOnlyObject (ObjectPtr object)
 
static void Cleanup ()
 
static ErrorPtr Init (IsolateGroup *isolate_group, const uint8_t *kernel_buffer, intptr_t kernel_buffer_size)
 
static void MakeUnusedSpaceTraversable (const Object &obj, intptr_t original_size, intptr_t used_size)
 
static intptr_t InstanceSize ()
 
template<class FakeObject >
static void VerifyBuiltinVtable (intptr_t cid)
 
static void VerifyBuiltinVtables ()
 
static bool ShouldHaveImmutabilityBitSet (classid_t class_id)
 

Friends

class Class
 

Additional Inherited Members

- Public Types inherited from dart::Object
enum  NameVisibility { kInternalName = 0 , kScrubbedName , kUserVisibleName }
 
enum class  NameDisambiguation { kYes , kNo }
 
using UntaggedObjectType = UntaggedObject
 
using ObjectPtrType = ObjectPtr
 
- Static Public Attributes inherited from dart::Object
static constexpr intptr_t kHashBits = 30
 
static const ClassId kClassId = kObjectCid
 
- Protected Member Functions inherited from dart::Instance
virtual void PrintSharedInstanceJSON (JSONObject *jsobj, bool ref, bool include_id=true) const
 
- Protected Member Functions inherited from dart::Object
 Object ()
 
uword raw_value () const
 
void setPtr (ObjectPtr value, intptr_t default_cid)
 
void CheckHandle () const
 
cpp_vtable vtable () const
 
void set_vtable (cpp_vtable value)
 
bool Contains (uword addr) const
 
template<typename type , std::memory_order order = std::memory_order_relaxed>
type LoadPointer (type const *addr) const
 
template<typename type , std::memory_order order = std::memory_order_relaxed>
void StorePointer (type const *addr, type value) const
 
template<typename type , typename compressed_type , std::memory_order order = std::memory_order_relaxed>
void StoreCompressedPointer (compressed_type const *addr, type value) const
 
template<typename type >
void StorePointerUnaligned (type const *addr, type value, Thread *thread) const
 
void StoreSmi (SmiPtr const *addr, SmiPtr value) const
 
template<typename FieldType >
void StoreSimd128 (const FieldType *addr, simd128_value_t value) const
 
template<typename FieldType >
FieldType LoadNonPointer (const FieldType *addr) const
 
template<typename FieldType , std::memory_order order>
FieldType LoadNonPointer (const FieldType *addr) const
 
template<typename FieldType , typename ValueType >
void StoreNonPointer (const FieldType *addr, ValueType value) const
 
template<typename FieldType , typename ValueType , std::memory_order order>
void StoreNonPointer (const FieldType *addr, ValueType value) const
 
template<typename FieldType >
FieldType * UnsafeMutableNonPointer (const FieldType *addr) const
 
 CLASS_LIST (STORE_NON_POINTER_ILLEGAL_TYPE)
 
void UnimplementedMethod () const
 
void AddCommonObjectProperties (JSONObject *jsobj, const char *protocol_type, bool ref) const
 
- Static Protected Member Functions inherited from dart::Object
static DART_NOINLINE ObjectHandleImpl (Zone *zone, ObjectPtr ptr, intptr_t default_cid)
 
static DART_NOINLINE ObjectZoneHandleImpl (Zone *zone, ObjectPtr ptr, intptr_t default_cid)
 
static DART_NOINLINE ObjectReadOnlyHandleImpl (intptr_t cid)
 
static ObjectPtr Allocate (intptr_t cls_id, intptr_t size, Heap::Space space, bool compressed, uword ptr_field_start_offset, uword ptr_field_end_offset)
 
template<typename T >
static DART_FORCE_INLINE T::ObjectPtrType Allocate (Heap::Space space)
 
template<typename T >
static DART_FORCE_INLINE T::ObjectPtrType Allocate (Heap::Space space, intptr_t elements)
 
template<typename T >
static DART_FORCE_INLINE T::ObjectPtrType AllocateVariant (intptr_t class_id, Heap::Space space)
 
template<typename T >
static DART_FORCE_INLINE T::ObjectPtrType AllocateVariant (intptr_t class_id, Heap::Space space, intptr_t elements)
 
static constexpr intptr_t RoundedAllocationSize (intptr_t size)
 
static ObjectPtr Clone (const Object &orig, Heap::Space space, bool load_with_relaxed_atomics=false)
 
template<typename T >
static DART_FORCE_INLINE uword from_offset ()
 
template<typename T >
static DART_FORCE_INLINE uword to_offset (intptr_t length=0)
 
- Protected Attributes inherited from dart::Object
ObjectPtr ptr_
 

Detailed Description

Definition at line 9888 of file object.h.

Member Function Documentation

◆ ArithmeticOp()

IntegerPtr dart::Integer::ArithmeticOp ( Token::Kind  operation,
const Integer other,
Heap::Space  space = Heap::kNew 
) const

Definition at line 23189 of file object.cc.

23191 {
23192 // In 32-bit mode, the result of any operation between two Smis will fit in a
23193 // 32-bit signed result, except the product of two Smis, which will be 64-bit.
23194 // In 64-bit mode, the result of any operation between two Smis will fit in a
23195 // 64-bit signed result, except the product of two Smis (see below).
23196 if (IsSmi() && other.IsSmi()) {
23197 const intptr_t left_value = Smi::Value(Smi::RawCast(ptr()));
23198 const intptr_t right_value = Smi::Value(Smi::RawCast(other.ptr()));
23199 switch (operation) {
23200 case Token::kADD:
23201 return Integer::New(left_value + right_value, space);
23202 case Token::kSUB:
23203 return Integer::New(left_value - right_value, space);
23204 case Token::kMUL:
23205 return Integer::New(
23206 Utils::MulWithWrapAround(static_cast<int64_t>(left_value),
23207 static_cast<int64_t>(right_value)),
23208 space);
23209 case Token::kTRUNCDIV:
23210 return Integer::New(left_value / right_value, space);
23211 case Token::kMOD: {
23212 const intptr_t remainder = left_value % right_value;
23213 if (remainder < 0) {
23214 if (right_value < 0) {
23215 return Integer::New(remainder - right_value, space);
23216 } else {
23217 return Integer::New(remainder + right_value, space);
23218 }
23219 }
23220 return Integer::New(remainder, space);
23221 }
23222 default:
23223 UNIMPLEMENTED();
23224 }
23225 }
23226 const int64_t left_value = AsInt64Value();
23227 const int64_t right_value = other.AsInt64Value();
23228 switch (operation) {
23229 case Token::kADD:
23230 return Integer::New(Utils::AddWithWrapAround(left_value, right_value),
23231 space);
23232
23233 case Token::kSUB:
23234 return Integer::New(Utils::SubWithWrapAround(left_value, right_value),
23235 space);
23236
23237 case Token::kMUL:
23238 return Integer::New(Utils::MulWithWrapAround(left_value, right_value),
23239 space);
23240
23241 case Token::kTRUNCDIV:
23242 if ((left_value == Mint::kMinValue) && (right_value == -1)) {
23243 // Division special case: overflow in int64_t.
23244 // MIN_VALUE / -1 = (MAX_VALUE + 1), which wraps around to MIN_VALUE
23245 return Integer::New(Mint::kMinValue, space);
23246 }
23247 return Integer::New(left_value / right_value, space);
23248
23249 case Token::kMOD: {
23250 if ((left_value == Mint::kMinValue) && (right_value == -1)) {
23251 // Modulo special case: overflow in int64_t.
23252 // MIN_VALUE % -1 = 0 for reason given above.
23253 return Integer::New(0, space);
23254 }
23255 const int64_t remainder = left_value % right_value;
23256 if (remainder < 0) {
23257 if (right_value < 0) {
23258 return Integer::New(remainder - right_value, space);
23259 } else {
23260 return Integer::New(remainder + right_value, space);
23261 }
23262 }
23263 return Integer::New(remainder, space);
23264 }
23265 default:
23266 UNIMPLEMENTED();
23267 return Integer::null();
23268 }
23269}
static void operation(T operation, uint32_t &a, uint32_t b, uint32_t c, uint32_t d, uint32_t x, uint8_t s, uint32_t t)
Definition SkMD5.cpp:144
static IntegerPtr New(const String &str, Heap::Space space=Heap::kNew)
Definition object.cc:23063
virtual int64_t AsInt64Value() const
Definition object.cc:23137
static constexpr int64_t kMinValue
Definition object.h:10049
static ObjectPtr null()
Definition object.h:433
ObjectPtr ptr() const
Definition object.h:332
static ObjectPtr RawCast(ObjectPtr obj)
Definition object.h:325
intptr_t Value() const
Definition object.h:9969
static T MulWithWrapAround(T a, T b)
Definition utils.h:434
static T AddWithWrapAround(T a, T b)
Definition utils.h:416
static T SubWithWrapAround(T a, T b)
Definition utils.h:425
#define UNIMPLEMENTED
bool IsSmi(int64_t v)

◆ AsDoubleValue()

double dart::Integer::AsDoubleValue ( ) const
virtual

Reimplemented in dart::Smi, and dart::Mint.

Definition at line 23131 of file object.cc.

23131 {
23132 // Integer is an abstract class.
23133 UNREACHABLE();
23134 return 0.0;
23135}
#define UNREACHABLE()
Definition assert.h:248

◆ AsInt64Value()

int64_t dart::Integer::AsInt64Value ( ) const
virtual

Reimplemented in dart::Smi, and dart::Mint.

Definition at line 23137 of file object.cc.

23137 {
23138 // Integer is an abstract class.
23139 UNREACHABLE();
23140 return 0;
23141}

◆ AsTruncatedInt64Value()

virtual int64_t dart::Integer::AsTruncatedInt64Value ( ) const
inlinevirtual

Definition at line 9924 of file object.h.

9924{ return AsInt64Value(); }

◆ AsTruncatedUint32Value()

uint32_t dart::Integer::AsTruncatedUint32Value ( ) const
virtual

Reimplemented in dart::Smi, and dart::Mint.

Definition at line 23143 of file object.cc.

23143 {
23144 // Integer is an abstract class.
23145 UNREACHABLE();
23146 return 0;
23147}

◆ AsValidInteger()

IntegerPtr dart::Integer::AsValidInteger ( ) const

Definition at line 23165 of file object.cc.

23165 {
23166 if (IsSmi()) return ptr();
23167 if (IsMint()) {
23168 Mint& mint = Mint::Handle();
23169 mint ^= ptr();
23170 if (Smi::IsValid(mint.value())) {
23171 return Smi::New(static_cast<intptr_t>(mint.value()));
23172 } else {
23173 return ptr();
23174 }
23175 }
23176 return ptr();
23177}
static Object & Handle()
Definition object.h:407
static SmiPtr New(intptr_t value)
Definition object.h:9985
static bool IsValid(int64_t value)
Definition object.h:10005

◆ BitOp()

IntegerPtr dart::Integer::BitOp ( Token::Kind  operation,
const Integer other,
Heap::Space  space = Heap::kNew 
) const

Definition at line 23271 of file object.cc.

23273 {
23274 if (IsSmi() && other.IsSmi()) {
23275 intptr_t op1_value = Smi::Value(Smi::RawCast(ptr()));
23276 intptr_t op2_value = Smi::Value(Smi::RawCast(other.ptr()));
23277 intptr_t result = 0;
23278 switch (kind) {
23279 case Token::kBIT_AND:
23280 result = op1_value & op2_value;
23281 break;
23282 case Token::kBIT_OR:
23283 result = op1_value | op2_value;
23284 break;
23285 case Token::kBIT_XOR:
23286 result = op1_value ^ op2_value;
23287 break;
23288 default:
23289 UNIMPLEMENTED();
23290 }
23292 return Smi::New(result);
23293 } else {
23294 int64_t a = AsInt64Value();
23295 int64_t b = other.AsInt64Value();
23296 switch (kind) {
23297 case Token::kBIT_AND:
23298 return Integer::New(a & b, space);
23299 case Token::kBIT_OR:
23300 return Integer::New(a | b, space);
23301 case Token::kBIT_XOR:
23302 return Integer::New(a ^ b, space);
23303 default:
23304 UNIMPLEMENTED();
23305 return Integer::null();
23306 }
23307 }
23308}
#define ASSERT(E)
static bool b
struct MyStruct a[10]
GAsyncResult * result

◆ CanonicalizeEquals()

virtual bool dart::Integer::CanonicalizeEquals ( const Instance other) const
inlinevirtual

Reimplemented from dart::Instance.

Definition at line 9911 of file object.h.

9911 {
9912 return Equals(other);
9913 }
virtual bool Equals(const Instance &other) const
Definition object.cc:23113

◆ CanonicalizeHash()

uint32_t dart::Integer::CanonicalizeHash ( ) const
virtual

Reimplemented from dart::Instance.

Definition at line 23161 of file object.cc.

23161 {
23162 return Multiply64Hash(AsInt64Value());
23163}
uint32_t Multiply64Hash(int64_t ivalue)
Definition integers.cc:276

◆ CompareWith()

int dart::Integer::CompareWith ( const Integer other) const
virtual

Reimplemented in dart::Smi, and dart::Mint.

Definition at line 23155 of file object.cc.

23155 {
23156 // Integer is an abstract class.
23157 UNREACHABLE();
23158 return 0;
23159}

◆ Equals()

bool dart::Integer::Equals ( const Instance other) const
virtual

Reimplemented in dart::Smi, and dart::Mint.

Definition at line 23113 of file object.cc.

23113 {
23114 // Integer is an abstract class.
23115 UNREACHABLE();
23116 return false;
23117}

◆ FitsIntoSmi()

bool dart::Integer::FitsIntoSmi ( ) const
virtual

Reimplemented in dart::Smi, and dart::Mint.

Definition at line 23149 of file object.cc.

23149 {
23150 // Integer is an abstract class.
23151 UNREACHABLE();
23152 return false;
23153}

◆ GetInt64Value()

static int64_t dart::Integer::GetInt64Value ( const IntegerPtr  obj)
inlinestatic

Definition at line 9949 of file object.h.

9949 {
9950 if (obj->IsSmi()) {
9951 return RawSmiValue(static_cast<const SmiPtr>(obj));
9952 } else {
9953 ASSERT(obj->IsMint());
9954 return static_cast<const MintPtr>(obj)->untag()->value_;
9955 }
9956 }
intptr_t RawSmiValue(const SmiPtr raw_value)
raw_obj untag() -> num_entries()) VARIABLE_COMPRESSED_VISITOR(Array, Smi::Value(raw_obj->untag() ->length())) VARIABLE_COMPRESSED_VISITOR(TypedData, TypedData::ElementSizeInBytes(raw_obj->GetClassId()) *Smi::Value(raw_obj->untag() ->length())) VARIABLE_COMPRESSED_VISITOR(Record, RecordShape(raw_obj->untag() ->shape()).num_fields()) VARIABLE_NULL_VISITOR(CompressedStackMaps, CompressedStackMaps::PayloadSizeOf(raw_obj)) VARIABLE_NULL_VISITOR(OneByteString, Smi::Value(raw_obj->untag() ->length())) VARIABLE_NULL_VISITOR(TwoByteString, Smi::Value(raw_obj->untag() ->length())) intptr_t UntaggedField::VisitFieldPointers(FieldPtr raw_obj, ObjectPointerVisitor *visitor)

◆ HashCode()

virtual ObjectPtr dart::Integer::HashCode ( ) const
inlinevirtual

Reimplemented from dart::Instance.

Definition at line 9917 of file object.h.

9917{ return ptr(); }

◆ IsNegative()

bool dart::Integer::IsNegative ( ) const
virtual

Reimplemented in dart::Smi, and dart::Mint.

Definition at line 23125 of file object.cc.

23125 {
23126 // Integer is an abstract class.
23127 UNREACHABLE();
23128 return false;
23129}

◆ IsValueInRange()

bool dart::Integer::IsValueInRange ( uint64_t  value)
static

Definition at line 23109 of file object.cc.

23109 {
23110 return (value <= static_cast<uint64_t>(Mint::kMaxValue));
23111}
static constexpr int64_t kMaxValue
Definition object.h:10047

◆ IsZero()

bool dart::Integer::IsZero ( ) const
virtual

Reimplemented in dart::Smi, and dart::Mint.

Definition at line 23119 of file object.cc.

23119 {
23120 // Integer is an abstract class.
23121 UNREACHABLE();
23122 return false;
23123}

◆ New() [1/2]

IntegerPtr dart::Integer::New ( const String str,
Heap::Space  space = Heap::kNew 
)
static

Definition at line 23063 of file object.cc.

23063 {
23064 // We are not supposed to have integers represented as two byte strings.
23065 ASSERT(str.IsOneByteString());
23066 if (str.IsNull() || (str.Length() == 0)) {
23067 return Integer::null();
23068 }
23069 int64_t value = 0;
23070 const char* cstr = str.ToCString();
23071 if (!OS::StringToInt64(cstr, &value)) {
23072 // Out of range.
23073 return Integer::null();
23074 }
23075 return Integer::New(value, space);
23076}
static bool StringToInt64(const char *str, int64_t *value)
uint8_t value

◆ New() [2/2]

IntegerPtr dart::Integer::New ( int64_t  value,
Heap::Space  space = Heap::kNew 
)
static

Definition at line 23097 of file object.cc.

23097 {
23098 const bool is_smi = Smi::IsValid(value);
23099 if (is_smi) {
23100 return Smi::New(static_cast<intptr_t>(value));
23101 }
23102 return Mint::New(value, space);
23103}
static MintPtr New(int64_t value, Heap::Space space=Heap::kNew)
Definition object.cc:23383

◆ NewCanonical() [1/2]

IntegerPtr dart::Integer::NewCanonical ( const String str)
static

Definition at line 23078 of file object.cc.

23078 {
23079 // We are not supposed to have integers represented as two byte strings.
23080 ASSERT(str.IsOneByteString());
23081 int64_t value = 0;
23082 const char* cstr = str.ToCString();
23083 if (!OS::StringToInt64(cstr, &value)) {
23084 // Out of range.
23085 return Integer::null();
23086 }
23087 return NewCanonical(value);
23088}
static IntegerPtr NewCanonical(const String &str)
Definition object.cc:23078

◆ NewCanonical() [2/2]

IntegerPtr dart::Integer::NewCanonical ( int64_t  value)
static

Definition at line 23090 of file object.cc.

23090 {
23091 if (Smi::IsValid(value)) {
23092 return Smi::New(static_cast<intptr_t>(value));
23093 }
23094 return Mint::NewCanonical(value);
23095}
static MintPtr NewCanonical(int64_t value)
Definition object.cc:23393

◆ NewFromUint64()

IntegerPtr dart::Integer::NewFromUint64 ( uint64_t  value,
Heap::Space  space = Heap::kNew 
)
static

Definition at line 23105 of file object.cc.

23105 {
23106 return Integer::New(static_cast<int64_t>(value), space);
23107}

◆ OperatorEquals()

virtual bool dart::Integer::OperatorEquals ( const Instance other) const
inlinevirtual

Reimplemented from dart::Instance.

Definition at line 9908 of file object.h.

9908 {
9909 return Equals(other);
9910 }

◆ ShiftOp()

IntegerPtr dart::Integer::ShiftOp ( Token::Kind  operation,
const Integer other,
Heap::Space  space = Heap::kNew 
) const

Definition at line 23310 of file object.cc.

23312 {
23313 int64_t a = AsInt64Value();
23314 int64_t b = other.AsInt64Value();
23315 ASSERT(b >= 0);
23316 switch (kind) {
23317 case Token::kSHL:
23319 case Token::kSHR:
23320 return Integer::New(a >> Utils::Minimum<int64_t>(b, Mint::kBits), space);
23321 case Token::kUSHR:
23322 return Integer::New(
23323 (b >= kBitsPerInt64) ? 0 : static_cast<uint64_t>(a) >> b, space);
23324 default:
23325 UNIMPLEMENTED();
23326 return Integer::null();
23327 }
23328}
static constexpr intptr_t kBits
Definition object.h:10046
static int64_t ShiftLeftWithTruncation(int64_t a, int64_t b)
Definition utils.h:449
constexpr intptr_t kBitsPerInt64
Definition globals.h:467

◆ ToHexCString()

const char * dart::Integer::ToHexCString ( Zone zone) const

Definition at line 23179 of file object.cc.

23179 {
23180 ASSERT(IsSmi() || IsMint());
23181 int64_t value = AsInt64Value();
23182 if (value < 0) {
23183 return OS::SCreate(zone, "-0x%" PX64, -static_cast<uint64_t>(value));
23184 } else {
23185 return OS::SCreate(zone, "0x%" PX64, static_cast<uint64_t>(value));
23186 }
23187}
static char * SCreate(Zone *zone, const char *format,...) PRINTF_ATTRIBUTE(2
#define PX64
Definition globals.h:419

Friends And Related Symbol Documentation

◆ Class

friend class Class
friend

Definition at line 9960 of file object.h.


The documentation for this class was generated from the following files: