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 296 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
307 NodeTraversal.traverse(compiler, functionBlock, new RenameInternalsToExt
ernalsCallback( | 307 NodeTraversal.traverse(compiler, functionBlock, new RenameInternalsToExt
ernalsCallback( |
308 namespace, exports, functionBlock)); | 308 namespace, exports, functionBlock)); |
309 } | 309 } |
310 | 310 |
311 private Map<String, String> objectLitToMap(Node objectLit) { | 311 private Map<String, String> objectLitToMap(Node objectLit) { |
312 Map<String, String> res = new HashMap<String, String>(); | 312 Map<String, String> res = new HashMap<String, String>(); |
313 | 313 |
314 for (Node keyNode : objectLit.children()) { | 314 for (Node keyNode : objectLit.children()) { |
315 String key = keyNode.getString(); | 315 String key = keyNode.getString(); |
316 | 316 |
317 // TODO(vitalyp): Can dict value be other than a simple NAME? What i
f NAME doesn't | 317 Node valueNode = keyNode.getFirstChild(); |
318 // refer to a function/constructor? | 318 if (valueNode.isName()) { |
319 String value = keyNode.getFirstChild().getString(); | 319 String value = keyNode.getFirstChild().getString(); |
320 | 320 res.put(value, key); |
321 res.put(value, key); | 321 } |
322 } | 322 } |
323 | 323 |
324 return res; | 324 return res; |
325 } | 325 } |
326 | 326 |
327 /** | 327 /** |
328 * For a string "a.b.c" produce the following JS IR: | 328 * For a string "a.b.c" produce the following JS IR: |
329 * | 329 * |
330 * <p><pre> | 330 * <p><pre> |
331 * var a = a || {}; | 331 * var a = a || {}; |
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
446 } | 446 } |
447 } | 447 } |
448 | 448 |
449 private Node buildQualifiedName(Node internalName) { | 449 private Node buildQualifiedName(Node internalName) { |
450 String externalName = this.exports.get(internalName.getString()); | 450 String externalName = this.exports.get(internalName.getString()); |
451 return NodeUtil.newQualifiedNameNode(compiler.getCodingConvention(), | 451 return NodeUtil.newQualifiedNameNode(compiler.getCodingConvention(), |
452 this.namespaceName + "." + externalName).srcrefTree(internal
Name); | 452 this.namespaceName + "." + externalName).srcrefTree(internal
Name); |
453 } | 453 } |
454 } | 454 } |
455 } | 455 } |
OLD | NEW |