namespace JSC {
class WeakRandom {
+friend class JSGlobalObject; // For access to initializeSeed() during replay.
public:
WeakRandom(unsigned seed)
- : m_low(seed ^ 0x49616E42)
- , m_high(seed)
{
+ initializeSeed(seed);
}
+
+ // Returns the seed provided that you've never called get() or getUint32().
+ unsigned seedUnsafe() const { return m_high; }
double get()
{
return advance() / (UINT_MAX + 1.0);
}
+ unsigned getUint32()
+ {
+ return advance();
+ }
+
private:
unsigned advance()
{
return m_high;
}
+ void initializeSeed(unsigned seed)
+ {
+ m_low = seed ^ 0x49616E42;
+ m_high = seed;
+ }
+
unsigned m_low;
unsigned m_high;
};