Diffstat (limited to 'noncore/tools/calc2/binary/binaryimpl.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/tools/calc2/binary/binaryimpl.cpp | 110 |
1 files changed, 110 insertions, 0 deletions
diff --git a/noncore/tools/calc2/binary/binaryimpl.cpp b/noncore/tools/calc2/binary/binaryimpl.cpp new file mode 100644 index 0000000..ffc56ad --- a/dev/null +++ b/noncore/tools/calc2/binary/binaryimpl.cpp | |||
@@ -0,0 +1,110 @@ | |||
1 | /********************************************************************** | ||
2 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. | ||
3 | ** | ||
4 | ** This file is part of Qtopia Environment. | ||
5 | ** | ||
6 | ** This file may be distributed and/or modified under the terms of the | ||
7 | ** GNU General Public License version 2 as published by the Free Software | ||
8 | ** Foundation and appearing in the file LICENSE.GPL included in the | ||
9 | ** packaging of this file. | ||
10 | ** | ||
11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | ||
12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | ||
13 | ** | ||
14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | ||
15 | ** | ||
16 | ** Contact info@trolltech.com if any conditions of this licensing are | ||
17 | ** not clear to you. | ||
18 | ** | ||
19 | **********************************************************************/ | ||
20 | |||
21 | #include "binaryimpl.h" | ||
22 | #include <instruction.h> | ||
23 | |||
24 | class iXOR : public Instruction { | ||
25 | public: | ||
26 | iXOR():Instruction(){}; | ||
27 | ~iXOR(){}; | ||
28 | Data eval(Data num) { | ||
29 | Data result; | ||
30 | result.i = num.i ^ acc.i; | ||
31 | return result; | ||
32 | }; | ||
33 | }; | ||
34 | class iAND : public Instruction { | ||
35 | public: | ||
36 | iAND():Instruction(){}; | ||
37 | ~iAND(){}; | ||
38 | Data eval(Data num) { | ||
39 | Data result; | ||
40 | result.i = num.i & acc.i; | ||
41 | return result; | ||
42 | }; | ||
43 | }; | ||
44 | class iNOT : public Instruction { | ||
45 | public: | ||
46 | iNOT():Instruction(){}; | ||
47 | ~iNOT(){}; | ||
48 | Data eval(Data num) { | ||
49 | Data result; | ||
50 | result.i = ~ num.i; | ||
51 | return result; | ||
52 | }; | ||
53 | }; | ||
54 | class iOR : public Instruction { | ||
55 | public: | ||
56 | iOR():Instruction(){}; | ||
57 | ~iOR(){}; | ||
58 | Data eval(Data num) { | ||
59 | Data result; | ||
60 | result.i = num.i | acc.i; | ||
61 | return result; | ||
62 | }; | ||
63 | }; | ||
64 | class iLSH : public Instruction { | ||
65 | public: | ||
66 | iLSH():Instruction(){}; | ||
67 | ~iLSH(){}; | ||
68 | Data eval(Data num) { | ||
69 | Data result; | ||
70 | result.i = num.i << 1; | ||
71 | return result; | ||
72 | }; | ||
73 | }; | ||
74 | class iRSH : public Instruction { | ||
75 | public: | ||
76 | iRSH():Instruction(){}; | ||
77 | ~iRSH(){}; | ||
78 | Data eval(Data num) { | ||
79 | Data result; | ||
80 | result.i = num.i >> 1; | ||
81 | return result; | ||
82 | }; | ||
83 | }; | ||
84 | |||
85 | void FormBinaryImpl::val0Clicked() { | ||
86 | engine->pushValue('0'); | ||
87 | } | ||
88 | |||
89 | void FormBinaryImpl::val1Clicked() { | ||
90 | engine->pushValue('1'); | ||
91 | } | ||
92 | |||
93 | void FormBinaryImpl::XORClicked() { | ||
94 | engine->pushInstruction(new iXOR()); | ||
95 | } | ||
96 | void FormBinaryImpl::ANDClicked() { | ||
97 | engine->pushInstruction(new iAND()); | ||
98 | } | ||
99 | void FormBinaryImpl::NOTClicked() { | ||
100 | engine->immediateInstruction(new iNOT()); | ||
101 | } | ||
102 | void FormBinaryImpl::ORClicked() { | ||
103 | engine->pushInstruction(new iOR()); | ||
104 | } | ||
105 | void FormBinaryImpl::LSHClicked() { | ||
106 | engine->immediateInstruction(new iLSH()); | ||
107 | } | ||
108 | void FormBinaryImpl::RSHClicked() { | ||
109 | engine->immediateInstruction(new iRSH()); | ||
110 | } | ||