2023-06-16 18:35:18 +01:00
|
|
|
// 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"
|
2024-04-25 23:26:09 +01:00
|
|
|
#include "Luau/Bytecode.h"
|
2023-08-11 15:42:37 +01:00
|
|
|
#include "Luau/DenseHash.h"
|
2024-05-03 21:17:51 +01:00
|
|
|
#include "ValueTracking.h"
|
2023-06-16 18:35:18 +01:00
|
|
|
|
2023-07-07 21:10:48 +01:00
|
|
|
#include <string>
|
|
|
|
|
2023-06-16 18:35:18 +01:00
|
|
|
namespace Luau
|
|
|
|
{
|
2024-05-31 20:18:18 +01:00
|
|
|
class BytecodeBuilder;
|
2023-07-07 21:10:48 +01:00
|
|
|
|
2024-08-02 15:30:04 +01:00
|
|
|
struct BuiltinAstTypes
|
2024-05-03 21:17:51 +01:00
|
|
|
{
|
2024-08-02 15:30:04 +01:00
|
|
|
BuiltinAstTypes(const char* vectorType)
|
2024-05-03 21:17:51 +01:00
|
|
|
: 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;
|
|
|
|
};
|
|
|
|
|
2024-08-02 15:30:04 +01:00
|
|
|
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 BuiltinAstTypes& builtinTypes,
|
|
|
|
const DenseHashMap<AstExprCall*, int>& builtinCalls,
|
|
|
|
const DenseHashMap<AstName, Compile::Global>& globals,
|
|
|
|
BytecodeBuilder& bytecode
|
|
|
|
);
|
2023-07-07 21:10:48 +01:00
|
|
|
|
2023-06-16 18:35:18 +01:00
|
|
|
} // namespace Luau
|