Skip to content
LeviMC
English
AutoLightDark
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;
27struct MolangScriptArg;
28namespace Json { class Value; }
29namespace Molang::details { class IComplexExpression; }
30namespace Molang::details { class SourceTree; }
31namespace cereal { struct ReflectionCtx; }
32namespace mce { class Color; }
33// clang-format on
34
35class ExpressionNode {
36public:
37 // ExpressionNode inner types declare
38 // clang-format off
39 struct ResourceReference;
40 // clang-format on
41
42 // ExpressionNode inner types define
43 struct ResourceReference {
44 public:
45// member variables
46// NOLINTBEGIN
47#ifdef LL_PLAT_S
49#else // LL_PLAT_C
51#endif
54 // NOLINTEND
55
56 public:
57 // prevent constructor by default
58 ResourceReference& operator=(ResourceReference const&);
59 ResourceReference(ResourceReference const&);
60 ResourceReference();
61
62 public:
63 // member functions
64 // NOLINTBEGIN
65#ifdef LL_PLAT_C
66 MCNAPI explicit ResourceReference(::MolangDataDrivenGeometry const& geometry);
67#endif
68 // NOLINTEND
69
70 public:
71 // constructor thunks
72 // NOLINTBEGIN
73#ifdef LL_PLAT_C
74 MCNAPI void* $ctor(::MolangDataDrivenGeometry const& geometry);
75#endif
76 // NOLINTEND
77 };
78
79 using GetParticleTintFunc = ::std::function<::mce::Color(::Block const&, ::BlockSource&, ::BlockPos const&)>;
80
81 using IComplexExpression = ::Molang::details::IComplexExpression;
82
83 using MissingResourceSet =
85
86 using ResourceTable = ::std::unordered_map<::HashedString, ::ExpressionNode::ResourceReference>;
87
88public:
89 // member variables
90 // NOLINTBEGIN
91 ::ll::TypedStorage<8, 16, ::std::variant<::std::unique_ptr<::Molang::details::IComplexExpression>, float>> mImpl;
92 // NOLINTEND
93
94public:
95 ExpressionNode(
96 std::string const& expression,
97 ::MolangVersion molangVersion,
98 ::gsl::span<::HashedString const> querySetID
99 )
100 : ExpressionNode(expression, molangVersion) {
101 MolangParseConfig config;
102 config.mVersion = molangVersion;
103 config.mAllowedQuerySets = querySetID;
104 parse(expression, config);
105 }
106
107 LLAPI MolangScriptArg const& evalGeneric(RenderParams& renderParams) const;
108
109 LLAPI static std::function<::MolangScriptArg const&(RenderParams&, std::vector<::ExpressionNode> const&)> const*
110 queryFunctionAccessorFromString(
111 ::HashedString const& functionName,
112 ::MolangVersion molangVersion,
113 ::MolangQueryFunctionReturnType& functionReturnType,
114 bool missingIsOkay_returnNullIfSo
115 );
116
117public:
118 // prevent constructor by default
121
122public:
123 // member functions
124 // NOLINTBEGIN
125#ifdef LL_PLAT_C
126 MCNAPI explicit ExpressionNode(::MaterialVariants const& materialVariants);
127#endif
128
130
131 MCAPI ExpressionNode(::std::string const& expression, ::MolangVersion molangVersion);
132
133#ifdef LL_PLAT_C
134 MCNAPI ExpressionNode(char const* expression, ::MolangVersion molangVersion);
135#endif
136
137 MCNAPI ExpressionNode(::Json::Value const& value, ::MolangParseConfig const& config);
138
139 MCNAPI ExpressionNode(::MolangScriptArg const& value, ::ExpressionOp op);
140
141 MCNAPI ::std::optional<::MolangScriptArg> _getValueIfConstant() const;
142
143 MCAPI ::std::string getExpressionString() const;
144
145 MCNAPI ::MolangCompileResult link();
146
147#ifdef LL_PLAT_C
148 MCNAPI ::ExpressionNode& operator=(::MaterialVariants const& materialVariants);
149#endif
150
151 MCNAPI ::ExpressionNode& operator=(::ExpressionNode const& rhs);
152
153#ifdef LL_PLAT_C
154 MCNAPI ::ExpressionNode& operator=(float value);
155#endif
156
157 MCAPI bool parse(::std::string_view expression, ::MolangParseConfig const& config);
158
159#ifdef LL_PLAT_C
160 MCNAPI bool parse(::std::string_view expression, ::MolangVersion version, ::gsl::span<::HashedString const> idSet);
161
162 MCNAPI void
163 replaceArrayVariables(::std::unordered_map<::HashedString, ::ExpressionNode>& dataMap, bool compileProgram);
164#endif
165 // NOLINTEND
166
167public:
168 // static functions
169 // NOLINTBEGIN
170 MCNAPI static bool _initializeMolangQueries(::ExpressionQueries&& queries);
171
173
174 MCAPI static ::MolangQueryFunction& registerQueryFunction(
175 ::std::string_view queryFunctionName,
176 ::std::function<::MolangScriptArg const&(::RenderParams&, ::std::vector<::ExpressionNode> const&)> accessor,
177 ::std::string_view documentation,
178 ::MolangQueryFunctionReturnType returnType,
179 ::HashedString querySetIdentifier,
180 uint64 minArgumentCount,
181 uint64 maxArgumentCount,
182 ::std::initializer_list<int> const& experiments
183 );
184
185 MCNAPI static void setExperiments(::Experiments const& experiments);
186
187 MCAPI static void
188 unregisterQueryFunction(::std::string const& queryFunctionName, ::HashedString querySetIdentifier);
189 // NOLINTEND
190
191public:
192 // static variables
193 // NOLINTBEGIN
194 MCAPI static ::std::function<::MolangScriptArg const&(::RenderParams&, ::std::vector<::ExpressionNode> const&)>&
195 _defaultUnknownQueryFunction();
196
197 MCNAPI static ::std::function<::mce::Color(::Block const&, ::BlockSource&, ::BlockPos const&)>&
199
200 MCAPI static ::std::unordered_multimap<::HashedString, ::MolangQueryFunction>& mQueryFunctionAccessors();
201
202 MCNAPI static ::std::unordered_map<::HashedString, ::std::unordered_set<::HashedString>>& mQuerySets();
203 // NOLINTEND
204
205public:
206 // constructor thunks
207 // NOLINTBEGIN
208#ifdef LL_PLAT_C
209 MCNAPI void* $ctor(::MaterialVariants const& materialVariants);
210#endif
211
213
214 MCAPI void* $ctor(::std::string const& expression, ::MolangVersion molangVersion);
215
216#ifdef LL_PLAT_C
217 MCNAPI void* $ctor(char const* expression, ::MolangVersion molangVersion);
218#endif
219
220 MCNAPI void* $ctor(::Json::Value const& value, ::MolangParseConfig const& config);
221
222 MCNAPI void* $ctor(::MolangScriptArg const& value, ::ExpressionOp op);
223 // NOLINTEND
224};
225
226// free functions
227// NOLINTBEGIN
228MCNAPI bool operator==(::ExpressionNode const& lhs, ::ExpressionNode const& rhs);
229// NOLINTEND
Definition BlockPos.h:14
Definition BlockSource.h:72
Definition Block.h:42
Definition Experiments.h:14
Definition ExpressionNode.h:35
static MCAPI void bindType(::cereal::ReflectionCtx &ctx)
MCAPI ExpressionNode(::Molang::details::SourceTree root)
MCAPI void * $ctor(::MolangScriptArg const &value, ::ExpressionOp op)
MCAPI ExpressionNode(::MolangScriptArg const &value, ::ExpressionOp op)
MCAPI::ExpressionNode & operator=(::ExpressionNode const &rhs)
static MCAPI ::std::unordered_map<::HashedString, ::std::unordered_set<::HashedString > > & mQuerySets()
MCAPI void * $ctor(::Molang::details::SourceTree root)
MCAPI ExpressionNode(::Json::Value const &value, ::MolangParseConfig const &config)
static MCAPI void setExperiments(::Experiments const &experiments)
MCAPI::MolangCompileResult link()
static MCAPI bool _initializeMolangQueries(::ExpressionQueries &&queries)
MCAPI void * $ctor(::Json::Value const &value, ::MolangParseConfig const &config)
static MCAPI ::std::function<::mce::Color(::Block const &, ::BlockSource &, ::BlockPos const &)> & mGetParticleTintFunc()
MCAPI ::std::optional<::MolangScriptArg > _getValueIfConstant() const
Definition HashedString.h:5
Definition Value.h:16
Definition MaterialVariants.h:8
Definition IComplexExpression.h:21
Definition SourceTree.h:14
Definition RenderParams.h:29
Definition flat_set.h:10
Definition Color.h:13
Definition ExpressionNode.h:43
Definition ExpressionQueries.h:12
Definition MolangDataDrivenGeometry.h:13
Definition MolangParseConfig.h:14
Definition MolangQueryFunction.h:16
Definition MolangScriptArg.h:28
Definition ReflectionCtx.h:11
Definition ctx.h:5
Definition Alias.h:14