$documentation: "Symbol naming the exception in catch",
}, AST_SymbolDeclaration);
-var AST_Label = DEFNODE("Label", "label_target", {
+var AST_Label = DEFNODE("Label", "references label_target", {
$documentation: "Symbol naming a label (declaration)",
}, AST_SymbolDeclaration);
node.scope = scope;
}
if (node instanceof AST_Label) {
+ node.thedef = node;
node.init_scope_vars();
var p = tw.parent(); // AST_LabeledStatement
var block = p.body;
}
if (node instanceof AST_LabelRef) {
var sym = labels[node.name];
- if (!sym) throw new Error("Undefined label " + node.name);
- node.reference(sym);
+ if (!sym) throw new Error(string_template("Undefined label {name} [{line},{col}]", {
+ name: node.name,
+ line: node.start.line,
+ col: node.start.col
+ }));
+ node.thedef = sym;
}
});
self.walk(tw);
func = prev_func;
return true;
}
+ if (node instanceof AST_LabelRef) {
+ node.reference();
+ return true;
+ }
if (node instanceof AST_SymbolRef) {
var name = node.name;
var sym = node.scope.find_variable(name);
this.references = [];
});
-AST_LabelRef.DEFMETHOD("reference", function(def){
- this.thedef = def;
- def.references.push(this);
+AST_LabelRef.DEFMETHOD("reference", function(){
+ this.thedef.references.push(this);
});
AST_Scope.DEFMETHOD("find_variable", function(name){