38 template <
class CC>
class Atom;
61 static bool ValidType(u32 type)
63 return type > INVALID && type < TYPE_COUNT;
66 static void AssertValidType(u32 type)
70 FAIL(ILLEGAL_ARGUMENT);
74 static const char *(m_typeNames[TYPE_COUNT]);
76 static const char * GetTypeName(u32 t)
82 return m_typeNames[t];
95 static s32 GetMin(u32 type, u32 bits)
100 case S32:
return bits==0 ? 0 : -MakeMask(bits-1) - 1;
102 case UNARY:
return 0;
104 default: FAIL(ILLEGAL_ARGUMENT);
108 static s32 GetMax(u32 type, u32 bits)
112 case U32:
return MakeMask(bits > 31 ? 31 : bits);
113 case S32:
return MakeMask(bits-1);
115 case UNARY:
return bits;
117 default: FAIL(ILLEGAL_ARGUMENT);
121 bool InRangeByLength(s32 val)
const
123 return GetMin(m_type, m_length) <= val && GetMax(m_type, m_length) >= val;
126 void AssertInRangeByLength(s32 val)
const
128 if (!InRangeByLength(val))
149 s32 GetDefault()
const
154 u64 GetLongDefault()
const
159 bool InRange(s32 val)
const
161 return m_min <= val && m_max >= val;
164 void AssertInRange(s32 val)
const
172 VD(u32 type, u32 len, u32 pos, s32 min, s32 vdef, s32 max)
173 : m_type(type), m_length(len), m_start(pos), m_min(min), m_vdef(vdef), m_max(max), m_longdef(0)
175 AssertValidType(m_type);
176 if (m_length > 32 || m_type == BITS)
178 FAIL(ILLEGAL_ARGUMENT);
180 AssertInRangeByLength(m_min);
181 AssertInRangeByLength(m_max);
182 AssertInRange(m_vdef);
185 VD(u32 type, u32 len, u32 pos, u64 longdef)
186 : m_type(type), m_length(len), m_start(pos), m_min(0), m_vdef(0), m_max(0), m_longdef(longdef)
188 if (m_type != BITS || m_length > 64)
190 FAIL(ILLEGAL_ARGUMENT);
194 void AssertIsType(u32 type)
const
198 FAIL(ILLEGAL_ARGUMENT);
202 static u32 MakeMask(u32 length)
204 return _GetNOnes32(length);
216 template <
class CC>
static u32
GetFieldAsBits(
const u32 length,
const u32 start,
const typename CC::ATOM_TYPE & a) ;
217 template <
class CC>
static void SetFieldAsBits(
const u32 length,
const u32 start,
typename CC::ATOM_TYPE & a,
const u32 val) ;
219 template <
class CC>
static u64 GetLongFieldAsBits(
const u32 length,
const u32 start,
const typename CC::ATOM_TYPE & a) ;
220 template <
class CC>
static void SetLongFieldAsBits(
const u32 length,
const u32 start,
typename CC::ATOM_TYPE & a,
const u64 val) ;
227 template <
class CC> s32
GetBitsAsS32(
const typename CC::ATOM_TYPE & a)
const ;
234 template <
class CC>
void SetBitsAsS32(
typename CC::ATOM_TYPE & a, s32 val)
const ;
240 template <
class CC> u64
GetBitsAsU64(
const typename CC::ATOM_TYPE & a)
const ;
246 template <
class CC>
void SetBitsAsU64(
typename CC::ATOM_TYPE & a, u64 val)
const ;
250 template <
class CC>
static u32
GetFieldAsU32(
const u32 length,
const u32 start,
const typename CC::ATOM_TYPE & a) ;
251 template <
class CC>
static void SetFieldAsU32(
const u32 length,
const u32 start,
typename CC::ATOM_TYPE & a,
const u32 val) ;
252 template <
class CC> u32 GetValueU32(
const typename CC::ATOM_TYPE & a)
const ;
253 template <
class CC>
void SetValueU32(
typename CC::ATOM_TYPE & a,
const u32 val)
const ;
257 template <
class CC>
static s32
GetFieldAsS32(
const u32 length,
const u32 start,
const typename CC::ATOM_TYPE & a) ;
258 template <
class CC>
static void SetFieldAsS32(
const u32 length,
const u32 start,
typename CC::ATOM_TYPE & a,
const s32 val) ;
259 template <
class CC> s32 GetValueS32(
const typename CC::ATOM_TYPE & a)
const ;
260 template <
class CC>
void SetValueS32(
typename CC::ATOM_TYPE & a,
const s32 val)
const ;
264 template <
class CC>
static bool GetFieldAsBool(
const u32 length,
const u32 start,
const typename CC::ATOM_TYPE & a) ;
265 template <
class CC>
static void SetFieldAsBool(
const u32 length,
const u32 start,
typename CC::ATOM_TYPE & a,
const bool val) ;
266 template <
class CC>
bool GetValueBool(
const typename CC::ATOM_TYPE & a)
const ;
267 template <
class CC>
void SetValueBool(
typename CC::ATOM_TYPE & a,
const bool val)
const ;
271 template <
class CC>
static u32
GetFieldAsUnary(
const u32 length,
const u32 start,
const typename CC::ATOM_TYPE & a) ;
272 template <
class CC>
static void SetFieldAsUnary(
const u32 length,
const u32 start,
typename CC::ATOM_TYPE & a,
const u32 val) ;
273 template <
class CC> u32 GetValueUnary(
const typename CC::ATOM_TYPE & a)
const ;
274 template <
class CC>
void SetValueUnary(
typename CC::ATOM_TYPE & a,
const u32 val)
const ;
static u32 GetFieldAsU32(const u32 length, const u32 start, const typename CC::ATOM_TYPE &a)
u32 value
Definition: VD.tcc:63
static bool GetFieldAsBool(const u32 length, const u32 start, const typename CC::ATOM_TYPE &a)
bool value
Definition: VD.tcc:117
s32 GetBitsAsS32(const typename CC::ATOM_TYPE &a) const
Definition: VD.tcc:43
void SetBitsAsU64(typename CC::ATOM_TYPE &a, u64 val) const
Definition: VD.tcc:37
static u32 GetFieldAsBits(const u32 length, const u32 start, const typename CC::ATOM_TYPE &a)
Raw bits value.
Definition: VD.tcc:7
void SetBitsAsS32(typename CC::ATOM_TYPE &a, s32 val) const
Definition: VD.tcc:49
u64 GetBitsAsU64(const typename CC::ATOM_TYPE &a) const
Definition: VD.tcc:31
static s32 GetFieldAsS32(const u32 length, const u32 start, const typename CC::ATOM_TYPE &a)
s32 value
Definition: VD.tcc:89
static u32 GetFieldAsUnary(const u32 length, const u32 start, const typename CC::ATOM_TYPE &a)
unary value
Definition: VD.tcc:144