Last change
on this file since eed0bf8 was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago |
initial commit
|
-
Property mode
set to
100644
|
File size:
598 bytes
|
Rev | Line | |
---|
[6a3a178] | 1 | var utils = require('../utils')
|
---|
| 2 | , nodes = require('../nodes');
|
---|
| 3 |
|
---|
| 4 | /**
|
---|
| 5 | * Set a variable `name` on current scope.
|
---|
| 6 | *
|
---|
| 7 | * @param {String} name
|
---|
| 8 | * @param {Expression} expr
|
---|
| 9 | * @param {Boolean} [global]
|
---|
| 10 | * @api public
|
---|
| 11 | */
|
---|
| 12 |
|
---|
| 13 | function define(name, expr, global){
|
---|
| 14 | utils.assertType(name, 'string', 'name');
|
---|
| 15 | expr = utils.unwrap(expr);
|
---|
| 16 | var scope = this.currentScope;
|
---|
| 17 | if (global && global.toBoolean().isTrue) {
|
---|
| 18 | scope = this.global.scope;
|
---|
| 19 | }
|
---|
| 20 | var node = new nodes.Ident(name.val, expr);
|
---|
| 21 | scope.add(node);
|
---|
| 22 | return nodes.null;
|
---|
| 23 | };
|
---|
| 24 | define.params = ['name', 'expr', 'global'];
|
---|
| 25 | module.exports = define;
|
---|
Note:
See
TracBrowser
for help on using the repository browser.