author | kergoth <kergoth> | 2002-01-25 22:14:26 (UTC) |
---|---|---|
committer | kergoth <kergoth> | 2002-01-25 22:14:26 (UTC) |
commit | 15318cad33835e4e2dc620d033e43cd930676cdd (patch) (unidiff) | |
tree | c2fa0399a2c47fda8e2cd0092c73a809d17f68eb /noncore/tools/calc2/stdinstructions.h | |
download | opie-15318cad33835e4e2dc620d033e43cd930676cdd.zip opie-15318cad33835e4e2dc620d033e43cd930676cdd.tar.gz opie-15318cad33835e4e2dc620d033e43cd930676cdd.tar.bz2 |
Initial revision
Diffstat (limited to 'noncore/tools/calc2/stdinstructions.h') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/tools/calc2/stdinstructions.h | 125 |
1 files changed, 125 insertions, 0 deletions
diff --git a/noncore/tools/calc2/stdinstructions.h b/noncore/tools/calc2/stdinstructions.h new file mode 100644 index 0000000..a575968 --- a/dev/null +++ b/noncore/tools/calc2/stdinstructions.h | |||
@@ -0,0 +1,125 @@ | |||
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 | #ifndef STDINSTRUCTION_H | ||
22 | #define STDINSTRUCTION_H | ||
23 | |||
24 | #include <qpe/qmath.h> | ||
25 | #include "instruction.h" | ||
26 | |||
27 | // Useful instructions for plugin writers | ||
28 | // If you use them, take note of their precedence | ||
29 | class iAdd:public Instruction { | ||
30 | public: | ||
31 | iAdd ():Instruction (10) { }; | ||
32 | ~iAdd () { }; | ||
33 | Data eval (Data num) { | ||
34 | Data result; | ||
35 | switch (rep) { | ||
36 | case rDouble: | ||
37 | result.dbl = acc.dbl + num.dbl; | ||
38 | break; | ||
39 | default: | ||
40 | result.i = acc.i + num.i; | ||
41 | }; | ||
42 | return result; | ||
43 | }; | ||
44 | }; | ||
45 | class iSub:public Instruction { | ||
46 | public: | ||
47 | iSub ():Instruction (10) { }; | ||
48 | ~iSub () { }; | ||
49 | Data eval (Data num) { | ||
50 | Data result; | ||
51 | switch (rep) { | ||
52 | case rDouble: | ||
53 | result.dbl = acc.dbl - num.dbl; | ||
54 | break; | ||
55 | default: | ||
56 | result.i = acc.i - num.i; | ||
57 | }; | ||
58 | return result; | ||
59 | }; | ||
60 | }; | ||
61 | class iMul:public Instruction { | ||
62 | public: | ||
63 | iMul ():Instruction (20) { }; | ||
64 | ~iMul () { }; | ||
65 | Data eval (Data num) { | ||
66 | Data result; | ||
67 | switch (rep) { | ||
68 | case rDouble: | ||
69 | result.dbl = acc.dbl * num.dbl; | ||
70 | break; | ||
71 | default: | ||
72 | result.i = acc.i * num.i; | ||
73 | }; | ||
74 | return result; | ||
75 | }; | ||
76 | }; | ||
77 | class iDiv:public Instruction { | ||
78 | public: | ||
79 | iDiv ():Instruction (20) { }; | ||
80 | ~iDiv () { }; | ||
81 | Data eval (Data num) { | ||
82 | Data result; | ||
83 | switch (rep) { | ||
84 | case rDouble: | ||
85 | result.dbl = acc.dbl / num.dbl; | ||
86 | break; | ||
87 | default: | ||
88 | result.i = acc.i / num.i; | ||
89 | }; | ||
90 | return result; | ||
91 | }; | ||
92 | }; | ||
93 | |||
94 | // Immediate double instructions only | ||
95 | class iSin:public Instruction { | ||
96 | public: | ||
97 | iSin ():Instruction () { }; | ||
98 | ~iSin () { }; | ||
99 | Data eval (Data num) { | ||
100 | Data result; | ||
101 | result.dbl = qSin(num.dbl); | ||
102 | return result; | ||
103 | }; | ||
104 | }; | ||
105 | class iCos:public Instruction { | ||
106 | public: | ||
107 | iCos ():Instruction () { }; | ||
108 | ~iCos () { }; | ||
109 | Data eval (Data num) { | ||
110 | Data result; | ||
111 | result.dbl = qCos(num.dbl); | ||
112 | return result; | ||
113 | }; | ||
114 | }; | ||
115 | class iTan:public Instruction { | ||
116 | public: | ||
117 | iTan ():Instruction () { }; | ||
118 | ~iTan () {}; | ||
119 | Data eval (Data num) { | ||
120 | Data result; | ||
121 | result.dbl = qTan(num.dbl); | ||
122 | return result; | ||
123 | }; | ||
124 | }; | ||
125 | #endif | ||