summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorGravatar Adam Chlipala <adamc@hcoop.net>2009-04-04 14:03:39 -0400
committerGravatar Adam Chlipala <adamc@hcoop.net>2009-04-04 14:03:39 -0400
commitcfcc0c0553a13a83cf674b00828c89b6f9459936 (patch)
treef845ffce49085952ab6313d30ed7d977dc2ab8d6 /lib
parent8e8c217003dcda28e14b330039062d9bf8463e64 (diff)
_Really_ implement embedded closure GC; extend Scriptcheck to figure out when client IDs must be assigned
Diffstat (limited to 'lib')
-rw-r--r--lib/js/urweb.js30
1 files changed, 21 insertions, 9 deletions
diff --git a/lib/js/urweb.js b/lib/js/urweb.js
index fe996833..de956d3f 100644
--- a/lib/js/urweb.js
+++ b/lib/js/urweb.js
@@ -22,11 +22,19 @@ function union(ls1, ls2) {
// Embedding closures in XML strings
+function cs(f) {
+ return {closure: f};
+}
+
+function isWeird(v) {
+ return v.closure != null || v.cat1 != null;
+}
+
function cat(s1, s2) {
- if (s1.length && s2.length)
- return s1 + s2;
+ if (isWeird(s1) || isWeird(s2))
+ return {cat1: s1, cat2: s2};
else
- return {_1: s1, _2: s2};
+ return s1 + s2;
}
var closures = [];
@@ -42,12 +50,12 @@ function cr(n) {
}
function flatten(tr) {
- if (tr.length)
- return tr;
- else if (tr._1)
- return cs(tr._1) + cs(tr._2);
+ if (tr.cat1 != null)
+ return flatten(tr.cat1) + flatten(tr.cat2);
+ else if (tr.closure != null)
+ return "cr(" + newClosure(tr.closure) + ")";
else
- return "cr(" + newClosure(tr) + ")";
+ return tr;
}
function clearClosures() {
@@ -157,7 +165,7 @@ function dyn(s) {
ls.data.dyns = remove(span, ls.data.dyns);
}
- x.innerHTML = v;
+ x.innerHTML = flatten(v);
runScripts(x);
if (--dynDepth == 0)
@@ -412,3 +420,7 @@ function rv(chn, parse, k) {
k(parse(msg))(null);
}
}
+
+
+// App-specific code
+