LTP GCOV extension - code coverage report
Current view: directory - src/libexpr - eval.hh
Test: app.info
Date: 2008-11-20 Instrumented lines: 1
Code covered: 100.0 % Executed lines: 1

       1                 : #ifndef __EVAL_H
       2                 : #define __EVAL_H
       3                 : 
       4                 : #include <map>
       5                 : 
       6                 : #include "aterm.hh"
       7                 : #include "nixexpr.hh"
       8                 : 
       9                 : 
      10                 : namespace nix {
      11                 : 
      12                 : 
      13                 : class Hash;
      14                 :     
      15                 : 
      16                 : typedef std::map<Path, PathSet> DrvRoots;
      17                 : typedef std::map<Path, Hash> DrvHashes;
      18                 : 
      19                 : /* Cache for calls to addToStore(); maps source paths to the store
      20                 :    paths. */
      21                 : typedef std::map<Path, Path> SrcToStore;
      22                 : 
      23                 : struct EvalState;
      24                 : 
      25                 : /* Note: using a ATermVector is safe here, since when we call a primop
      26                 :    we also have an ATermList on the stack. */
      27                 : typedef Expr (* PrimOp) (EvalState &, const ATermVector & args);
      28                 : 
      29                 : 
      30                 : struct EvalState 
      31             236 : {
      32                 :     ATermMap normalForms;
      33                 :     ATermMap primOps;
      34                 :     DrvRoots drvRoots;
      35                 :     DrvHashes drvHashes; /* normalised derivation hashes */
      36                 :     SrcToStore srcToStore; 
      37                 : 
      38                 :     unsigned int nrEvaluated;
      39                 :     unsigned int nrCached;
      40                 : 
      41                 :     EvalState();
      42                 : 
      43                 :     void addPrimOps();
      44                 :     void addPrimOp(const string & name,
      45                 :         unsigned int arity, PrimOp primOp);
      46                 : };
      47                 : 
      48                 : 
      49                 : /* Evaluate an expression to normal form. */
      50                 : Expr evalExpr(EvalState & state, Expr e);
      51                 : 
      52                 : /* Evaluate an expression read from the given file to normal form. */
      53                 : Expr evalFile(EvalState & state, const Path & path);
      54                 : 
      55                 : /* Evaluate an expression, and recursively evaluate list elements and
      56                 :    attributes.  If `canonicalise' is true, we remove things like
      57                 :    position information and make sure that attribute sets are in
      58                 :    sorded order. */
      59                 : Expr strictEvalExpr(EvalState & state, Expr e);
      60                 : 
      61                 : /* Specific results. */
      62                 : string evalString(EvalState & state, Expr e, PathSet & context);
      63                 : string evalStringNoCtx(EvalState & state, Expr e);
      64                 : int evalInt(EvalState & state, Expr e);
      65                 : bool evalBool(EvalState & state, Expr e);
      66                 : ATermList evalList(EvalState & state, Expr e);
      67                 : 
      68                 : /* Flatten nested lists into a single list (or expand a singleton into
      69                 :    a list). */
      70                 : ATermList flattenList(EvalState & state, Expr e);
      71                 : 
      72                 : /* String coercion.  Converts strings, paths and derivations to a
      73                 :    string.  If `coerceMore' is set, also converts nulls, integers,
      74                 :    booleans and lists to a string. */
      75                 : string coerceToString(EvalState & state, Expr e, PathSet & context,
      76                 :     bool coerceMore = false, bool copyToStore = true);
      77                 : 
      78                 : /* Path coercion.  Converts strings, paths and derivations to a path.
      79                 :    The result is guaranteed to be an canonicalised, absolute path.
      80                 :    Nothing is copied to the store. */
      81                 : Path coerceToPath(EvalState & state, Expr e, PathSet & context);
      82                 : 
      83                 : /* Automatically call a function for which each argument has a default
      84                 :    value or has a binding in the `args' map.  Note: result is a call,
      85                 :    not a normal form; it should be evaluated by calling evalExpr(). */
      86                 : Expr autoCallFunction(Expr e, const ATermMap & args);
      87                 : 
      88                 : /* Print statistics. */
      89                 : void printEvalStats(EvalState & state);
      90                 : 
      91                 :  
      92                 : }
      93                 : 
      94                 : 
      95                 : #endif /* !__EVAL_H */

Generated by: LTP GCOV extension version 1.6