Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
Roblox
GitHub Repository: Roblox/luau
Path: blob/master/Compiler/src/Types.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
#pragma once
3
4
#include "Luau/Ast.h"
5
#include "Luau/Bytecode.h"
6
#include "Luau/Compiler.h"
7
#include "Luau/DenseHash.h"
8
#include "ValueTracking.h"
9
10
#include <string>
11
12
namespace Luau
13
{
14
class BytecodeBuilder;
15
16
struct BuiltinAstTypes
17
{
18
BuiltinAstTypes(const char* hostVectorType)
19
: hostVectorType{{}, std::nullopt, AstName{hostVectorType}, std::nullopt, {}}
20
{
21
}
22
23
// AstName use here will not match the AstNameTable, but the way we use them here always forces a full string compare
24
AstTypeReference booleanType{{}, std::nullopt, AstName{"boolean"}, std::nullopt, {}};
25
AstTypeReference numberType{{}, std::nullopt, AstName{"number"}, std::nullopt, {}};
26
AstTypeReference integerType{{}, std::nullopt, AstName{"integer"}, std::nullopt, {}};
27
AstTypeReference stringType{{}, std::nullopt, AstName{"string"}, std::nullopt, {}};
28
AstTypeReference vectorType{{}, std::nullopt, AstName{"vector"}, std::nullopt, {}};
29
30
AstTypeReference hostVectorType;
31
};
32
33
void buildTypeMap(
34
DenseHashMap<AstExprFunction*, std::string>& functionTypes,
35
DenseHashMap<AstLocal*, LuauBytecodeType>& localTypes,
36
DenseHashMap<AstExpr*, LuauBytecodeType>& exprTypes,
37
AstNode* root,
38
const char* hostVectorType,
39
const DenseHashMap<AstName, uint8_t>& userdataTypes,
40
const BuiltinAstTypes& builtinTypes,
41
const DenseHashMap<AstExprCall*, int>& builtinCalls,
42
const DenseHashMap<AstName, Compile::Global>& globals,
43
LibraryMemberTypeCallback libraryMemberTypeCb,
44
BytecodeBuilder& bytecode
45
);
46
47
} // namespace Luau
48
49