HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros 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_IntArray.h>
19 #include <UT/UT_Set.h>
20 #include <iosfwd>
21 
22 class EX_Stream; // Internal classes
23 class EX_Token;
24 class EX_Function;
25 
27 public:
28  //EX_Symbol(const char *name);
29  EX_Symbol(const char *name, int type, int thread);
30  ~EX_Symbol();
31 
32  int64 getMemoryUsage(bool inclusive) const;
33 
34  int myFlag;
38 };
39 
41 public:
42  EX_ExprLine();
43  ~EX_ExprLine();
44 
45  int64 getMemoryUsage(bool inclusive) const;
46 
47  bool saveCompiled(std::ostream &os);
48  bool loadCompiled(UT_IStream &is);
49 
50  void setExpression(const char *source);
51 
52  int myFlag;
53  int myLineNum;
54  int myOperand;
60 };
61 
63 public:
64  EX_ExprFunc();
65  ~EX_ExprFunc();
66 
67  int64 getMemoryUsage(bool inclusive) const;
68 
69  // These return 0 on failure, 1 on success. When loading, the
70  // stream will be positioned just after the last line of the function
71  // read.
72  int save(std::ostream &os);
73  bool saveCompiled(std::ostream &os, int thread);
74  bool load(UT_IStream &is, const char *filename, std::ostream *err,
75  int thread);
76  bool loadCompiled(UT_IStream &is, int thread);
77 
78  // This function will wire in the function to the expression library
79  void wire();
80 
81  const char *getName() const { return myName; }
82  int getNArgs() const { return myArgTypes.entries(); }
83  const char *getReturnType() const;
84  const char *getArgName(int i);
85  const char *getArgType(int i);
86 
87  void touchMyReferences();
88  void functionDeleted(EV_EXPRESSION *expr);
89 
90  void updateDependency(void *ref_id, int thread);
91  int changeOpReference(UT_String &new_source,
92  const EV_ChangeOpReferenceParms &parms,
93  int thread);
94 
95  void setInlineFlag(bool f) { myInlineFlag = f; }
96  bool getInlineFlag() const { return myInlineFlag; }
97 
98  int getRunningCount() const { return myRunningCount; }
99 
100  void unresolveLocalVars(int thread);
101 
102 private:
103  void unwire();
104 
105  void errorMessage(const char *fmt, int linenum = -1,
106  const char *a1=0, const char *a2=0);
107 
108 
109  int getLastLineNum() const;
110  int checkValidName(const char *name);
111  int checkType(const char *name);
112  EX_Symbol *symbolExists(const char *name);
113  EX_Symbol *addToSymbolTable(const char *name, int type, bool exists,
114  int thread);
115  void addLineToExpr(EX_ExprLine *line);
116  int addLoopBranch(int linenum);
117  void resolveBreakCont(EX_ExprLine *line, int brk, int cont);
118  int getAssignment(EX_ExprLine *, EX_Stream &, EX_Token *, int eol,
119  int thread);
120  int doForLine(EX_ExprLine *line, EX_Stream &is, int thread);
121  int doWhileLine(EX_ExprLine *line, EX_Stream &is, int thread);
122  int doIfLine(EX_ExprLine *line, EX_Stream &is, int thread);
123  int doBreakLine(EX_ExprLine *line, EX_Stream &is, int);
124  int doReturnLine(EX_ExprLine *line, EX_Stream &is);
125  int addReturn0();
126  int parseLine(EX_Stream &is, int thread);
127  int resolveBranches();
128  int parseFunction(EX_Stream &is, int thread);
129 
130  int getScopeNest(EX_Stream &is, int thread);
131 
132  void internalEvaluate(EV_SYMBOL *result, EV_SYMBOL **argv,
133  int thread, unsigned &func_flags);
134  static void evaluate(EV_FUNCTION *, EV_SYMBOL *result, EV_SYMBOL **argv,
135  int thread, unsigned int &func_flags);
136 
137  // Load helper methods.
138  int load(EX_Stream &xis, const char *filename, std::ostream *err,
139  int thread);
140 
141  UT_String myName;
142  UT_String mySourceFile;
143  UT_IntArray myArgTypes;
144  int myResultType;
145  UT_String mySource;
146  std::ostream*myError;
147 
148  bool myInlineFlag;
149  int myRunningCount;
150 
151 
152  EX_Symbol *mySymbols;
153  EX_ExprLine *myLines;
154  EX_ExprLine *myLastLine;
155  EX_Function *myTableEntry;
156  UT_Set<EV_EXPRESSION *> myReferences;
157 };
158 
159 #endif
bool getInlineFlag() const
Definition: EX_ExprFunc.h:96
EX_ExprLine * myBranch
Definition: EX_ExprFunc.h:57
EV_EXPRESSION * myExpr
Definition: EX_ExprFunc.h:56
png_uint_32 i
Definition: png.h:2877
EV_SYMBOL * mySym
Definition: EX_ExprFunc.h:36
long long int64
Definition: SYS_Types.h:106
int myBranchNum
Definition: EX_ExprFunc.h:59
const char * getName() const
Definition: EX_ExprFunc.h:81
GLfloat f
Definition: glcorearb.h:1925
GLsizei GLsizei GLchar * source
Definition: glcorearb.h:802
GLuint const GLchar * name
Definition: glcorearb.h:785
class representing a symbol operated upon by expressions
Definition: EXPR.h:157
int getRunningCount() const
Definition: EX_ExprFunc.h:98
EX_ExprLine * myNext
Definition: EX_ExprFunc.h:58
EX_Symbol * myNext
Definition: EX_ExprFunc.h:37
GLint GLint GLsizei GLint GLenum GLenum type
Definition: glcorearb.h:107
int myFlag
Definition: EX_ExprFunc.h:34
#define EXPR_API
Definition: EXPR_API.h:10
int getNArgs() const
Definition: EX_ExprFunc.h:82
EX_Symbol * mySymbols
Definition: EX_ExprFunc.h:55
UT_String myName
Definition: EX_ExprFunc.h:35
void setInlineFlag(bool f)
Definition: EX_ExprFunc.h:95