X Tutup
Skip to content

Commit 06191f0

Browse files
committed
update moonscript.util moon.mtype -> mtype to differentiate between the type function in moon
1 parent 980acd2 commit 06191f0

File tree

8 files changed

+28
-28
lines changed

8 files changed

+28
-28
lines changed

moonscript/cmd/lint.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ Set = require("moonscript.data").Set
55
local Block
66
Block = require("moonscript.compile").Block
77
local mtype
8-
mtype = require("moonscript.util").moon.type
8+
mtype = require("moonscript.util").mtype
99
local default_whitelist = Set({
1010
'_G',
1111
'_VERSION',

moonscript/cmd/lint.moon

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import insert from table
33
import Set from require "moonscript.data"
44
import Block from require "moonscript.compile"
55

6-
{type: mtype} = require("moonscript.util").moon
6+
import mtype from require "moonscript.util"
77

88
-- globals allowed to be referenced
99
default_whitelist = Set {

moonscript/compile.lua

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,8 @@ do
2020
local _obj_0 = table
2121
concat, insert = _obj_0.concat, _obj_0.insert
2222
end
23-
local pos_to_line, get_closest_line, trim, unpack
24-
pos_to_line, get_closest_line, trim, unpack = util.pos_to_line, util.get_closest_line, util.trim, util.unpack
25-
local mtype = util.moon.type
23+
local pos_to_line, get_closest_line, trim, unpack, mtype
24+
pos_to_line, get_closest_line, trim, unpack, mtype = util.pos_to_line, util.get_closest_line, util.trim, util.unpack, util.mtype
2625
local indent_char = " "
2726
local Line, DelayedLine, Lines, Block, RootBlock
2827
do

moonscript/compile.moon

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,7 @@ statement_compilers = require "moonscript.compile.statement"
1111
value_compilers = require "moonscript.compile.value"
1212

1313
import concat, insert from table
14-
import pos_to_line, get_closest_line, trim, unpack from util
15-
16-
mtype = util.moon.type
14+
import pos_to_line, get_closest_line, trim, unpack, mtype from util
1715

1816
indent_char = " "
1917

moonscript/types.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ ntype = function(node)
3636
end
3737
local mtype
3838
do
39-
local moon_type = util.moon.type
39+
local moon_type = util.mtype
4040
mtype = function(val)
4141
local mt = getmetatable(val)
4242
if mt and mt.smart_node then

moonscript/types.moon

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ ntype = (node) ->
3333

3434
-- gets the class of a type if possible
3535
mtype = do
36-
moon_type = util.moon.type
36+
moon_type = util.mtype
3737
-- lets us check a smart node without throwing an error
3838
(val) ->
3939
mt = getmetatable val

moonscript/util.lua

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -16,18 +16,19 @@ local moon = {
1616
return mt and rawget(mt, "__index") == mt and rawget(value, "__index") ~= value
1717
end
1818
return false
19-
end,
20-
type = function(value)
21-
local base_type = type(value)
22-
if base_type == "table" then
23-
local cls = value.__class
24-
if cls and rawget(value, "__class") == nil then
25-
return cls
26-
end
27-
end
28-
return base_type
2919
end
3020
}
21+
local mtype
22+
mtype = function(value)
23+
local base_type = type(value)
24+
if base_type == "table" then
25+
local cls = value.__class
26+
if cls and rawget(value, "__class") == nil then
27+
return cls
28+
end
29+
end
30+
return base_type
31+
end
3132
local pos_to_line
3233
pos_to_line = function(str, pos)
3334
local line = 1
@@ -200,6 +201,7 @@ safe_module = function(name, tbl)
200201
end
201202
return {
202203
moon = moon,
204+
mtype = mtype,
203205
pos_to_line = pos_to_line,
204206
get_closest_line = get_closest_line,
205207
get_line = get_line,

moonscript/util.moon

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -17,15 +17,16 @@ moon = {
1717
return mt and rawget(mt, "__index") == mt and rawget(value, "__index") != value
1818
false
1919

20-
type: (value) -> -- the moonscript object class
21-
base_type = type value
22-
if base_type == "table"
23-
cls = value.__class
24-
if cls and rawget(value, "__class") == nil
25-
return cls
26-
base_type
2720
}
2821

22+
mtype = (value) -> -- the moonscript object class
23+
base_type = type value
24+
if base_type == "table"
25+
cls = value.__class
26+
if cls and rawget(value, "__class") == nil
27+
return cls
28+
base_type
29+
2930
-- convet position in text to line number
3031
pos_to_line = (str, pos) ->
3132
line = 1
@@ -135,7 +136,7 @@ safe_module = (name, tbl) ->
135136
}
136137

137138
{
138-
:moon, :pos_to_line, :get_closest_line, :get_line, :trim, :split, :dump,
139+
:moon, :mtype, :pos_to_line, :get_closest_line, :get_line, :trim, :split, :dump,
139140
:debug_posmap, :getfenv, :setfenv, :get_options, :unpack, :safe_module
140141
}
141142

0 commit comments

Comments
 (0)
X Tutup