summaryrefslogtreecommitdiff
path: root/Build/source/utils/asymptote/virtualfieldaccess.cc
blob: 13cb088d2ac1660dbcb9b28689e378b46af85f58 (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
/*****
 * virtualfieldaccess.cc
 * Andy Hammerlindl 2009/07/23
 *
 * Implements the access subclass used to read and write virtual fields.
 *****/

#include "virtualfieldaccess.h"
#include "coder.h"

namespace trans {

inline void virtualFieldAccess::encode(action act, position pos, coder &e)
{
  switch(act) {
    case CALL:
      this->encode(READ, pos, e);
      e.encode(inst::popcall);
      return;
    case READ:
      assert(getter);
      getter->encode(CALL, pos, e);
      return;
    case WRITE:
      if (setter)
        setter->encode(CALL, pos, e);
      else {
        em.error(pos);
        em << "virtual field is read-only";
      }
      return;
  }
}

void virtualFieldAccess::encode(action act, position pos, coder &e, frame *)
{
  e.encode(inst::pop);
  encode(act, pos, e);
}

} // namespace trans