summaryrefslogtreecommitdiff
path: root/Build/source/utils/asymptote/coenv.h
blob: b8d751570e928ed6f5d0820f0b79a73f91282223 (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
/*****
 * coenv.h
 * Andy Hammerlindl 2004/11/18
 *
 * Bundles the env and coder classes needed in translating the abstract syntax
 * tree.  It also also implements some functions that involve both the env and
 * coder, such as implicitCast().
 *****/

#ifndef COENV_H
#define COENV_H

#include "env.h"
#include "coder.h"

namespace trans {

class coenv {
public:
  coder &c;
  env &e;

  coenv(coder &c, env &e)
    : c(c), e(e) {}

  // This is used when an expression of type source needs to be an
  // expression of type target.
  // If it is allowed, the casting instructions (if any) will be added.
  // Otherwise, an appropriate error message will be printed.
  bool implicitCast(position pos, ty *target, ty *source);
  bool explicitCast(position pos, ty *target, ty *source);

  void add(protoenv &source, varEntry *qualifier) {
    e.add(source, qualifier, c);
  }
};

} // namespace trans

#endif