/usr/include/JAGS/compiler/Compiler.h is in jags 4.2.0-2.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 | #ifndef COMPILER_H_
#define COMPILER_H_
#include <compiler/LogicalFactory.h>
#include <compiler/MixtureFactory.h>
#include <compiler/CounterTab.h>
#include <compiler/ObsFuncTab.h>
#include <distribution/DistTab.h>
#include <function/FuncTab.h>
#include <model/BUGSModel.h>
#include <graph/Graph.h>
#include <map>
#include <string>
#include <utility>
#include <list>
#include <utility>
#include <set>
namespace jags {
class ParseTree;
class SymTab;
class FuncTab;
class DistTab;
class NodeAlias;
class SimpleRange;
class Compiler;
typedef void (Compiler::*CompilerMemFn) (ParseTree const *);
/**
* @short Creates a BUGSModel from a ParseTree
*/
class Compiler {
BUGSModel &_model;
CounterTab _countertab;
std::map<std::string, SArray> const &_data_table;
std::map<std::string, std::vector<bool> > _constant_mask;
unsigned int _n_resolved, _n_relations;
std::vector<bool> _is_resolved;
unsigned int _resolution_level;
int _index_expression;
std::vector<Node*> _index_nodes;
LogicalFactory _logicalfactory;
MixtureFactory _mixfactory1;
MixtureFactory _mixfactory2;
std::map<std::string, std::vector<int> > _node_array_bounds;
std::map<std::pair<std::string, Range>, std::set<int> > _umap;
std::set<std::string> _lhs_vars;
Node *getArraySubset(ParseTree const *t);
SimpleRange VariableSubsetRange(ParseTree const *var);
Range CounterRange(ParseTree const *var);
Node* VarGetNode(ParseTree const *var);
Range getRange(ParseTree const *var, SimpleRange const &default_range);
void traverseTree(ParseTree const *relations, CompilerMemFn fun,
bool resetcounter=true);
void allocate(ParseTree const *rel);
Node * allocateStochastic(ParseTree const *stoch_rel);
Node * allocateLogical(ParseTree const *dtrm_rel);
void setConstantMask(ParseTree const *rel);
void writeConstantData(ParseTree const *rel);
Node *getLength(ParseTree const *p, SymTab const &symtab);
Node *getDim(ParseTree const *p, SymTab const &symtab);
void getArrayDim(ParseTree const *p);
bool getParameterVector(ParseTree const *t,
std::vector<Node const *> &parents);
Node * constFromTable(ParseTree const *p);
void addDevianceNode();
Node *getConstant(double value, unsigned int nchain, bool observed);
Node *getConstant(std::vector<unsigned int> const &dim,
std::vector<double> const &value,
unsigned int nchain, bool observed);
void getLHSVars(ParseTree const *rel);
public:
bool indexExpression(ParseTree const *t, std::vector<int> &value);
BUGSModel &model() const;
Node * getParameter(ParseTree const *t);
/**
* @param model Model to be created by the compiler.
*
* @param datatab Data table, mapping a variable name onto a
* multi-dimensional array of values. This is required since some
* constant expressions in the BUGS language may depend on data
* values.
*/
Compiler(BUGSModel &model, std::map<std::string, SArray> const &data_table);
/**
* Adds variables to the symbol table.
*
* @param pvariables vector of ParseTree pointers, each one corresponding
* to a parsed variable declaration.
*/
void declareVariables(std::vector<ParseTree*> const &pvariables);
/**
* Adds variables without an explicit declaration to the symbol
* table. Variables supplied in the data table are added, then
* any variables that appear on the left hand side of a relation
*
* @param prelations ParseTree corresponding to a parsed model block
*/
void undeclaredVariables(ParseTree const *prelations);
/**
* Traverses the ParseTree creating nodes.
*
* @param prelations ParseTree corresponding to a parsed model block
*/
void writeRelations(ParseTree const *prelations);
/**
* The function table used by the compiler to look up functions by
* name. It is shared by all Compiler objects.
*
* @see Module
*/
static FuncTab &funcTab();
/**
* The distribution table used by the compiler to look up
* distributions by name. It is shared by all Compiler objects.
*
* @see Module
*/
static DistTab &distTab();
/**
* The table for observable functions used by the compiler to substitute
* a logical node for a stochastic node when required
*/
static ObsFuncTab &obsFuncTab();
MixtureFactory &mixtureFactory1();
MixtureFactory &mixtureFactory2();
};
} /* namespace jags */
#endif /* COMPILER_H_ */
|