170b7156d4563022157732cecf076d76516ebd6f5cushon/* 270b7156d4563022157732cecf076d76516ebd6f5cushon * Copyright 2016 Google Inc. All Rights Reserved. 370b7156d4563022157732cecf076d76516ebd6f5cushon * 470b7156d4563022157732cecf076d76516ebd6f5cushon * Licensed under the Apache License, Version 2.0 (the "License"); 570b7156d4563022157732cecf076d76516ebd6f5cushon * you may not use this file except in compliance with the License. 670b7156d4563022157732cecf076d76516ebd6f5cushon * You may obtain a copy of the License at 770b7156d4563022157732cecf076d76516ebd6f5cushon * 870b7156d4563022157732cecf076d76516ebd6f5cushon * http://www.apache.org/licenses/LICENSE-2.0 970b7156d4563022157732cecf076d76516ebd6f5cushon * 1070b7156d4563022157732cecf076d76516ebd6f5cushon * Unless required by applicable law or agreed to in writing, software 1170b7156d4563022157732cecf076d76516ebd6f5cushon * distributed under the License is distributed on an "AS IS" BASIS, 1270b7156d4563022157732cecf076d76516ebd6f5cushon * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1370b7156d4563022157732cecf076d76516ebd6f5cushon * See the License for the specific language governing permissions and 1470b7156d4563022157732cecf076d76516ebd6f5cushon * limitations under the License. 1570b7156d4563022157732cecf076d76516ebd6f5cushon */ 1670b7156d4563022157732cecf076d76516ebd6f5cushon 1770b7156d4563022157732cecf076d76516ebd6f5cushonpackage com.google.turbine.binder.env; 1870b7156d4563022157732cecf076d76516ebd6f5cushon 1970b7156d4563022157732cecf076d76516ebd6f5cushonimport com.google.turbine.binder.sym.ClassSymbol; 20bd2b29bb7fd05aed8481ef8342c09c4e88492c88cushonimport com.google.turbine.binder.sym.Symbol; 2170b7156d4563022157732cecf076d76516ebd6f5cushon 2270b7156d4563022157732cecf076d76516ebd6f5cushon/** 23bd2b29bb7fd05aed8481ef8342c09c4e88492c88cushon * An environment that maps {@link Symbols} {@code S} to bound nodes {@code V}. 2470b7156d4563022157732cecf076d76516ebd6f5cushon * 2570b7156d4563022157732cecf076d76516ebd6f5cushon * <p>For example, {@link BoundClass} represents superclasses as a {@link ClassSymbol}, which only 2670b7156d4563022157732cecf076d76516ebd6f5cushon * contains the binary name of the type. To get the {@link BoundClass} for that supertype, an {@code 2770b7156d4563022157732cecf076d76516ebd6f5cushon * Env<BoundClass>} is used. 2870b7156d4563022157732cecf076d76516ebd6f5cushon * 2970b7156d4563022157732cecf076d76516ebd6f5cushon * <p>The indirection through env makes it possible to represent a graph with cycles using immutable 3070b7156d4563022157732cecf076d76516ebd6f5cushon * nodes, and makes it easy to reason about the information produced and consumed by each pass. 3170b7156d4563022157732cecf076d76516ebd6f5cushon * 3270b7156d4563022157732cecf076d76516ebd6f5cushon * <p>TODO(cushon): keep an eye on the cost of indirections, and consider caching lookups in bound 3370b7156d4563022157732cecf076d76516ebd6f5cushon * nodes if it looks like it would make a difference. 3470b7156d4563022157732cecf076d76516ebd6f5cushon */ 35bd2b29bb7fd05aed8481ef8342c09c4e88492c88cushonpublic interface Env<S extends Symbol, V> { 3670b7156d4563022157732cecf076d76516ebd6f5cushon /** Returns the information associated with the given symbol in this environment. */ 37bd2b29bb7fd05aed8481ef8342c09c4e88492c88cushon V get(S sym); 3870b7156d4563022157732cecf076d76516ebd6f5cushon} 39