| 1 | package uk.co.zonetora.fj.typecheck; |
| 2 | |
| 3 | import java.util.HashMap; |
| 4 | import java.util.Map; |
| 5 | |
| 6 | import uk.co.zonetora.fj.model.ArgumentName; |
| 7 | import uk.co.zonetora.fj.model.ClassName; |
| 8 | import uk.co.zonetora.fj.model.FieldName; |
| 9 | |
| 10 | public class TypeEnvironment { |
| 11 | |
| 12 | private final Map<ArgumentName, ClassName> bindings; |
| 13 | |
| 14 | public TypeEnvironment() { |
| 15 | this.bindings = new HashMap<ArgumentName, ClassName>(); |
| 16 | } |
| 17 | |
| 18 | public ClassName getBinding(ArgumentName f) { |
| 19 | return this.bindings.get(f); |
| 20 | } |
| 21 | |
| 22 | public void addBinding(ArgumentName f, ClassName c) { |
| 23 | if(null != this.bindings.put(f, c)) { |
| 24 | throw new RuntimeException("Precondition failure"); |
| 25 | } |
| 26 | } |
| 27 | } |