luau/Compiler/src/Types.h
2024-05-31 10:46:33 -07:00

34 lines
1.3 KiB
C++

// This file is part of the Luau programming language and is licensed under MIT License; see LICENSE.txt for details
#pragma once
#include "Luau/Ast.h"
#include "Luau/Bytecode.h"
#include "Luau/DenseHash.h"
#include "ValueTracking.h"
#include <string>
namespace Luau
{
class BytecodeBuilder;
struct BuiltinTypes
{
BuiltinTypes(const char* vectorType)
: vectorType{{}, std::nullopt, AstName{vectorType}, std::nullopt, {}}
{
}
// AstName use here will not match the AstNameTable, but the was we use them here always force a full string compare
AstTypeReference booleanType{{}, std::nullopt, AstName{"boolean"}, std::nullopt, {}};
AstTypeReference numberType{{}, std::nullopt, AstName{"number"}, std::nullopt, {}};
AstTypeReference stringType{{}, std::nullopt, AstName{"string"}, std::nullopt, {}};
AstTypeReference vectorType;
};
void buildTypeMap(DenseHashMap<AstExprFunction*, std::string>& functionTypes, DenseHashMap<AstLocal*, LuauBytecodeType>& localTypes,
DenseHashMap<AstExpr*, LuauBytecodeType>& exprTypes, AstNode* root, const char* vectorType, const DenseHashMap<AstName, uint8_t>& userdataTypes,
const BuiltinTypes& builtinTypes, const DenseHashMap<AstExprCall*, int>& builtinCalls, const DenseHashMap<AstName, Compile::Global>& globals,
BytecodeBuilder& bytecode);
} // namespace Luau