Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
Roblox
GitHub Repository: Roblox/luau
Path: blob/master/VM/src/lcommon.h
2725 views
1
// This file is part of the Luau programming language and is licensed under MIT License; see LICENSE.txt for details
2
// This code is based on Lua 5.x implementation licensed under MIT License; see lua_LICENSE.txt for details
3
#pragma once
4
5
#include <limits.h>
6
#include <stdint.h>
7
8
#include "luaconf.h"
9
10
#include "Luau/Common.h"
11
12
// internal assertions for in-house debugging
13
#define check_exp(c, e) (LUAU_ASSERT(c), (e))
14
#define api_check(l, e) LUAU_ASSERT(e)
15
16
#ifndef cast_to
17
#define cast_to(t, exp) ((t)(exp))
18
#endif
19
20
#define cast_byte(i) cast_to(uint8_t, (i))
21
#define cast_num(i) cast_to(double, (i))
22
#define cast_int(i) cast_to(int, (i))
23
24
/*
25
** type for virtual-machine instructions
26
** must be an unsigned with (at least) 4 bytes (see details in lopcodes.h)
27
*/
28
typedef uint32_t Instruction;
29
30
/*
31
** macro to control inclusion of some hard tests on stack reallocation
32
*/
33
#if defined(HARDSTACKTESTS) && HARDSTACKTESTS
34
#define condhardstacktests(x) (x)
35
#else
36
#define condhardstacktests(x) ((void)0)
37
#endif
38
39
/*
40
** macro to control inclusion of some hard tests on garbage collection
41
*/
42
#if defined(HARDMEMTESTS) && HARDMEMTESTS
43
#define condhardmemtests(x, l) (HARDMEMTESTS >= l ? (x) : (void)0)
44
#else
45
#define condhardmemtests(x, l) ((void)0)
46
#endif
47
48