v0.5.1+luau558
This commit is contained in:
parent
7ca687e621
commit
f4642da510
|
@ -1,6 +1,6 @@
|
|||
[package]
|
||||
name = "luau0-src"
|
||||
version = "0.5.0+luau555"
|
||||
version = "0.5.1+luau558"
|
||||
authors = ["Aleksandr Orlenko <zxteam@protonmail.com>"]
|
||||
edition = "2021"
|
||||
repository = "https://github.com/khvzak/luau-src-rs"
|
||||
|
|
|
@ -5,6 +5,7 @@
|
|||
|
||||
#include <optional>
|
||||
#include <functional>
|
||||
#include <string>
|
||||
|
||||
#include <string.h>
|
||||
|
||||
|
|
|
@ -1,8 +1,6 @@
|
|||
// This file is part of the Luau programming language and is licensed under MIT License; see LICENSE.txt for details
|
||||
#pragma once
|
||||
|
||||
#include <string>
|
||||
|
||||
namespace Luau
|
||||
{
|
||||
|
||||
|
@ -10,130 +8,36 @@ struct Position
|
|||
{
|
||||
unsigned int line, column;
|
||||
|
||||
Position(unsigned int line, unsigned int column)
|
||||
: line(line)
|
||||
, column(column)
|
||||
{
|
||||
}
|
||||
Position(unsigned int line, unsigned int 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;
|
||||
bool operator!=(const Position& rhs) const;
|
||||
bool operator<(const Position& rhs) const;
|
||||
bool operator>(const Position& rhs) const;
|
||||
bool operator<=(const Position& rhs) const;
|
||||
bool operator>=(const Position& rhs) const;
|
||||
|
||||
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)
|
||||
{
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
void shift(const Position& start, const Position& oldEnd, const Position& newEnd);
|
||||
};
|
||||
|
||||
struct Location
|
||||
{
|
||||
Position begin, end;
|
||||
|
||||
Location()
|
||||
: begin(0, 0)
|
||||
, end(0, 0)
|
||||
{
|
||||
}
|
||||
Location();
|
||||
Location(const Position& begin, const Position& end);
|
||||
Location(const Position& begin, unsigned int length);
|
||||
Location(const Location& begin, const Location& end);
|
||||
|
||||
Location(const Position& begin, const Position& end)
|
||||
: begin(begin)
|
||||
, end(end)
|
||||
{
|
||||
}
|
||||
bool operator==(const Location& rhs) const;
|
||||
bool operator!=(const Location& rhs) const;
|
||||
|
||||
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
|
||||
{
|
||||
return begin <= l.begin && end >= l.end;
|
||||
}
|
||||
bool 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 contains(const Position& p) const
|
||||
{
|
||||
return begin <= p && p < end;
|
||||
}
|
||||
bool containsClosed(const Position& p) const
|
||||
{
|
||||
return begin <= p && p <= end;
|
||||
}
|
||||
void extend(const Location& other)
|
||||
{
|
||||
if (other.begin < begin)
|
||||
begin = other.begin;
|
||||
if (other.end > end)
|
||||
end = other.end;
|
||||
}
|
||||
void shift(const Position& start, const Position& oldEnd, const Position& newEnd)
|
||||
{
|
||||
begin.shift(start, oldEnd, newEnd);
|
||||
end.shift(start, oldEnd, newEnd);
|
||||
}
|
||||
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);
|
||||
};
|
||||
|
||||
std::string toString(const Position& position);
|
||||
std::string toString(const Location& location);
|
||||
|
||||
} // namespace Luau
|
||||
|
|
|
@ -4,14 +4,128 @@
|
|||
namespace Luau
|
||||
{
|
||||
|
||||
std::string toString(const Position& position)
|
||||
Position::Position(unsigned int line, unsigned int column)
|
||||
: line(line)
|
||||
, column(column)
|
||||
{
|
||||
return "{ line = " + std::to_string(position.line) + ", col = " + std::to_string(position.column) + " }";
|
||||
}
|
||||
|
||||
std::string toString(const Location& location)
|
||||
bool Position::operator==(const Position& rhs) const
|
||||
{
|
||||
return "Location { " + toString(location.begin) + ", " + toString(location.end) + " }";
|
||||
return this->column == rhs.column && this->line == rhs.line;
|
||||
}
|
||||
|
||||
bool Position::operator!=(const Position& rhs) const
|
||||
{
|
||||
return !(*this == rhs);
|
||||
}
|
||||
|
||||
bool Position::operator<(const Position& rhs) const
|
||||
{
|
||||
if (line == rhs.line)
|
||||
return column < rhs.column;
|
||||
else
|
||||
return line < rhs.line;
|
||||
}
|
||||
|
||||
bool Position::operator>(const Position& rhs) const
|
||||
{
|
||||
if (line == rhs.line)
|
||||
return column > rhs.column;
|
||||
else
|
||||
return line > rhs.line;
|
||||
}
|
||||
|
||||
bool Position::operator<=(const Position& rhs) const
|
||||
{
|
||||
return *this == rhs || *this < rhs;
|
||||
}
|
||||
|
||||
bool Position::operator>=(const Position& rhs) const
|
||||
{
|
||||
return *this == rhs || *this > rhs;
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Location::Location()
|
||||
: begin(0, 0)
|
||||
, end(0, 0)
|
||||
{
|
||||
}
|
||||
|
||||
Location::Location(const Position& begin, const Position& end)
|
||||
: begin(begin)
|
||||
, end(end)
|
||||
{
|
||||
}
|
||||
|
||||
Location::Location(const Position& begin, unsigned int length)
|
||||
: begin(begin)
|
||||
, end(begin.line, begin.column + length)
|
||||
{
|
||||
}
|
||||
|
||||
Location::Location(const Location& begin, const Location& end)
|
||||
: begin(begin.begin)
|
||||
, end(end.end)
|
||||
{
|
||||
}
|
||||
|
||||
bool Location::operator==(const Location& rhs) const
|
||||
{
|
||||
return this->begin == rhs.begin && this->end == rhs.end;
|
||||
}
|
||||
|
||||
bool Location::operator!=(const Location& rhs) const
|
||||
{
|
||||
return !(*this == rhs);
|
||||
}
|
||||
|
||||
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
|
||||
|
|
|
@ -27,6 +27,7 @@ LUAU_FASTINTVARIABLE(LuauCompileInlineDepth, 5)
|
|||
|
||||
LUAU_FASTFLAG(LuauInterpolatedStringBaseSupport)
|
||||
LUAU_FASTFLAGVARIABLE(LuauMultiAssignmentConflictFix, false)
|
||||
LUAU_FASTFLAGVARIABLE(LuauSelfAssignmentSkip, false)
|
||||
|
||||
namespace Luau
|
||||
{
|
||||
|
@ -350,7 +351,7 @@ struct Compiler
|
|||
{
|
||||
LUAU_ASSERT(!multRet || unsigned(target + targetCount) == regTop);
|
||||
|
||||
setDebugLine(expr); // normally compileExpr sets up line info, but compileExprCall can be called directly
|
||||
setDebugLine(expr); // normally compileExpr sets up line info, but compileExprVarargs can be called directly
|
||||
|
||||
bytecode.emitABC(LOP_GETVARARGS, target, multRet ? 0 : uint8_t(targetCount + 1), 0);
|
||||
}
|
||||
|
@ -2027,6 +2028,8 @@ struct Compiler
|
|||
// note: this can't check expr->upvalue because upvalues may be upgraded to locals during inlining
|
||||
if (int reg = getExprLocalReg(expr); reg >= 0)
|
||||
{
|
||||
// Optimization: we don't need to move if target happens to be in the same register
|
||||
if (!FFlag::LuauSelfAssignmentSkip || options.optimizationLevel == 0 || target != reg)
|
||||
bytecode.emitABC(LOP_MOVE, target, uint8_t(reg), 0);
|
||||
}
|
||||
else
|
||||
|
|
Loading…
Reference in New Issue