00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00027
#ifndef SHSTATEMENT_HPP
00028
#define SHSTATEMENT_HPP
00029
00030
#include <iosfwd>
00031
#include <set>
00032
#include <list>
00033
#include "ShDllExport.hpp"
00034
#include "ShVariable.hpp"
00035
00036
namespace SH {
00037
00043 enum ShOperation {
00044
SH_OP_ASN,
00045
00046
SH_OP_NEG,
00047
SH_OP_ADD,
00048
SH_OP_MUL,
00049
00050
SH_OP_DIV,
00051
00052
00053
SH_OP_SLT,
00054
SH_OP_SLE,
00055
SH_OP_SGT,
00056
SH_OP_SGE,
00057
SH_OP_SEQ,
00058
SH_OP_SNE,
00059
00060
SH_OP_ABS,
00061
SH_OP_ACOS,
00062
SH_OP_ASIN,
00063
SH_OP_ATAN,
00064
SH_OP_ATAN2,
00065
SH_OP_CBRT,
00066
SH_OP_CEIL,
00067
SH_OP_COS,
00068
SH_OP_CMUL,
00069
SH_OP_CSUM,
00070
SH_OP_DOT,
00071
SH_OP_DX,
00072
SH_OP_DY,
00073
SH_OP_EXP,
00074
SH_OP_EXP2,
00075
SH_OP_EXP10,
00076
SH_OP_FLR,
00077
SH_OP_FRAC,
00078
SH_OP_LRP,
00079
SH_OP_MAD,
00080
SH_OP_MAX,
00081
SH_OP_MIN,
00082
SH_OP_MOD,
00083
SH_OP_LOG,
00084
SH_OP_LOG2,
00085
SH_OP_LOG10,
00086
SH_OP_POW,
00087
SH_OP_RCP,
00088
SH_OP_RND,
00089
SH_OP_RSQ,
00090
SH_OP_SIN,
00091
SH_OP_SGN,
00092
SH_OP_SQRT,
00093
SH_OP_TAN,
00094
00095
SH_OP_NORM,
00096
SH_OP_XPD,
00097
00098
SH_OP_TEX,
00099
SH_OP_TEXI,
00100
SH_OP_TEXD,
00101
00102
SH_OP_COND,
00103
00104
SH_OP_KIL,
00105
00106
SH_OP_OPTBRA,
00107
00108
00109
00110
SH_OP_FETCH,
00111
00112
SH_OP_PAL,
00113 };
00114
00115
#ifdef IGNORE
00116
#undef IGNORE
00117
#endif
00118
00120 struct
00121
SH_DLLEXPORT ShOperationInfo {
00122 const char* name;
00123 int arity;
00124
00125
enum ResultSource {
00126 LINEAR,
00127 ALL,
00128 EXTERNAL,
00129
00130 IGNORE
00131 } result_source;
00132
00133 bool commutative;
00134 };
00135
00136 SH_DLLEXPORT
00137
extern const ShOperationInfo
opInfo[];
00138
00142 class
00143
SH_DLLEXPORT
00144 ShStatementInfo {
00145
public:
00146
virtual ~ShStatementInfo();
00147
00148
virtual ShStatementInfo* clone()
const = 0;
00149
00150
protected:
00151 ShStatementInfo();
00152
00153 };
00154
00163 class
00164
SH_DLLEXPORT ShStatement {
00165
public:
00166 ShStatement(
ShVariable dest,
ShOperation op);
00167 ShStatement(
ShVariable dest,
ShOperation op,
ShVariable src);
00168 ShStatement(
ShVariable dest,
ShVariable src0,
ShOperation op,
ShVariable src1);
00169 ShStatement(
ShVariable dest,
ShOperation op,
ShVariable src0,
ShVariable src1,
ShVariable src2);
00170 ShStatement(
const ShStatement& other);
00171
00172 ~ShStatement();
00173
00174 ShStatement& operator=(
const ShStatement& other);
00175
00176
00177
ShVariable dest;
00178
ShVariable src[3];
00179
00180
ShOperation op;
00181
00182
00183
00184
00185 std::list<ShStatementInfo*> info;
00186
00187
00188
00189
template<
typename T>
00190 T* get_info();
00191
00192
00193
template<
typename T>
00194
void destroy_info();
00195
00196
00197
void add_info(ShStatementInfo* new_info);
00198
00199
00200
00201
void remove_info(ShStatementInfo* old_info);
00202
00203
bool marked;
00204 };
00205
00206 std::ostream&
operator<<(std::ostream& out,
const SH::ShStatement& stmt);
00207
00208
template<
typename T>
00209 T* ShStatement::get_info()
00210 {
00211
for (std::list<ShStatementInfo*>::iterator I = info.begin(); I != info.end(); ++I) {
00212 T* item = dynamic_cast<T*>(*I);
00213
if (item) {
00214
return item;
00215 }
00216 }
00217
return 0;
00218 }
00219
00220
template<
typename T>
00221
void ShStatement::destroy_info()
00222 {
00223
for (std::list<ShStatementInfo*>::iterator I = info.begin(); I != info.end();) {
00224 T* item = dynamic_cast<T*>(*I);
00225
if (item) {
00226 I = info.erase(I);
00227
delete item;
00228 }
else {
00229 ++I;
00230 }
00231 }
00232 }
00233
00234 }
00235
00236
#endif