author | mickeyl <mickeyl> | 2005-08-23 10:06:07 (UTC) |
---|---|---|
committer | mickeyl <mickeyl> | 2005-08-23 10:06:07 (UTC) |
commit | d6e8e6bf49bb176ec54efed5eb0d012098f056d7 (patch) (unidiff) | |
tree | 7fc70f3d3b41ee05ddb2ea559c7339a18ef0464b /noncore/tools/calc2/main/stdinstructions.h | |
parent | ce5b18efcb27c853ed4af2b603a82d3f89097764 (diff) | |
download | opie-d6e8e6bf49bb176ec54efed5eb0d012098f056d7.zip opie-d6e8e6bf49bb176ec54efed5eb0d012098f056d7.tar.gz opie-d6e8e6bf49bb176ec54efed5eb0d012098f056d7.tar.bz2 |
make calc2 a subdir project
Diffstat (limited to 'noncore/tools/calc2/main/stdinstructions.h') (more/less context) (show whitespace changes)
-rw-r--r-- | noncore/tools/calc2/main/stdinstructions.h | 125 |
1 files changed, 125 insertions, 0 deletions
diff --git a/noncore/tools/calc2/main/stdinstructions.h b/noncore/tools/calc2/main/stdinstructions.h new file mode 100644 index 0000000..a575968 --- a/dev/null +++ b/noncore/tools/calc2/main/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 | ||