Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
Roblox
GitHub Repository: Roblox/luau
Path: blob/master/Analysis/include/Luau/Metamethods.h
2727 views
1
// This file is part of the Luau programming language and is licensed under MIT License; see LICENSE.txt for details
2
#pragma once
3
4
#include "Luau/Ast.h"
5
6
#include <unordered_map>
7
8
namespace Luau
9
{
10
11
inline const std::unordered_map<AstExprBinary::Op, const char*> kBinaryOpMetamethods{
12
{AstExprBinary::Op::CompareEq, "__eq"},
13
{AstExprBinary::Op::CompareNe, "__eq"},
14
{AstExprBinary::Op::CompareGe, "__lt"},
15
{AstExprBinary::Op::CompareGt, "__le"},
16
{AstExprBinary::Op::CompareLe, "__le"},
17
{AstExprBinary::Op::CompareLt, "__lt"},
18
{AstExprBinary::Op::Add, "__add"},
19
{AstExprBinary::Op::Sub, "__sub"},
20
{AstExprBinary::Op::Mul, "__mul"},
21
{AstExprBinary::Op::Div, "__div"},
22
{AstExprBinary::Op::FloorDiv, "__idiv"},
23
{AstExprBinary::Op::Pow, "__pow"},
24
{AstExprBinary::Op::Mod, "__mod"},
25
{AstExprBinary::Op::Concat, "__concat"},
26
};
27
28
inline const std::unordered_map<AstExprUnary::Op, const char*> kUnaryOpMetamethods{
29
{AstExprUnary::Op::Minus, "__unm"},
30
{AstExprUnary::Op::Len, "__len"},
31
};
32
33
} // namespace Luau
34
35