00001 //===-- typecheck/RangeChecker.h ------------------------------ -*- C++ -*-===// 00002 // 00003 // This file is distributed under the MIT license. See LICENSE.txt for details. 00004 // 00005 // Copyright (C) 2009, Stephen Wilson 00006 // 00007 //===----------------------------------------------------------------------===// 00008 00009 #ifndef COMMA_TYPECHECK_RANGECHECKER_HDR_GUARD 00010 #define COMMA_TYPECHECK_RANGECHECKER_HDR_GUARD 00011 00012 //===----------------------------------------------------------------------===// 00016 //===----------------------------------------------------------------------===// 00017 00018 #include "comma/basic/Diagnostic.h" 00019 00020 namespace comma { 00021 00022 class DiscreteType; 00023 class Expr; 00024 class Range; 00025 class TypeCheck; 00026 00027 //===----------------------------------------------------------------------===// 00028 // RangeChecker 00029 // 00033 class RangeChecker { 00034 00035 public: 00036 RangeChecker(TypeCheck &TC) : TC(TC) { } 00037 00052 bool checkDeclarationRange(Expr *lower, Expr *upper); 00053 00071 DiscreteType *checkDSTRange(Expr *lower, Expr *upper); 00072 00080 DiscreteType *checkSubtypeRange(DiscreteType *base, 00081 Expr *lower, Expr *upper); 00082 00084 bool resolveRange(Range *range, DiscreteType *type); 00085 00086 private: 00087 TypeCheck &TC; // Supporting TypeChecker instance. 00088 00090 DiagnosticStream &report(Location loc, diag::Kind kind); 00091 }; 00092 00093 } // end comma namespace. 00094 00095 #endif