LeviLamina
Loading...
Searching...
No Matches
ExpressionNode.h
1#pragma once
2
3#include "mc/_HeaderOutputPredefine.h"
4
5// auto generated inclusion list
6#include "mc/molang/MolangVersion.h"
7#include "mc/util/ExpressionOp.h"
8#include "mc/util/MolangCompileResult.h"
9#include "mc/util/MolangQueryFunctionReturnType.h"
10#include "mc/util/MolangVariableIndex.h"
11
12// auto generated forward declare list
13// clang-format off
14class Block;
15class BlockPos;
16class BlockSource;
18class HashedString;
21class RenderParams;
23struct MolangEvalParams;
26struct MolangScriptArg;
27namespace Json { class Value; }
28namespace mce { class Color; }
29// clang-format on
30
32public:
33 // ExpressionNode inner types define
34 using QueryLookupFunc = ::std::function<
35 ::std::function<::MolangScriptArg const&(::RenderParams&, ::std::vector<::ExpressionNode> const&)> const*(
36 ::std::string const&,
37 ::MolangQueryFunctionReturnType&,
38 bool
39 )>;
40
41 using GetParticleTintFunc = ::std::function<::mce::Color(::Block const&, ::BlockSource&, ::BlockPos const&)>;
42
43public:
44 // member variables
45 // NOLINTBEGIN
46 ::ll::TypedStorage<2, 2, ::ExpressionOp> mOp;
47 ::ll::TypedStorage<2, 2, ::MolangVersion> mMolangVersion;
48 ::ll::TypedStorage<4, 4, float> mMul;
49 ::ll::TypedStorage<4, 4, float> mAdd;
50 ::ll::TypedStorage<1, 1, bool> mStoreStackState;
51 ::ll::TypedStorage<1, 1, bool> mNeedsToCompile;
52 ::ll::TypedStorage<1, 1, ::std::atomic<bool>> mIsBeingCompiled;
53 ::ll::TypedStorage<8, 88, ::MolangScriptArg> mValue;
54 ::ll::TypedStorage<8, 24, ::std::vector<::ExpressionNode>> mChildren;
55 ::ll::TypedStorage<8, 24, ::std::vector<::std::unique_ptr<::IMolangInstruction>>> mInstructions;
56 ::ll::TypedStorage<8, 32, ::std::string> _mExpressionString;
57 ::ll::TypedStorage<8, 32, ::std::string> _mContentScopeString;
58 // NOLINTEND
59
60public:
62 std::string const& value,
63 ::MolangVersion molangVersion,
64 ::gsl::span<::HashedString const> querySetID
65 )
66 : ExpressionNode() {
67 parse(value, molangVersion, querySetID);
68 }
69
70public:
71 // member functions
72 // NOLINTBEGIN
73 MCAPI ExpressionNode();
74
76
77 MCAPI ExpressionNode(::ExpressionNode const& rhs);
78
79 MCAPI ExpressionNode(::MolangScriptArg& value, ::ExpressionOp op);
80
81 MCAPI ExpressionNode(
82 ::Json::Value const& value,
83 ::MolangVersion molangVersion,
84 ::gsl::span<::HashedString const> querySetID
85 );
86
87 MCAPI bool _buildTree(::ExpressionOpBitField const& usedTokenFlags, ::MolangVersion molangVersion);
88
89 MCFOLD bool _checkAllOperationsAreValid() const;
90
91 MCAPI bool _hasDisallowedQueryPtrs(
92 ::std::vector<::std::function<
93 ::MolangScriptArg const&(::RenderParams&, ::std::vector<::ExpressionNode> const&)> const*> const&
94 allowedQueryPtrs
95 ) const;
96
97 MCAPI bool _optimize(::MolangVersion version, ::RenderParams& outRenderParams, int recursionDepth);
98
99 MCAPI bool _processBinaryExpressions(::std::function<bool(::ExpressionOp)> predicate);
100
101 MCAPI bool _processTernaryAndConditionalExpressions();
102
103 MCAPI bool _readNextToken(
104 char const*& expression,
105 ::gsl::span<::HashedString const> const& idSet,
106 ::MolangVersion molangVersion
107 );
108
109 MCAPI void _setExpressionStringWithoutRelink(::std::string const& expressionString);
110
111 MCAPI bool _tokenize(
112 char const* expression,
113 ::ExpressionOpBitField& usedTokenFlags,
114 ::gsl::span<::HashedString const> const& idSet,
115 ::MolangVersion molangVersion
116 );
117
118 MCAPI bool _validate(::MolangVersion version, bool inLoop, int inAssignmentLHSDepth) const;
119
120 MCAPI bool _validateChildrenAreNumerical(::MolangVersion version) const;
121
122 MCAPI void clear();
123
124 MCAPI float evalAsFloat(::RenderParams& renderParams) const;
125
126 MCAPI ::MolangScriptArg const& evalGeneric(::RenderParams& renderParams) const;
127
128 MCAPI bool findClosingOp(uint64& i, ::ExpressionOp endOp) const;
129
130 MCAPI ::std::string const getExpressionString() const;
131
132 MCAPI ::std::string const& getExpressionString();
133
134 MCAPI uint64 getTreeHash(bool sideEffectsReturnZero) const;
135
136 MCAPI bool getTreeString(::std::string& dest, bool sideEffectsReturnZero) const;
137
138 MCAPI bool hasDisallowedQueries(::std::vector<::std::string> const& allowedQueries) const;
139
140 MCAPI bool hasMadd() const;
141
142 MCAPI bool hasSideEffects(bool countRandomAsSideEffect) const;
143
144 MCFOLD bool isValid() const;
145
146 MCAPI ::MolangCompileResult link() const;
147
148 MCAPI ::MolangCompileResult link(::MolangVersion molangVersion) const;
149
150 MCAPI void moveConstantChildToValueIfFloatOrHashType(int firstConstChildIndex);
151
152 MCAPI ::ExpressionNode& operator=(::ExpressionNode&& rhs);
153
154 MCAPI ::ExpressionNode& operator=(::ExpressionNode const& rhs);
155
156 MCAPI ::ExpressionNode& operator=(float value);
157
158 MCAPI bool operator==(::ExpressionNode const& rhs) const;
159
160 MCAPI bool optimizeFunctionCallParams();
161
162 MCAPI bool
163 parse(::std::string const& inputExpression, ::MolangVersion molangVersion, ::gsl::span<::HashedString const> idSet);
164
165 MCAPI bool processArrays();
166
167 MCAPI bool processBinaryExpression(::ExpressionOp op);
168
169 MCAPI bool processMathFuncs();
170
171 MCAPI bool processMemberAccessors();
172
173 MCAPI bool processNegativesAndLogicalNots();
174
175 MCAPI bool processQueriesAndFunctions();
176
177 MCAPI bool processSections();
178
179 MCAPI bool processSemicolons();
180
181 MCAPI bool processUnaryExpression(::ExpressionOp op);
182
183 MCAPI ~ExpressionNode();
184 // NOLINTEND
185
186public:
187 // static functions
188 // NOLINTBEGIN
189 MCAPI static ::MolangCompileResult
190 _buildProgram(::MolangProgramBuildState& buildState, ::ExpressionNode const* node, ::MolangVersion molangVersion);
191
192 MCAPI static ::MolangScriptArg* _getOrCreateReferencedMemberVariableScriptArg(
193 ::MolangEvalParams& state,
194 ::ExpressionNode const& memberAccessorNode
195 );
196
197 MCAPI static bool _getQueryFunctionAccessor(
199 ::std::string const& functionName,
200 ::MolangVersion molangVersion,
201 ::MolangQueryFunctionReturnType functionReturnType,
202 ::HashedString const& querySetId
203 );
204
205 MCAPI static ::MolangScriptArg const*
206 _getScriptArgFromMemberAccessedVariable(::MolangEvalParams& state, ::ExpressionNode const& memberAccessorNode);
207
208 MCAPI static bool _initializeMolangQueries();
209
210 MCAPI static void _writeScriptArgToMemberAccessedVariable(
211 ::MolangEvalParams& state,
212 ::ExpressionNode const& memberAccessorNode,
213 ::MolangScriptArg const& value
214 );
215
216 MCAPI static void _writeScriptArgToMolangVariable(
217 ::MolangVariableMap& destMap,
218 ::MolangVariableIndex variableIndex,
219 ::MolangScriptArg const& value
220 );
221
222 MCAPI static void buildExpressionOpTable();
223
224 MCAPI static float fast_atof_positiveOnly(char const*& ptr);
225
226 MCAPI static char const* getOpFriendlyName(::ExpressionOp op);
227
228 MCAPI static ::std::function<
229 ::MolangScriptArg const&(::RenderParams&, ::std::vector<::ExpressionNode> const&)> const*
230 queryFunctionAccessorFromString(
231 ::std::string const& functionName,
232 ::MolangVersion molangVersion,
233 ::MolangQueryFunctionReturnType& functionReturnType,
234 bool missingIsOkay_returnNullIfSo
235 );
236
237 MCAPI static ::MolangQueryFunction& registerQueryFunction(
238 ::std::string const& queryFunctionName,
239 ::std::function<::MolangScriptArg const&(::RenderParams&, ::std::vector<::ExpressionNode> const&)> accessor,
240 ::std::string const& documentation,
241 ::MolangQueryFunctionReturnType returnType,
242 ::HashedString querySetIdentifier,
243 uint64 minArgumentCount,
244 uint64 maxArgumentCount,
245 ::std::initializer_list<int> const& experiments
246 );
247
248 MCAPI static void
249 unregisterQueryFunction(::std::string const& queryFunctionName, ::HashedString querySetIdentifier);
250 // NOLINTEND
251
252public:
253 // static variables
254 // NOLINTBEGIN
255 MCAPI static ::std::function<::MolangScriptArg const&(::RenderParams&, ::std::vector<::ExpressionNode> const&)>&
256 _defaultUnknownQueryFunction();
257
258 MCAPI static ::std::vector<::std::pair<::std::string, ::ExpressionOp>>& mAliasOpTokens();
259
260 MCAPI static ::ExperimentStorage& mExperiments();
261
262 MCAPI static ::std::vector<::std::string>& mExpressionOpTokens();
263
264 MCAPI static ::std::function<::mce::Color(::Block const&, ::BlockSource&, ::BlockPos const&)>&
265 mGetParticleTintFunc();
266
267 MCAPI static bool& mMolangInitialized();
268
269 MCAPI static ::std::unordered_multimap<::HashedString, ::MolangQueryFunction>& mQueryFunctionAccessors();
270
271 MCAPI static ::std::unordered_map<::HashedString, ::std::unordered_set<::HashedString>>& mQuerySets();
272 // NOLINTEND
273
274public:
275 // constructor thunks
276 // NOLINTBEGIN
277 MCAPI void* $ctor();
278
279 MCAPI void* $ctor(::ExpressionNode&& rhs);
280
281 MCAPI void* $ctor(::ExpressionNode const& rhs);
282
283 MCAPI void* $ctor(::MolangScriptArg& value, ::ExpressionOp op);
284
285 MCAPI void*
286 $ctor(::Json::Value const& value, ::MolangVersion molangVersion, ::gsl::span<::HashedString const> querySetID);
287 // NOLINTEND
288
289public:
290 // destructor thunk
291 // NOLINTBEGIN
292 MCAPI void $dtor();
293 // NOLINTEND
294};
Definition BlockPos.h:18
Definition BlockSource.h:67
Definition Block.h:36
Definition ExperimentStorage.h:5
Definition ExpressionNode.h:31
Definition HashedString.h:5
Definition IMolangInstruction.h:10
Definition Value.h:16
Definition MolangVariableMap.h:15
Definition RenderParams.h:30
Definition Color.h:13
Definition ExpressionOpBitField.h:8
Definition MolangEvalParams.h:17
Definition MolangProgramBuildState.h:5
Definition MolangQueryFunction.h:22
Definition MolangScriptArg.h:47