| 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 <OpenSP/Resource.h> |
| 10 |
#include <OpenSP/Ptr.h> |
| 11 |
#include <OpenSP/Vector.h> |
| 12 |
#include <OpenSP/NCVector.h> |
| 13 |
#include <OpenSP/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 |
AcceptFlags acceptFlags(ProcessContext &) const |
| 64 |
{ return afAlways; } |
| 65 |
void unpack(VM &); |
| 66 |
private: |
| 67 |
void operator=(const MacroFlowObj &); // undefined |
| 68 |
// Only one pointer/owner allowed. |
| 69 |
struct S { |
| 70 |
S(Definition *d, ELObj **c = 0) |
| 71 |
: def_(d), charicVals_(c) {} |
| 72 |
Ptr<Definition> def_; |
| 73 |
ELObj **charicVals_; |
| 74 |
}; |
| 75 |
Owner<S> sp_; |
| 76 |
}; |
| 77 |
|
| 78 |
inline |
| 79 |
bool MacroFlowObj::Definition::isCompound() const |
| 80 |
{ |
| 81 |
return contentsId_ != 0; |
| 82 |
} |
| 83 |
|
| 84 |
inline |
| 85 |
const Vector<const Identifier *> &MacroFlowObj::Definition::nics() const |
| 86 |
{ |
| 87 |
return charics_; |
| 88 |
} |
| 89 |
|
| 90 |
#ifdef DSSSL_NAMESPACE |
| 91 |
} |
| 92 |
#endif |
| 93 |
|
| 94 |
#endif /* not MacroFlowObj_INCLUDED */ |