From 0055f2fdb169788a7796821d20c7fba2230ea9ae Mon Sep 17 00:00:00 2001 From: Li Jin Date: Mon, 14 Mar 2022 13:46:17 +0800 Subject: fix more cases that global values are not being cached. --- spec/inputs/cond.yue | 11 +++++++++++ spec/inputs/with.yue | 13 +++++++++++++ spec/outputs/cond.lua | 22 ++++++++++++++++++++++ spec/outputs/with.lua | 37 +++++++++++++++++++++++++++++++++---- 4 files changed, 79 insertions(+), 4 deletions(-) (limited to 'spec') diff --git a/spec/inputs/cond.yue b/spec/inputs/cond.yue index 42b22a7..773ef91 100644 --- a/spec/inputs/cond.yue +++ b/spec/inputs/cond.yue @@ -208,6 +208,17 @@ do if :pi = math print pi +do + if _M = {} + :Thing = _M + :a, :b = _M + +do + global _M + if _M = {} + :Thing = _M + :a, :b = _M + nil diff --git a/spec/inputs/with.yue b/spec/inputs/with.yue index d88e109..fe140ac 100644 --- a/spec/inputs/with.yue +++ b/spec/inputs/with.yue @@ -121,3 +121,16 @@ do with dad .if "yes" y = .end.of.function + +do + global mask + with? mask = SolidRect width: w, height: h, color: 0x66000000 + .touchEnabled = true + .swallowTouches = true + +do + with? mask = SolidRect width: w, height: h, color: 0x66000000 + .touchEnabled = true + .swallowTouches = true + +nil diff --git a/spec/outputs/cond.lua b/spec/outputs/cond.lua index 4dc5aa5..178bf9b 100644 --- a/spec/outputs/cond.lua +++ b/spec/outputs/cond.lua @@ -313,4 +313,26 @@ do print(pi) end end +do + do + local _M = { } + if _M then + local Thing = _M.Thing + a, b = _M.a, _M.b + end + end +end +do + do + local _des_0 = { } + if _des_0 then + _M = _des_0 + local Thing = _M.Thing + do + local _obj_0 = _M + a, b = _obj_0.a, _obj_0.b + end + end + end +end return nil diff --git a/spec/outputs/with.lua b/spec/outputs/with.lua index e1497c6..f172b01 100644 --- a/spec/outputs/with.lua +++ b/spec/outputs/with.lua @@ -157,8 +157,37 @@ do end end do - local _with_0 = dad - _with_0["if"]("yes") - local y = _with_0["end"].of["function"] - return _with_0 + do + local _with_0 = dad + _with_0["if"]("yes") + local y = _with_0["end"].of["function"] + end +end +do + do + local _with_0 = SolidRect({ + width = w, + height = h, + color = 0x66000000 + }) + mask = _with_0 + if _with_0 ~= nil then + _with_0.touchEnabled = true + _with_0.swallowTouches = true + end + end +end +do + do + local mask = SolidRect({ + width = w, + height = h, + color = 0x66000000 + }) + if mask ~= nil then + mask.touchEnabled = true + mask.swallowTouches = true + end + end end +return nil -- cgit v1.2.3-55-g6feb