mirror of
https://github.com/luau-lang/luau.git
synced 2024-12-13 21:40:43 +00:00
551a43c424
- Updated Roblox copyright to 2023 - Floor division operator `//` (implements #832) - Autocomplete now shows `end` within `do` blocks - Restore BraceType when using `Lexer::lookahead` (fixes #1019) # New typechecker - Subtyping tests between metatables and tables - Subtyping tests between string singletons and tables - Subtyping tests for class types # Native codegen - Fixed macOS test failure (wrong spill restore offset) - Fixed clobbering of non-volatile xmm registers on Windows - Fixed wrong storage location of SSA reg spills - Implemented A64 support for add/sub extended - Eliminated zextReg from A64 lowering - Remove identical table slot lookups - Propagate values from predecessor into the linear block - Disabled reuse slot optimization - Keep `LuaNode::val` check for nil when optimizing `CHECK_SLOT_MATCH` - Implemented IR translation of `table.insert` builtin - Fixed mmap error handling on macOS/Linux # Tooling - Used `|` as a column separator instead of `+` in `bench.py` - Added a `table.sort` micro-benchmark - Switched `libprotobuf-mutator` to a less problematic version
69 lines
1.8 KiB
C
69 lines
1.8 KiB
C
// This file is part of the Luau programming language and is licensed under MIT License; see LICENSE.txt for details
|
|
// This code is based on Lua 5.x implementation licensed under MIT License; see lua_LICENSE.txt for details
|
|
#pragma once
|
|
|
|
#include <math.h>
|
|
|
|
#define luai_numadd(a, b) ((a) + (b))
|
|
#define luai_numsub(a, b) ((a) - (b))
|
|
#define luai_nummul(a, b) ((a) * (b))
|
|
#define luai_numdiv(a, b) ((a) / (b))
|
|
#define luai_numpow(a, b) (pow(a, b))
|
|
#define luai_numunm(a) (-(a))
|
|
#define luai_numisnan(a) ((a) != (a))
|
|
#define luai_numeq(a, b) ((a) == (b))
|
|
#define luai_numlt(a, b) ((a) < (b))
|
|
#define luai_numle(a, b) ((a) <= (b))
|
|
|
|
inline bool luai_veceq(const float* a, const float* b)
|
|
{
|
|
#if LUA_VECTOR_SIZE == 4
|
|
return a[0] == b[0] && a[1] == b[1] && a[2] == b[2] && a[3] == b[3];
|
|
#else
|
|
return a[0] == b[0] && a[1] == b[1] && a[2] == b[2];
|
|
#endif
|
|
}
|
|
|
|
inline bool luai_vecisnan(const float* a)
|
|
{
|
|
#if LUA_VECTOR_SIZE == 4
|
|
return a[0] != a[0] || a[1] != a[1] || a[2] != a[2] || a[3] != a[3];
|
|
#else
|
|
return a[0] != a[0] || a[1] != a[1] || a[2] != a[2];
|
|
#endif
|
|
}
|
|
|
|
LUAU_FASTMATH_BEGIN
|
|
inline double luai_nummod(double a, double b)
|
|
{
|
|
return a - floor(a / b) * b;
|
|
}
|
|
LUAU_FASTMATH_END
|
|
|
|
LUAU_FASTMATH_BEGIN
|
|
inline double luai_numidiv(double a, double b)
|
|
{
|
|
return floor(a / b);
|
|
}
|
|
LUAU_FASTMATH_END
|
|
|
|
#define luai_num2int(i, d) ((i) = (int)(d))
|
|
|
|
// On MSVC in 32-bit, double to unsigned cast compiles into a call to __dtoui3, so we invoke x87->int64 conversion path manually
|
|
#if defined(_MSC_VER) && defined(_M_IX86)
|
|
#define luai_num2unsigned(i, n) \
|
|
{ \
|
|
__int64 l; \
|
|
__asm { __asm fld n __asm fistp l} \
|
|
; \
|
|
i = (unsigned int)l; \
|
|
}
|
|
#else
|
|
#define luai_num2unsigned(i, n) ((i) = (unsigned)(long long)(n))
|
|
#endif
|
|
|
|
#define LUAI_MAXNUM2STR 48
|
|
|
|
LUAI_FUNC char* luai_num2str(char* buf, double n);
|
|
|
|
#define luai_str2num(s, p) strtod((s), (p))
|