Flutter Engine
The Flutter Engine
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
virtual bool OperatorEquals (const Instance &other) const
 
bool IsIdenticalTo (const Instance &other) const
 
virtual bool CanonicalizeEquals (const Instance &other) const
 
virtual uint32_t CanonicalizeHash () 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
 
virtual ObjectPtr HashCode () 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 9909 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 23110 of file object.cc.

23112 {
23113 // In 32-bit mode, the result of any operation between two Smis will fit in a
23114 // 32-bit signed result, except the product of two Smis, which will be 64-bit.
23115 // In 64-bit mode, the result of any operation between two Smis will fit in a
23116 // 64-bit signed result, except the product of two Smis (see below).
23117 if (IsSmi() && other.IsSmi()) {
23118 const intptr_t left_value = Smi::Value(Smi::RawCast(ptr()));
23119 const intptr_t right_value = Smi::Value(Smi::RawCast(other.ptr()));
23120 switch (operation) {
23121 case Token::kADD:
23122 return Integer::New(left_value + right_value, space);
23123 case Token::kSUB:
23124 return Integer::New(left_value - right_value, space);
23125 case Token::kMUL:
23126 return Integer::New(
23127 Utils::MulWithWrapAround(static_cast<int64_t>(left_value),
23128 static_cast<int64_t>(right_value)),
23129 space);
23130 case Token::kTRUNCDIV:
23131 return Integer::New(left_value / right_value, space);
23132 case Token::kMOD: {
23133 const intptr_t remainder = left_value % right_value;
23134 if (remainder < 0) {
23135 if (right_value < 0) {
23136 return Integer::New(remainder - right_value, space);
23137 } else {
23138 return Integer::New(remainder + right_value, space);
23139 }
23140 }
23141 return Integer::New(remainder, space);
23142 }
23143 default:
23144 UNIMPLEMENTED();
23145 }
23146 }
23147 const int64_t left_value = AsInt64Value();
23148 const int64_t right_value = other.AsInt64Value();
23149 switch (operation) {
23150 case Token::kADD:
23151 return Integer::New(Utils::AddWithWrapAround(left_value, right_value),
23152 space);
23153
23154 case Token::kSUB:
23155 return Integer::New(Utils::SubWithWrapAround(left_value, right_value),
23156 space);
23157
23158 case Token::kMUL:
23159 return Integer::New(Utils::MulWithWrapAround(left_value, right_value),
23160 space);
23161
23162 case Token::kTRUNCDIV:
23163 if ((left_value == Mint::kMinValue) && (right_value == -1)) {
23164 // Division special case: overflow in int64_t.
23165 // MIN_VALUE / -1 = (MAX_VALUE + 1), which wraps around to MIN_VALUE
23166 return Integer::New(Mint::kMinValue, space);
23167 }
23168 return Integer::New(left_value / right_value, space);
23169
23170 case Token::kMOD: {
23171 if ((left_value == Mint::kMinValue) && (right_value == -1)) {
23172 // Modulo special case: overflow in int64_t.
23173 // MIN_VALUE % -1 = 0 for reason given above.
23174 return Integer::New(0, space);
23175 }
23176 const int64_t remainder = left_value % right_value;
23177 if (remainder < 0) {
23178 if (right_value < 0) {
23179 return Integer::New(remainder - right_value, space);
23180 } else {
23181 return Integer::New(remainder + right_value, space);
23182 }
23183 }
23184 return Integer::New(remainder, space);
23185 }
23186 default:
23187 UNIMPLEMENTED();
23188 return Integer::null();
23189 }
23190}
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:22984
virtual int64_t AsInt64Value() const
Definition: object.cc:23058
static constexpr int64_t kMinValue
Definition: object.h:10070
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:9990
static T MulWithWrapAround(T a, T b)
Definition: utils.h:449
static T AddWithWrapAround(T a, T b)
Definition: utils.h:431
static T SubWithWrapAround(T a, T b)
Definition: utils.h:440
#define UNIMPLEMENTED
bool IsSmi(int64_t v)
Definition: runtime_api.cc:31

◆ AsDoubleValue()

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

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

Definition at line 23052 of file object.cc.

23052 {
23053 // Integer is an abstract class.
23054 UNREACHABLE();
23055 return 0.0;
23056}
#define UNREACHABLE()
Definition: assert.h:248

