1 // -*- mode: C++ -*- 2 // 3 // Copyright (c) 2007, 2008, 2009, 2010, 2011, 2014, 2015 The University of Utah 4 // All rights reserved. 5 // 6 // This file is part of `csmith', a random generator of C programs. 7 // 8 // Redistribution and use in source and binary forms, with or without 9 // modification, are permitted provided that the following conditions are met: 10 // 11 // * Redistributions of source code must retain the above copyright notice, 12 // this list of conditions and the following disclaimer. 13 // 14 // * Redistributions in binary form must reproduce the above copyright 15 // notice, this list of conditions and the following disclaimer in the 16 // documentation and/or other materials provided with the distribution. 17 // 18 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 19 // AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 20 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 21 // ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 22 // LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 23 // CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 24 // SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 25 // INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 26 // CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 27 // ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 28 // POSSIBILITY OF SUCH DAMAGE. 29 30 #ifndef FUNCTION_INVOCATION_BINARY_H 31 #define FUNCTION_INVOCATION_BINARY_H 32 33 /////////////////////////////////////////////////////////////////////////////// 34 35 #include <ostream> 36 #include <string> 37 38 #include "FunctionInvocation.h" 39 40 class Type; 41 class Variable; 42 class CGContext; 43 44 class FunctionInvocationBinary : public FunctionInvocation 45 { 46 friend class FunctionInvocation; /* XXX --- yuck! */ 47 48 public: 49 50 static FunctionInvocationBinary *CreateFunctionInvocationBinary(CGContext &cg_context, eBinaryOps op, SafeOpFlags *flags); 51 52 FunctionInvocationBinary(eBinaryOps op, const SafeOpFlags *flags); 53 54 FunctionInvocationBinary(eBinaryOps op, const SafeOpFlags *flags, std::string &name1, std::string &name2); 55 56 FunctionInvocationBinary(eBinaryOps op, const Expression* exp1, const Expression* exp2, const SafeOpFlags *flags); 57 58 virtual ~FunctionInvocationBinary(void); 59 60 virtual FunctionInvocation * clone() const; 61 compatible(const Variable *)62 virtual bool compatible(const Variable *) const { return false; } 63 64 virtual const Type &get_type(void) const; 65 66 virtual void Output(std::ostream &) const; 67 68 virtual void indented_output(std::ostream &out, int indent) const; 69 safe_invocation()70 virtual bool safe_invocation() const { return false; } 71 72 virtual bool visit_facts(vector<const Fact*>& inputs, CGContext& cg_context) const; 73 get_operation(void)74 eBinaryOps get_operation(void) const {return eFunc;} set_operation(eBinaryOps op)75 void set_operation(eBinaryOps op) { eFunc = op;} 76 get_tmp_var1()77 std::string get_tmp_var1() { return tmp_var1; } 78 get_tmp_var2()79 std::string get_tmp_var2() { return tmp_var2; } 80 81 static std::string get_binop_string(eBinaryOps bop); 82 83 virtual bool equals(int num) const ; 84 virtual bool is_0_or_1(void) const; 85 86 private: 87 eBinaryOps eFunc; 88 89 std::string tmp_var1; 90 91 std::string tmp_var2; 92 93 private: 94 95 bool is_return_type_float() const; 96 97 static bool safe_ops(eBinaryOps op); 98 99 // unimplemented 100 FunctionInvocationBinary &operator=(const FunctionInvocationBinary &fi); 101 102 explicit FunctionInvocationBinary(const FunctionInvocationBinary &fbinary); 103 104 }; 105 106 /////////////////////////////////////////////////////////////////////////////// 107 108 #endif // FUNCTION_INVOCATION_BINARY_H 109 110 // Local Variables: 111 // c-basic-offset: 4 112 // tab-width: 4 113 // End: 114 115 // End of file. 116