|
|
|
@ -9,251 +9,215 @@
|
|
|
|
|
#include "literals.hpp"
|
|
|
|
|
|
|
|
|
|
namespace
|
|
|
|
|
{
|
|
|
|
|
Interpreter::Type_Code segment0 (unsigned int c, unsigned int arg0)
|
|
|
|
|
{
|
|
|
|
|
assert (c<64);
|
|
|
|
|
return (c<<24) | (arg0 & 0xffffff);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Interpreter::Type_Code segment1 (unsigned int c, unsigned int arg0, unsigned int arg1)
|
|
|
|
|
{
|
|
|
|
|
assert (c<64);
|
|
|
|
|
return 0x40000000 | (c<<24) | ((arg0 & 0xfff)<<12) | (arg1 & 0xfff);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Interpreter::Type_Code segment2 (unsigned int c, unsigned int arg0)
|
|
|
|
|
{
|
|
|
|
|
assert (c<1024);
|
|
|
|
|
return 0x80000000 | (c<<20) | (arg0 & 0xfffff);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Interpreter::Type_Code segment3 (unsigned int c, unsigned int arg0)
|
|
|
|
|
{
|
|
|
|
|
assert (c<1024);
|
|
|
|
|
return 0xc0000000 | (c<<20) | (arg0 & 0xffff);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Interpreter::Type_Code segment4 (unsigned int c, unsigned int arg0, unsigned int arg1)
|
|
|
|
|
{
|
|
|
|
|
assert (c<1024);
|
|
|
|
|
return 0xc4000000 | (c<<16) | ((arg0 & 0xff)<<8) | (arg1 & 0xff);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Interpreter::Type_Code segment5 (unsigned int c)
|
|
|
|
|
{
|
|
|
|
|
assert (c<67108864);
|
|
|
|
|
return 0xc8000000 | c;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
{
|
|
|
|
|
void opPushInt (Compiler::Generator::CodeContainer& code, int value)
|
|
|
|
|
{
|
|
|
|
|
code.push_back (segment0 (0, value));
|
|
|
|
|
code.push_back (Compiler::Generator::segment0 (0, value));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void opFetchIntLiteral (Compiler::Generator::CodeContainer& code)
|
|
|
|
|
{
|
|
|
|
|
code.push_back (segment5 (4));
|
|
|
|
|
code.push_back (Compiler::Generator::segment5 (4));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void opFetchFloatLiteral (Compiler::Generator::CodeContainer& code)
|
|
|
|
|
{
|
|
|
|
|
code.push_back (segment5 (5));
|
|
|
|
|
code.push_back (Compiler::Generator::segment5 (5));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void opIntToFloat (Compiler::Generator::CodeContainer& code)
|
|
|
|
|
{
|
|
|
|
|
code.push_back (segment5 (3));
|
|
|
|
|
code.push_back (Compiler::Generator::segment5 (3));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void opFloatToInt (Compiler::Generator::CodeContainer& code)
|
|
|
|
|
{
|
|
|
|
|
code.push_back (segment5 (6));
|
|
|
|
|
code.push_back (Compiler::Generator::segment5 (6));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void opStoreLocalShort (Compiler::Generator::CodeContainer& code)
|
|
|
|
|
{
|
|
|
|
|
code.push_back (segment5 (0));
|
|
|
|
|
code.push_back (Compiler::Generator::segment5 (0));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void opStoreLocalLong (Compiler::Generator::CodeContainer& code)
|
|
|
|
|
{
|
|
|
|
|
code.push_back (segment5 (1));
|
|
|
|
|
code.push_back (Compiler::Generator::segment5 (1));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void opStoreLocalFloat (Compiler::Generator::CodeContainer& code)
|
|
|
|
|
{
|
|
|
|
|
code.push_back (segment5 (2));
|
|
|
|
|
code.push_back (Compiler::Generator::segment5 (2));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void opNegateInt (Compiler::Generator::CodeContainer& code)
|
|
|
|
|
{
|
|
|
|
|
code.push_back (segment5 (7));
|
|
|
|
|
code.push_back (Compiler::Generator::segment5 (7));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void opNegateFloat (Compiler::Generator::CodeContainer& code)
|
|
|
|
|
{
|
|
|
|
|
code.push_back (segment5 (8));
|
|
|
|
|
code.push_back (Compiler::Generator::segment5 (8));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void opAddInt (Compiler::Generator::CodeContainer& code)
|
|
|
|
|
{
|
|
|
|
|
code.push_back (segment5 (9));
|
|
|
|
|
code.push_back (Compiler::Generator::segment5 (9));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void opAddFloat (Compiler::Generator::CodeContainer& code)
|
|
|
|
|
{
|
|
|
|
|
code.push_back (segment5 (10));
|
|
|
|
|
code.push_back (Compiler::Generator::segment5 (10));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void opSubInt (Compiler::Generator::CodeContainer& code)
|
|
|
|
|
{
|
|
|
|
|
code.push_back (segment5 (11));
|
|
|
|
|
code.push_back (Compiler::Generator::segment5 (11));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void opSubFloat (Compiler::Generator::CodeContainer& code)
|
|
|
|
|
{
|
|
|
|
|
code.push_back (segment5 (12));
|
|
|
|
|
code.push_back (Compiler::Generator::segment5 (12));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void opMulInt (Compiler::Generator::CodeContainer& code)
|
|
|
|
|
{
|
|
|
|
|
code.push_back (segment5 (13));
|
|
|
|
|
code.push_back (Compiler::Generator::segment5 (13));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void opMulFloat (Compiler::Generator::CodeContainer& code)
|
|
|
|
|
{
|
|
|
|
|
code.push_back (segment5 (14));
|
|
|
|
|
code.push_back (Compiler::Generator::segment5 (14));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void opDivInt (Compiler::Generator::CodeContainer& code)
|
|
|
|
|
{
|
|
|
|
|
code.push_back (segment5 (15));
|
|
|
|
|
code.push_back (Compiler::Generator::segment5 (15));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void opDivFloat (Compiler::Generator::CodeContainer& code)
|
|
|
|
|
{
|
|
|
|
|
code.push_back (segment5 (16));
|
|
|
|
|
code.push_back (Compiler::Generator::segment5 (16));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void opIntToFloat1 (Compiler::Generator::CodeContainer& code)
|
|
|
|
|
{
|
|
|
|
|
code.push_back (segment5 (17));
|
|
|
|
|
code.push_back (Compiler::Generator::segment5 (17));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void opFloatToInt1 (Compiler::Generator::CodeContainer& code)
|
|
|
|
|
{
|
|
|
|
|
code.push_back (segment5 (18));
|
|
|
|
|
code.push_back (Compiler::Generator::segment5 (18));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void opSquareRoot (Compiler::Generator::CodeContainer& code)
|
|
|
|
|
{
|
|
|
|
|
code.push_back (segment5 (19));
|
|
|
|
|
code.push_back (Compiler::Generator::segment5 (19));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void opReturn (Compiler::Generator::CodeContainer& code)
|
|
|
|
|
{
|
|
|
|
|
code.push_back (segment5 (20));
|
|
|
|
|
code.push_back (Compiler::Generator::segment5 (20));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void opMessageBox (Compiler::Generator::CodeContainer& code, int buttons)
|
|
|
|
|
{
|
|
|
|
|
code.push_back (segment3 (0, buttons));
|
|
|
|
|
code.push_back (Compiler::Generator::segment3 (0, buttons));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void opFetchLocalShort (Compiler::Generator::CodeContainer& code)
|
|
|
|
|
{
|
|
|
|
|
code.push_back (segment5 (21));
|
|
|
|
|
code.push_back (Compiler::Generator::segment5 (21));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void opFetchLocalLong (Compiler::Generator::CodeContainer& code)
|
|
|
|
|
{
|
|
|
|
|
code.push_back (segment5 (22));
|
|
|
|
|
code.push_back (Compiler::Generator::segment5 (22));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void opFetchLocalFloat (Compiler::Generator::CodeContainer& code)
|
|
|
|
|
{
|
|
|
|
|
code.push_back (segment5 (23));
|
|
|
|
|
code.push_back (Compiler::Generator::segment5 (23));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void opJumpForward (Compiler::Generator::CodeContainer& code, int offset)
|
|
|
|
|
{
|
|
|
|
|
code.push_back (segment0 (1, offset));
|
|
|
|
|
code.push_back (Compiler::Generator::segment0 (1, offset));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void opJumpBackward (Compiler::Generator::CodeContainer& code, int offset)
|
|
|
|
|
{
|
|
|
|
|
code.push_back (segment0 (2, offset));
|
|
|
|
|
code.push_back (Compiler::Generator::segment0 (2, offset));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void opSkipOnZero (Compiler::Generator::CodeContainer& code)
|
|
|
|
|
{
|
|
|
|
|
code.push_back (segment5 (24));
|
|
|
|
|
code.push_back (Compiler::Generator::segment5 (24));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void opSkipOnNonZero (Compiler::Generator::CodeContainer& code)
|
|
|
|
|
{
|
|
|
|
|
code.push_back (segment5 (25));
|
|
|
|
|
code.push_back (Compiler::Generator::segment5 (25));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void opEqualInt (Compiler::Generator::CodeContainer& code)
|
|
|
|
|
{
|
|
|
|
|
code.push_back (segment5 (26));
|
|
|
|
|
code.push_back (Compiler::Generator::segment5 (26));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void opNonEqualInt (Compiler::Generator::CodeContainer& code)
|
|
|
|
|
{
|
|
|
|
|
code.push_back (segment5 (27));
|
|
|
|
|
code.push_back (Compiler::Generator::segment5 (27));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void opLessThanInt (Compiler::Generator::CodeContainer& code)
|
|
|
|
|
{
|
|
|
|
|
code.push_back (segment5 (28));
|
|
|
|
|
code.push_back (Compiler::Generator::segment5 (28));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void opLessOrEqualInt (Compiler::Generator::CodeContainer& code)
|
|
|
|
|
{
|
|
|
|
|
code.push_back (segment5 (29));
|
|
|
|
|
code.push_back (Compiler::Generator::segment5 (29));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void opGreaterThanInt (Compiler::Generator::CodeContainer& code)
|
|
|
|
|
{
|
|
|
|
|
code.push_back (segment5 (30));
|
|
|
|
|
code.push_back (Compiler::Generator::segment5 (30));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void opGreaterOrEqualInt (Compiler::Generator::CodeContainer& code)
|
|
|
|
|
{
|
|
|
|
|
code.push_back (segment5 (31));
|
|
|
|
|
code.push_back (Compiler::Generator::segment5 (31));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void opEqualFloat (Compiler::Generator::CodeContainer& code)
|
|
|
|
|
{
|
|
|
|
|
code.push_back (segment5 (32));
|
|
|
|
|
code.push_back (Compiler::Generator::segment5 (32));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void opNonEqualFloat (Compiler::Generator::CodeContainer& code)
|
|
|
|
|
{
|
|
|
|
|
code.push_back (segment5 (33));
|
|
|
|
|
code.push_back (Compiler::Generator::segment5 (33));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void opLessThanFloat (Compiler::Generator::CodeContainer& code)
|
|
|
|
|
{
|
|
|
|
|
code.push_back (segment5 (34));
|
|
|
|
|
code.push_back (Compiler::Generator::segment5 (34));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void opLessOrEqualFloat (Compiler::Generator::CodeContainer& code)
|
|
|
|
|
{
|
|
|
|
|
code.push_back (segment5 (35));
|
|
|
|
|
code.push_back (Compiler::Generator::segment5 (35));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void opGreaterThanFloat (Compiler::Generator::CodeContainer& code)
|
|
|
|
|
{
|
|
|
|
|
code.push_back (segment5 (36));
|
|
|
|
|
code.push_back (Compiler::Generator::segment5 (36));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void opGreaterOrEqualFloat (Compiler::Generator::CodeContainer& code)
|
|
|
|
|
{
|
|
|
|
|
code.push_back (segment5 (37));
|
|
|
|
|
code.push_back (Compiler::Generator::segment5 (37));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|