add dynfn type for non-cacheable evaluation
s-ol
3 months ago
56 | 56 |
out: '%1',
|
57 | 57 |
cost: 1
|
58 | 58 |
transform: (val, fileder) => val fileder
|
|
59 |
}
|
|
60 |
{
|
|
61 |
inp: 'dynfn -> (.+)',
|
|
62 |
out: '%1',
|
|
63 |
cost: 1,1
|
|
64 |
transform: (val, fileder) => val fileder
|
|
65 |
dynamic: true
|
59 | 66 |
}
|
60 | 67 |
{
|
61 | 68 |
inp: 'mmm/component',
|
154 | 154 |
-- returns converted value
|
155 | 155 |
err_and_trace = (msg) -> debug.traceback msg, 2
|
156 | 156 |
apply_conversions = (fileder, conversions, value, key) ->
|
|
157 |
static = true
|
157 | 158 |
for i=#conversions,1,-1
|
158 | 159 |
refs\push!
|
159 | 160 |
step = conversions[i]
|
160 | 161 |
ok, value = xpcall step.convert.transform, err_and_trace, step, value, fileder, key
|
161 | 162 |
refs\pop!
|
|
163 |
|
|
164 |
if step.convert.dynamic
|
|
165 |
static = false
|
|
166 |
|
162 | 167 |
if not ok
|
163 | 168 |
error "error while converting #{fileder} #{key} from '#{step.from}' to '#{step.to}':\n#{value}"
|
164 | 169 |
|
165 | |
value
|
|
170 |
value, static
|
166 | 171 |
|
167 | 172 |
-- find and apply a conversion path from 'have' to 'want'
|
168 | 173 |
-- * have - start type string or list of type strings
|
282 | 282 |
key, conversions = @find want
|
283 | 283 |
|
284 | 284 |
if key
|
285 | |
value = apply_conversions @, conversions, @facets[key], key
|
286 | |
CACHE\set @, want, value if CACHE
|
|
285 |
value, static = apply_conversions @, conversions, @facets[key], key
|
|
286 |
CACHE\set @, want, value if CACHE and static
|
287 | 287 |
value, key
|
288 | 288 |
|
289 | 289 |
-- like @get, throw if no value or conversion path
|