summaryrefslogtreecommitdiff
path: root/Build/source/utils/asymptote/application.h
diff options
context:
space:
mode:
Diffstat (limited to 'Build/source/utils/asymptote/application.h')
-rw-r--r--Build/source/utils/asymptote/application.h33
1 files changed, 26 insertions, 7 deletions
diff --git a/Build/source/utils/asymptote/application.h b/Build/source/utils/asymptote/application.h
index 994f0bb1970..060afeafdb3 100644
--- a/Build/source/utils/asymptote/application.h
+++ b/Build/source/utils/asymptote/application.h
@@ -16,6 +16,11 @@
#include "coenv.h"
#include "exp.h"
+// Defined in runtime.in:
+namespace run {
+ void pushDefault(vm::stack *Stack);
+}
+
using absyntax::arglist;
using absyntax::varinit;
using absyntax::arrayinit;
@@ -38,12 +43,20 @@ typedef mem::vector<score> score_vector;
typedef mem::vector<tempExp *> temp_vector;
struct arg : public gc {
+ types::ty *t;
+
+ arg(types::ty *t)
+ : t(t) {}
virtual ~arg() {}
+
+ virtual void trans(coenv &e, temp_vector &) = 0;
+};
+
+struct varinitArg : public arg {
varinit *v;
- types::ty *t;
- arg(varinit *v, types::ty *t)
- : v(v), t(t) {}
+ varinitArg(varinit *v, types::ty *t)
+ : arg(t), v(v) {}
virtual void trans(coenv &e, temp_vector &) {
// Open signatures can match overloaded variables, but there is no way to
@@ -57,10 +70,16 @@ struct arg : public gc {
}
};
+
// Pushes a default argument token on the stack as a placeholder for the
// argument.
struct defaultArg : public arg {
- defaultArg(types::ty *t);
+ defaultArg(types::ty *t)
+ : arg(t) {}
+
+ virtual void trans(coenv &e, temp_vector &) {
+ e.c.encode(inst::builtin, run::pushDefault);
+ }
};
// Handles translation of all the arguments matched to the rest formal.
@@ -96,11 +115,11 @@ public:
// used to ensure left-to-right order of evaluation of keyword arguments, even
// if they are given out of the order specified in the declaration.
class sequencer {
- struct sequencedArg : public arg {
+ struct sequencedArg : public varinitArg {
sequencer &parent;
size_t i;
sequencedArg(varinit *v, types::ty *t, sequencer &parent, size_t i)
- : arg(v, t), parent(parent), i(i) {}
+ : varinitArg(v, t), parent(parent), i(i) {}
void trans(coenv &e, temp_vector &temps) {
parent.trans(e, i, temps);
@@ -138,7 +157,7 @@ class sequencer {
advance(e, i, temps);
// Translate using the base method.
- args[i]->arg::trans(e,temps);
+ args[i]->varinitArg::trans(e,temps);
// Push null to indicate the argument has been translated.
temps.push_back(0);