scope-tree
Version:
Module scope tree for CodeInspector
40 lines (34 loc) • 1.92 kB
JavaScript
module.exports.__fsLocationMap = [[1, 8, 3, 1], [1, 14, 3, 7], [2, 5, 4, 3], [3, 9, 5, 5], [3, 14, 5, 10], [3, 22, 5, 18], [3, 26, 5, 22], [5, 5, 8, 3], [6, 9, 10, 5], [6, 16, 10, 12], [6, 21, 10, 17], [6, 27, 10, 23], [6, 31, 10, 27], [6, 40, 10, 36], [8, 5, 13, 3], [9, 9, 15, 5], [9, 16, 15, 12], [9, 21, 15, 17], [9, 27, 15, 23], [9, 31, 15, 27], [11, 5, 18, 3], [12, 9, 20, 5], [12, 12, 20, 9], [12, 17, 20, 14], [12, 23, 20, 20], [12, 27, 20, 24], [13, 13, 21, 7], [13, 20, 21, 14], [13, 25, 21, 19], [13, 31, 21, 25], [13, 35, 21, 29], [14, 9, 22, 7], [14, 14, 22, 16], [14, 19, 22, 21], [15, 13, 23, 7], [15, 20, 23, 14], [15, 25, 23, 19], [15, 37, 23, 31], [15, 44, 23, 38], [16, 9, 24, 7], [17, 13, 25, 7], [17, 20, 25, 14], [19, 5, 29, 3], [20, 9, 31, 5], [20, 14, 31, 10], [20, 28, 31, 24], [22, 5, 34, 3], [22, 14, 34, 12], [23, 9, 35, 5], [23, 16, 35, 12], [23, 21, 35, 17], [23, 27, 35, 23], [23, 35, 35, 31], [1, 14, 38, 16], [1, 14, 38, 24]];
module.exports.__esModule = true;
const FirescriptRuntime = require('firescript-runtime').FirescriptRuntime;
class Scope {
constructor () {
this.scope = new Map();
}
getItem (name) {
FirescriptRuntime.paramTyping(FirescriptRuntime.TYPE_STR, name, 'name');
return this.scope.get(name) || null;
}
exists (name) {
FirescriptRuntime.paramTyping(FirescriptRuntime.TYPE_STR, name, 'name');
return this.scope.has(name);
}
lookup (name) {
FirescriptRuntime.paramTyping(FirescriptRuntime.TYPE_STR, name, 'name');
if (this.scope.has(name)) {
return this.scope.get(name);
} else if (this.parentScope) {
return this.parentScope.lookup(name);
} else {
return null;
}
}
setParentScope (scope) {
FirescriptRuntime.paramTyping(FirescriptRuntime.TYPE_OBJ, scope, 'scope');
this.parentScope = scope;
}
forEach (fn) {
return this.scope.forEach(fn);
}
}
module.exports.Scope = Scope;