mirror of
https://github.com/luau-lang/luau.git
synced 2025-05-04 10:33:46 +01:00
Fix + json encoder
This commit is contained in:
parent
50847e134f
commit
e399794562
3 changed files with 26 additions and 21 deletions
|
@ -776,7 +776,10 @@ struct AstJsonEncoder : public AstVisitor
|
|||
writeNode(node, "AstTypeReference", [&]() {
|
||||
if (node->prefix)
|
||||
PROP(prefix);
|
||||
if (node->prefixLocation)
|
||||
write("prefixLocation", *node->prefixLocation);
|
||||
PROP(name);
|
||||
PROP(nameLocation);
|
||||
PROP(parameters);
|
||||
});
|
||||
}
|
||||
|
|
|
@ -94,15 +94,15 @@ public:
|
|||
switch (ptv.type)
|
||||
{
|
||||
case PrimitiveType::NilType:
|
||||
return allocator->alloc<AstTypeReference>(Location(), std::nullopt, AstName("nil"));
|
||||
return allocator->alloc<AstTypeReference>(Location(), std::nullopt, AstName("nil"), std::nullopt, Location());
|
||||
case PrimitiveType::Boolean:
|
||||
return allocator->alloc<AstTypeReference>(Location(), std::nullopt, AstName("boolean"));
|
||||
return allocator->alloc<AstTypeReference>(Location(), std::nullopt, AstName("boolean"), std::nullopt, Location());
|
||||
case PrimitiveType::Number:
|
||||
return allocator->alloc<AstTypeReference>(Location(), std::nullopt, AstName("number"));
|
||||
return allocator->alloc<AstTypeReference>(Location(), std::nullopt, AstName("number"), std::nullopt, Location());
|
||||
case PrimitiveType::String:
|
||||
return allocator->alloc<AstTypeReference>(Location(), std::nullopt, AstName("string"));
|
||||
return allocator->alloc<AstTypeReference>(Location(), std::nullopt, AstName("string"), std::nullopt, Location());
|
||||
case PrimitiveType::Thread:
|
||||
return allocator->alloc<AstTypeReference>(Location(), std::nullopt, AstName("thread"));
|
||||
return allocator->alloc<AstTypeReference>(Location(), std::nullopt, AstName("thread"), std::nullopt, Location());
|
||||
default:
|
||||
return nullptr;
|
||||
}
|
||||
|
@ -110,12 +110,12 @@ public:
|
|||
|
||||
AstType* operator()(const BlockedType& btv)
|
||||
{
|
||||
return allocator->alloc<AstTypeReference>(Location(), std::nullopt, AstName("*blocked*"));
|
||||
return allocator->alloc<AstTypeReference>(Location(), std::nullopt, AstName("*blocked*"), std::nullopt, Location());
|
||||
}
|
||||
|
||||
AstType* operator()(const PendingExpansionType& petv)
|
||||
{
|
||||
return allocator->alloc<AstTypeReference>(Location(), std::nullopt, AstName("*pending-expansion*"));
|
||||
return allocator->alloc<AstTypeReference>(Location(), std::nullopt, AstName("*pending-expansion*"), std::nullopt, Location());
|
||||
}
|
||||
|
||||
AstType* operator()(const SingletonType& stv)
|
||||
|
@ -135,7 +135,7 @@ public:
|
|||
|
||||
AstType* operator()(const AnyType&)
|
||||
{
|
||||
return allocator->alloc<AstTypeReference>(Location(), std::nullopt, AstName("any"));
|
||||
return allocator->alloc<AstTypeReference>(Location(), std::nullopt, AstName("any"), std::nullopt, Location());
|
||||
}
|
||||
AstType* operator()(const TableType& ttv)
|
||||
{
|
||||
|
@ -157,15 +157,16 @@ public:
|
|||
parameters.data[i] = {{}, rehydrate(ttv.instantiatedTypePackParams[i])};
|
||||
}
|
||||
|
||||
return allocator->alloc<AstTypeReference>(Location(), std::nullopt, AstName(ttv.name->c_str()), parameters.size != 0, parameters);
|
||||
return allocator->alloc<AstTypeReference>(
|
||||
Location(), std::nullopt, AstName(ttv.name->c_str()), std::nullopt, Location(), parameters.size != 0, parameters);
|
||||
}
|
||||
|
||||
if (hasSeen(&ttv))
|
||||
{
|
||||
if (ttv.name)
|
||||
return allocator->alloc<AstTypeReference>(Location(), std::nullopt, AstName(ttv.name->c_str()));
|
||||
return allocator->alloc<AstTypeReference>(Location(), std::nullopt, AstName(ttv.name->c_str()), std::nullopt, Location());
|
||||
else
|
||||
return allocator->alloc<AstTypeReference>(Location(), std::nullopt, AstName("<Cycle>"));
|
||||
return allocator->alloc<AstTypeReference>(Location(), std::nullopt, AstName("<Cycle>"), std::nullopt, Location());
|
||||
}
|
||||
|
||||
AstArray<AstTableProp> props;
|
||||
|
@ -208,7 +209,7 @@ public:
|
|||
char* name = allocateString(*allocator, ctv.name);
|
||||
|
||||
if (!options.expandClassProps || hasSeen(&ctv) || count > 1)
|
||||
return allocator->alloc<AstTypeReference>(Location(), std::nullopt, AstName{name});
|
||||
return allocator->alloc<AstTypeReference>(Location(), std::nullopt, AstName{name}, std::nullopt, Location());
|
||||
|
||||
AstArray<AstTableProp> props;
|
||||
props.size = ctv.props.size();
|
||||
|
@ -233,7 +234,7 @@ public:
|
|||
RecursionCounter counter(&count);
|
||||
|
||||
if (hasSeen(&ftv))
|
||||
return allocator->alloc<AstTypeReference>(Location(), std::nullopt, AstName("<Cycle>"));
|
||||
return allocator->alloc<AstTypeReference>(Location(), std::nullopt, AstName("<Cycle>"), std::nullopt, Location());
|
||||
|
||||
AstArray<AstGenericType> generics;
|
||||
generics.size = ftv.generics.size();
|
||||
|
@ -304,11 +305,12 @@ public:
|
|||
}
|
||||
AstType* operator()(const Unifiable::Error&)
|
||||
{
|
||||
return allocator->alloc<AstTypeReference>(Location(), std::nullopt, AstName("Unifiable<Error>"));
|
||||
return allocator->alloc<AstTypeReference>(Location(), std::nullopt, AstName("Unifiable<Error>"), std::nullopt, Location());
|
||||
}
|
||||
AstType* operator()(const GenericType& gtv)
|
||||
{
|
||||
return allocator->alloc<AstTypeReference>(Location(), std::nullopt, AstName(getName(allocator, syntheticNames, gtv)));
|
||||
return allocator->alloc<AstTypeReference>(
|
||||
Location(), std::nullopt, AstName(getName(allocator, syntheticNames, gtv)), std::nullopt, Location());
|
||||
}
|
||||
AstType* operator()(const Unifiable::Bound<TypeId>& bound)
|
||||
{
|
||||
|
@ -316,7 +318,7 @@ public:
|
|||
}
|
||||
AstType* operator()(const FreeType& ftv)
|
||||
{
|
||||
return allocator->alloc<AstTypeReference>(Location(), std::nullopt, AstName("free"));
|
||||
return allocator->alloc<AstTypeReference>(Location(), std::nullopt, AstName("free"), std::nullopt, Location());
|
||||
}
|
||||
AstType* operator()(const UnionType& uv)
|
||||
{
|
||||
|
@ -342,15 +344,15 @@ public:
|
|||
}
|
||||
AstType* operator()(const LazyType& ltv)
|
||||
{
|
||||
return allocator->alloc<AstTypeReference>(Location(), std::nullopt, AstName("<Lazy?>"));
|
||||
return allocator->alloc<AstTypeReference>(Location(), std::nullopt, AstName("<Lazy?>"), std::nullopt, Location());
|
||||
}
|
||||
AstType* operator()(const UnknownType& ttv)
|
||||
{
|
||||
return allocator->alloc<AstTypeReference>(Location(), std::nullopt, AstName{"unknown"});
|
||||
return allocator->alloc<AstTypeReference>(Location(), std::nullopt, AstName{"unknown"}, std::nullopt, Location());
|
||||
}
|
||||
AstType* operator()(const NeverType& ttv)
|
||||
{
|
||||
return allocator->alloc<AstTypeReference>(Location(), std::nullopt, AstName{"never"});
|
||||
return allocator->alloc<AstTypeReference>(Location(), std::nullopt, AstName{"never"}, std::nullopt, Location());
|
||||
}
|
||||
AstType* operator()(const NegationType& ntv)
|
||||
{
|
||||
|
|
|
@ -848,10 +848,10 @@ public:
|
|||
|
||||
bool hasParameterList;
|
||||
std::optional<AstName> prefix;
|
||||
AstName name;
|
||||
AstArray<AstTypeOrPack> parameters;
|
||||
std::optional<Location> prefixLocation;
|
||||
AstName name;
|
||||
Location nameLocation;
|
||||
AstArray<AstTypeOrPack> parameters;
|
||||
};
|
||||
|
||||
struct AstTableProp
|
||||
|
|
Loading…
Add table
Reference in a new issue