1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162 |
- /*!
- * Stylus - stack - Scope
- * Copyright (c) Automattic <developer.wordpress.com>
- * MIT Licensed
- */
- /**
- * Initialize a new `Scope`.
- *
- * @api private
- */
- var Scope = module.exports = function Scope() {
- this.locals = {};
- };
- /**
- * Add `ident` node to the current scope.
- *
- * @param {Ident} ident
- * @api private
- */
- Scope.prototype.add = function(ident){
- this.locals[ident.name] = ident.val;
- };
- /**
- * Lookup the given local variable `name`.
- *
- * @param {String} name
- * @return {Node}
- * @api private
- */
- Scope.prototype.lookup = function(name){
- return hasOwnProperty(this.locals, name) ? this.locals[name] : undefined;
- };
- /**
- * Custom inspect.
- *
- * @return {String}
- * @api public
- */
- Scope.prototype.inspect = function(){
- var keys = Object.keys(this.locals).map(function(key){ return '@' + key; });
- return '[Scope'
- + (keys.length ? ' ' + keys.join(', ') : '')
- + ']';
- };
- /**
- * @param {Object} obj
- * @param {String} propName
- * @returns {Boolean}
- */
- function hasOwnProperty(obj, propName) {
- return Object.prototype.hasOwnProperty.call(obj, propName);
- }
|