summaryrefslogtreecommitdiff
path: root/Build/source/utils/asymptote/virtualfieldaccess.cc
diff options
context:
space:
mode:
Diffstat (limited to 'Build/source/utils/asymptote/virtualfieldaccess.cc')
-rw-r--r--Build/source/utils/asymptote/virtualfieldaccess.cc41
1 files changed, 41 insertions, 0 deletions
diff --git a/Build/source/utils/asymptote/virtualfieldaccess.cc b/Build/source/utils/asymptote/virtualfieldaccess.cc
new file mode 100644
index 00000000000..13cb088d2ac
--- /dev/null
+++ b/Build/source/utils/asymptote/virtualfieldaccess.cc
@@ -0,0 +1,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