LeviLamina
Loading...
Searching...
No Matches
ExpressionNode.h
1#pragma once
2
3#include "mc/_HeaderOutputPredefine.h"
4#include "mc/util/molang/IComplexExpression.h"
5#include "mc/util/molang/MolangParseConfig.h"
6
7// auto generated inclusion list
8#include "mc/molang/MolangVersion.h"
9#include "mc/platform/brstd/flat_set.h"
10#include "mc/util/MolangCompileResult.h"
11#include "mc/util/MolangQueryFunctionReturnType.h"
12#include "mc/util/molang/ExpressionOp.h"
13
14// auto generated forward declare list
15// clang-format off
16class Block;
17class BlockPos;
18class BlockSource;
19class Experiments;
20class HashedString;
22class RenderParams;
28struct MolangScriptArg;
29namespace Json { class Value; }
30namespace Molang::details { class IComplexExpression; }
31namespace Molang::details { class SourceTree; }
32namespace cereal { struct ReflectionCtx; }
33namespace mce { class Color; }
34// clang-format on
35
36class ExpressionNode {
37public:
38 // ExpressionNode inner types declare
39 // clang-format off
40 struct ResourceReference;
41 // clang-format on
42
43 // ExpressionNode inner types define
44 struct ResourceReference {
45 public:
46// member variables
47// NOLINTBEGIN
48#ifdef LL_PLAT_S
50#else // LL_PLAT_C
52#endif
55 // NOLINTEND
56
57 public:
58 // prevent constructor by default
59 ResourceReference& operator=(ResourceReference const&);
60 ResourceReference(ResourceReference const&);
61 ResourceReference();
62
63 public:
64 // member functions
65 // NOLINTBEGIN
66#ifdef LL_PLAT_C
67 MCNAPI explicit ResourceReference(::MolangDataDrivenGeometry const& geometry);
68
69 MCNAPI explicit ResourceReference(::MaterialVariants const& matVariants);
70
71 MCNAPI explicit ResourceReference(::MolangClientTextureSet const& textureSet);
72#endif
73 // NOLINTEND
74
75 public:
76 // constructor thunks
77 // NOLINTBEGIN
78#ifdef LL_PLAT_C
79 MCNAPI void* $ctor(::MolangDataDrivenGeometry const& geometry);
80
81 MCNAPI void* $ctor(::MaterialVariants const& matVariants);
82
83 MCNAPI void* $ctor(::MolangClientTextureSet const& textureSet);
84#endif
85 // NOLINTEND
86 };
87
88 using GetParticleTintFunc = ::std::function<::mce::Color(::Block const&, ::BlockSource&, ::BlockPos const&)>;
89
90 using IComplexExpression = ::Molang::details::IComplexExpression;
91
92 using MissingResourceSet =
94
95 using ResourceTable = ::std::unordered_map<::HashedString, ::ExpressionNode::ResourceReference>;
96
97public:
98 // member variables
99 // NOLINTBEGIN
100 ::ll::TypedStorage<8, 16, ::std::variant<::std::unique_ptr<::Molang::details::IComplexExpression>, float>> mImpl;
101 // NOLINTEND
102
103public:
104 ExpressionNode(
105 std::string const& expression,
106 ::MolangVersion molangVersion,
107 ::gsl::span<::HashedString const> querySetID
108 )
109 : ExpressionNode(expression, molangVersion) {
110 MolangParseConfig config;
111 config.mVersion = molangVersion;
112 config.mAllowedQuerySets = querySetID;
113 parse(expression, config);
114 }
115
116public:
117 // member functions
118 // NOLINTBEGIN
119 MCAPI ExpressionNode();
120
121#ifdef LL_PLAT_C
122 MCAPI explicit ExpressionNode(::MaterialVariants const& materialVariants);
123#endif
124
125 MCAPI ExpressionNode(::ExpressionNode const& rhs);
126
128
129 MCAPI explicit ExpressionNode(float value);
130
131 MCAPI ExpressionNode(::std::string_view expression, ::MolangParseConfig const& config);
132
133 MCAPI ExpressionNode(::std::string const& expression, ::MolangVersion molangVersion);
134
135#ifdef LL_PLAT_C
136 MCAPI ExpressionNode(char const* expression, ::MolangVersion molangVersion);
137#endif
138
139 MCAPI ExpressionNode(::Json::Value const& value, ::MolangParseConfig const& config);
140
141 MCAPI ExpressionNode(::MolangScriptArg const& value, ::ExpressionOp op);
142
143 MCAPI ::std::optional<::MolangScriptArg> _getValueIfConstant() const;
144
145 MCAPI void clear();
146
147 MCAPI ::MolangScriptArg const& evalGeneric(::RenderParams& renderParams) const;
148
149 MCAPI ::std::string getExpressionString() const;
150
151 MCAPI ::MolangVersion const getMolangVersion() const;
152
153 MCAPI ::ExpressionOp getOp() const;
154
155#ifdef LL_PLAT_C
156 MCAPI bool hasVariableAssignments() const;
157
158 MCAPI bool isConstantValue() const;
159#endif
160
161 MCAPI bool isInitialized() const;
162
163 MCAPI bool isValid() const;
164
165 MCAPI ::MolangCompileResult link();
166
167#ifdef LL_PLAT_C
168 MCAPI bool needsToCompile() const;
169
170 MCAPI ::ExpressionNode& operator=(::MaterialVariants const& materialVariants);
171#endif
172
173 MCAPI ::ExpressionNode& operator=(::ExpressionNode const& rhs);
174
175 MCAPI ::ExpressionNode& operator=(float value);
176
177 MCAPI bool parse(::std::string_view expression, ::MolangParseConfig const& config);
178
179 MCAPI bool parse(::std::string_view expression, ::MolangVersion version, ::gsl::span<::HashedString const> idSet);
180
181#ifdef LL_PLAT_C
182 MCAPI void
183 replaceArrayVariables(::std::unordered_map<::HashedString, ::ExpressionNode>& dataMap, bool compileProgram);
184
185 MCAPI ::brstd::flat_set<::HashedString, ::std::less<::HashedString>, ::std::vector<::HashedString>>
186 replaceResourceVariables(::std::unordered_map<::HashedString, ::ExpressionNode::ResourceReference>& resourceTable);
187
188 MCAPI void validateArrayVariables() const;
189#endif
190 // NOLINTEND
191
192public:
193 // static functions
194 // NOLINTBEGIN
195 MCAPI static bool _initializeMolangQueries(::ExpressionQueries&& queries);
196
197 MCAPI static void assertMolangInitialized();
198
199 MCAPI static void bindType(::cereal::ReflectionCtx& ctx);
200
201 MCAPI static ::Experiments& getExperiments();
202
203#ifdef LL_PLAT_S
204 MCAPI static ::std::unordered_multimap<::HashedString, ::MolangQueryFunction> const& getQueryFunctionAccessors();
205
206 MCAPI static ::std::unordered_map<::HashedString, ::std::unordered_set<::HashedString>> const& getQuerySets();
207#endif
208
209 MCAPI static void initializeMolang(::ExpressionQueries&& queries);
210
211 MCAPI static ::std::function<
212 ::MolangScriptArg const&(::RenderParams&, ::std::vector<::ExpressionNode> const&)> const*
213 queryFunctionAccessorFromString(
214 ::HashedString const& functionName,
215 ::MolangVersion molangVersion,
216 ::MolangQueryFunctionReturnType& functionReturnType,
217 bool missingIsOkay_returnNullIfSo
218 );
219
220 MCAPI static ::MolangQueryFunction& registerQueryFunction(
221 ::std::string_view queryFunctionName,
222 ::std::function<::MolangScriptArg const&(::RenderParams&, ::std::vector<::ExpressionNode> const&)> accessor,
223 ::std::string_view documentation,
224 ::MolangQueryFunctionReturnType returnType,
225 ::HashedString querySetIdentifier,
226 uint64 minArgumentCount,
227 uint64 maxArgumentCount,
228 ::std::initializer_list<int> const& experiments
229 );
230
231 MCAPI static void setExperiments(::Experiments const& experiments);
232
233#ifdef LL_PLAT_C
234 MCAPI static void
235 setParticleTintFunc(::std::function<::mce::Color(::Block const&, ::BlockSource&, ::BlockPos const&)> tintFunc);
236
237 MCAPI static ::std::string& toLowerInPlaceExceptStrings(::std::string& expression);
238#endif
239
240 MCAPI static void
241 unregisterQueryFunction(::std::string const& queryFunctionName, ::HashedString querySetIdentifier);
242 // NOLINTEND
243
244public:
245 // static variables
246 // NOLINTBEGIN
247 MCAPI static ::std::function<::MolangScriptArg const&(::RenderParams&, ::std::vector<::ExpressionNode> const&)>&
248 _defaultUnknownQueryFunction();
249
250 MCAPI static ::std::function<::mce::Color(::Block const&, ::BlockSource&, ::BlockPos const&)>&
251 mGetParticleTintFunc();
252
253 MCAPI static ::std::unordered_multimap<::HashedString, ::MolangQueryFunction>& mQueryFunctionAccessors();
254
255 MCAPI static ::std::unordered_map<::HashedString, ::std::unordered_set<::HashedString>>& mQuerySets();
256 // NOLINTEND
257
258public:
259 // constructor thunks
260 // NOLINTBEGIN
261 MCFOLD void* $ctor();
262
263#ifdef LL_PLAT_C
264 MCAPI void* $ctor(::MaterialVariants const& materialVariants);
265#endif
266
267 MCAPI void* $ctor(::ExpressionNode const& rhs);
268
269 MCAPI void* $ctor(::Molang::details::SourceTree root);
270
271 MCAPI void* $ctor(float value);
272
273 MCAPI void* $ctor(::std::string_view expression, ::MolangParseConfig const& config);
274
275 MCAPI void* $ctor(::std::string const& expression, ::MolangVersion molangVersion);
276
277#ifdef LL_PLAT_C
278 MCAPI void* $ctor(char const* expression, ::MolangVersion molangVersion);
279#endif
280
281 MCAPI void* $ctor(::Json::Value const& value, ::MolangParseConfig const& config);
282
283 MCAPI void* $ctor(::MolangScriptArg const& value, ::ExpressionOp op);
284 // NOLINTEND
285};
286
287// free functions
288// NOLINTBEGIN
289MCAPI bool operator!=(::ExpressionNode const& lhs, ::ExpressionNode const& rhs);
290
291MCAPI bool operator==(::ExpressionNode const& lhs, ::ExpressionNode const& rhs);
292// NOLINTEND
Definition BlockPos.h:21
Definition BlockSource.h:73
Definition Block.h:69
Definition Experiments.h:14
Definition ExpressionNode.h:36
Definition HashedString.h:5
Definition Value.h:16
Definition MaterialVariants.h:8
Definition IComplexExpression.h:21
Definition SourceTree.h:25
Definition RenderParams.h:30
Definition flat_set.h:10
Definition Color.h:13
Definition ExpressionNode.h:44
Definition ExpressionQueries.h:12
Definition MolangClientTextureSet.h:18
Definition MolangDataDrivenGeometry.h:13
Definition MolangParseConfig.h:14
Definition MolangQueryFunction.h:16
Definition MolangScriptArg.h:35
Definition ReflectionCtx.h:11
Definition ctx.h:5
Definition Alias.h:14