summaryrefslogtreecommitdiff
path: root/Build/source/utils/asymptote/virtualfieldaccess.h
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2011-05-28 02:18:52 +0000
committerKarl Berry <karl@freefriends.org>2011-05-28 02:18:52 +0000
commitc59fe5fe4739f0c61560f05d4e42b4e552219b27 (patch)
tree8cf79e85e394b3177a28d374415840a4e0a025ad /Build/source/utils/asymptote/virtualfieldaccess.h
parent771db15706dbf3f4af8b630dcb15646a3e5fda00 (diff)
asy 2.10
git-svn-id: svn://tug.org/texlive/trunk@22633 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Build/source/utils/asymptote/virtualfieldaccess.h')
-rw-r--r--Build/source/utils/asymptote/virtualfieldaccess.h23
1 files changed, 18 insertions, 5 deletions
diff --git a/Build/source/utils/asymptote/virtualfieldaccess.h b/Build/source/utils/asymptote/virtualfieldaccess.h
index a47627df750..048e4e6b6a2 100644
--- a/Build/source/utils/asymptote/virtualfieldaccess.h
+++ b/Build/source/utils/asymptote/virtualfieldaccess.h
@@ -21,19 +21,32 @@ namespace trans {
// function, which pops a real number and then z off of the stack, sets the
// z.x to that new value, and puts the value back on the stack. In this case,
// pairs are immutable, but other virtual fields may not be.
+//
+// Some virtual fields are functions, such as a.push for an array a. In rare
+// cases, code such as
+// void f(int) = a.push;
+// requires an object representing a.push, and so a getter for the field must
+// be provided. Most of the time, however, these fields are just called.
+// As an optimization, a caller access can be provided. If this access is
+// given, then a call to the virtualFieldAccess just translates into a call to
+// caller.
class virtualFieldAccess : public access {
access *getter;
access *setter;
+ access *caller;
- // As an optimization, one could add a 'caller' field, to handle calls to
- // functions such as 'a.push(x)' where a is an array more efficiently.
public:
- virtualFieldAccess(access *getter, access *setter = 0)
+ virtualFieldAccess(access *getter,
+ access *setter = 0,
+ access *caller = 0)
: getter(getter), setter(setter) {}
- virtualFieldAccess(vm::bltin getter, vm::bltin setter = 0)
+ virtualFieldAccess(vm::bltin getter,
+ vm::bltin setter = 0,
+ vm::bltin caller = 0)
: getter(new bltinAccess(getter)),
- setter(setter ? new bltinAccess(setter) : 0) {}
+ setter(setter ? new bltinAccess(setter) : 0),
+ caller(caller ? new bltinAccess(caller) : 0) {}
void encode(action act, position pos, coder &e);
void encode(action act, position pos, coder &e, frame *);