Blender V5.3
symbol_class.hh
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2026 Blender Authors
2 *
3 * SPDX-License-Identifier: GPL-2.0-or-later */
4
8
9#pragma once
10
11#include "resource.hh"
12#include "symbol_scope.hh"
13#include "symbol_template.hh"
14
15namespace bsl {
16
17namespace builtin {
18
19enum ClassFlag : uint16_t {
20 /* Bitfield Masks & Flags (16-bit layout) */
23 /* clang-format off */
24 LEN_MASK = 0b0000'0000'0000'0111, /* Bits 0..2: Component length (1..4). */
25 RANK_MASK = 0b0000'0000'0111'1000, /* Bits 3..6: Type promotion rank. */
26 FLAG_NUMERIC = 0b0000'0000'1000'0000, /* Bit 7: Numeric flag. */
27 FLAG_INTEGER = 0b0000'0001'0000'0000, /* Bit 8: Integer flag. */
28 MATRIX_MASK = 0b0000'1110'0000'0000, /* Bit 9..11: Matrix column length (2..4). */
29 FLAG_SIGN = 0b0001'0000'0000'0000, /* Bit 12: Signedness bit. */
30 /* clang-format on */
31
33
34 /* Base Type Encodings */
45};
46
47enum ClassId : uint16_t {
48
49 /* Concrete Type Identifiers */
54
59
64
69
74
79
84
89
94
104
106};
107
111
112} // namespace builtin
113
119
121
123
124 int size = -1; /* -1 is for not computed yet. */
125 int align = -1; /* -1 is for not computed yet. */
126
128
129 /* For builtin types, number of components. */
130 int8_t comp_len = 0;
131
132 bool is_anonymous = false;
133 bool is_union = false;
134 bool is_enum = false;
137 bool is_error = false;
138 /* e.g. image2D, sampler2d, string_t ... */
139 bool is_opaque = false;
140
141 SymbolClass(SymbolScope *parent, ast::ClassDecl decl, const string &suffix = "");
142
144 Token tok,
145 const string &builtin_id,
146 int size_in_bytes = 1,
147 int align_in_bytes = 1,
149 : SymbolScope(parent, tok, builtin_id, CLASS),
150 size(size_in_bytes),
151 align(align_in_bytes),
153 {
154 }
155
156 void ensure_size_and_align(NodeErrorHandler *err_handler = nullptr, bool check_st430 = false);
157
158 bool is_srt() const
159 {
161 }
162
163 bool is_builtin() const
164 {
166 }
167
168 /* Structure to hold the flattened member data */
174
176
177 private:
178 static optional<TokenException> get_flat_members_recursive(const SymbolClass *cls,
179 const string &current_path,
180 int current_offset,
181 vector<MemberNode> &out_buffer);
182};
183
184} // namespace bsl
ClassId binary_operator_return_type(SymbolClass *lhs, TokenType op, SymbolClass *rhs)
Definition operator.cc:102
ClassId unary_suffix_operator_return_type(SymbolClass *lhs, TokenType op)
Definition operator.cc:219
ClassId unary_prefix_operator_return_type(TokenType op, SymbolClass *rhs)
Definition operator.cc:193
Definition codegen.cc:18
SymbolTemplate< SymbolClass > SymbolClassTemplate
ResourceTableType
Definition resource.hh:131
TokenType
Definition types.hh:41
SymbolFunction * operator_subscript
SymbolClassTemplate * template_data
ResourceTableType srt_type
SymbolClass(SymbolScope *parent, Token tok, const string &builtin_id, int size_in_bytes=1, int align_in_bytes=1, builtin::ClassId builtin_class=builtin::ClassId::Invalid)
builtin::ClassId builtin_class
bool is_builtin() const
bool is_srt() const
SymbolClass(SymbolScope *parent, ast::ClassDecl decl, const string &suffix="")
void ensure_size_and_align(NodeErrorHandler *err_handler=nullptr, bool check_st430=false)
Result< vector< MemberNode >, TokenException > get_all_members_flat() const
SymbolScope(ast::LocalScope decl)
SymbolScope * parent