1
0
mirror of https://gitlab.com/OpenMW/openmw.git synced 2025-01-15 22:49:48 +00:00
OpenMW/components/interpreter/genericopcodes.hpp

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

83 lines
2.0 KiB
C++
Raw Normal View History

2010-06-28 19:49:48 +00:00
#ifndef INTERPRETER_GENERICOPCODES_H_INCLUDED
#define INTERPRETER_GENERICOPCODES_H_INCLUDED
#include "opcodes.hpp"
#include "runtime.hpp"
namespace Interpreter
{
class OpPushInt : public Opcode1
{
public:
void execute(Runtime& runtime, unsigned int arg0) override { runtime.push(static_cast<Type_Integer>(arg0)); }
2010-06-28 19:49:48 +00:00
};
2022-09-22 18:26:05 +00:00
2010-06-28 19:49:48 +00:00
class OpIntToFloat : public Opcode0
{
public:
void execute(Runtime& runtime) override
2010-06-28 19:49:48 +00:00
{
Type_Integer data = runtime[0].mInteger;
2010-06-28 19:49:48 +00:00
Type_Float floatValue = static_cast<Type_Float>(data);
runtime[0].mFloat = floatValue;
2010-06-28 19:49:48 +00:00
}
};
2022-09-22 18:26:05 +00:00
class OpFloatToInt : public Opcode0
{
public:
void execute(Runtime& runtime) override
{
Type_Float data = runtime[0].mFloat;
Type_Integer integerValue = static_cast<Type_Integer>(data);
runtime[0].mInteger = integerValue;
}
};
2022-09-22 18:26:05 +00:00
class OpNegateInt : public Opcode0
{
public:
void execute(Runtime& runtime) override
{
Type_Integer data = runtime[0].mInteger;
data = -data;
runtime[0].mInteger = data;
}
};
2022-09-22 18:26:05 +00:00
class OpNegateFloat : public Opcode0
{
public:
void execute(Runtime& runtime) override
{
Type_Float data = runtime[0].mFloat;
data = -data;
runtime[0].mFloat = data;
}
2010-06-29 14:11:19 +00:00
};
2022-09-22 18:26:05 +00:00
2010-06-29 14:11:19 +00:00
class OpIntToFloat1 : public Opcode0
{
public:
void execute(Runtime& runtime) override
2010-06-29 14:11:19 +00:00
{
Type_Integer data = runtime[1].mInteger;
2010-06-29 14:11:19 +00:00
Type_Float floatValue = static_cast<Type_Float>(data);
runtime[1].mFloat = floatValue;
2010-06-29 14:11:19 +00:00
}
};
2022-09-22 18:26:05 +00:00
2010-06-29 14:11:19 +00:00
class OpFloatToInt1 : public Opcode0
{
public:
void execute(Runtime& runtime) override
2010-06-29 14:11:19 +00:00
{
Type_Float data = runtime[1].mFloat;
2010-06-29 14:11:19 +00:00
Type_Integer integerValue = static_cast<Type_Integer>(data);
runtime[1].mInteger = integerValue;
2010-06-29 14:11:19 +00:00
}
};
2010-06-28 19:49:48 +00:00
}
#endif