MCPcopy Create free account
hub / github.com/WasmEdge/WasmEdge / Limit

Class Limit

include/ast/type.h:30–97  ·  view source on GitHub ↗

AST Limit node.

Source from the content-addressed store, hash-verified

28
29/// AST Limit node.
30class Limit {
31public:
32 /// Limit type enumeration class.
33 enum class LimitType : uint8_t {
34 HasMin = 0x00,
35 HasMinMax = 0x01,
36 SharedNoMax = 0x02, // from threads proposal, invalid
37 Shared = 0x03, // from threads proposal
38 I64HasMin = 0x04,
39 I64HasMinMax = 0x05,
40 I64SharedNoMax = 0x06, // from threads proposal, invalid
41 I64Shared = 0x07, // from threads proposal
42 };
43
44 /// Constructors.
45 Limit() noexcept : Type(LimitType::HasMin), Min(0U), Max(0U) {}
46 Limit(uint64_t MinVal, bool Is64 = false) noexcept
47 : Min(MinVal), Max(MinVal) {
48 if (Is64) {
49 Type = LimitType::I64HasMin;
50 } else {
51 Type = LimitType::HasMin;
52 }
53 }
54 Limit(uint64_t MinVal, uint64_t MaxVal, bool Is64 = false,
55 bool Shared = false) noexcept
56 : Min(MinVal), Max(MaxVal) {
57 if (Shared) {
58 if (Is64) {
59 Type = LimitType::I64Shared;
60 } else {
61 Type = LimitType::Shared;
62 }
63 } else {
64 if (Is64) {
65 Type = LimitType::I64HasMinMax;
66 } else {
67 Type = LimitType::HasMinMax;
68 }
69 }
70 }
71
72 /// Getter and setter for limit mode.
73 bool hasMax() const noexcept { return static_cast<uint8_t>(Type) & 0x01U; }
74 bool isShared() const noexcept { return static_cast<uint8_t>(Type) & 0x02U; }
75 bool is32() const noexcept { return static_cast<uint8_t>(Type) < 0x04U; }
76 bool is64() const noexcept { return !is32(); }
77 AddressType getAddrType() const noexcept {
78 return is32() ? AddressType::I32 : AddressType::I64;
79 }
80 void setType(LimitType TargetType) noexcept { Type = TargetType; }
81
82 /// Getter and setter for min value.
83 uint64_t getMin() const noexcept { return Min; }
84 void setMin(uint64_t Val) noexcept { Min = Val; }
85
86 /// Getter and setter for max value.
87 uint64_t getMax() const noexcept { return Max; }

Callers 1

SpecTestModuleMethod · 0.85

Calls

no outgoing calls

Tested by 1

SpecTestModuleMethod · 0.68