◆ AsInt64Value()

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

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

Definition at line 23058 of file object.cc.

23058 {
23059 // Integer is an abstract class.
23060 UNREACHABLE();
23061 return 0;
23062}

◆ AsTruncatedInt64Value()

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

Definition at line 9945 of file object.h.

9945{ return AsInt64Value(); }

◆ AsTruncatedUint32Value()

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

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

Definition at line 23064 of file object.cc.

23064 {
23065 // Integer is an abstract class.
23066 UNREACHABLE();
23067 return 0;
23068}

◆ AsValidInteger()

IntegerPtr dart::Integer::AsValidInteger ( ) const

Definition at line 23086 of file object.cc.

23086 {
23087 if (IsSmi()) return ptr();
23088 if (IsMint()) {
23089 Mint& mint = Mint::Handle();
23090 mint ^= ptr();
23091 if (Smi::IsValid(mint.value())) {
23092 return Smi::New(static_cast<intptr_t>(mint.value()));
23093 } else {
23094 return ptr();
23095 }
23096 }
23097 return ptr();
23098}
static Object & Handle()
Definition: object.h:407
static SmiPtr New(intptr_t value)
Definition: object.h:10006
static bool IsValid(int64_t value)
Definition: object.h:10026

◆ BitOp()

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

Definition at line 23192 of file object.cc.

23194 {
23195 if (IsSmi() && other.IsSmi()) {
23196 intptr_t op1_value = Smi::Value(Smi::RawCast(ptr()));
23197 intptr_t op2_value = Smi::Value(Smi::RawCast(other.ptr()));
23198 intptr_t result = 0;
23199 switch (kind) {
23200 case Token::kBIT_AND:
23201 result = op1_value & op2_value;
23202 break;
23203 case Token::kBIT_OR:
23204 result = op1_value | op2_value;
23205 break;
23206 case Token::kBIT_XOR:
23207 result = op1_value ^ op2_value;
23208 break;
23209 default:
23210 UNIMPLEMENTED();
23211 }
23213 return Smi::New(result);
23214 } else {
23215 int64_t a = AsInt64Value();
23216 int64_t b = other.AsInt64Value();
23217 switch (kind) {
23218 case Token::kBIT_AND:
23219 return Integer::New(a & b, space);
23220 case Token::kBIT_OR:
23221 return Integer::New(a | b, space);
23222 case Token::kBIT_XOR:
23223 return Integer::New(a ^ b, space);
23224 default:
23225 UNIMPLEMENTED();
23226 return Integer::null();
23227 }
23228 }
23229}
#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 9932 of file object.h.

9932 {
9933 return Equals(other);
9934 }
virtual bool Equals(const Instance &other) const
Definition: object.cc:23034

◆ CanonicalizeHash()

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

Reimplemented from dart::Instance.

Definition at line 23082 of file object.cc.

23082 {
23083 return Multiply64Hash(AsInt64Value());
23084}
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 23076 of file object.cc.

23076 {
23077 // Integer is an abstract class.
23078 UNREACHABLE();
23079 return 0;
23080}

◆ Equals()

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

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

Definition at line 23034 of file object.cc.

23034 {
23035 // Integer is an abstract class.
23036 UNREACHABLE();
23037 return false;
23038}

◆ FitsIntoSmi()

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

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

Definition at line 23070 of file object.cc.

23070 {
23071 // Integer is an abstract class.
23072 UNREACHABLE();
23073 return false;
23074}

◆ GetInt64Value()

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

Definition at line 9970 of file object.h.

9970 {
9971 if (obj->IsSmi()) {
9972 return RawSmiValue(static_cast<const SmiPtr>(obj));
9973 } else {
9974 ASSERT(obj->IsMint());
9975 return static_cast<const MintPtr>(obj)->untag()->value_;
9976 }
9977 }
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)
Definition: raw_object.cc:558

◆ HashCode()

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

Reimplemented from dart::Instance.

Definition at line 9938 of file object.h.

9938{ return ptr(); }

◆ IsNegative()

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

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

Definition at line 23046 of file object.cc.

23046 {
23047 // Integer is an abstract class.
23048 UNREACHABLE();
23049 return false;
23050}

◆ IsValueInRange()

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

Definition at line 23030 of file object.cc.

