summaryrefslogtreecommitdiff
path: root/Build/source/utils/asymptote/frame.h
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2009-05-16 00:19:13 +0000
committerKarl Berry <karl@freefriends.org>2009-05-16 00:19:13 +0000
commitbab45528d65eaafe68a705dbb2a57075c7b7cbd8 (patch)
tree10b4ae2b5195c8dede153ab89359ec00f55f325f /Build/source/utils/asymptote/frame.h
parent8643d90372e9c31e0f461c15c596b60a545bd7d3 (diff)
asymptote 1.72 sources (not integrated into build yet)
git-svn-id: svn://tug.org/texlive/trunk@13110 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Build/source/utils/asymptote/frame.h')
-rw-r--r--Build/source/utils/asymptote/frame.h76
1 files changed, 76 insertions, 0 deletions
diff --git a/Build/source/utils/asymptote/frame.h b/Build/source/utils/asymptote/frame.h
new file mode 100644
index 00000000000..9f3db9247a4
--- /dev/null
+++ b/Build/source/utils/asymptote/frame.h
@@ -0,0 +1,76 @@
+/*****
+ * frame.h
+ * Andy Hammerlindl 2002/07/22
+ *
+ * Describes the frame levels for the functions of the language.
+ * Also creates accesses for the variable for automated loading
+ * and saving of variables.
+ *****/
+
+#ifndef FRAME_H
+#define FRAME_H
+
+#include <cassert>
+
+#include "access.h"
+
+namespace trans {
+
+class frame : public gc {
+ frame *parent;
+ size_t numFormals;
+ Int numLocals;
+
+public:
+ frame(frame *parent, size_t numFormals)
+ : parent(parent), numFormals(numFormals), numLocals(0) {}
+
+ size_t getNumFormals() {
+ return numFormals;
+ }
+ Int getNumLocals() {
+ return numLocals;
+ }
+
+ frame *getParent() {
+ return parent;
+ }
+
+ Int size() {
+ return (Int) (1+numFormals+numLocals);
+ }
+
+ access *accessFormal(size_t index) {
+ assert(index < numFormals);
+ return new localAccess((Int) (1 + index), this);
+ }
+
+ access *allocLocal() {
+ return new localAccess((Int) (1 + numFormals + numLocals++), this);
+ }
+
+ // Checks if the frame f is a descendent of this frame.
+ // For our purposes, a frame is its own descendant.
+ bool isDescendant(frame *f)
+ {
+ while (f != 0) {
+ if (f == this)
+ return true;
+ f = f->parent;
+ }
+ return false;
+ }
+};
+
+inline void print(ostream& out, frame *f) {
+ out << f;
+ if (f != 0) {
+ out << " -> ";
+ print(out, f->getParent());
+ }
+}
+
+} // namespace trans
+
+#endif
+