You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

25 lines
572 B
JavaScript

'use strict';
const createsBlockScope = require("../scope/creates-block-scope");
const createsFunctionScope = require("../scope/creates-function-scope");
/* FIXME: Find a better solution for this? */
const FUNCTION_SCOPE = 1;
const BLOCK_SCOPE = 2;
module.exports = function () {
let scopeId = 0;
return {
onEnter: function onEnter(node) {
if (createsFunctionScope(node)) {
node._scopeId = scopeId++;
node._scopeType = FUNCTION_SCOPE;
} if (createsBlockScope(node)) {
node._scopeId = scopeId++;
node._scopeType = BLOCK_SCOPE;
}
}
};
};