/usr/include/classad/exprTree.h is in libclassad-dev 8.6.8~dfsg.1-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 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 | /***************************************************************
*
* Copyright (C) 1990-2007, Condor Team, Computer Sciences Department,
* University of Wisconsin-Madison, WI.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you
* may not use this file except in compliance with the License. You may
* obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
***************************************************************/
#ifndef __CLASSAD_EXPR_TREE_H__
#define __CLASSAD_EXPR_TREE_H__
#include "classad/classad_stl.h"
#include "classad/common.h"
#include "classad/value.h"
namespace classad {
// forward declarations
class ExprTree;
class ClassAd;
class MatchClassAd;
class EvalState {
public:
EvalState( );
~EvalState( );
void SetRootScope( );
void SetScopes( const ClassAd* );
int depth_remaining; // max recursion depth - current depth
// Normally, rootAd will be the ClassAd at the root of the tree
// of ExprTrees in the current evaluation. That is, the parent
// scope whose parent scope is NULL.
// It can be set to a closer parent scope. Then that ClassAd is
// treated like it has no parent scope for LookupInScope() and
// Evaluate().
const ClassAd *rootAd;
const ClassAd *curAd;
bool flattenAndInline; // NAC
bool debug;
bool inAttrRefScope;
// Cache_to_free are the things in the cache that must be
// freed when this gets deleted. The problem is that we put
// two kinds of things into the cache: some that must be
// freed, and some that must not be freed. We keep track of
// the ones that must be freed separately. Memory managment
// is a pain! We should all use languages that do memory
// management for you.
//EvalCache cache_to_delete;
};
/** A node of the expression tree, which may be a literal, attribute reference,
function call, classad, expression list, or an operator applied to other
ExprTree operands.
@see NodeKind
*/
class ExprTree
{
public:
/// The kinds of nodes in expression trees
enum NodeKind {
/// Literal node (string, integer, real, boolean, undefined, error)
LITERAL_NODE,
/// Attribute reference node (attr, .attr, expr.attr)
ATTRREF_NODE,
/// Expression operation node (unary, binary, ternary)/
OP_NODE,
/// Function call node
FN_CALL_NODE,
/// ClassAd node
CLASSAD_NODE,
/// Expression list node
EXPR_LIST_NODE,
/// Expression envelope.
EXPR_ENVELOPE
};
/// Virtual destructor
virtual ~ExprTree ();
/** Sets the lexical parent scope of the expression, which is used to
determine the lexical scoping structure for resolving attribute
references. (However, the semantic parent may be different from
the lexical parent if a <tt>super</tt> attribute is specified.)
This method is automatically called when expressions are
inserted into ClassAds, and should thus be called explicitly
only when evaluating expressions which haven't been inserted
into a ClassAd.
@param p The parent ClassAd.
*/
void SetParentScope( const ClassAd* p );
/** Gets the parent scope of the expression.
@return The parent scope of the expression.
*/
const ClassAd *GetParentScope( ) const { return( parentScope ); }
/** Makes a deep copy of the expression tree
* @return A deep copy of the expression, or NULL on failure.
*/
virtual ExprTree *Copy( ) const = 0;
/** Gets the node kind of this expression node.
@return The node kind. Child nodes MUST implement this.
@see NodeKind
*/
virtual NodeKind GetKind (void) const = 0;
/**
* To eliminate the mass of external checks to see if the ExprTree is
* a classad.
*/
virtual bool isClassad(ClassAd ** ptr=0);
/**
* Return a ptr to the raw exprtree below the interface
*/
SAL_Ret_notnull
virtual const ExprTree* self() const;
/* This version is for shared-library compatibility.
* Remove it the next time we have to bump the ClassAds SO version.
*/
SAL_Ret_notnull
virtual const ExprTree* self();
/// A debugging method; send expression to stdout
void Puke( ) const;
/** Evaluate this tree
* @param state The current state
* @param val The result of the evaluation
* @return true on success, false on failure
*/
bool Evaluate( EvalState &state, Value &val ) const;
/** Evaluate this tree.
* This only works if the expression is currently part of a ClassAd.
* @param val The result of the evaluation
* @return true on success, false on failure
*/
bool Evaluate( Value& v ) const;
/** Is this ExprTree the same as the tree?
* @return true if it is the same, false otherwise
*/
virtual bool SameAs(const ExprTree *tree) const = 0;
// Pass in a pointer to a function taking a const char *, which will
// print it out somewhere useful, when the classad debug() function
// is called
static void set_user_debug_function(void (*dbf)(const char *));
protected:
void debug_print(const char *message) const;
void debug_format_value(Value &value, double time=0) const;
ExprTree ();
/** Fill in this ExprTree with the contents of the other ExprTree.
* @return true if the copy succeeded, false otherwise.
*/
void CopyFrom(const ExprTree &literal);
bool Evaluate( Value& v, ExprTree*& t ) const;
bool Flatten( Value& val, ExprTree*& tree) const;
bool Flatten( EvalState&, Value&, ExprTree*&, int* = NULL ) const;
bool Evaluate( EvalState &, Value &, ExprTree *& ) const;
const ClassAd *parentScope;
enum {
EVAL_FAIL,
EVAL_OK,
EVAL_UNDEF,
EVAL_ERROR
};
private:
friend class Operation;
#ifdef TJ_REFACTOR
#else
friend class Operation1;
friend class Operation2;
friend class Operation3;
friend class OperationParens;
#endif
friend class AttributeReference;
friend class FunctionCall;
friend class FunctionTable;
friend class ExprList;
friend class ExprListIterator;
friend class ClassAd;
friend class CachedExprEnvelope;
/// Copy constructor
ExprTree(const ExprTree &tree);
ExprTree &operator=(const ExprTree &literal);
virtual void _SetParentScope( const ClassAd* )=0;
virtual bool _Evaluate( EvalState&, Value& ) const=0;
virtual bool _Evaluate( EvalState&, Value&, ExprTree*& ) const=0;
virtual bool _Flatten( EvalState&, Value&, ExprTree*&, int* )const=0;
friend bool operator==(const ExprTree &tree1, const ExprTree &tree2);
// To avoid making classads depend on a condor debug function,
// have the user set a function to call to debug classads
static void (*user_debug_function)(const char *);
};
std::ostream& operator<<(std::ostream &os, const ExprTree *expr);
} // classad
#include "classad/literals.h"
#include "classad/attrrefs.h"
#include "classad/operators.h"
#include "classad/exprList.h"
#include "classad/classad.h"
#include "classad/fnCall.h"
#endif//__CLASSAD_EXPR_TREE_H__
|