22 #ifndef MTROPOLIS_MINISCRIPT_H 23 #define MTROPOLIS_MINISCRIPT_H 25 #include "mtropolis/data.h" 26 #include "mtropolis/runtime.h" 30 class MiniscriptThread;
31 struct MiniscriptStackValue;
32 struct SIMiniscriptInstructionFactory;
34 bool miniscriptEvaluateTruth(
const DynamicValue &value);
40 virtual MiniscriptInstructionOutcome execute(
MiniscriptThread *thread)
const = 0;
47 virtual uint registerGlobalGUIDIndex(uint32 guid) = 0;
104 static SIMiniscriptInstructionFactory *resolveOpcode(uint16 opcode);
107 struct InstructionData {
113 SIMiniscriptInstructionFactory *instrFactory;
118 namespace MiniscriptInstructions {
121 virtual MiniscriptInstructionOutcome execute(
MiniscriptThread *thread)
const override;
126 MiniscriptInstructionOutcome execute(
MiniscriptThread *thread)
const override;
134 MiniscriptInstructionOutcome execute(
MiniscriptThread *thread)
const override;
142 MiniscriptInstructionOutcome execute(
MiniscriptThread *thread)
const override;
145 virtual MiniscriptInstructionOutcome arithExecute(
MiniscriptThread *thread,
double &result,
double left,
double right)
const = 0;
150 MiniscriptInstructionOutcome arithExecute(
MiniscriptThread *thread,
double &result,
double left,
double right)
const override;
155 MiniscriptInstructionOutcome arithExecute(
MiniscriptThread *thread,
double &result,
double left,
double right)
const override;
160 MiniscriptInstructionOutcome arithExecute(
MiniscriptThread *thread,
double &result,
double left,
double right)
const override;
165 MiniscriptInstructionOutcome arithExecute(
MiniscriptThread *thread,
double &result,
double left,
double right)
const override;
170 MiniscriptInstructionOutcome arithExecute(
MiniscriptThread *thread,
double &result,
double left,
double right)
const override;
175 MiniscriptInstructionOutcome arithExecute(
MiniscriptThread *thread,
double &result,
double left,
double right)
const override;
180 MiniscriptInstructionOutcome arithExecute(
MiniscriptThread *thread,
double &result,
double left,
double right)
const override;
185 MiniscriptInstructionOutcome execute(
MiniscriptThread *thread)
const override;
190 MiniscriptInstructionOutcome execute(
MiniscriptThread *thread)
const override;
195 MiniscriptInstructionOutcome execute(
MiniscriptThread *thread)
const override;
200 MiniscriptInstructionOutcome execute(
MiniscriptThread *thread)
const override;
205 virtual bool compareFloat(
double a,
double b)
const = 0;
208 MiniscriptInstructionOutcome execute(
MiniscriptThread *thread)
const override;
213 virtual bool resolve(
bool isEqual)
const = 0;
216 MiniscriptInstructionOutcome execute(
MiniscriptThread *thread)
const override;
221 bool resolve(
bool isEqual)
const override {
return isEqual; };
226 bool resolve(
bool isEqual)
const override {
return !isEqual; };
231 bool compareFloat(
double a,
double b)
const override {
return a <= b; }
236 bool compareFloat(
double a,
double b)
const override {
return a < b; }
241 bool compareFloat(
double a,
double b)
const override {
return a >= b; }
246 bool compareFloat(
double a,
double b)
const override {
return a > b; }
251 enum BuiltinFunctionID {
277 MiniscriptInstructionOutcome execute(
MiniscriptThread *thread)
const override;
286 BuiltinFunctionID _funcID;
291 MiniscriptInstructionOutcome execute(
MiniscriptThread *thread)
const override;
296 MiniscriptInstructionOutcome execute(
MiniscriptThread *thread)
const override;
301 MiniscriptInstructionOutcome execute(
MiniscriptThread *thread)
const override;
309 GetChild(uint32 attribute,
bool isLValue,
bool isIndexed);
312 MiniscriptInstructionOutcome execute(
MiniscriptThread *thread)
const override;
323 MiniscriptInstructionOutcome execute(
MiniscriptThread *thread)
const override;
328 MiniscriptInstructionOutcome execute(
MiniscriptThread *thread)
const override;
347 PushValue(DataType dataType,
const void *value,
bool isLValue);
351 MiniscriptInstructionOutcome execute(
MiniscriptThread *thread)
const override;
369 explicit PushGlobal(uint32 globalID,
bool isLValue);
371 MiniscriptInstructionOutcome execute(
MiniscriptThread *thread)
const override;
375 kGlobalRefElement = 1,
376 kGlobalRefModifier = 2,
377 kGlobalRefSource = 3,
378 kGlobalRefIncomingData = 4,
382 kGlobalRefSharedScene = 8,
383 kGlobalRefSection = 9,
384 kGlobalRefProject = 10,
385 kGlobalRefActiveScene = 11,
399 MiniscriptInstructionOutcome execute(
MiniscriptThread *thread)
const override;
406 Jump(uint32 instrOffset,
bool isConditional);
409 MiniscriptInstructionOutcome execute(
MiniscriptThread *thread)
const override;
434 void popValues(
size_t count);
435 size_t getStackSize()
const;
437 MiniscriptInstructionOutcome dereferenceRValue(
size_t offset);
439 void jumpOffset(
size_t offset);
441 bool evaluateTruthOfResult(
bool &isTrue);
445 void retryInstruction();
448 CORO_DEFINE_RETURN_TYPE(
void);
453 struct IncomingDataWriteInterface {
459 MiniscriptInstructionOutcome runNextInstruction();
474 size_t _currentInstruction;
478 MiniscriptInstructionOutcome miniscriptIgnoreFailure(MiniscriptInstructionOutcome outcome);
Definition: runtime.h:816
Definition: miniscript.h:81
Definition: miniscript.h:447
Definition: miniscript.h:60
Definition: miniscript.h:178
Definition: miniscript.h:198
Definition: miniscript.h:331
Definition: miniscript.h:219
Definition: miniscript.h:183
Definition: miniscript.h:342
Definition: miniscript.h:173
Definition: miniscript.h:158
Definition: miniscript.h:404
Definition: runtime.h:1594
Definition: runtime.h:488
Definition: miniscript.h:52
Definition: miniscript.h:229
Definition: miniscript.h:153
Definition: runtime.h:3035
Definition: miniscript.h:193
Definition: miniscript.h:421
Definition: runtime.h:544
Definition: miniscript.h:289
Definition: miniscript.h:163
Definition: miniscript.h:234
Definition: miniscript.h:119
Definition: runtime.h:369
Definition: runtime.h:1307
Definition: miniscript.h:367
Definition: runtime.h:2118
Definition: miniscript.h:148
Definition: miniscript.h:50
Definition: miniscript.h:168
Definition: miniscript.h:417
Definition: miniscript.h:84
Definition: miniscript.h:100
Definition: miniscript.h:304
Definition: miniscript.h:140
Definition: miniscript.h:203
Definition: miniscript.h:394
Definition: miniscript.h:321
Definition: miniscript.h:188
void NORETURN_PRE error(MSVC_PRINTF const char *s,...) GCC_PRINTF(1
Definition: miniscript.h:129
Definition: miniscript.h:244
Definition: miniscript.h:307
Definition: miniscript.h:326
Definition: miniscript.h:299
Definition: miniscript.h:36
Definition: miniscript.h:43
Definition: miniscript.h:294
Definition: miniscript.h:124
Definition: miniscript.h:211
Definition: miniscript.h:239
Definition: miniscript.h:224
Definition: miniscript.h:249