Skip to content

Commit cf4c39a

Browse files
committed
replace @self with the new @SelfArgument
1 parent e22d38b commit cf4c39a

27 files changed

Lines changed: 76 additions & 76 deletions

File tree

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ Vec3.__index = Vec3
5353
type Vec3.@Name = "Vector"
5454

5555
-- define the type of the first argument in setmetatable
56-
type Vec3.@Self = {
56+
type Vec3.@SelfArgument = {
5757
x = number,
5858
y = number,
5959
z = number,

examples/projects/love2d/dist/main.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ IMPORTS["src/vec2.nlua"] = function(...)
127127
for key, op in pairs(op) do
128128
local code = [[
129129
local Vec2 = ...
130-
function Vec2.]] .. key .. [[(a--[=[#: Vec2.@Self]=], b--[=[#: number | Vec2.@Self]=])
130+
function Vec2.]] .. key .. [[(a--[=[#: Vec2.@SelfArgument]=], b--[=[#: number | Vec2.@SelfArgument]=])
131131
if type(b) == "number" then
132132
return Vec2(a.x ]] .. op .. [[ b, a.y ]] .. op .. [[ b)
133133
end

examples/projects/love2d/src/main.nlua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ type love = import("./love_api.nlua")
44
local Maze = import("./maze.nlua")
55
local Vec2 = import("./vec2.nlua")
66
-- not sure about this, Vec2 the metatable and which doubles as a constructor and NOT the type Vec2
7-
local type Vec2 = Vec2.@Self
7+
local type Vec2 = Vec2.@SelfArgument
88
local type Node = {
99
pos = Vec2,
1010
wall = boolean,

examples/projects/love2d/src/maze.nlua

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
local Maze = {}
22
Maze.__index = Maze
3-
type Maze.@Self = {
3+
type Maze.@SelfArgument = {
44
width = 0 .. inf,
55
height = 0 .. inf,
66
grid = {[0 .. inf] = 1 | 0},
@@ -81,7 +81,7 @@ local function constructor(_, width: 0 .. inf, height: 0 .. inf)
8181
--[[ lie to the typesystem since we're just about to fill the grid with numbers ]]
8282
width = width,
8383
height = height,
84-
} as Maze.@Self,
84+
} as Maze.@SelfArgument,
8585
Maze
8686
)
8787

examples/projects/love2d/src/vec2.nlua

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
local Vec2 = {}
22
Vec2.__index = Vec2
33
type Vec2.@Name = "Vec2"
4-
type Vec2.@Self = {x = number, y = number}
5-
local type Vec2 = Vec2.@Self
4+
type Vec2.@SelfArgument = {x = number, y = number}
5+
local type Vec2 = Vec2.@SelfArgument
66

77
function Vec2:__tostring()
88
return ("Vec2(%f, %f)"):format(self.x, self.y)
@@ -22,7 +22,7 @@ local op = {
2222
for key, op in pairs(op) do
2323
local code = [[
2424
local Vec2 = ...
25-
function Vec2.]] .. key .. [[(a--[=[#: Vec2.@Self]=], b--[=[#: number | Vec2.@Self]=])
25+
function Vec2.]] .. key .. [[(a--[=[#: Vec2.@SelfArgument]=], b--[=[#: number | Vec2.@SelfArgument]=])
2626
if type(b) == "number" then
2727
return Vec2(a.x ]] .. op .. [[ b, a.y ]] .. op .. [[ b)
2828
end

nattlua/code.lua

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ local class = require("nattlua.other.class")
66
local callstack = require("nattlua.other.callstack")
77
local META = class.CreateTemplate("code")
88
--[[#type META.@Name = "Code"]]
9-
--[[#type META.@Self = {
9+
--[[#type META.@SelfArgument = {
1010
Buffer = string,
1111
Name = string,
1212
}]]
@@ -32,7 +32,7 @@ local has_ffi, ffi = pcall(require, "ffi")
3232

3333
if has_ffi--[[# as false]] then
3434
--[[#-- todo, ffimetatype inference
35-
type META.@Self = {
35+
type META.@SelfArgument = {
3636
Buffer = string,
3737
buffer_len = number,
3838
Name = string,
@@ -204,5 +204,5 @@ else
204204
end
205205
end
206206

207-
--[[#type META.Code = META.@Self]]
207+
--[[#type META.Code = META.@SelfArgument]]
208208
return META

nattlua/compiler.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ local NATTLUA_MARKDOWN_OUTPUT = _G.NATTLUA_MARKDOWN_OUTPUT
3131
emitter = Partial<|import("~/nattlua/emitter/config.nlua")|>,
3232
}
3333
|>]]
34-
--[[#type META.@Self = {
34+
--[[#type META.@SelfArgument = {
3535
Code = any,
3636
ParentSourceLine = string,
3737
ParentSourceName = string,

nattlua/emitter/base.lua

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -22,24 +22,24 @@ local B = string.byte
2222
--[[#local type EmitterConfig = import("~/nattlua/emitter/config.nlua")]]
2323
return function()
2424
local META = class.CreateTemplate("emitter")
25-
--[[#type META.@Self.toggled_indents = Map<|string, true | nil|>]]
26-
--[[#type META.@Self.last_indent_index = nil | number]]
27-
--[[#type META.@Self.level = number]]
28-
--[[#type META.@Self.out = List<|string|>]]
29-
--[[#type META.@Self.i = number]]
30-
--[[#type META.@Self.config = EmitterConfig]]
31-
--[[#type META.@Self.last_non_space_index = false | number]]
32-
--[[#type META.@Self.last_newline_index = nil | number]]
33-
--[[#type META.@Self.force_newlines = nil | List<|boolean|>]]
34-
--[[#type META.@Self.during_comment_type = false | number]]
35-
--[[#type META.@Self.is_call_expression = boolean]]
36-
--[[#type META.@Self.inside_call_expression = boolean]]
37-
--[[#type META.@Self.OnEmitStatement = false | Function]]
38-
--[[#type META.@Self.loop_nodes = false | List<|Node|>]]
39-
--[[#type META.@Self.tracking_indents = nil | Map<|string, List<|{info = any, level = number}|>|>]]
40-
--[[#type META.@Self.done = nil | Map<|string, true|>]]
41-
--[[#type META.@Self.FFI_DECLARATION_EMITTER = false | any]]
42-
--[[#type META.@Self.pre_toggle_level = nil | number]]
25+
--[[#type META.@SelfArgument.toggled_indents = Map<|string, true | nil|>]]
26+
--[[#type META.@SelfArgument.last_indent_index = nil | number]]
27+
--[[#type META.@SelfArgument.level = number]]
28+
--[[#type META.@SelfArgument.out = List<|string|>]]
29+
--[[#type META.@SelfArgument.i = number]]
30+
--[[#type META.@SelfArgument.config = EmitterConfig]]
31+
--[[#type META.@SelfArgument.last_non_space_index = false | number]]
32+
--[[#type META.@SelfArgument.last_newline_index = nil | number]]
33+
--[[#type META.@SelfArgument.force_newlines = nil | List<|boolean|>]]
34+
--[[#type META.@SelfArgument.during_comment_type = false | number]]
35+
--[[#type META.@SelfArgument.is_call_expression = boolean]]
36+
--[[#type META.@SelfArgument.inside_call_expression = boolean]]
37+
--[[#type META.@SelfArgument.OnEmitStatement = false | Function]]
38+
--[[#type META.@SelfArgument.loop_nodes = false | List<|Node|>]]
39+
--[[#type META.@SelfArgument.tracking_indents = nil | Map<|string, List<|{info = any, level = number}|>|>]]
40+
--[[#type META.@SelfArgument.done = nil | Map<|string, true|>]]
41+
--[[#type META.@SelfArgument.FFI_DECLARATION_EMITTER = false | any]]
42+
--[[#type META.@SelfArgument.pre_toggle_level = nil | number]]
4343

4444
do -- internal
4545
function META:Whitespace(str--[[#: string]], force--[[#: boolean]])
@@ -1462,7 +1462,7 @@ return function()
14621462
end
14631463
end
14641464

1465-
local function general_kind(self--[[#: META.@Self]], node--[[#: Node]])
1465+
local function general_kind(self--[[#: META.@SelfArgument]], node--[[#: Node]])
14661466
if node.Type == "statement_call_expression" then
14671467
for i, v in ipairs(node.value.expressions) do
14681468
if v.Type == "expression_function" then return "other" end

nattlua/lexer/lexer.lua

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,14 +30,14 @@ local IsKeyword = characters.IsKeyword
3030
local IsSymbol = characters.IsSymbol
3131
local META = class.CreateTemplate("lexer")
3232
--[[#type META.@Name = "Lexer"]]
33-
--[[#type META.@Self = {
33+
--[[#type META.@SelfArgument = {
3434
Code = Code,
3535
Position = number,
3636
comment_escape = false | string,
3737
OnError = function=(self: self, code: Code, msg: string, start: number | nil, stop: number | nil)>(),
3838
Config = {} | nil,
3939
}]]
40-
--[[#local type Lexer = META.@Self]]
40+
--[[#local type Lexer = META.@SelfArgument]]
4141

4242
function META:GetLength()--[[#: number]]
4343
return self.Code:GetByteSize()

nattlua/lexer/token.lua

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ local assert = _G.assert
1616
--[[#type META.@Name = "Token"]]
1717
--[[#type META.TokenWhitespaceType = "line_comment" | "multiline_comment" | "comment_escape" | "space"]]
1818
--[[#type META.TokenType = "analyzer_debug_code" | "parser_debug_code" | "letter" | "string" | "number" | "symbol" | "end_of_file" | "shebang" | "unknown" | META.TokenWhitespaceType]]
19-
--[[#type META.@Self = {
19+
--[[#type META.@SelfArgument = {
2020
@Name = "Token",
2121
type = META.TokenType,
2222
sub_type = false | string,
@@ -33,7 +33,7 @@ local assert = _G.assert
3333
is_token = true,
3434
unexpanded_form = any, -- for c preprocessor macros
3535
}]]
36-
--[[#type META.Token = META.@Self]]
36+
--[[#type META.Token = META.@SelfArgument]]
3737

3838
function META:GetRoot()
3939
if self.parent then return (self.parent--[[# as any]]):GetRoot() end
@@ -457,7 +457,7 @@ function META:HasWhitespace()--[[#: boolean]]
457457
return self.whitespace_start ~= nil
458458
end
459459

460-
function META:GetWhitespace()--[[#: List<|META.@Self|>]]
460+
function META:GetWhitespace()--[[#: List<|META.@SelfArgument|>]]
461461
if false--[[# as true]] then return _--[[# as List<|META.Token|>]] end -- TODO
462462
if self.whitespace then return self.whitespace end
463463

@@ -531,7 +531,7 @@ function META.New(
531531
start--[[#: number]],
532532
stop--[[#: number]],
533533
whitespace_start--[[#: nil | number]]
534-
)--[[#: META.@Self]]
534+
)--[[#: META.@SelfArgument]]
535535
return META.NewObject(
536536
{
537537
type = type,
@@ -541,7 +541,7 @@ function META.New(
541541
start = start,
542542
stop = stop,
543543
whitespace_start = whitespace_start,
544-
}--[[# as META.@Self]]
544+
}--[[# as META.@SelfArgument]]
545545
)
546546
end
547547

@@ -550,15 +550,15 @@ function META.NewVirtualToken(
550550
value--[[#: string]],
551551
start--[[#: number]],
552552
stop--[[#: number]]
553-
)--[[#: META.@Self]]
553+
)--[[#: META.@SelfArgument]]
554554
return META.NewObject(
555555
{
556556
type = type,
557557
sub_type = value,
558558
value = value,
559559
start = start,
560560
stop = stop,
561-
}--[[# as META.@Self]]
561+
}--[[# as META.@SelfArgument]]
562562
)
563563
end
564564

0 commit comments

Comments
 (0)