| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 package com.google.javascript.jscomp; | 5 package com.google.javascript.jscomp; |
| 6 | 6 |
| 7 import com.google.javascript.jscomp.NodeTraversal.AbstractPostOrderCallback; | 7 import com.google.javascript.jscomp.NodeTraversal.AbstractPostOrderCallback; |
| 8 import com.google.javascript.rhino.IR; | 8 import com.google.javascript.rhino.IR; |
| 9 import com.google.javascript.rhino.JSDocInfoBuilder; | 9 import com.google.javascript.rhino.JSDocInfoBuilder; |
| 10 import com.google.javascript.rhino.JSTypeExpression; | 10 import com.google.javascript.rhino.JSTypeExpression; |
| (...skipping 295 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 306 NodeTraversal.traverse(compiler, functionBlock, new RenameInternalsToExt
ernalsCallback( | 306 NodeTraversal.traverse(compiler, functionBlock, new RenameInternalsToExt
ernalsCallback( |
| 307 namespace, exports, functionBlock)); | 307 namespace, exports, functionBlock)); |
| 308 } | 308 } |
| 309 | 309 |
| 310 private Map<String, String> objectLitToMap(Node objectLit) { | 310 private Map<String, String> objectLitToMap(Node objectLit) { |
| 311 Map<String, String> res = new HashMap<String, String>(); | 311 Map<String, String> res = new HashMap<String, String>(); |
| 312 | 312 |
| 313 for (Node keyNode : objectLit.children()) { | 313 for (Node keyNode : objectLit.children()) { |
| 314 String key = keyNode.getString(); | 314 String key = keyNode.getString(); |
| 315 | 315 |
| 316 // TODO(vitalyp): Can dict value be other than a simple NAME? What i
f NAME doesn't | 316 Node valueNode = keyNode.getFirstChild(); |
| 317 // refer to a function/constructor? | 317 if (valueNode.isName()) { |
| 318 String value = keyNode.getFirstChild().getString(); | 318 String value = keyNode.getFirstChild().getString(); |
| 319 | 319 res.put(value, key); |
| 320 res.put(value, key); | 320 } |
| 321 } | 321 } |
| 322 | 322 |
| 323 return res; | 323 return res; |
| 324 } | 324 } |
| 325 | 325 |
| 326 /** | 326 /** |
| 327 * For a string "a.b.c" produce the following JS IR: | 327 * For a string "a.b.c" produce the following JS IR: |
| 328 * | 328 * |
| 329 * <p><pre> | 329 * <p><pre> |
| 330 * var a = a || {}; | 330 * var a = a || {}; |
| (...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 445 } | 445 } |
| 446 } | 446 } |
| 447 | 447 |
| 448 private Node buildQualifiedName(Node internalName) { | 448 private Node buildQualifiedName(Node internalName) { |
| 449 String externalName = this.exports.get(internalName.getString()); | 449 String externalName = this.exports.get(internalName.getString()); |
| 450 return NodeUtil.newQName(compiler, this.namespaceName + "." + extern
alName).srcrefTree( | 450 return NodeUtil.newQName(compiler, this.namespaceName + "." + extern
alName).srcrefTree( |
| 451 internalName); | 451 internalName); |
| 452 } | 452 } |
| 453 } | 453 } |
| 454 } | 454 } |
| OLD | NEW |