aboutsummaryrefslogtreecommitdiff
path: root/spec/outputs/metatable.lua
diff options
context:
space:
mode:
authorLi Jin <dragon-fly@qq.com>2022-09-08 09:26:49 +0800
committerLi Jin <dragon-fly@qq.com>2022-09-08 09:26:49 +0800
commitd4af1fa275b1d27229fc995f4a45137380040933 (patch)
tree955c76511d7021e6d1a0f06b46de3852eeac4176 /spec/outputs/metatable.lua
parentdf85ad2e7f975026ca1e6bd84b26fff81c8d99c8 (diff)
downloadyuescript-d4af1fa275b1d27229fc995f4a45137380040933.tar.gz
yuescript-d4af1fa275b1d27229fc995f4a45137380040933.tar.bz2
yuescript-d4af1fa275b1d27229fc995f4a45137380040933.zip
redesigned metatable syntax. add support for destructuring a field with string and expression
Diffstat (limited to 'spec/outputs/metatable.lua')
-rw-r--r--spec/outputs/metatable.lua33
1 files changed, 33 insertions, 0 deletions
diff --git a/spec/outputs/metatable.lua b/spec/outputs/metatable.lua
index 6f5ceed..937136f 100644
--- a/spec/outputs/metatable.lua
+++ b/spec/outputs/metatable.lua
@@ -111,4 +111,37 @@ do
111 ctor, update = _obj_0.new, _obj_0.update 111 ctor, update = _obj_0.new, _obj_0.update
112 end 112 end
113end 113end
114local tb = { }
115do
116 do
117 local _obj_0 = getmetatable(tb)
118 f = _obj_0["value" .. tostring(x < y)](_obj_0, 123, ...)
119 end
120 f((function(...)
121 local _obj_0 = getmetatable(tb)
122 return _obj_0['value'](_obj_0, 123, ...)
123 end)(...))
124 do
125 local _obj_0 = getmetatable(tb)
126 _obj_0[ [[ value
127 1
128 ]]](_obj_0, 123, ...)
129 end
130 local _obj_0 = getmetatable(tb)
131 return _obj_0["value" .. tostring(x > y)](_obj_0, 123, ...)
132end
133do
134 f = getmetatable(tb):__value(123, ...)
135 f(getmetatable(tb):__value(123, ...))
136 getmetatable(tb):__value(123, ...)
137 return getmetatable(tb):__value(123, ...)
138end
139do
140 f = getmetatable(tb).__value(123, ...)
141 f = getmetatable(tb)["value" .. tostring(x < y)](123, ...)
142 f(getmetatable(tb)['value'](123, ...))
143 getmetatable(tb)[ [[ value
1441]]](123, ...)
145 return getmetatable(tb)["value" .. tostring(x > y)](123, ...)
146end
114return nil 147return nil