1 /*
2 
3 Copyright (C) 2015-2018 Night Dive Studios, LLC.
4 
5 This program is free software: you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation, either version 3 of the License, or
8 (at your option) any later version.
9 
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13 GNU General Public License for more details.
14 
15 You should have received a copy of the GNU General Public License
16 along with this program.  If not, see <http://www.gnu.org/licenses/>.
17 
18 */
19 /*
20  * $Header: r:/prj/lib/src/fixpp/RCS/fixpp.cc 1.28 1994/08/30 11:32:42 jak Exp $
21  */
22 
23 // ЅЅЅ For now, turn debugging on, so we can run the test programs.
24 //#define FIXDEBUG 1
25 
26 #ifdef FIXDEBUG
27 
28 #include "fixpp.h"
29 #include <iostream>
30 
31 // =========================================================
32 // touch() is a function that does nothing except cause the
33 // variable passed in to "escape" in the optimization sense,
34 // so that the compiler cannot optimize it as much.
35 // =========================================================
36 
touch(Fixpoint & a)37 void touch(Fixpoint &a) { a = a; }
38 
39 // ===========================================================
40 // bitdump() dumps the fixpoint to a string and returns
41 // the address of the string.
42 // ===========================================================
43 
bitdump(Fixpoint & a)44 char *bitdump(Fixpoint &a) {
45     static char string[30];
46 
47     sprintf(string, "[%#lx]", a.val);
48 
49     return string;
50 }
51 
52 uint8_t Fixpoint::click_bool = 1;
53 
54 uint32_t Fixpoint::constructor_void = 0, Fixpoint::constructor_Fixpoint = 0, Fixpoint::constructor_int = 0,
55     Fixpoint::constructor_uint = 0, Fixpoint::constructor_lint = 0, Fixpoint::constructor_ulint = 0,
56     Fixpoint::constructor_double = 0;
57 
58 uint32_t Fixpoint::ass_Fixpoint = 0, Fixpoint::ass_int = 0, Fixpoint::ass_lint = 0, Fixpoint::ass_uint = 0,
59     Fixpoint::ass_ulint = 0, Fixpoint::ass_double = 0;
60 
61 uint32_t Fixpoint::binary_add = 0, Fixpoint::binary_div = 0, Fixpoint::binary_sub = 0, Fixpoint::binary_mul = 0;
62 
63 uint32_t Fixpoint::add_eq = 0, Fixpoint::sub_eq = 0, Fixpoint::mul_eq = 0, Fixpoint::div_eq = 0;
64 
65 uint32_t Fixpoint::unary_minus = 0, Fixpoint::unary_plus = 0;
66 
67 uint32_t Fixpoint::cond_l = 0, Fixpoint::cond_g = 0, Fixpoint::cond_le = 0, Fixpoint::cond_ge = 0,
68     Fixpoint::cond_eq = 0, Fixpoint::cond_neq = 0;
69 
report(void)70 void Fixpoint::report(void) { report(std::cout); }
71 
report(std::ostream & os)72 void Fixpoint::report(std::ostream &os) {
73     os << "Constructor     void: " << constructor_void << '\n';
74     os << "Constructor Fixpoint: " << constructor_Fixpoint << '\n';
75     os << "Constructor      int: " << constructor_int << '\n';
76     os << "Constructor     lint: " << constructor_lint << '\n';
77     os << "Constructor     uint: " << constructor_uint << '\n';
78     os << "Constructor    ulint: " << constructor_ulint << '\n';
79     os << "Constructor   double: " << constructor_double << '\n';
80 
81     os << "Assign to Fixpoint:   " << ass_Fixpoint << '\n';
82     os << "Assign to int:        " << ass_int << '\n';
83     os << "Assign to uint:       " << ass_uint << '\n';
84     os << "Assign to lint:       " << ass_lint << '\n';
85     os << "Assign to ulint:      " << ass_ulint << '\n';
86     os << "Assign to double:     " << ass_double << '\n';
87 
88     os << "Binary Add:           " << binary_add << '\n';
89     os << "Binary Sub:           " << binary_sub << '\n';
90     os << "Binary Div:           " << binary_div << '\n';
91     os << "Binary Mul:           " << binary_mul << '\n';
92 
93     os << "Add-equals            " << add_eq << '\n';
94     os << "Sub-equals            " << sub_eq << '\n';
95     os << "Mul-equals            " << mul_eq << '\n';
96     os << "Div-equals            " << div_eq << '\n';
97 
98     os << "Unary minus           " << unary_minus << '\n';
99     os << "Unary  plus           " << unary_plus << '\n';
100 
101     os << "<                     " << cond_l << '\n';
102     os << ">                     " << cond_g << '\n';
103     os << "<=                    " << cond_le << '\n';
104     os << ">=                    " << cond_ge << '\n';
105     os << "==                    " << cond_eq << '\n';
106     os << "!=                    " << cond_neq << '\n';
107 }
108 
reset_report(void)109 void Fixpoint::reset_report(void) {
110     constructor_void = constructor_Fixpoint = constructor_int = constructor_uint = constructor_lint =
111         constructor_ulint = constructor_double = ass_Fixpoint = ass_int = ass_uint = ass_lint = ass_ulint =
112         ass_double = binary_add = binary_sub = binary_div = binary_mul = add_eq = sub_eq = mul_eq = div_eq =
113         unary_minus = unary_plus = cond_l = cond_g = cond_le = cond_ge = cond_eq = cond_neq = 0;
114 }
115 
116 #endif /* FIXDEBUG */
117