(Symbol sym)
| 61 | } |
| 62 | |
| 63 | public Var intern(Symbol sym){ |
| 64 | if(sym.ns != null) |
| 65 | { |
| 66 | throw new IllegalArgumentException("Can't intern namespace-qualified symbol"); |
| 67 | } |
| 68 | |
| 69 | IPersistentMap map = getMappings(); |
| 70 | Object o; |
| 71 | Var v = null; |
| 72 | while((o = map.valAt(sym)) == null) |
| 73 | { |
| 74 | if(v == null) |
| 75 | v = new Var(this, sym); |
| 76 | IPersistentMap newMap = map.assoc(sym, v); |
| 77 | mappings.compareAndSet(map, newMap); |
| 78 | map = getMappings(); |
| 79 | } |
| 80 | if(isInternedMapping(sym, o)) |
| 81 | return (Var) o; |
| 82 | |
| 83 | if(v == null) |
| 84 | v = new Var(this, sym); |
| 85 | |
| 86 | if(checkReplacement(sym, o, v)){ |
| 87 | while (!mappings.compareAndSet(map, map.assoc(sym, v))) |
| 88 | map = getMappings(); |
| 89 | |
| 90 | return v; |
| 91 | } |
| 92 | |
| 93 | return (Var) o; |
| 94 | } |
| 95 | |
| 96 | /* |
| 97 | This method checks if a namespace's mapping is applicable and warns on problematic cases. |
nothing calls this directly
no test coverage detected