ast-type-bounds.h 1007 Bytes
Newer Older
1 2 3 4 5 6 7 8 9
// Copyright 2016 the V8 project authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

// A container to associate type bounds with AST Expression nodes.

#ifndef V8_AST_AST_TYPE_BOUNDS_H_
#define V8_AST_AST_TYPE_BOUNDS_H_

10
#include "src/ast/ast-types.h"
11
#include "src/zone/zone-containers.h"
12 13 14 15 16 17 18 19 20 21 22

namespace v8 {
namespace internal {

class Expression;

class AstTypeBounds {
 public:
  explicit AstTypeBounds(Zone* zone) : bounds_map_(zone) {}
  ~AstTypeBounds() {}

23 24
  AstBounds get(Expression* expression) const {
    ZoneMap<Expression*, AstBounds>::const_iterator i =
25
        bounds_map_.find(expression);
26
    return (i != bounds_map_.end()) ? i->second : AstBounds::Unbounded();
27 28
  }

29
  void set(Expression* expression, AstBounds bounds) {
30 31 32 33
    bounds_map_[expression] = bounds;
  }

 private:
34
  ZoneMap<Expression*, AstBounds> bounds_map_;
35 36 37 38 39 40
};

}  // namespace internal
}  // namespace v8

#endif  // V8_AST_AST_TYPE_BOUNDS_H_