1 #ifndef INTERPRETER_MATHOPCODES_H_INCLUDED
2 #define INTERPRETER_MATHOPCODES_H_INCLUDED
19 T result = getData<T> (runtime[1]) + getData<T> (runtime[0]);
23 getData<T> (runtime[0]) = result;
34 T result = getData<T> (runtime[1]) - getData<T> (runtime[0]);
38 getData<T> (runtime[0]) = result;
49 T result = getData<T> (runtime[1]) * getData<T> (runtime[0]);
53 getData<T> (runtime[0]) = result;
64 T left = getData<T> (runtime[0]);
67 throw std::runtime_error (
"division by zero");
69 T result = getData<T> (runtime[1]) / left;
73 getData<T> (runtime[0]) = result;
86 throw std::runtime_error (
87 "square root of negative number (we aren't that imaginary)");
89 value = std::sqrt (value);
91 runtime[0].mFloat = value;
95 template<
typename T,
typename C>
102 int result = C() (getData<T> (runtime[1]), getData<T> (runtime[0]));
106 runtime[0].mInteger = result;
void pop()
pop stack
Definition: runtime.cpp:94
Runtime data and engine interface.
Definition: runtime.hpp:15
Definition: mathopcodes.hpp:13
opcode for 0 arguments
Definition: opcodes.hpp:9
virtual void execute(Runtime &runtime)
Definition: mathopcodes.hpp:62
Definition: mathopcodes.hpp:43
Definition: mathopcodes.hpp:77
virtual void execute(Runtime &runtime)
Definition: mathopcodes.hpp:32
virtual void execute(Runtime &runtime)
Definition: mathopcodes.hpp:100
virtual void execute(Runtime &runtime)
Definition: mathopcodes.hpp:17
virtual void execute(Runtime &runtime)
Definition: mathopcodes.hpp:81
virtual void execute(Runtime &runtime)
Definition: mathopcodes.hpp:47
float Type_Float
Definition: types.hpp:16
Definition: mathopcodes.hpp:28
Definition: mathopcodes.hpp:58
Definition: mathopcodes.hpp:96