summaryrefslogtreecommitdiff
path: root/deps/v8/test/cctest/expression-type-collector-macros.h
blob: 39774f0a71089faea01896120e4a3cad81d738c2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
// Copyright 2015 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.

#ifndef V8_EXPRESSION_TYPE_COLLECTOR_MACROS_H_
#define V8_EXPRESSION_TYPE_COLLECTOR_MACROS_H_

#define CHECK_TYPES_BEGIN \
  {                       \
    size_t index = 0;     \
    int depth = 0;

#define CHECK_TYPES_END          \
  CHECK_EQ(index, types.size()); \
  }

#ifdef DEBUG
#define CHECK_TYPE(type)                    \
  if (!types[index].bounds.Narrows(type)) { \
    fprintf(stderr, "Expected:\n");         \
    fprintf(stderr, "  lower: ");           \
    type.lower->Print();                    \
    fprintf(stderr, "  upper: ");           \
    type.upper->Print();                    \
    fprintf(stderr, "Actual:\n");           \
    fprintf(stderr, "  lower: ");           \
    types[index].bounds.lower->Print();     \
    fprintf(stderr, "  upper: ");           \
    types[index].bounds.upper->Print();     \
  }                                         \
  CHECK(types[index].bounds.Narrows(type));
#else
#define CHECK_TYPE(type) CHECK(types[index].bounds.Narrows(type));
#endif

#define CHECK_EXPR(ekind, type)                   \
  CHECK_LT(index, types.size());                  \
  CHECK_EQ(strcmp(#ekind, types[index].kind), 0); \
  CHECK_EQ(depth, types[index].depth);            \
  CHECK_TYPE(type);                               \
  for (int j = (++depth, ++index, 0); j < 1 ? 1 : (--depth, 0); ++j)

#define CHECK_VAR(vname, type)                                     \
  CHECK_EXPR(VariableProxy, type);                                 \
  CHECK_EQ(#vname, std::string(types[index - 1].name->raw_data(),  \
                               types[index - 1].name->raw_data() + \
                                   types[index - 1].name->byte_length()));

#define CHECK_SKIP()                                             \
  {                                                              \
    ++index;                                                     \
    while (index < types.size() && types[index].depth > depth) { \
      ++index;                                                   \
    }                                                            \
  }

#endif  // V8_EXPRESSION_TYPE_COLLECTOR_MACROS_H_