I said, "OR'ing can result in an object tripping multiple flags" but
meant "OR'ing
can result in a value tripping multiple flags".

On Tue, Nov 17, 2015 at 10:08 AM, Louis Santillan <[email protected]>
wrote:

> On Mon, Nov 16, 2015 at 9:44 PM, Arthur O'Dwyer <[email protected]
> > wrote:
>
>> I'm going to start using the following function for debugging purposes,
>> but *man* it would be nice if V8 provided something like this out of the
>> box. This is just Too Much Typing.
>>
>> uint64_t GetTypeFlags(const v8::Local<v8::Value>& v)
>> {
>>     uint64_t result = 0;
>>     if (v->IsArgumentsObject()   ) result |= 0x0000000000000001;
>>     if (v->IsArrayBuffer()       ) result |= 0x0000000000000002;
>>     if (v->IsArrayBufferView()   ) result |= 0x0000000000000004;
>>     if (v->IsArray()             ) result |= 0x0000000000000008;
>>     if (v->IsBooleanObject()     ) result |= 0x0000000000000010;
>>     if (v->IsBoolean()           ) result |= 0x0000000000000020;
>>     if (v->IsDataView()          ) result |= 0x0000000000000040;
>>     if (v->IsDate()              ) result |= 0x0000000000000080;
>>     if (v->IsExternal()          ) result |= 0x0000000000000100;
>>     if (v->IsFalse()             ) result |= 0x0000000000000200;
>>     if (v->IsFloat32Array()      ) result |= 0x0000000000000400;
>>     if (v->IsFloat64Array()      ) result |= 0x0000000000000800;
>>     if (v->IsFunction()          ) result |= 0x0000000000001000;
>>     if (v->IsGeneratorFunction() ) result |= 0x0000000000002000;
>>     if (v->IsGeneratorObject()   ) result |= 0x0000000000004000;
>>     if (v->IsInt16Array()        ) result |= 0x0000000000008000;
>>     if (v->IsInt32Array()        ) result |= 0x0000000000010000;
>>     if (v->IsInt32()             ) result |= 0x0000000000020000;
>>     if (v->IsInt8Array()         ) result |= 0x0000000000040000;
>>     if (v->IsMapIterator()       ) result |= 0x0000000000080000;
>>     if (v->IsMap()               ) result |= 0x0000000000100000;
>>     if (v->IsName()              ) result |= 0x0000000000200000;
>>     if (v->IsNativeError()       ) result |= 0x0000000000400000;
>>     if (v->IsNull()              ) result |= 0x0000000000800000;
>>     if (v->IsNumberObject()      ) result |= 0x0000000001000000;
>>     if (v->IsNumber()            ) result |= 0x0000000002000000;
>>     if (v->IsObject()            ) result |= 0x0000000004000000;
>>     if (v->IsPromise()           ) result |= 0x0000000008000000;
>>     if (v->IsRegExp()            ) result |= 0x0000000010000000;
>>     if (v->IsSetIterator()       ) result |= 0x0000000020000000;
>>     if (v->IsSet()               ) result |= 0x0000000040000000;
>>     if (v->IsStringObject()      ) result |= 0x0000000080000000;
>>     if (v->IsString()            ) result |= 0x0000000100000000;
>>     if (v->IsSymbolObject()      ) result |= 0x0000000200000000;
>>     if (v->IsSymbol()            ) result |= 0x0000000400000000;
>>     if (v->IsTrue()              ) result |= 0x0000000800000000;
>>     if (v->IsTypedArray()        ) result |= 0x0000001000000000;
>>     if (v->IsUint16Array()       ) result |= 0x0000002000000000;
>>     if (v->IsUint32Array()       ) result |= 0x0000004000000000;
>>     if (v->IsUint32()            ) result |= 0x0000008000000000;
>>     if (v->IsUint8Array()        ) result |= 0x0000010000000000;
>>     if (v->IsUint8ClampedArray() ) result |= 0x0000020000000000;
>>     if (v->IsUndefined()         ) result |= 0x0000040000000000;
>>     if (v->IsWeakMap()           ) result |= 0x0000080000000000;
>>     if (v->IsWeakSet()           ) result |= 0x0000100000000000;
>>     return result;
>> }
>>
>>
> Somebody correct me if I'm wrong, but OR'ing can result in an object
> tripping multiple flags.  Like a `var s = new String( "yo!" );` would
> trigger an IsObject & IsStringObject, and `var x = 42;` would trigger
> IsNumber, IsInt32, IsUint32.  Is that your intent Arthur?  Do you really
> want to do duck typing via bit masking?
>

-- 
-- 
v8-users mailing list
[email protected]
http://groups.google.com/group/v8-users
--- 
You received this message because you are subscribed to the Google Groups 
"v8-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to