Permalink
Browse files

Create new master using bdParse for AST parsing.

  • Loading branch information...
1 parent 016f2da commit 465451e9ecfb095d52f81c4a24ba7ac49042af14 @csnover committed Sep 26, 2011
Showing with 347 additions and 27 deletions.
  1. +3 −3 .gitmodules
  2. +1 −0 bdParse
  3. +1 −1 dojo
  4. +25 −17 lib/Scope.js
  5. +313 −0 lib/bdParser.js
  6. +3 −4 parse.js
  7. +1 −1 parse.sh
  8. +0 −1 uglify-js
View
@@ -1,6 +1,6 @@
[submodule "dojo"]
path = dojo
url = https://github.com/dojo/dojo.git
-[submodule "uglify-js"]
- path = uglify-js
- url = https://github.com/mishoo/UglifyJS.git
+[submodule "bdParse"]
+ path = bdParse
+ url = https://github.com/csnover/bdParse
Submodule bdParse added at 3c4103
2 dojo
Submodule dojo updated from 03c6ef to b1fcb0
View
@@ -1,4 +1,4 @@
-define([ 'dojo/_base/lang', './env', './Variable' ], function (lang, env, Variable) {
+define([ 'dojo/_base/lang', './env', './Variable', './node!util' ], function (lang, env, Variable, util) {
/**
* A variable scope.
*/
@@ -46,7 +46,7 @@ define([ 'dojo/_base/lang', './env', './Variable' ], function (lang, env, Variab
return this.vars[name];
}
- console.info('Adding variable ' + name + ' to scope');
+ console.debug('Adding variable ' + name + ' to scope');
return this.vars[name] = new Variable();
},
@@ -55,37 +55,45 @@ define([ 'dojo/_base/lang', './env', './Variable' ], function (lang, env, Variab
* @param name An array of accessors, or a dot-separated accessor string like a.b.c.
*/
setVariableValue: function (/**Array|string*/ name, /**Value?*/ value) {
- if (!lang.isArray(name)) {
+ if (typeof name === 'string') {
name = name.split('.');
}
+ if (typeof name[0] !== 'string') {
+ throw Error('Only arrays of strings can be passed to setVariableValue');
+ }
+
var scope = this, variable;
- // find variable in nearest scope
- do {
- if ((variable = scope.vars[name[0]])) {
- break;
+ if (name[0] === 'this') {
+ if (!scope.vars['this']) {
+ variable = scope.addVariable('this');
}
- } while ((scope = scope.parent));
-
- if (!variable) {
- console.warn(name.join('.') + ': Implicit global variable declaration');
- variable = env.globalScope.addVariable(name[0]);
}
-
- if (name.length === 1) {
- if (variable.value) {
- console.info(name.join('.') + ': Changing value reference');
+ else {
+ // find variable in nearest scope
+ do {
+ if ((variable = scope.vars[name[0]])) {
+ break;
+ }
+ } while ((scope = scope.parent));
+
+ if (!variable) {
+ console.warn(name.join('.') + ': Implicit global variable declaration');
+ variable = env.globalScope.addVariable(name[0]);
}
+ }
+ if (name.length === 1) {
+ variable.value && console.info(name.join('.') + ': Changing value reference');
variable.value = value;
}
else {
variable.setProperty(name.slice(1), value);
}
},
- resolveVariables: function () {
+ getVariable: function (/**Array|string*/ name) {
}
};
Oops, something went wrong.

0 comments on commit 465451e

Please sign in to comment.