@@ -36,7 +36,7 @@ namespace wabt {
36
36
37
37
struct Module ;
38
38
39
- enum class VarType {
39
+ enum class VarType : uint16_t {
40
40
Index,
41
41
Name,
42
42
};
@@ -54,6 +54,7 @@ struct Var {
54
54
VarType type () const { return type_; }
55
55
bool is_index () const { return type_ == VarType::Index; }
56
56
bool is_name () const { return type_ == VarType::Name; }
57
+ bool has_opt_type () const { return opt_type_ < 0 ; }
57
58
58
59
Index index () const {
59
60
assert (is_index ());
@@ -63,17 +64,24 @@ struct Var {
63
64
assert (is_name ());
64
65
return name_;
65
66
}
67
+ Type::Enum opt_type () const {
68
+ assert (has_opt_type ());
69
+ return static_cast <Type::Enum>(opt_type_);
70
+ }
66
71
67
72
void set_index (Index);
68
73
void set_name (std::string&&);
69
74
void set_name (std::string_view);
75
+ void set_opt_type (Type::Enum);
70
76
71
77
Location loc;
72
78
73
79
private:
74
80
void Destroy ();
75
81
76
82
VarType type_;
83
+ // Can be set to Type::Enum types, 0 represent no optional type.
84
+ int16_t opt_type_;
77
85
union {
78
86
Index index_;
79
87
std::string name_;
@@ -734,9 +742,7 @@ class CallRefExpr : public ExprMixin<ExprType::CallRef> {
734
742
explicit CallRefExpr (const Location& loc = Location())
735
743
: ExprMixin<ExprType::CallRef>(loc) {}
736
744
737
- // This field is setup only during Validate phase,
738
- // so keep that in mind when you use it.
739
- Var function_type_index;
745
+ Var function_type;
740
746
};
741
747
742
748
template <ExprType TypeEnum>
0 commit comments