Skip to content

Commit 6342742

Browse files
committed
v0.11.2+luau653
1 parent 3188c68 commit 6342742

29 files changed

+501
-200
lines changed

Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "luau0-src"
3-
version = "0.11.1+luau650"
3+
version = "0.11.2+luau653"
44
authors = ["Aleksandr Orlenko <[email protected]>"]
55
edition = "2021"
66
repository = "https://github.com/khvzak/luau-src-rs"

luau/Ast/include/Luau/Allocator.h

+48
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
// This file is part of the Luau programming language and is licensed under MIT License; see LICENSE.txt for details
2+
#pragma once
3+
4+
#include "Luau/Ast.h"
5+
#include "Luau/Location.h"
6+
#include "Luau/DenseHash.h"
7+
#include "Luau/Common.h"
8+
9+
#include <vector>
10+
11+
namespace Luau
12+
{
13+
14+
class Allocator
15+
{
16+
public:
17+
Allocator();
18+
Allocator(Allocator&&);
19+
20+
Allocator& operator=(Allocator&&) = delete;
21+
22+
~Allocator();
23+
24+
void* allocate(size_t size);
25+
26+
template<typename T, typename... Args>
27+
T* alloc(Args&&... args)
28+
{
29+
static_assert(std::is_trivially_destructible<T>::value, "Objects allocated with this allocator will never have their destructors run!");
30+
31+
T* t = static_cast<T*>(allocate(sizeof(T)));
32+
new (t) T(std::forward<Args>(args)...);
33+
return t;
34+
}
35+
36+
private:
37+
struct Page
38+
{
39+
Page* next;
40+
41+
char data[8192];
42+
};
43+
44+
Page* root;
45+
size_t offset;
46+
};
47+
48+
}

luau/Ast/include/Luau/Ast.h

+7-4
Original file line numberDiff line numberDiff line change
@@ -316,16 +316,18 @@ class AstExprConstantString : public AstExpr
316316

317317
enum QuoteStyle
318318
{
319-
Quoted,
319+
QuotedSimple,
320+
QuotedRaw,
320321
Unquoted
321322
};
322323

323-
AstExprConstantString(const Location& location, const AstArray<char>& value, QuoteStyle quoteStyle = Quoted);
324+
AstExprConstantString(const Location& location, const AstArray<char>& value, QuoteStyle quoteStyle);
324325

325326
void visit(AstVisitor* visitor) override;
327+
bool isQuoted() const;
326328

327329
AstArray<char> value;
328-
QuoteStyle quoteStyle = Quoted;
330+
QuoteStyle quoteStyle;
329331
};
330332

331333
class AstExprLocal : public AstExpr
@@ -876,13 +878,14 @@ class AstStatTypeFunction : public AstStat
876878
public:
877879
LUAU_RTTI(AstStatTypeFunction);
878880

879-
AstStatTypeFunction(const Location& location, const AstName& name, const Location& nameLocation, AstExprFunction* body);
881+
AstStatTypeFunction(const Location& location, const AstName& name, const Location& nameLocation, AstExprFunction* body, bool exported);
880882

881883
void visit(AstVisitor* visitor) override;
882884

883885
AstName name;
884886
Location nameLocation;
885887
AstExprFunction* body;
888+
bool exported;
886889
};
887890

888891
class AstStatDeclareGlobal : public AstStat

luau/Ast/include/Luau/Lexer.h

+1-34
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
// This file is part of the Luau programming language and is licensed under MIT License; see LICENSE.txt for details
22
#pragma once
33

