UNPKG

cst

Version:

JavaScript CST Implementation

83 lines (73 loc) 2.42 kB
'use strict'; Object.defineProperty(exports, '__esModule', { value: true }); var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ('value' in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })(); function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } } var Definition = (function () { function Definition(_ref) { var node = _ref.node; var type = _ref.type; var scope = _ref.scope; return (function () { _classCallCheck(this, Definition); this._node = node; this._type = type; this._scope = scope; }).apply(this, arguments); } /** * Possible variable types. */ _createClass(Definition, [{ key: 'node', get: function get() { return this._node; } }, { key: 'type', get: function get() { return this._type; } }, { key: 'scope', get: function get() { return this._scope; } }, { key: 'variable', get: function get() { return this._variable; } }]); return Definition; })(); exports['default'] = Definition; var types = { LetVariable: 'LetVariable', Constant: 'Constant', Variable: 'Variable', Parameter: 'Parameter', SelfReference: 'SelfReference', CatchClauseError: 'CatchClauseError', ImportBinding: 'ImportBinding', ImplicitGlobal: 'ImplicitGlobal', BuiltIn: 'BuiltIn' }; exports.types = types; /** * Priorities in variable scopes. * For instance, `var x` hides `x` function argument and `x` argument hides global `x`. */ var typeOrder = { LetVariable: 0, Constant: 0, Variable: 0, ImportBinding: 1, Parameter: 1, CatchClauseError: 1, SelfReference: 2, BuiltIn: 3, ImplicitGlobal: 3 }; exports.typeOrder = typeOrder;