Mercurial > urweb
comparison lib/js/urweb.js @ 977:2ecf308772ba
Might have fixed demo/listEdit
author | Adam Chlipala <adamc@hcoop.net> |
---|---|
date | Thu, 24 Sep 2009 07:52:57 -0400 |
parents | 68eda5b0636d |
children | e1f3f1ea8cff |
comparison
equal
deleted
inserted
replaced
976:68eda5b0636d | 977:2ecf308772ba |
---|---|
113 } | 113 } |
114 | 114 |
115 var disconnectHandlers = null; | 115 var disconnectHandlers = null; |
116 | 116 |
117 function flift(f) { | 117 function flift(f) { |
118 return {c:"l", b:f}; | 118 return {env:cons(f,null), body:{c:"v", n:1}}; |
119 } | 119 } |
120 | 120 |
121 function onDisconnect(f) { | 121 function onDisconnect(f) { |
122 disconnectHandlers = cons(flift(f), disconnectHandlers); | 122 disconnectHandlers = cons(flift(f), disconnectHandlers); |
123 } | 123 } |
215 | 215 |
216 function populate(node) { | 216 function populate(node) { |
217 var s = node.signal; | 217 var s = node.signal; |
218 var oldSources = node.sources; | 218 var oldSources = node.sources; |
219 try { | 219 try { |
220 var sr = exec0(s.env, s.body); | 220 var sr = execF(s, null); |
221 var newSources = sr._sources; | 221 var newSources = sr._sources; |
222 | 222 |
223 for (var sp = oldSources; sp; sp = sp.next) | 223 for (var sp = oldSources; sp; sp = sp.next) |
224 if (!member(sp.data, newSources)) | 224 if (!member(sp.data, newSources)) |
225 sp.data.dyns = remove(node, sp.data.dyns); | 225 sp.data.dyns = remove(node, sp.data.dyns); |
258 return {env:null, body:{c:"c", v:{_sources : null, _data : v}}}; | 258 return {env:null, body:{c:"c", v:{_sources : null, _data : v}}}; |
259 } | 259 } |
260 function sb(x,y) { | 260 function sb(x,y) { |
261 return {env:cons(y,cons(x,null)), | 261 return {env:cons(y,cons(x,null)), |
262 body:{c:"=", | 262 body:{c:"=", |
263 e1:{c:"a", f:{c:"v", n:1}, x:{c:"c", v:null}}, | 263 e1:{c:"a", f:{c:"v", n:2}, x:{c:"c", v:null}}, |
264 e2:{c:"=", | 264 e2:{c:"=", |
265 e1:{c:"a", | 265 e1:{c:"a", |
266 f:{c:"a", f:{c:"v", n:1}, x:{c:".", r:{c:"v", n:0}, f:"data"}}, | 266 f:{c:"a", f:{c:"v", n:2}, x:{c:".", r:{c:"v", n:0}, f:"data"}}, |
267 x:{c:"c", v:null}}, | 267 x:{c:"c", v:null}}, |
268 e2:{c:"r", l:cons( | 268 e2:{c:"r", l:cons( |
269 {n:"sources", v:{c:"f", f:union, a:cons({c:".", r:{c:"v", n:1}, f:"sources"}, | 269 {n:"sources", v:{c:"f", f:union, a:cons({c:".", r:{c:"v", n:1}, f:"sources"}, |
270 cons({c:".", r:{c:"v", n:0}, f:"sources"}, null))}}, | 270 cons({c:".", r:{c:"v", n:0}, f:"sources"}, null))}}, |
271 cons({n:"data", v:{c:".", r:{c:"v", n:0}, f:"data"}}, null))}}}}; | 271 cons({n:"data", v:{c:".", r:{c:"v", n:0}, f:"data"}}, null))}}}}; |
631 isok = true; | 631 isok = true; |
632 } catch (e) { } | 632 } catch (e) { } |
633 | 633 |
634 if (isok) { | 634 if (isok) { |
635 try { | 635 try { |
636 k(parse(xhr.responseText)); | 636 execF(k, parse(xhr.responseText)); |
637 } catch (v) { | 637 } catch (v) { |
638 doExn(v); | 638 doExn(v); |
639 } | 639 } |
640 } else { | 640 } else { |
641 conn(); | 641 conn(); |
781 var msg = dequeue(ch.msgs); | 781 var msg = dequeue(ch.msgs); |
782 if (msg == null) { | 782 if (msg == null) { |
783 enqueue(ch.listeners, function(msg) { k(parse(msg))(null); }); | 783 enqueue(ch.listeners, function(msg) { k(parse(msg))(null); }); |
784 } else { | 784 } else { |
785 try { | 785 try { |
786 k(parse(msg))(null); | 786 execF(execF(k, parse(msg)), null); |
787 } catch (v) { | 787 } catch (v) { |
788 doExn(v); | 788 doExn(v); |
789 } | 789 } |
790 } | 790 } |
791 } | 791 } |
1023 return function(v) { return exec0(cons(v, r.env), r.body); }; | 1023 return function(v) { return exec0(cons(v, r.env), r.body); }; |
1024 else | 1024 else |
1025 return r; | 1025 return r; |
1026 } | 1026 } |
1027 | 1027 |
1028 function execF(f, x) { | |
1029 return exec0(cons(x, f.env), f.body); | |
1030 } | |
1031 | |
1028 | 1032 |
1029 // App-specific code | 1033 // App-specific code |
1030 | 1034 |