1
1
mirror of https://github.com/github/semantic.git synced 2024-11-25 11:04:00 +03:00

Recursive constructors close over a/b instead of passing them.

This commit is contained in:
Rob Rix 2015-10-21 16:52:49 -04:00
parent 2c542fbd66
commit f92daa8aeb

View File

@ -59,7 +59,7 @@
function Term(json, source) { function Term(json, source) {
this.range = json.extract; this.range = json.extract;
this.syntax = syntax(json.unwrap, null, null, function(x) { return new Term(x, source); }); this.syntax = syntax(json.unwrap, function(x) { return new Term(x, source); });
return this; return this;
} }
@ -155,15 +155,15 @@
return this; return this;
} }
function syntax(json, a, b, continuation) { function syntax(json, continuation) {
if (json instanceof Array) { return new Indexed(json, a, b, continuation); } if (json instanceof Array) { return new Indexed(json, continuation); }
if (json instanceof Object) { return new Keyed(json, a, b, continuation); } if (json instanceof Object) { return new Keyed(json, continuation); }
return new Leaf(json, a, b); return new Leaf(json);
} }
function Diff(json, a, b) { function Diff(json, a, b) {
if (json.pure != null) { this.pure = patch(json.pure, a, b); } if (json.pure != null) { this.pure = patch(json.pure, a, b); }
if (json.roll != null) { this.roll = syntax(json.roll, a, b, function(x, a, b) { return new Diff(x, a, b); }); } if (json.roll != null) { this.roll = syntax(json.roll, function(x) { return new Diff(x, a, b); }); }
return this; return this;
} }
</script> </script>