summaryrefslogtreecommitdiff
path: root/graphics/asymptote/process.h
diff options
context:
space:
mode:
authorNorbert Preining <norbert@preining.info>2021-12-28 03:01:00 +0000
committerNorbert Preining <norbert@preining.info>2021-12-28 03:01:00 +0000
commitecdf859b6ce481abfd530425dcf6f0f764bd0001 (patch)
tree13bc161dc046876ac6c92fce5f9f5034ba9aa573 /graphics/asymptote/process.h
parent790995b7e79697514364450bf9c04f1b8d500838 (diff)
CTAN sync 202112280300
Diffstat (limited to 'graphics/asymptote/process.h')
-rw-r--r--graphics/asymptote/process.h83
1 files changed, 81 insertions, 2 deletions
diff --git a/graphics/asymptote/process.h b/graphics/asymptote/process.h
index 3f3e739089..e076c39dfb 100644
--- a/graphics/asymptote/process.h
+++ b/graphics/asymptote/process.h
@@ -17,7 +17,9 @@
#include "pipestream.h"
#include "callable.h"
#include "pen.h"
+#include "dec.h"
#include "transform.h"
+#include "parser.h"
#ifdef HAVE_RPC_RPC_H
#include "xstream.h"
@@ -107,15 +109,16 @@ struct processDataStruct {
string KEY;
xkey_t xkey;
xmap_t xmap;
+ unsigned int xmapCount;
terminator<std::ofstream> ofile;
terminator<std::fstream> ifile;
#ifdef HAVE_RPC_RPC_H
- terminator<xdr::ioxstream> ixfile;
+ terminator<xdr::ixstream> ixfile;
terminator<xdr::oxstream> oxfile;
#endif
- processDataStruct() {
+ processDataStruct() : xmapCount(0) {
atExitFunction=NULL;
atUpdateFunction=NULL;
atBreakpointFunction=NULL;
@@ -125,6 +128,82 @@ struct processDataStruct {
};
+enum transMode {
+ TRANS_INTERACTIVE,
+ TRANS_NORMAL
+};
+
+// Abstract base class for the core object being run in line-at-a-time mode, it
+// may be a block of code, file, or interactive prompt.
+struct icore {
+ virtual ~icore() {}
+ virtual void doParse() = 0;
+ virtual void doList() = 0;
+
+public:
+ virtual void preRun(trans::coenv &e, istack &s);
+ virtual void run(trans::coenv &e, istack &s, transMode tm=TRANS_NORMAL) = 0;
+ virtual void postRun(trans::coenv &, istack &s);
+ virtual void doRun(bool purge=false, transMode tm=TRANS_NORMAL);
+ virtual void process(bool purge=false);
+};
+
+// Abstract base class for one-time processing of an abstract syntax tree.
+class itree : public icore {
+ string name;
+ absyntax::block *cachedTree;
+public:
+ itree(string name="<unnamed>");
+ virtual absyntax::block *buildTree() = 0;
+
+ // Build the tree, possibly throwing a handled_error if it cannot be built.
+ virtual absyntax::block *getTree();
+ virtual string getName();
+
+ void doParse();
+ void doList();
+ void run(trans::coenv &e, istack &s, transMode tm=TRANS_NORMAL);
+ void doExec(transMode tm=TRANS_NORMAL);
+};
+
+class ifile : public itree {
+ string filename;
+ string outname;
+ string outname_save;
+
+public:
+ ifile(const string& filename);
+ absyntax::block *buildTree();
+
+ void preRun(trans::coenv& e, istack& s);
+ void postRun(trans::coenv &e, istack& s);
+ void process(bool purge=false);
+};
+
+class icode : public itree {
+ absyntax::block *tree;
+
+public:
+ icode(absyntax::block *tree, string name="<unnamed>")
+ : itree(name), tree(tree) {}
+
+ absyntax::block *buildTree() {
+ return tree;
+ }
+};
+
+class istring : public itree {
+ string str;
+
+public:
+ istring(const string& str, string name="<eval>")
+ : itree(name), str(str) {}
+
+ absyntax::block *buildTree() {
+ return parser::parseString(str, getName());
+ }
+};
+
processDataStruct &processData();
#endif