Blender V5.3
symbol_variable.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 "constexpr.hh"
12#include "resource.hh"
13#include "source_location.hh"
14
15#include <cstdint>
16
17namespace bsl {
18
19struct SymbolScope;
20struct SymbolClass;
21struct SymbolTable;
22
26struct Symbol {
27 /* Mangled identifier (eg. for 'i' in 'struct A { static int i; }' it would be 'A_i'). */
28 string identifier;
29 /* Unresolved identifier */
30 string original;
32 SymbolScope *parent = nullptr;
33};
34
36
37std::string constexpr_to_string(const ConstexprValue &v);
38
43 SymbolClass *type = nullptr;
44
45 /* Valid if the variable is a local reference.
46 * The variable will be substituted to this statement. */
48 /* Valid if the variable has runtime array capacity. */
50 /* Condition set when declaring a resource using the condition attribute. */
52
53 /* Value if constexpr. */
55
57
58 int8_t array_dimensions = 0;
59 /* Number of array elements in the declaration.
60 * 0 if not array.
61 * -1 if not known at compile time. */
63 /* In bytes. From scope start, taking alignment into account. */
64 int offset = 0;
65 /* In bits. From start and length in a bitfield. 0 otherwise. */
66 int bit_offset = 0;
67 int bit_length = 0;
68
69 bool is_bitfield = false;
70 bool is_static = false;
71 bool is_error = false;
72 bool is_constexpr = false;
73 bool is_macro = false;
74 bool is_const = false;
76
79 ast::Declarator decl,
80 const SymbolTable &table);
81
83 : Symbol(string(decl.identifier().str()),
84 string(decl.identifier().str()),
85 decl.front(),
86 parent),
87 type(type),
88 is_static(true)
89 {
90 }
91
93 : Symbol(str, str, id, parent), type(type)
94 {
95 }
96
97 void set_offset(bool is_union, int &offset);
98
99 /* Can be null if in global space. */
101
102 string value_str() const;
103};
104
105} // namespace bsl
#define str(s)
Definition codegen.cc:18
ConstexprValue ConstexprError
std::string constexpr_to_string(const ConstexprValue &v)
ResourceType
Definition resource.hh:20
Represents a specific position within a source file or included sub-file.
string value_str() const
void set_offset(bool is_union, int &offset)
SymbolVariable(SymbolScope *parent, SymbolClass *type, Token id, const string &str)
SymbolClass * parent_class()
SymbolVariable(SymbolScope *parent, SymbolClass *type, ast::EnumValue decl)
SymbolVariable(SymbolScope *parent, SymbolClass *type, ast::Declarator decl, const SymbolTable &table)
SymbolScope * parent
SourceLocation loc