Debian Codegraph @

style/VM.h

raw
1 // Copyright (c) 1996 James Clark
2 // See the file copying.txt for copying permission.
3
4 #ifndef VM_INCLUDED
5 #define VM_INCLUDED 1
6
7 #include "Collector.h"
8 #include "EvalContext.h"
9 #include <OpenSP/Location.h>
10
11 #ifdef DSSSL_NAMESPACE
12 namespace DSSSL_NAMESPACE {
13 #endif
14
15 class ELObj;
16 class ContinuationObj;
17 class Interpreter;
18 class Insn;
19
20 class VM : public EvalContext, private Collector::DynamicRoot {
21 public:
22 VM(Interpreter &);
23 VM(EvalContext &, Interpreter &);
24 virtual ~VM();
25 ELObj **sp;
26 Interpreter *interp;
27 ELObj **closure;
28 ELObj *protectClosure;
29 ELObj **frame;
30 int nActualArgs;
31 Location closureLoc;
32 ELObj *eval(const Insn *, ELObj **display = 0, ELObj *arg = 0);
33 void initStack();
34 void needStack(int);
35 void pushFrame(const Insn *next, int argsPushed);
36 const Insn *popFrame();
37 void setClosureArgToCC();
38 void trace(Collector &) const;
39 Vector<const ProcessingMode *> modeStack;
40 private:
41 void growStack(int);
42 void init();
43 void stackTrace();
44
45 ELObj **slim;
46 ELObj **sbase;
47
48 struct ControlStackEntry {
49 int frameSize; // before pushing args
50 ELObj **closure;
51 ELObj *protectClosure;
52 Location closureLoc;
53 ContinuationObj *continuation;
54 const Insn *next;
55 };
56
57 ControlStackEntry *csp;
58 ControlStackEntry *csbase;
59 ControlStackEntry *cslim;
60 friend class ContinuationObj;
61 };
62
63 inline
64 void VM::needStack(int n)
65 {
66 if (slim - sp < n)
67 growStack(n);
68 }
69
70 #ifdef DSSSL_NAMESPACE
71 }
72 #endif
73
74 #endif /* not VM_INCLUDED */