4+
#include "Luau/Allocator.h"
45
#include "Luau/Ast.h"
56
#include "Luau/Location.h"
67
#include "Luau/DenseHash.h"
@@ -11,40 +12,6 @@
1112
namespace Luau
1213
{
1314

14-
class Allocator
15-
{
16-
public:
17-
Allocator();
18-
Allocator(Allocator&&);
19-
20-
Allocator& operator=(Allocator&&) = delete;
21-
22-
~Allocator();
23-
24-
void* allocate(size_t size);
25-
26-
template<typename T, typename... Args>
27-
T* alloc(Args&&... args)
28-
{
29-
static_assert(std::is_trivially_destructible<T>::value, "Objects allocated with this allocator will never have their destructors run!");
30-
31-
T* t = static_cast<T*>(allocate(sizeof(T)));
32-
new (t) T(std::forward<Args>(args)...);
33-
return t;
34-
}
35-
36-
private:
37-
struct Page
38-
{
39-
Page* next;
40-
41-
char data[8192];
42-
};
43-
44-
Page* root;
45-
size_t offset;
46-
};
47-
4815
struct Lexeme
4916
{
5017
enum Type

luau/Ast/src/Allocator.cpp

+66
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
// This file is part of the Luau programming language and is licensed under MIT License; see LICENSE.txt for details
2+
3+
#include "Luau/Allocator.h"
4+
5+
namespace Luau
6+
{
7+
8+
Allocator::Allocator()
9+
: root(static_cast<Page*>(operator new(sizeof(Page))))
10+
, offset(0)
11+
{
12+
root->next = nullptr;
13+
}
14+
15+
Allocator::Allocator(Allocator&& rhs)
16+
: root(rhs.root)
17+
, offset(rhs.offset)
18+
{
19+
rhs.root = nullptr;
20+
rhs.offset = 0;
21+
}
22+
23+
Allocator::~Allocator()
24+
{
25+
Page* page = root;
26+
27+
while (page)
28+
{
29+
Page* next = page->next;
30+
31+
operator delete(page);
32+
33+
page = next;
34+
}
35+
}
36+
37+
void* Allocator::allocate(size_t size)
38+
{
39+
constexpr size_t align = alignof(void*) > alignof(double) ? alignof(void*) : alignof(double);
40+
41+
if (root)
42+
{
43+
uintptr_t data = reinterpret_cast<uintptr_t>(root->data);
44+
uintptr_t result = (data + offset + align - 1) & ~(align - 1);
45+
if (result + size <= data + sizeof(root->data))
46+
{
47+
offset = result - data + size;
48+
return reinterpret_cast<void*>(result);
49+
}
50+
}
51+
52+
// allocate new page
53+
size_t pageSize = size > sizeof(root->data) ? size : sizeof(root->data);
54+
void* pageData = operator new(offsetof(Page, data) + pageSize);
55+
56+
Page* page = static_cast<Page*>(pageData);
57+
58+
page->next = root;
59+
60+
root = page;
61+
offset = size;
62+
63+
return page->data;
64+
}
65+
66+
}

luau/Ast/src/Ast.cpp

+13-10
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,6 @@
33

44
#include "Luau/Common.h"
55

6-
LUAU_FASTFLAG(LuauNativeAttribute);
7-
8-
// The default value here is 643 because the first release in which this was implemented is 644,
9-
// and actively we want new changes to be off by default until they're enabled consciously.
10-
// The flag is placed in AST project here to be common in all Luau libraries
11-
LUAU_DYNAMIC_FASTINTVARIABLE(LuauTypeSolverRelease, 643)
12-
136
namespace Luau
147
{
158

@@ -92,6 +85,11 @@ void AstExprConstantString::visit(AstVisitor* visitor)
9285
visitor->visit(this);
9386
}
9487

88+
bool AstExprConstantString::isQuoted() const
89+
{
90+
return quoteStyle == QuoteStyle::QuotedSimple || quoteStyle == QuoteStyle::QuotedRaw;
91+
}
92+
9593
AstExprLocal::AstExprLocal(const Location& location, AstLocal* local, bool upvalue)
9694
: AstExpr(ClassIndex(), location)
9795
, local(local)
@@ -239,8 +237,6 @@ void AstExprFunction::visit(AstVisitor* visitor)
239237

240238
bool AstExprFunction::hasNativeAttribute() const
241239
{
242-
LUAU_ASSERT(FFlag::LuauNativeAttribute);
243-
244240
for (const auto attribute : attributes)
245241
{
246242
if (attribute->type == AstAttr::Type::Native)
@@ -760,11 +756,18 @@ void AstStatTypeAlias::visit(AstVisitor* visitor)
760756
}
761757
}
762758

763-
AstStatTypeFunction::AstStatTypeFunction(const Location& location, const AstName& name, const Location& nameLocation, AstExprFunction* body)
759+
AstStatTypeFunction::AstStatTypeFunction(
760+
const Location& location,
761+
const AstName& name,
762+
const Location& nameLocation,
763+
AstExprFunction* body,
764+
bool exported
765+
)
764766
: AstStat(ClassIndex(), location)
765767
, name(name)
766768
, nameLocation(nameLocation)
767769
, body(body)
770+
, exported(exported)
768771
{
769772
}
770773

luau/Ast/src/Lexer.cpp

+1-58
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
// This file is part of the Luau programming language and is licensed under MIT License; see LICENSE.txt for details
22
#include "Luau/Lexer.h"
33

4+
#include "Luau/Allocator.h"
45
#include "Luau/Common.h"
56
#include "Luau/Confusables.h"
67
#include "Luau/StringUtils.h"
@@ -10,64 +11,6 @@
1011
namespace Luau
1112
{
1213

13-
Allocator::Allocator()
14-
: root(static_cast<Page*>(operator new(sizeof(Page))))
15-
, offset(0)
16-
{
17-
root->next = nullptr;
18-
}
19-
20-
Allocator::Allocator(Allocator&& rhs)
21-
: root(rhs.root)
22-
, offset(rhs.offset)
23-
{
24-
rhs.root = nullptr;
25-
rhs.offset = 0;
26-
}
27-
28-
Allocator::~Allocator()
29-
{
30-
Page* page = root;
31-
32-
while (page)
33-
{
34-
Page* next = page->next;
35-
36-
operator delete(page);
37-
38-
page = next;
39-
}
40-
}
41-
42-
void* Allocator::allocate(size_t size)
43-
{
44-
constexpr size_t align = alignof(void*) > alignof(double) ? alignof(void*) : alignof(double);
45-
46-
if (root)
47-
{
48-
uintptr_t data = reinterpret_cast<uintptr_t>(root->data);
49-
uintptr_t result = (data + offset + align - 1) & ~(align - 1);
50-
if (result + size <= data + sizeof(root->data))
51-
{
52-
offset = result - data + size;
53-
return reinterpret_cast<void*>(result);
54-
}
55-
}
56-
57-
// allocate new page
58-
size_t pageSize = size > sizeof(root->data) ? size : sizeof(root->data);
59-
void* pageData = operator new(offsetof(Page, data) + pageSize);
60-
61-
Page* page = static_cast<Page*>(pageData);
62-
63-
page->next = root;
64-
65-
root = page;
66-
offset = size;
67-
68-
return page->data;
69-
}
70-
7114
Lexeme::Lexeme(const Location& location, Type type)
7215
: type(type)
7316
, location(location)

0 commit comments

Comments
 (0)