(Object reader, Object colon, Object opts, Object pendingForms)
| 648 | // ::a{:c 1} => {:a.b/c 1} (where a is aliased to a.b) |
| 649 | public static class NamespaceMapReader extends AFn{ |
| 650 | public Object invoke(Object reader, Object colon, Object opts, Object pendingForms) { |
| 651 | PushbackReader r = (PushbackReader) reader; |
| 652 | |
| 653 | boolean auto = false; |
| 654 | int autoChar = read1(r); |
| 655 | if(autoChar == ':') |
| 656 | auto = true; |
| 657 | else |
| 658 | unread(r, autoChar); |
| 659 | |
| 660 | Object sym = null; |
| 661 | int nextChar = read1(r); |
| 662 | if(isWhitespace(nextChar)) { // the #:: { } case or an error |
| 663 | if(auto) { |
| 664 | while (isWhitespace(nextChar)) |
| 665 | nextChar = read1(r); |
| 666 | if(nextChar != '{') { |
| 667 | unread(r, nextChar); |
| 668 | throw Util.runtimeException("Namespaced map must specify a namespace"); |
| 669 | } |
| 670 | } else { |
| 671 | unread(r, nextChar); |
| 672 | throw Util.runtimeException("Namespaced map must specify a namespace"); |
| 673 | } |
| 674 | } else if(nextChar != '{') { // #:foo { } or #::foo { } |
| 675 | unread(r, nextChar); |
| 676 | sym = read(r, true, null, false, opts, pendingForms); |
| 677 | nextChar = read1(r); |
| 678 | while(isWhitespace(nextChar)) |
| 679 | nextChar = read1(r); |
| 680 | } |
| 681 | if(nextChar != '{') |
| 682 | throw Util.runtimeException("Namespaced map must specify a map"); |
| 683 | |
| 684 | // Resolve autoresolved ns |
| 685 | String ns; |
| 686 | if (auto) { |
| 687 | Resolver resolver = (Resolver) RT.READER_RESOLVER.deref(); |
| 688 | if (sym == null) { |
| 689 | if(resolver != null) |
| 690 | ns = resolver.currentNS().name; |
| 691 | else |
| 692 | ns = Compiler.currentNS().getName().getName(); |
| 693 | } else if (!(sym instanceof Symbol) || ((Symbol)sym).getNamespace() != null) { |
| 694 | throw Util.runtimeException("Namespaced map must specify a valid namespace: " + sym); |
| 695 | } else { |
| 696 | Symbol resolvedNS; |
| 697 | if (resolver != null) |
| 698 | resolvedNS = resolver.resolveAlias((Symbol) sym); |
| 699 | else{ |
| 700 | Namespace rns = Compiler.currentNS().lookupAlias((Symbol)sym); |
| 701 | resolvedNS = rns != null?rns.getName():null; |
| 702 | } |
| 703 | |
| 704 | if(resolvedNS == null) { |
| 705 | throw Util.runtimeException("Unknown auto-resolved namespace alias: " + sym); |
| 706 | } else { |
| 707 | ns = resolvedNS.getName(); |
nothing calls this directly
no test coverage detected