2022-09-15 23:38:17 +01:00
|
|
|
// This file is part of the Luau programming language and is licensed under MIT License; see LICENSE.txt for details
|
|
|
|
#include "ConstraintGraphBuilderFixture.h"
|
|
|
|
|
|
|
|
namespace Luau
|
|
|
|
{
|
|
|
|
|
|
|
|
ConstraintGraphBuilderFixture::ConstraintGraphBuilderFixture()
|
|
|
|
: Fixture()
|
|
|
|
, mainModule(new Module)
|
|
|
|
, forceTheFlag{"DebugLuauDeferredConstraintResolution", true}
|
|
|
|
{
|
|
|
|
BlockedTypeVar::nextIndex = 0;
|
|
|
|
BlockedTypePack::nextIndex = 0;
|
|
|
|
}
|
|
|
|
|
2022-10-21 18:54:01 +01:00
|
|
|
void ConstraintGraphBuilderFixture::generateConstraints(const std::string& code)
|
|
|
|
{
|
|
|
|
AstStatBlock* root = parse(code);
|
|
|
|
dfg = std::make_unique<DataFlowGraph>(DataFlowGraphBuilder::build(root, NotNull{&ice}));
|
|
|
|
cgb = std::make_unique<ConstraintGraphBuilder>("MainModule", mainModule, &arena, NotNull(&moduleResolver), singletonTypes, NotNull(&ice),
|
|
|
|
frontend.getGlobalScope(), &logger, NotNull{dfg.get()});
|
|
|
|
cgb->visit(root);
|
|
|
|
rootScope = cgb->rootScope;
|
|
|
|
constraints = Luau::collectConstraints(NotNull{cgb->rootScope});
|
|
|
|
}
|
|
|
|
|
|
|
|
void ConstraintGraphBuilderFixture::solve(const std::string& code)
|
|
|
|
{
|
|
|
|
generateConstraints(code);
|
|
|
|
ConstraintSolver cs{NotNull{&normalizer}, NotNull{rootScope}, "MainModule", NotNull(&moduleResolver), {}, &logger};
|
|
|
|
cs.run();
|
|
|
|
}
|
|
|
|
|
2022-10-14 20:48:41 +01:00
|
|
|
} // namespace Luau
|