mirror of
https://github.com/luau-lang/luau.git
synced 2025-04-17 02:13:55 +01:00
Some checks failed
benchmark / callgrind (map[branch:main name:luau-lang/benchmark-data], ubuntu-22.04) (push) Has been cancelled
build / macos (push) Has been cancelled
build / macos-arm (push) Has been cancelled
build / ubuntu (push) Has been cancelled
build / windows (Win32) (push) Has been cancelled
build / windows (x64) (push) Has been cancelled
build / coverage (push) Has been cancelled
build / web (push) Has been cancelled
release / macos (push) Has been cancelled
release / ubuntu (push) Has been cancelled
release / windows (push) Has been cancelled
release / web (push) Has been cancelled
# General All code has been re-formatted by `clang-format`; this is not mechanically enforced, so Luau may go out-of-sync over the course of the year. # New Solver * Track free types interior to a block of code on `Scope`, which should reduce the number of free types that remain un-generalized after type checking is complete (e.g.: less errors like `'a <: number is incompatible with number`). # Autocomplete * Fragment autocomplete now does *not* provide suggestions within comments (matching non-fragment autocomplete behavior). * Autocomplete now respects iteration and recursion limits (some hangs will now early exit with a "unification too complex error," some crashes will now become internal complier exceptions). # Runtime * Add a limit to how many Luau codegen slot nodes addresses can be in use at the same time (fixes #1605, fixes #1558). * Added constant folding for vector arithmetic (fixes #1553). * Added support for `buffer.readbits` and `buffer.writebits` (see: https://github.com/luau-lang/rfcs/pull/18). --- Co-authored-by: Aaron Weiss <aaronweiss@roblox.com> Co-authored-by: David Cope <dcope@roblox.com> Co-authored-by: Hunter Goldstein <hgoldstein@roblox.com> Co-authored-by: Vighnesh Vijay <vvijay@roblox.com> Co-authored-by: Vyacheslav Egorov <vegorov@roblox.com>
55 lines
1.3 KiB
C++
55 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
|
|
#include "Luau/Location.h"
|
|
|
|
namespace Luau
|
|
{
|
|
|
|
void Position::shift(const Position& start, const Position& oldEnd, const Position& newEnd)
|
|
{
|
|
if (*this >= start)
|
|
{
|
|
if (this->line > oldEnd.line)
|
|
this->line += (newEnd.line - oldEnd.line);
|
|
else
|
|
{
|
|
this->line = newEnd.line;
|
|
this->column += (newEnd.column - oldEnd.column);
|
|
}
|
|
}
|
|
}
|
|
|
|
bool Location::encloses(const Location& l) const
|
|
{
|
|
return begin <= l.begin && end >= l.end;
|
|
}
|
|
|
|
bool Location::overlaps(const Location& l) const
|
|
{
|
|
return (begin <= l.begin && end >= l.begin) || (begin <= l.end && end >= l.end) || (begin >= l.begin && end <= l.end);
|
|
}
|
|
|
|
bool Location::contains(const Position& p) const
|
|
{
|
|
return begin <= p && p < end;
|
|
}
|
|
|
|
bool Location::containsClosed(const Position& p) const
|
|
{
|
|
return begin <= p && p <= end;
|
|
}
|
|
|
|
void Location::extend(const Location& other)
|
|
{
|
|
if (other.begin < begin)
|
|
begin = other.begin;
|
|
if (other.end > end)
|
|
end = other.end;
|
|
}
|
|
|
|
void Location::shift(const Position& start, const Position& oldEnd, const Position& newEnd)
|
|
{
|
|
begin.shift(start, oldEnd, newEnd);
|
|
end.shift(start, oldEnd, newEnd);
|
|
}
|
|
|
|
} // namespace Luau
|