History

Convert static members to constexpr getters. This is hopefully going to avoid the built issues on Mac.

arr committed 9 years ago

Commit b0ff2261 parent c55b47f2 files · +44 −44Browse files

Showing the changes to src/include (1 of 2 files). Show all

Unified · Split

src/include/vm_asm_sigkind.h+41−26
@@ -11,7 +11,6 @@ · 10 unmodified lines
11#include <sstream>11#include <sstream>
12#include <cassert>12#include <cassert>
13#include <cstdint>13#include <cstdint>
14#include "opcodes.h"
15#include "runtime.h"14#include "runtime.h"
16 15
17namespace disvm16namespace disvm
@@ -29,7 +28,7 @@ namespace disvm · 11 unmodified lines
29 static uint32_t compute_signature_hash(const char *);28 static uint32_t compute_signature_hash(const char *);
30 29
31 // Type delimiter30 // Type delimiter
32 static const char delim;31 static constexpr char delim();
33 32
34 public:33 public:
35 std::string get_signature() const;34 std::string get_signature() const;
@@ -45,6 +44,8 @@ namespace disvm · 9 unmodified lines
45 mutable std::stringstream _ss;44 mutable std::stringstream _ss;
46 };45 };
47 46
47 constexpr char sig_stream_t::delim() { return ','; }
48
48 // Type context modifiers49 // Type context modifiers
49 enum class modifier_id_t : uint8_t50 enum class modifier_id_t : uint8_t
50 {51 {
@@ -196,7 +197,7 @@ namespace disvm · 145 unmodified lines
196 template<typename T1, typename T2, typename ...S>197 template<typename T1, typename T2, typename ...S>
197 void nested_type(sig_stream_t &ss, const T1 &t1, const T2 &t2, const S&...s)198 void nested_type(sig_stream_t &ss, const T1 &t1, const T2 &t2, const S&...s)
198 {199 {
199 ss << t1 << sig_stream_t::delim;200 ss << t1 << sig_stream_t::delim();
200 nested_type(ss, t2, s...);201 nested_type(ss, t2, s...);
201 }202 }
202 203
@@ -205,18 +206,18 @@ namespace disvm · 2 unmodified lines
205 class Tnested_aggregate_type : public Tbasic_type<ID>206 class Tnested_aggregate_type : public Tbasic_type<ID>
206 {207 {
207 public: // static208 public: // static
208 static const char begin;209 static constexpr char begin();
209 static const char end;210 static constexpr char end();
210 211
211 template<typename ...NT>212 template<typename ...NT>
212 static Tnested_aggregate_type create(const NT&... nestedTypes)213 static Tnested_aggregate_type create(const NT&... nestedTypes)
213 {214 {
214 sig_stream_t ss;215 sig_stream_t ss;
215 ss << Tbasic_type<ID>::id << Tnested_aggregate_type::begin;216 ss << Tbasic_type<ID>::id << Tnested_aggregate_type::begin();
216 217
217 nested_type(ss, nestedTypes...);218 nested_type(ss, nestedTypes...);
218 219
219 ss << Tnested_aggregate_type::end;220 ss << Tnested_aggregate_type::end();
220 221
221 return Tnested_aggregate_type{ ss };222 return Tnested_aggregate_type{ ss };
222 }223 }
@@ -234,6 +235,16 @@ namespace disvm · 11 unmodified lines
234 235
235 using Ttuple = Tnested_aggregate_type<type_id_t::tuple>;236 using Ttuple = Tnested_aggregate_type<type_id_t::tuple>;
236 using Tmodule = Tnested_aggregate_type<type_id_t::module>;237 using Tmodule = Tnested_aggregate_type<type_id_t::module>;
238 using _Tadt = Tnested_aggregate_type<type_id_t::adt>;
239
240 template<> constexpr char Ttuple::begin() { return '('; }
241 template<> constexpr char Ttuple::end() { return ')'; }
242
243 template<> constexpr char Tmodule::begin() { return '{'; }
244 template<> constexpr char Tmodule::end() { return '}'; }
245
246 template<> constexpr char _Tadt::begin() { return '('; }
247 template<> constexpr char _Tadt::end() { return ')'; }
237 248
238 sig_stream_t &operator<<(sig_stream_t &, const disvm::assembly::sigkind::Ttuple &);249 sig_stream_t &operator<<(sig_stream_t &, const disvm::assembly::sigkind::Ttuple &);
239 sig_stream_t &operator<<(sig_stream_t &, const disvm::assembly::sigkind::Tmodule &);250 sig_stream_t &operator<<(sig_stream_t &, const disvm::assembly::sigkind::Tmodule &);
@@ -243,9 +254,9 @@ namespace disvm · 3 unmodified lines
243 class Tadt_pick_tag final : public Tbasic_type<type_id_t::adt_pick_tag>254 class Tadt_pick_tag final : public Tbasic_type<type_id_t::adt_pick_tag>
244 {255 {
245 public: // static256 public: // static
246 static const char *tag_delim;257 static constexpr char *tag_delim();
247 static const char begin;258 static constexpr char begin();
248 static const char end;259 static constexpr char end();
249 260
250 static Tadt_pick_tag create(const char *pick_tag, uint32_t adt_ref, std::initializer_list<const Tm> tms);261 static Tadt_pick_tag create(const char *pick_tag, uint32_t adt_ref, std::initializer_list<const Tm> tms);
251 262
@@ -256,24 +267,28 @@ namespace disvm · 4 unmodified lines
256 Tadt_pick_tag(sig_stream_t &s) : _s{ std::move(s) } { }267 Tadt_pick_tag(sig_stream_t &s) : _s{ std::move(s) } { }
257 };268 };
258 269
270 constexpr char *Tadt_pick_tag::tag_delim() { return "=>"; }
271 constexpr char Tadt_pick_tag::begin() { return '('; }
272 constexpr char Tadt_pick_tag::end() { return ')'; }
273
259 sig_stream_t &operator<<(sig_stream_t &, const disvm::assembly::sigkind::Tadt_pick_tag &);274 sig_stream_t &operator<<(sig_stream_t &, const disvm::assembly::sigkind::Tadt_pick_tag &);
260 275
261 // Abstract data type (ADT)276 // Abstract data type (ADT)
262 class Tadt final : public Tnested_aggregate_type<type_id_t::adt>277 class Tadt final : public _Tadt
263 {278 {
264 public: // static279 public: // static
265 // Unhide base class version of function280 // Unhide base class version of function
266 using Tnested_aggregate_type::create;281 using _Tadt::create;
267 282
268 // Create an ADT with a single pick tag283 // Create an ADT with a single pick tag
269 static Tadt create(const Tadt_pick_tag &p)284 static Tadt create(const Tadt_pick_tag &p)
270 {285 {
271 sig_stream_t ss;286 sig_stream_t ss;
272 ss << Tbasic_type::id287 ss << Tbasic_type::id
273 << Tadt::begin288 << Tadt::begin()
274 << sig_stream_t::delim289 << sig_stream_t::delim()
275 << p290 << p
276 << Tadt::end;291 << Tadt::end();
277 292
278 return Tadt{ ss };293 return Tadt{ ss };
279 }294 }
@@ -288,20 +303,20 @@ namespace disvm · 8 unmodified lines
288 // single pick tag for an ADT must also be handled (above).303 // single pick tag for an ADT must also be handled (above).
289 sig_stream_t ss;304 sig_stream_t ss;
290 ss << Tbasic_type::id305 ss << Tbasic_type::id
291 << Tadt::begin306 << Tadt::begin()
292 << sig_stream_t::delim307 << sig_stream_t::delim()
293 << p308 << p
294 << sig_stream_t::delim;309 << sig_stream_t::delim();
295 310
296 nested_type(ss, t, nestedTypes...);311 nested_type(ss, t, nestedTypes...);
297 312
298 ss << Tadt::end;313 ss << Tadt::end();
299 314
300 return Tadt{ ss };315 return Tadt{ ss };
301 }316 }
302 317
303 private:318 private:
304 Tadt(sig_stream_t &s) : Tnested_aggregate_type{ s } { }319 Tadt(sig_stream_t &s) : _Tadt{ s } { }
305 };320 };
306 321
307 sig_stream_t &operator<<(sig_stream_t &, const disvm::assembly::sigkind::Tnested_aggregate_type<type_id_t::adt> &);322 sig_stream_t &operator<<(sig_stream_t &, const disvm::assembly::sigkind::Tnested_aggregate_type<type_id_t::adt> &);
@@ -311,18 +326,18 @@ namespace disvm · 3 unmodified lines
311 class Tfunction_base_type final : public Tbasic_type<T>326 class Tfunction_base_type final : public Tbasic_type<T>
312 {327 {
313 public: // static328 public: // static
314 static const char begin;329 static constexpr char begin();
315 static const char end;330 static constexpr char end();
316 331
317 template<typename ...AT>332 template<typename ...AT>
318 static Tfunction_base_type create(AT... argTypes)333 static Tfunction_base_type create(AT... argTypes)
319 {334 {
320 Tfunction_base_type a;335 Tfunction_base_type a;
321 a._s << Tfunction_base_type::id << Tfunction_base_type::begin;336 a._s << Tfunction_base_type::id << Tfunction_base_type::begin();
322 337
323 nested_type(a._s, argTypes...);338 nested_type(a._s, argTypes...);
324 339
325 a._s << Tfunction_base_type::end;340 a._s << Tfunction_base_type::end();
326 return a;341 return a;
327 }342 }
328 343
@@ -347,10 +362,10 @@ namespace disvm · 18 unmodified lines
347 };362 };
348 363
349 template<type_id_t T>364 template<type_id_t T>
350 const char Tfunction_base_type<T>::begin = '(';365 constexpr char Tfunction_base_type<T>::begin() { return '('; }
351 366
352 template<type_id_t T>367 template<type_id_t T>
353 const char Tfunction_base_type<T>::end = ')';368 constexpr char Tfunction_base_type<T>::end() { return ')'; }
354 369
355 using Tfunction = Tfunction_base_type<type_id_t::function>;370 using Tfunction = Tfunction_base_type<type_id_t::function>;
356 using Tfunction_varargs = Tfunction_base_type<type_id_t::function_varargs>;371 using Tfunction_varargs = Tfunction_base_type<type_id_t::function_varargs>;