23030 {
23031 return (value <= static_cast<uint64_t>(Mint::kMaxValue));
23032}
static constexpr int64_t kMaxValue
Definition: object.h:10068
uint8_t value

◆ IsZero()

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

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

Definition at line 23040 of file object.cc.

23040 {
23041 // Integer is an abstract class.
23042 UNREACHABLE();
23043 return false;
23044}

◆ New() [1/2]

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

Definition at line 22984 of file object.cc.

22984 {
22985 // We are not supposed to have integers represented as two byte strings.
22986 ASSERT(str.IsOneByteString());
22987 if (str.IsNull() || (str.Length() == 0)) {
22988 return Integer::null();
22989 }
22990 int64_t value = 0;
22991 const char* cstr = str.ToCString();
22992 if (!OS::StringToInt64(cstr, &value)) {
22993 // Out of range.
22994 return Integer::null();
22995 }
22996 return Integer::New(value, space);
22997}
static bool StringToInt64(const char *str, int64_t *value)

◆ New() [2/2]

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

Definition at line 23018 of file object.cc.

23018 {
23019 const bool is_smi = Smi::IsValid(value);
23020 if (is_smi) {
23021 return Smi::New(static_cast<intptr_t>(value));
23022 }
23023 return Mint::New(value, space);
23024}
static MintPtr New(int64_t value, Heap::Space space=Heap::kNew)
Definition: object.cc:23304

◆ NewCanonical() [1/2]

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

Definition at line 22999 of file object.cc.

22999 {
23000 // We are not supposed to have integers represented as two byte strings.
23001 ASSERT(str.IsOneByteString());
23002 int64_t value = 0;
23003 const char* cstr = str.ToCString();
23004 if (!OS::StringToInt64(cstr, &value)) {
23005 // Out of range.
23006 return Integer::null();
23007 }
23008 return NewCanonical(value);
23009}
static IntegerPtr NewCanonical(const String &str)
Definition: object.cc:22999

◆ NewCanonical() [2/2]

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

Definition at line 23011 of file object.cc.

23011 {
23012 if (Smi::IsValid(value)) {
23013 return Smi::New(static_cast<intptr_t>(value));
23014 }
23015 return Mint::NewCanonical(value);
23016}
static MintPtr NewCanonical(int64_t value)
Definition: object.cc:23314

◆ NewFromUint64()

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

Definition at line 23026 of file object.cc.

23026 {
23027 return Integer::New(static_cast<int64_t>(value), space);
23028}

◆ OperatorEquals()

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

Reimplemented from dart::Instance.

Definition at line 9929 of file object.h.

9929 {
9930 return Equals(other);
9931 }

◆ ShiftOp()

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

Definition at line 23231 of file object.cc.

23233 {
23234 int64_t a = AsInt64Value();
23235 int64_t b = other.AsInt64Value();
23236 ASSERT(b >= 0);
23237 switch (kind) {
23238 case Token::kSHL:
23240 case Token::kSHR:
23241 return Integer::New(a >> Utils::Minimum<int64_t>(b, Mint::kBits), space);
23242 case Token::kUSHR:
23243 return Integer::New(
23244 (b >= kBitsPerInt64) ? 0 : static_cast<uint64_t>(a) >> b, space);
23245 default:
23246 UNIMPLEMENTED();
23247 return Integer::null();
23248 }
23249}
static constexpr intptr_t kBits
Definition: object.h:10067
static int64_t ShiftLeftWithTruncation(int64_t a, int64_t b)
Definition: utils.h:464
constexpr intptr_t kBitsPerInt64
Definition: globals.h:467

◆ ToHexCString()

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

Definition at line 23100 of file object.cc.

23100 {
23101 ASSERT(IsSmi() || IsMint());
23102 int64_t value = AsInt64Value();
23103 if (value < 0) {
23104 return OS::SCreate(zone, "-0x%" PX64, -static_cast<uint64_t>(value));
23105 } else {
23106 return OS::SCreate(zone, "0x%" PX64, static_cast<uint64_t>(value));
23107 }
23108}
static char * SCreate(Zone *zone, const char *format,...) PRINTF_ATTRIBUTE(2
#define PX64
Definition: globals.h:419

Friends And Related Function Documentation

◆ Class

friend class Class
friend

Definition at line 9981 of file object.h.


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