mirror of
https://github.com/luau-lang/luau.git
synced 2025-01-19 17:28:06 +00:00
c759cd5581
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>
97 lines
2.2 KiB
C++
97 lines
2.2 KiB
C++
// This file is part of the Luau programming language and is licensed under MIT License; see LICENSE.txt for details
|
|
#pragma once
|
|
|
|
namespace Luau
|
|
{
|
|
|
|
struct Position
|
|
{
|
|
unsigned int line, column;
|
|
|
|
Position(unsigned int line, unsigned int column)
|
|
: line(line)
|
|
, column(column)
|
|
{
|
|
}
|
|
|
|
bool operator==(const Position& rhs) const
|
|
{
|
|
return this->column == rhs.column && this->line == rhs.line;
|
|
}
|
|
|
|
bool operator!=(const Position& rhs) const
|
|
{
|
|
return !(*this == rhs);
|
|
}
|
|
bool operator<(const Position& rhs) const
|
|
{
|
|
if (line == rhs.line)
|
|
return column < rhs.column;
|
|
else
|
|
return line < rhs.line;
|
|
}
|
|
bool operator>(const Position& rhs) const
|
|
{
|
|
if (line == rhs.line)
|
|
return column > rhs.column;
|
|
else
|
|
return line > rhs.line;
|
|
}
|
|
bool operator<=(const Position& rhs) const
|
|
{
|
|
return *this == rhs || *this < rhs;
|
|
}
|
|
bool operator>=(const Position& rhs) const
|
|
{
|
|
return *this == rhs || *this > rhs;
|
|
}
|
|
|
|
void shift(const Position& start, const Position& oldEnd, const Position& newEnd);
|
|
};
|
|
|
|
struct Location
|
|
{
|
|
Position begin, end;
|
|
|
|
Location()
|
|
: begin(0, 0)
|
|
, end(0, 0)
|
|
{
|
|
}
|
|
|
|
Location(const Position& begin, const Position& end)
|
|
: begin(begin)
|
|
, end(end)
|
|
{
|
|
}
|
|
|
|
Location(const Position& begin, unsigned int length)
|
|
: begin(begin)
|
|
, end(begin.line, begin.column + length)
|
|
{
|
|
}
|
|
|
|
Location(const Location& begin, const Location& end)
|
|
: begin(begin.begin)
|
|
, end(end.end)
|
|
{
|
|
}
|
|
|
|
bool operator==(const Location& rhs) const
|
|
{
|
|
return this->begin == rhs.begin && this->end == rhs.end;
|
|
}
|
|
bool operator!=(const Location& rhs) const
|
|
{
|
|
return !(*this == rhs);
|
|
}
|
|
|
|
bool encloses(const Location& l) const;
|
|
bool overlaps(const Location& l) const;
|
|
bool contains(const Position& p) const;
|
|
bool containsClosed(const Position& p) const;
|
|
void extend(const Location& other);
|
|
void shift(const Position& start, const Position& oldEnd, const Position& newEnd);
|
|
};
|
|
|
|
} // namespace Luau
|