Initial commit
[profile/ivi/openjade.git] / style / MacroFlowObj.h
1 // Copyright (c) 1997 James Clark
2 // See the file copying.txt for copying permission.
3
4 #ifndef MacroFlowObj_INCLUDED
5 #define MacroFlowObj_INCLUDED 1
6
7 #include "SosofoObj.h"
8 #include "Insn.h"
9 #include "Resource.h"
10 #include "Ptr.h"
11 #include "Vector.h"
12 #include "NCVector.h"
13 #include "Owner.h"
14 #include "Expression.h"
15
16 #ifdef DSSSL_NAMESPACE
17 namespace DSSSL_NAMESPACE {
18 #endif
19
20 class ProcessContext;
21 class Identifier;
22 class Interpreter;
23
24 class MacroFlowObj : public CompoundFlowObj {
25 public:
26   void *operator new(size_t, Collector &c) {
27     return c.allocateObject(1);
28   }
29   class Definition : public Resource {
30   public:
31     Definition(Vector<const Identifier *> &,
32                NCVector<Owner<Expression> > &,
33                const Identifier *contentsId,
34                Owner<Expression> &);
35
36     void process(ProcessContext &, MacroFlowObj *);
37     bool isCompound() const;
38     const Vector<const Identifier *> &nics() const;
39   private:
40     Definition(const Definition &); // undefined
41     void operator=(const Definition &); // undefined
42     void compile(Interpreter &);
43
44     Vector<const Identifier *> charics_;
45     NCVector<Owner<Expression> > charicInits_;
46     const Identifier *contentsId_;
47     Owner<Expression> body_;
48     InsnPtr code_;
49   };
50
51   MacroFlowObj(Vector<const Identifier *> &,
52                NCVector<Owner<Expression> > &,
53                const Identifier *contentsId,
54                Owner<Expression> &);
55   MacroFlowObj(const MacroFlowObj &);
56   ~MacroFlowObj();
57   FlowObj *copy(Collector &) const;
58   CompoundFlowObj *asCompoundFlowObj();
59   bool hasNonInheritedC(const Identifier *) const;
60   void setNonInheritedC(const Identifier *, ELObj *, const Location &, Interpreter &);
61   void traceSubObjects(Collector &) const;
62   void processInner(ProcessContext &);
63   void unpack(VM &);
64 private:
65   void operator=(const MacroFlowObj &); // undefined
66   Ptr<Definition> def_;
67   ELObj **charicVals_;
68 };
69
70 inline
71 bool MacroFlowObj::Definition::isCompound() const
72 {
73   return contentsId_ != 0;
74 }
75
76 inline
77 const Vector<const Identifier *> &MacroFlowObj::Definition::nics() const
78 {
79   return charics_;
80 }
81
82 #ifdef DSSSL_NAMESPACE
83 }
84 #endif
85
86 #endif /* not MacroFlowObj_INCLUDED */