00001 #include "../cvdl.h"
00002
00003 int main(int argc, char *argv[])
00004 {
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036 BinStr bin;
00037 bin.read("/groups/polaris/work/cvdl/base/test/binstrings/TIS.olda.bs");
00038
00039 ProgramUnit pgm("PGM1", bin);
00040
00041 cout << "Expression construction functions:" << endl;
00042
00043 Expression *new_e, *new_e2, *new_e3, *new_e4;
00044
00045 new_e = add(constant(1), constant(1));
00046 cout << *new_e ;
00047 new_e = simplify(new_e);
00048 cout << " -> " << *new_e << endl;
00049 new_e = sub(constant("1.0"),add(constant(1), constant("1.0d0")));
00050 cout << *new_e ;
00051 new_e = simplify(new_e);
00052 cout << " -> " << *new_e << endl;
00053
00054 new_e = id("NUM", pgm);
00055 cout << *new_e << endl;
00056 new_e2 = eq(add(constant(1), new_e), mul(constant("2.0"), new_e->clone()));
00057 cout << *new_e2 << endl;
00058
00059 new_e = not(eq(add(constant(1), id("NUM", pgm)), mul(constant("2.0"), unary_minus(id("NUM", pgm)))));
00060 cout << *new_e << endl;
00061
00062 new_e = and(constant(".true."), constant(".false."));
00063 cout << *new_e << endl;
00064
00065 new_e = add(new_variable("XXQQ10", make_type(INTEGER_TYPE,4), pgm),constant(2));
00066 cout << *new_e << endl;
00067
00068 new_e = new_array_variable("YYQQ10",
00069 make_type(INTEGER_TYPE, 4),
00070 pgm,
00071 colon(constant(1),constant(10)));
00072 cout << *new_e << endl;
00073
00074 new_e = new_array_variable( "YYQQ20", make_type(REAL_TYPE, 8),
00075 pgm,
00076 colon(constant(1),constant(10)),
00077 colon(constant(1),constant(100)) );
00078 cout << *new_e << endl;
00079
00080 new_e = new_function("addup", make_type(REAL_TYPE, 8), pgm);
00081 new_e2 = function_call(new_e,
00082 comma(constant(6),
00083 add(id("NUM",pgm),constant(1)),
00084 exponent(id("NUM", pgm),constant(2))));
00085 cout << *new_e2 << endl;
00086
00087 new_e = div(id("NUM",pgm),paren(add(constant(10),id("NUM",pgm))));
00088 cout << *new_e << endl;
00089
00090 new_e = concat(constant("'hi there'"),constant("'how''re ya doin''?'"));
00091 cout << *new_e << endl;
00092
00093
00094
00095 new_e = constant("17.7");
00096 if (is_integer_constant(*new_e))
00097 cout << "ERROR: system thinks " << *new_e << " is an integer constant" << endl;
00098 else
00099 cout << "OK: system knows that " << *new_e << " is not an integer constant" << endl;
00100
00101 new_e = constant(5);
00102 if (is_integer_constant(*new_e))
00103 cout << "OK: system knows that " << *new_e << " is an integer constant" << endl;
00104 else
00105 cout << "ERROR: system thinks " << *new_e << " is not an integer constant" << endl;
00106
00107 if (is_integer_zero(*new_e))
00108 cout << "ERROR: system thinks " << *new_e << " is an integer zero" << endl;
00109 else
00110 cout << "OK: system knows that " << *new_e << " is not an integer zero" << endl;
00111
00112 new_e = constant (0);
00113 if (is_integer_zero(*new_e))
00114 cout << "OK: system knows that " << *new_e << " is an integer zero" << endl;
00115 else
00116 cout << "ERROR: system thinks " << *new_e << " is not an integer zero" << endl;
00117
00118
00119
00120
00121
00122
00123
00124
00125
00126
00127
00128
00129
00130
00131
00132
00133 Iterator<Statement> li = pgm.iterate_block(pgm.first_stmt_ref(),
00134 pgm.last_stmt_ref());
00135
00136 for (li.reset(); li.valid(); ++li) {
00137
00138 li.current().fortran_write(cout,0);
00139 cout << endl;
00140
00141 int i = 0;
00142
00143 for (Iterator<Expression> iter=li.current().iterate_expressions();
00144 iter.valid();
00145 ++iter)
00146 {
00147 if (iter.current_valid()) {
00148 cout << "Expression " << i++ << ": " << iter.current() << endl;
00149 cout << endl;
00150 }
00151 }
00152 }
00153 };