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
00113
#ifdef IGNORE
00114
#undef IGNORE
00115
#endif
00116
00118 struct
00119
SH_DLLEXPORT ShOperationInfo {
00120 const char* name;
00121 int arity;
00122
00123
enum ResultSource {
00124 LINEAR,
00125 ALL,
00126 EXTERNAL,
00127
00128 IGNORE
00129 } result_source;
00130
00131 bool commutative;
00132 };
00133
00134 SH_DLLEXPORT
00135
extern const ShOperationInfo
opInfo[];
00136
00140 class
00141
SH_DLLEXPORT
00142 ShStatementInfo {
00143
public:
00144
virtual ~ShStatementInfo();
00145
00146
virtual ShStatementInfo* clone()
const = 0;
00147
00148
protected:
00149 ShStatementInfo();
00150
00151 };
00152
00161 class
00162
SH_DLLEXPORT ShStatement {
00163
public:
00164 ShStatement(
ShVariable dest,
ShOperation op);
00165 ShStatement(
ShVariable dest,
ShOperation op,
ShVariable src);
00166 ShStatement(
ShVariable dest,
ShVariable src0,
ShOperation op,
ShVariable src1);
00167 ShStatement(
ShVariable dest,
ShOperation op,
ShVariable src0,
ShVariable src1,
ShVariable src2);
00168 ShStatement(
const ShStatement& other);
00169
00170 ~ShStatement();
00171
00172 ShStatement& operator=(
const ShStatement& other);
00173
00174
00175
ShVariable dest;
00176
ShVariable src[3];
00177
00178
ShOperation op;
00179
00180
00181
00182
00183 std::list<ShStatementInfo*> info;
00184
00185
00186
00187
template<
typename T>
00188 T* get_info();
00189
00190
00191
template<
typename T>
00192
void destroy_info();
00193
00194
00195
void add_info(ShStatementInfo* new_info);
00196
00197
00198
00199
void remove_info(ShStatementInfo* old_info);
00200
00201
bool marked;
00202 };
00203
00204 std::ostream&
operator<<(std::ostream& out,
const SH::ShStatement& stmt);
00205
00206
template<
typename T>
00207 T* ShStatement::get_info()
00208 {
00209
for (std::list<ShStatementInfo*>::iterator I = info.begin(); I != info.end(); ++I) {
00210 T* item = dynamic_cast<T*>(*I);
00211
if (item) {
00212
return item;
00213 }
00214 }
00215
return 0;
00216 }
00217
00218
template<
typename T>
00219
void ShStatement::destroy_info()
00220 {
00221
for (std::list<ShStatementInfo*>::iterator I = info.begin(); I != info.end();) {
00222 T* item = dynamic_cast<T*>(*I);
00223
if (item) {
00224 I = info.erase(I);
00225
delete item;
00226 }
else {
00227 ++I;
00228 }
00229 }
00230 }
00231
00232 }
00233
00234
#endif