allow top-level input in Op.inputs
s-ol
1 year, 12 days ago
139 | 139 | new: (@out, @state) => |
140 | 140 | |
141 | 141 | do_setup = (old, cur) -> |
142 | for k, cur_val in pairs cur | |
143 | old_val = old and old[k] | |
142 | -- are these inputs or nested tables? | |
143 | old_plain = old and not old.__class | |
144 | cur_plain = cur and not cur.__class | |
144 | 145 | |
145 | -- are these inputs or nested tables? | |
146 | cur_plain = cur_val and not cur_val.__class | |
147 | old_plain = old_val and not old_val.__class | |
146 | if cur_plain | |
147 | -- both are tables, recurse | |
148 | for k, cur_nest in pairs cur | |
149 | do_setup (old and old[k]), cur_nest | |
150 | elseif cur and not (cur_plain or old_plain) | |
151 | -- both are streams (or nil), setup them | |
152 | cur\setup old | |
148 | 153 | |
149 | if cur_plain | |
150 | -- both are tables, recurse | |
151 | do_setup old_val, cur_val | |
152 | elseif not (cur_plain or old_plain) | |
153 | -- both are streams (or nil), setup them | |
154 | cur_val\setup old_val | |
155 | 154 | --- setup previous `inputs`, if any, with the new inputs, and write them to |
156 | 155 | -- `inputs`. The `inputs` table can be nested with string or integer keys, |
157 | 156 | -- but all leaf-entries must be `Input` instances. It must not contain loops |