Mercurial > urweb
comparison lib/js/urweb.js @ 982:6934343267c0
Grid1 seems to work in latest Firefox
author | Adam Chlipala <adamc@hcoop.net> |
---|---|
date | Thu, 24 Sep 2009 15:36:44 -0400 |
parents | 3612ff0c6a10 |
children | 2cd8c1aa0d3a |
comparison
equal
deleted
inserted
replaced
981:27a3412d23e4 | 982:6934343267c0 |
---|---|
208 } | 208 } |
209 | 209 |
210 | 210 |
211 | 211 |
212 // Dynamic tree management | 212 // Dynamic tree management |
213 | |
214 var trace = ""; | |
215 | 213 |
216 function populate(node) { | 214 function populate(node) { |
217 var s = node.signal; | 215 var s = node.signal; |
218 var oldSources = node.sources; | 216 var oldSources = node.sources; |
219 try { | 217 try { |
269 {n:"sources", v:{c:"f", f:union, a:cons({c:".", r:{c:"v", n:1}, f:"sources"}, | 267 {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))}}, | 268 cons({c:".", r:{c:"v", n:0}, f:"sources"}, null))}}, |
271 cons({n:"data", v:{c:".", r:{c:"v", n:0}, f:"data"}}, null))}}}}; | 269 cons({n:"data", v:{c:".", r:{c:"v", n:0}, f:"data"}}, null))}}}}; |
272 } | 270 } |
273 function scur(s) { | 271 function scur(s) { |
274 return exec(s).data; | 272 return execF(s, null)._data; |
275 } | 273 } |
276 | 274 |
277 function lastParent() { | 275 function lastParent() { |
278 var pos = document; | 276 var pos = document; |
279 | 277 |
564 } else if (tok == "Cons") { | 562 } else if (tok == "Cons") { |
565 var d = getData(); | 563 var d = getData(); |
566 var l = uul(getToken, getData); | 564 var l = uul(getToken, getData); |
567 return {_1:d, _2:l}; | 565 return {_1:d, _2:l}; |
568 } else | 566 } else |
569 throw ("Can't unmarshal list (" + tok + ")"); | 567 whine("Can't unmarshal list (" + tok + ")"); |
570 } | 568 } |
571 | 569 |
572 function strcmp(str1, str2) { | 570 function strcmp(str1, str2) { |
573 return ((str1 == str2) ? 0 : ((str1 > str2) ? 1 : -1)); | 571 return ((str1 == str2) ? 0 : ((str1 > str2) ? 1 : -1)); |
574 } | 572 } |
590 return new ActiveXObject("Msxml2.XMLHTTP"); | 588 return new ActiveXObject("Msxml2.XMLHTTP"); |
591 } catch (e) { | 589 } catch (e) { |
592 try { | 590 try { |
593 return new ActiveXObject("Microsoft.XMLHTTP"); | 591 return new ActiveXObject("Microsoft.XMLHTTP"); |
594 } catch (e) { | 592 } catch (e) { |
595 throw "Your browser doesn't seem to support AJAX."; | 593 whine("Your browser doesn't seem to support AJAX."); |
596 } | 594 } |
597 } | 595 } |
598 } | 596 } |
599 } | 597 } |
600 | 598 |
817 --n; | 815 --n; |
818 env = env.next; | 816 env = env.next; |
819 } | 817 } |
820 } | 818 } |
821 | 819 |
822 throw "Out-of-bounds Ur variable reference"; | 820 whine("Out-of-bounds Ur variable reference"); |
823 } | 821 } |
824 | 822 |
825 function execP(env, p, v) { | 823 function execP(env, p, v) { |
826 switch (p.c) { | 824 switch (p.c) { |
827 case "w": | 825 case "w": |
849 if (env == false) | 847 if (env == false) |
850 return false; | 848 return false; |
851 } | 849 } |
852 return env; | 850 return env; |
853 default: | 851 default: |
854 throw ("Unknown Ur pattern kind" + p.c); | 852 whine("Unknown Ur pattern kind" + p.c); |
855 } | 853 } |
856 } | 854 } |
857 | 855 |
858 function exec0(env, e) { | 856 function exec0(env, e) { |
859 var stack = null; | 857 var stack = null; |
879 fr.args[fr.pos++] = v; | 877 fr.args[fr.pos++] = v; |
880 if (fr.a == null) { | 878 if (fr.a == null) { |
881 e = {c: "c", v: fr.f.apply(null, fr.args)}; | 879 e = {c: "c", v: fr.f.apply(null, fr.args)}; |
882 stack = stack.next; | 880 stack = stack.next; |
883 } else { | 881 } else { |
884 trace += "" + fr.pos; | |
885 e = fr.a.data; | 882 e = fr.a.data; |
886 fr.a = fr.a.next; | 883 fr.a = fr.a.next; |
887 } | 884 } |
888 break; | 885 break; |
889 case "a1": | 886 case "a1": |
890 e = fr.x; | 887 e = fr.x; |
891 stack = cons({c: "a2", f: v}, stack.next); | 888 stack = cons({c: "a2", f: v}, stack.next); |
892 break; | 889 break; |
893 case "a2": | 890 case "a2": |
894 if (fr.f == null) | 891 if (fr.f == null) |
895 throw "Ur: applying null function"; | 892 whine("Ur: applying null function"); |
896 else if (fr.f.body) { | 893 else if (fr.f.body) { |
897 stack = cons({c: "<", env: env}, stack.next); | 894 stack = cons({c: "<", env: env}, stack.next); |
898 env = cons(v, fr.f.env); | 895 env = cons(v, fr.f.env); |
899 e = fr.f.body; | 896 e = fr.f.body; |
900 } else { | 897 } else { |
940 e = ps.data.b; | 937 e = ps.data.b; |
941 break; | 938 break; |
942 } | 939 } |
943 } | 940 } |
944 if (ps == null) | 941 if (ps == null) |
945 throw "Match failure in Ur interpretation"; | 942 whine("Match failure in Ur interpretation"); |
946 break; | 943 break; |
947 default: | 944 default: |
948 throw ("Unknown Ur continuation kind " + fr.c); | 945 whine("Unknown Ur continuation kind " + fr.c); |
949 } | 946 } |
950 | 947 |
951 break; | 948 break; |
952 case "v": | 949 case "v": |
953 e = {c: "c", v: lookup(env, e.n)}; | 950 e = {c: "c", v: lookup(env, e.n)}; |
967 if (e.a == null) | 964 if (e.a == null) |
968 e = {c: "c", v: e.f()}; | 965 e = {c: "c", v: e.f()}; |
969 else { | 966 else { |
970 var args = []; | 967 var args = []; |
971 stack = cons({c: "f", f: e.f, args: args, pos: 0, a: e.a.next}, stack); | 968 stack = cons({c: "f", f: e.f, args: args, pos: 0, a: e.a.next}, stack); |
969 if (!e.a.data.c) alert("[2] fr.f = " + e.f + "; 0 = " + e.a.data); | |
972 e = e.a.data; | 970 e = e.a.data; |
973 } | 971 } |
974 break; | 972 break; |
975 case "l": | 973 case "l": |
976 e = {c: "c", v: {env: env, body: e.b}}; | 974 e = {c: "c", v: {env: env, body: e.b}}; |
979 stack = cons({c: "a1", x: e.x}, stack); | 977 stack = cons({c: "a1", x: e.x}, stack); |
980 e = e.f; | 978 e = e.f; |
981 break; | 979 break; |
982 case "r": | 980 case "r": |
983 if (e.l == null) | 981 if (e.l == null) |
984 throw "Empty Ur record in interpretation"; | 982 whine("Empty Ur record in interpretation"); |
985 var fs = {}; | 983 var fs = {}; |
986 stack = cons({c: "r", n: e.l.data.n, fs: fs, l: e.l.next}, stack); | 984 stack = cons({c: "r", n: e.l.data.n, fs: fs, l: e.l.next}, stack); |
987 e = e.l.data.v; | 985 e = e.l.data.v; |
988 break; | 986 break; |
989 case ".": | 987 case ".": |
1008 case "wc": | 1006 case "wc": |
1009 env = e.env; | 1007 env = e.env; |
1010 e = e.body; | 1008 e = e.body; |
1011 break; | 1009 break; |
1012 default: | 1010 default: |
1013 throw ("Unknown Ur expression kind " + e.c); | 1011 whine("Unknown Ur expression kind " + e.c); |
1014 } | 1012 } |
1015 } | 1013 } |
1016 } | 1014 } |
1017 | 1015 |
1018 function execD(e) { | 1016 function execD(e) { |