JSDOC/Walker2.js
[gnome.introspection-doc-generator] / JSDOC / ScopeParser.js
index a7abc9c..bc695ef 100644 (file)
@@ -277,7 +277,7 @@ ScopeParser.prototype = {
                         
 
                         if (this.mode == "BUILDING_SYMBOL_TREE") {
-                            identifier = thisScope.getIdentifier(token.data) ;
+                            identifier = thisScope.getIdentifier(token.data,token) ;
                             
                             if (identifier == false) {
                                 thisScope.declareIdentifier(token.data, token);
@@ -328,6 +328,7 @@ ScopeParser.prototype = {
 
                 case "PUNC.LEFT_CURLY": // {
                 case "PUNC.LEFT_PAREN": // (    
+                case "PUNC.LEFT_BRACE": // [
                     //print('SCOPE-CURLY/PAREN:' + token.toString());
                     //println("<i>"+token.data+"</i>");
                     var curTS = this.ts;
@@ -348,7 +349,7 @@ ScopeParser.prototype = {
                             // key value..
                             
                             this.ts = new TokenStream(token.props[prop].val);
-                            this.parseScope(false);
+                            this.parseExpression();
                             
                         }
                         this.ts = curTS;
@@ -485,7 +486,7 @@ ScopeParser.prototype = {
                         //println("GOT IDENT: <B>" + symbol + "</B><BR/>");
                              
                             //println("GOT IDENT (2): <B>" + symbol + "</B><BR/>");
-                        identifier = this.getIdentifier(symbol, thisScope);
+                        identifier = this.getIdentifier(symbol, thisScope, token);
                         
                         if (identifier == false) {
 // BUG!find out where builtin is defined...
@@ -525,7 +526,7 @@ ScopeParser.prototype = {
                                 var _t = this;
                                 this.ts.look(-1).data.replace(/eval:var:([a-z_]+)/ig, function(m, a) {
                                     
-                                    var hi = _t.getIdentifier(a, thisScope);
+                                    var hi = _t.getIdentifier(a, thisScope, token);
                                    // println("PROTECT "+a+" from munge" + (hi ? "FOUND" : "MISSING"));
                                     if (hi) {
                                      //   println("PROTECT "+a+" from munge");
@@ -628,20 +629,23 @@ ScopeParser.prototype = {
                         case '{': //Token.LC:
                         case '[': //Token.LB:
                             //print('SCOPE-CURLY/PAREN/BRACE:' + token.toString());
+                           // print('SCOPE-CURLY/PAREN/BRACE:' + JSON.stringify(token, null,4));
                             //println("<i>"+token.data+"</i>");
                             var curTS = this.ts;
                             if (token.props) {
                                 
                                 for (var prop in token.props) {
-                                    if (token.props[prop].val.data == 'function') {
+                                    if (token.props[prop].val[0].data == 'function') {
                                         // parse a function..
-                                        this.parseFunctProp(token.props[prop]);
+                                        this.ts = new TokenStream(token.props[prop].val);
+                                        this.ts.nextTok();
+                                        this.parseFunctionDeclaration();
                                         continue;
                                     }
                                     // key value..
                                     
                                     this.ts = new TokenStream(token.props[prop].val);
-                                    this.parseScope(false);
+                                    this.parseExpression();
                                     
                                 }
                                 this.ts = curTS;
@@ -717,7 +721,7 @@ ScopeParser.prototype = {
                     
                     if (this.mode == 'PASS2_SYMBOL_TREE') {
 
-                        identifier = this.getIdentifier(symbol, currentScope);
+                        identifier = this.getIdentifier(symbol, currentScope, token);
                         //println("<B>??</B>");
                         if (identifier == false) {
 
@@ -767,7 +771,7 @@ ScopeParser.prototype = {
                                 // look for eval:var:noreplace\n
                                 var _t = this;
                                 this.ts.look(-1).data.replace(/eval:var:([a-z]+)/ig, function(m, a) {
-                                    var hi = _t.getIdentifier(a, currentScope);
+                                    var hi = _t.getIdentifier(a, currentScope, token);
                                    //println("PROTECT "+a+" from munge" + (hi ? "FOUND" : "MISSING"));
                                     if (hi) {
                                       //  println("PROTECT "+a+" from munge");
@@ -822,7 +826,7 @@ ScopeParser.prototype = {
             currentScope.declareIdentifier(symbol, token);
         } else {
             //?? why inc the refcount?? - that should be set when building the tree???
-            identifier = this.getIdentifier(symbol, currentScope);
+            identifier = this.getIdentifier(symbol, currentScope, token);
             identifier.refcount++;
         }
 
@@ -848,7 +852,7 @@ ScopeParser.prototype = {
             if (this.mode == 'BUILDING_SYMBOL_TREE') {
                 // Get the name of the function and declare it in the current scope.
                 symbol = token.data;
-                if (currentScope.getIdentifier(symbol) != false) {
+                if (currentScope.getIdentifier(symbol,token) != false) {
                     this.warn("The function " + symbol + " has already been declared in the same scope...", true);
                 }
                 currentScope.declareIdentifier(symbol,token);
@@ -858,7 +862,7 @@ ScopeParser.prototype = {
 
         //assert token.getType() == Token.LP;
         if (this.mode == 'BUILDING_SYMBOL_TREE') {
-            fnScope = new Scope(1, currentScope, token.n, '');
+            fnScope = new Scope(1, currentScope, token.n, '', token);
             
             //println("STORING SCOPE" + this.ts.cursor);
             
@@ -937,10 +941,10 @@ ScopeParser.prototype = {
         scope.preventMunging();
     },
     
-    getIdentifier: function(symbol, scope) {
+    getIdentifier: function(symbol, scope, token) {
         var identifier;
         while (scope != false) {
-            identifier = scope.getIdentifier(symbol);
+            identifier = scope.getIdentifier(symbol, token);
             //println("ScopeParser.getIdentgetUsedSymbols("+symbol+")=" + scope.getUsedSymbols().join(','));
             if (identifier) {
                 return identifier;