HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
EX_ExprFunc.h
Go to the documentation of this file.
1 /*
2  * PROPRIETARY INFORMATION. This software is proprietary to
3  * Side Effects Software Inc., and is not to be reproduced,
4  * transmitted, or disclosed in any way without written permission.
5  *
6  * NAME: Expr library (C++)
7  *
8  * COMMENTS: This is a real C++ class which provides an interface
9  * to the expression functions for Houdini
10  *
11  */
12 
13 #ifndef __EX_Func_h__
14 #define __EX_Func_h__
15 
16 #include "EXPR_API.h"
17 #include "EXPR.h"
18 #include <UT/UT_Array.h>
19 #include <UT/UT_IntArray.h>
20 #include <UT/UT_NonCopyable.h>
21 #include <UT/UT_Set.h>
22 #include <iosfwd>
23 
24 class EX_Stream; // Internal classes
25 class EX_Token;
26 class EX_Function;
27 struct ex_Locals;
28 
30 public:
31  //EX_Symbol(const char *name);
32  EX_Symbol(const char *name, int type, int thread);
33 
34  int64 getMemoryUsage(bool inclusive) const;
35 
36  int myFlag;
37  int myType;
39 };
40 
42 {
43 public:
44  EX_ExprLine();
45  ~EX_ExprLine();
46 
48 
49  int64 getMemoryUsage(bool inclusive) const;
50 
51  bool saveCompiled(std::ostream &os);
52  bool loadCompiled(UT_IStream &is);
53 
54  void setExpression(const char *source);
55 
56  int myFlag;
57  int myLineNum;
58  int myOperand;
64 };
65 
67 {
68 public:
69  EX_ExprFunc();
70  ~EX_ExprFunc();
71 
73 
74  int64 getMemoryUsage(bool inclusive) const;
75 
76  // These return 0 on failure, 1 on success. When loading, the
77  // stream will be positioned just after the last line of the function
78  // read.
79  int save(std::ostream &os);
80  bool saveCompiled(std::ostream &os, int thread);
81  bool load(UT_IStream &is, const char *filename, std::ostream *err,
82  int thread);
83  bool loadCompiled(UT_IStream &is, int thread);
84 
85  // This function will wire in the function to the expression library
86  void wire();
87 
88  const char *getName() const { return myName; }
89  int getNArgs() const { return myArgTypes.entries(); }
90  const char *getReturnType() const;
91  const char *getArgName(int i);
92  const char *getArgType(int i);
93 
94  void functionDeleted(EV_EXPRESSION *expr);
95 
96  void updateDependency(void *ref_id, int thread);
97  int changeOpReference(UT_String &new_source,
98  const EV_ChangeOpReferenceParms &parms,
99  int thread);
100 
101  void setInlineFlag(bool f) { myInlineFlag = f; }
102  bool getInlineFlag() const { return myInlineFlag; }
103 
104  int getRunningCount() const { return myRunningCount; }
105 
106  void unresolveLocalVars(int thread);
107 
108 private:
109  void unwire();
110 
111  void errorMessage(const char *fmt, int linenum = -1,
112  const char *a1=0, const char *a2=0);
113 
114 
115  int getLastLineNum() const;
116  int checkValidName(const char *name);
117  int checkType(const char *name);
118  int symbolExists(const char *name);
119  int addToSymbolTable(const char *name, int type, bool exists,
120  int thread);
121  void addLineToExpr(EX_ExprLine *line);
122  int addLoopBranch(int linenum);
123  void resolveBreakCont(EX_ExprLine *line, int brk, int cont);
124  int getAssignment(EX_ExprLine *, EX_Stream &, EX_Token *, int eol,
125  int thread);
126  int doForLine(EX_ExprLine *line, EX_Stream &is, int thread);
127  int doWhileLine(EX_ExprLine *line, EX_Stream &is, int thread);
128  int doIfLine(EX_ExprLine *line, EX_Stream &is, int thread);
129  int doBreakLine(EX_ExprLine *line, EX_Stream &is, int);
130  int doReturnLine(EX_ExprLine *line, EX_Stream &is);
131  int addReturn0();
132  int parseLine(EX_Stream &is, int thread);
133  int resolveBranches();
134  int parseFunction(EX_Stream &is, int thread);
135 
136  int getScopeNest(EX_Stream &is, int thread);
137 
138  void internalEvaluate(EV_SYMBOL *result, EV_SYMBOL **argv,
139  int thread, unsigned &func_flags);
140  static void evaluate(EV_FUNCTION *, EV_SYMBOL *result, EV_SYMBOL **argv,
141  int thread, unsigned int &func_flags);
142 
143  // Load helper methods.
144  int load(EX_Stream &xis, const char *filename, std::ostream *err,
145  int thread);
146 
147  inline ex_Locals *pushLocals(ex_Locals &locals, int thread);
148  inline void popLocals(ex_Locals *locals, int thread);
149 
150 
151  static void dependEvalCallback(EV_FUNCTION *me, EV_SYMBOL **argv,
152  void *ref_id);
153 
154  UT_String myName;
155  UT_String mySourceFile;
156  UT_IntArray myArgTypes;
157  int myResultType;
158  UT_String mySource;
159  std::ostream*myError;
160 
161  bool myInlineFlag;
162  int myRunningCount;
163 
164 
165  UT_Array<EX_Symbol> mySymbols;
166  EX_ExprLine *myLines;
167  EX_ExprLine *myLastLine;
168  EX_Function *myTableEntry;
169  UT_Set<EV_EXPRESSION *> myReferences;
170 };
171 
172 #endif
GT_API const UT_StringHolder filename
bool getInlineFlag() const
Definition: EX_ExprFunc.h:102
int mySymbolIndex
Definition: EX_ExprFunc.h:59
EX_ExprLine * myBranch
Definition: EX_ExprFunc.h:61
EV_EXPRESSION * myExpr
Definition: EX_ExprFunc.h:60
**But if you need a result
Definition: thread.h:613
int myBranchNum
Definition: EX_ExprFunc.h:63
const char * getName() const
Definition: EX_ExprFunc.h:88
GLfloat f
Definition: glcorearb.h:1926
GLsizei GLsizei GLchar * source
Definition: glcorearb.h:803
#define UT_NON_COPYABLE(CLASS)
Define deleted copy constructor and assignment operator inside a class.
int myType
Definition: EX_ExprFunc.h:37
long long int64
Definition: SYS_Types.h:116
OIIO_UTIL_API bool exists(string_view path) noexcept
GLuint const GLchar * name
Definition: glcorearb.h:786
class representing a symbol operated upon by expressions
Definition: EXPR.h:159
**Note that the tasks the is the thread number *for the or if it s being executed by a non pool thread(this *can happen in cases where the whole pool is occupied and the calling *thread contributes to running the work load).**Thread pool.Have fun
int getRunningCount() const
Definition: EX_ExprFunc.h:104
EX_ExprLine * myNext
Definition: EX_ExprFunc.h:62
int myFlag
Definition: EX_ExprFunc.h:36
#define EXPR_API
Definition: EXPR_API.h:10
int getNArgs() const
Definition: EX_ExprFunc.h:89
type
Definition: core.h:1059
UT_String myName
Definition: EX_ExprFunc.h:38
void setInlineFlag(bool f)
Definition: EX_ExprFunc.h:101