aboutsummaryrefslogtreecommitdiff
path: root/lib/scope.js
diff options
context:
space:
mode:
Diffstat (limited to 'lib/scope.js')
-rw-r--r--lib/scope.js8
1 files changed, 6 insertions, 2 deletions
diff --git a/lib/scope.js b/lib/scope.js
index b40807fa..131235f6 100644
--- a/lib/scope.js
+++ b/lib/scope.js
@@ -194,7 +194,7 @@ AST_Toplevel.DEFMETHOD("figure_out_scope", function(options) {
if (node instanceof AST_SymbolCatch) {
var scope = node.thedef.defun;
if (scope.name instanceof AST_SymbolLambda && scope.name.name == node.name) {
- scope = scope.parent_scope;
+ scope = scope.parent_scope.resolve();
}
redefine(node, scope);
return true;
@@ -202,7 +202,11 @@ AST_Toplevel.DEFMETHOD("figure_out_scope", function(options) {
if (node instanceof AST_SymbolLambda) {
var def = node.thedef;
redefine(node, node.scope.parent_scope.resolve());
- if (def.init) node.thedef.init = def.init;
+ if (typeof node.thedef.init !== "undefined") {
+ node.thedef.init = false;
+ } else if (def.init) {
+ node.thedef.init = def.init;
+ }
return true;
}
}));
sOf (node) { return links.filter(function (e) { return e.source === node; }).map(function (e) { return e.target; }); } function zoomed () { zoomer.attr("transform", "translate(" + d3.event.translate + ")" + "scale(" + d3.event.scale + ")"); } function fade (opacity, root) { return function (g, i) { root.selectAll("g path.chord") .filter(function (d) { return d.source.index != i && d.target.index != i; }) .transition() .style("opacity", opacity); }; } // Now that we have all nodes in an object we can replace each reference // with the actual node object. links.forEach(function (link) { link.target = nodes[link.target]; link.source = nodes[link.source]; }); // Construct a square matrix for package dependencies nodeArray.forEach(function (d, index, arr) { var source = index, row = matrix[source]; if (!row) { row = matrix[source] = []; for (var i = -1; ++i < arr.length;) row[i] = 0; } neighborsOf(d).forEach(function (d) { row[d.index]++; }); }); // chord layout var chord = d3.layout.chord() .padding(0.01) .sortSubgroups(d3.descending) .sortChords(d3.descending) .matrix(matrix); var arc = d3.svg.arc() .innerRadius(innerRadius) .outerRadius(innerRadius + 20); var zoom = d3.behavior.zoom() .scaleExtent([0.1, 10]) .on("zoom", zoomed); var svg = d3.select("body").append("svg") .attr("width", "100%") .attr("height", "100%") .attr('viewBox', '0 0 ' + Math.min(width, height) + ' ' + Math.min(width, height)) .attr('preserveAspectRatio', 'xMinYMin') .call(zoom); var zoomer = svg.append("g"); var container = zoomer.append("g") .attr("transform", "translate(" + outerRadius + "," + outerRadius + ")"); // Group for arcs and labels var g = container.selectAll(".group") .data(chord.groups) .enter().append("g") .attr("class", "group") .on("mouseout", fade(1, container)) .on("mouseover", fade(0.1, container)); // Draw one segment per package g.append("path") .style("fill", function (d) { return colors(d.index); }) .style("stroke", function (d) { return colors(d.index); }) .attr("d", arc); // Add circular labels g.append("text") .each(function (d) { d.angle = (d.startAngle + d.endAngle) / 2; }) .attr("dy", ".35em") .attr("transform", function (d) { return "rotate(" + (d.angle * 180 / Math.PI - 90) + ")" + "translate(" + (innerRadius + 26) + ")" + (d.angle > Math.PI ? "rotate(180)" : ""); }) .style("text-anchor", function (d) { return d.angle > Math.PI ? "end" : null; }) .text(function (d) { return nodeArray[d.index].label; }); // Draw chords from source to target; color by source. container.selectAll(".chord") .data(chord.chords) .enter().append("path") .attr("class", "chord") .style("stroke", function (d) { return d3.rgb(colors(d.source.index)).darker(); }) .style("fill", function (d) { return colors(d.source.index); }) .attr("d", d3.svg.chord().radius(innerRadius));