add bindingEquals, typeEquals, referenceEquals helper methods to Scope
This commit is contained in:
parent
399d835285
commit
a6d1a5a724
@ -24,8 +24,8 @@ var visitor = {
|
|||||||
// constant so we can just ignore it
|
// constant so we can just ignore it
|
||||||
if (id === constant) continue;
|
if (id === constant) continue;
|
||||||
|
|
||||||
var localBinding = scope.getBinding(key);
|
// check if there's been a local binding that shadows this constant
|
||||||
if (localBinding !== constant) continue;
|
if (scope.bindingEquals(key, constant)) continue;
|
||||||
|
|
||||||
throw state.file.errorWithNode(id, key + " is read-only");
|
throw state.file.errorWithNode(id, key + " is read-only");
|
||||||
}
|
}
|
||||||
|
|||||||
@ -492,6 +492,10 @@ each({
|
|||||||
binding: "Binding",
|
binding: "Binding",
|
||||||
type: "Type"
|
type: "Type"
|
||||||
}, function (title, type) {
|
}, function (title, type) {
|
||||||
|
Scope.prototype[type + "Equals"] = function (id, node) {
|
||||||
|
return this["get" + title](id) === node;
|
||||||
|
};
|
||||||
|
|
||||||
each([
|
each([
|
||||||
"get",
|
"get",
|
||||||
"has",
|
"has",
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user