diff options
author | Li Jin <dragon-fly@qq.com> | 2022-09-08 09:26:49 +0800 |
---|---|---|
committer | Li Jin <dragon-fly@qq.com> | 2022-09-08 09:26:49 +0800 |
commit | d4af1fa275b1d27229fc995f4a45137380040933 (patch) | |
tree | 955c76511d7021e6d1a0f06b46de3852eeac4176 /spec/outputs/metatable.lua | |
parent | df85ad2e7f975026ca1e6bd84b26fff81c8d99c8 (diff) | |
download | yuescript-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.lua | 33 |
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 |
113 | end | 113 | end |
114 | local tb = { } | ||
115 | do | ||
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, ...) | ||
132 | end | ||
133 | do | ||
134 | f = getmetatable(tb):__value(123, ...) | ||
135 | f(getmetatable(tb):__value(123, ...)) | ||
136 | getmetatable(tb):__value(123, ...) | ||
137 | return getmetatable(tb):__value(123, ...) | ||
138 | end | ||
139 | do | ||
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 | ||
144 | 1]]](123, ...) | ||
145 | return getmetatable(tb)["value" .. tostring(x > y)](123, ...) | ||
146 | end | ||
114 | return nil | 147 | return nil |