2023-06-16 10:35:18 -07: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 15:26:09 -07:00
|
|
|
#include "Luau/Bytecode.h"
|
2024-12-13 13:02:30 -08:00
|
|
|
#include "Luau/Compiler.h"
|
2023-08-11 07:42:37 -07:00
|
|
|
#include "Luau/DenseHash.h"
|
2024-05-03 13:17:51 -07:00
|
|
|
#include "ValueTracking.h"
|
2023-06-16 10:35:18 -07:00
|
|
|
|
2023-07-07 13:10:48 -07:00
|
|
|
#include <string>
|
|
|
|
|
2023-06-16 10:35:18 -07:00
|
|
|
namespace Luau
|
|
|
|
{
|
2024-05-31 12:18:18 -07:00
|
|
|
class BytecodeBuilder;
|
2023-07-07 13:10:48 -07:00
|
|
|
|
2024-08-02 07:30:04 -07:00
|
|
|
struct BuiltinAstTypes
|
2024-05-03 13:17:51 -07:00
|
|
|
{
|
2024-11-01 12:06:07 -07:00
|
|
|
BuiltinAstTypes(const char* hostVectorType)
|
|
|
|
: hostVectorType{{}, std::nullopt, AstName{hostVectorType}, std::nullopt, {}}
|
2024-05-03 13:17:51 -07:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2024-12-13 13:02:30 -08:00
|
|
|
// AstName use here will not match the AstNameTable, but the way we use them here always forces a full string compare
|
2024-05-03 13:17:51 -07:00
|
|
|
AstTypeReference booleanType{{}, std::nullopt, AstName{"boolean"}, std::nullopt, {}};
|
|
|
|
AstTypeReference numberType{{}, std::nullopt, AstName{"number"}, std::nullopt, {}};
|
|
|
|
AstTypeReference stringType{{}, std::nullopt, AstName{"string"}, std::nullopt, {}};
|
2024-11-01 12:06:07 -07:00
|
|
|
AstTypeReference vectorType{{}, std::nullopt, AstName{"vector"}, std::nullopt, {}};
|
|
|
|
|
|
|
|
AstTypeReference hostVectorType;
|
2024-05-03 13:17:51 -07:00
|
|
|
};
|
|
|
|
|
2024-08-02 07:30:04 -07:00
|
|
|
void buildTypeMap(
|
|
|
|
DenseHashMap<AstExprFunction*, std::string>& functionTypes,
|
|
|
|
DenseHashMap<AstLocal*, LuauBytecodeType>& localTypes,
|
|
|
|
DenseHashMap<AstExpr*, LuauBytecodeType>& exprTypes,
|
|
|
|
AstNode* root,
|
2024-11-01 12:06:07 -07:00
|
|
|
const char* hostVectorType,
|
2024-08-02 07:30:04 -07:00
|
|
|
const DenseHashMap<AstName, uint8_t>& userdataTypes,
|
|
|
|
const BuiltinAstTypes& builtinTypes,
|
|
|
|
const DenseHashMap<AstExprCall*, int>& builtinCalls,
|
|
|
|
const DenseHashMap<AstName, Compile::Global>& globals,
|
2024-12-13 13:02:30 -08:00
|
|
|
LibraryMemberTypeCallback libraryMemberTypeCb,
|
2024-08-02 07:30:04 -07:00
|
|
|
BytecodeBuilder& bytecode
|
|
|
|
);
|
2023-07-07 13:10:48 -07:00
|
|
|
|
2023-06-16 10:35:18 -07:00
|
|
|
} // namespace Luau
|