00001 /********************************************************************** 00002 ** Copyright (C) 2000 Trolltech AS. All rights reserved. 00003 ** 00004 ** This file is part of Qtopia Environment. 00005 ** 00006 ** This file may be distributed and/or modified under the terms of the 00007 ** GNU General Public License version 2 as published by the Free Software 00008 ** Foundation and appearing in the file LICENSE.GPL included in the 00009 ** packaging of this file. 00010 ** 00011 ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 00012 ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 00013 ** 00014 ** See http://www.trolltech.com/gpl/ for GPL licensing information. 00015 ** 00016 ** Contact info@trolltech.com if any conditions of this licensing are 00017 ** not clear to you. 00018 ** 00019 **********************************************************************/ 00020 00021 #ifndef STDINSTRUCTION_H 00022 #define STDINSTRUCTION_H 00023 00024 #include <qpe/qmath.h> 00025 #include "instruction.h" 00026 00027 // Useful instructions for plugin writers 00028 // If you use them, take note of their precedence 00029 class iAdd:public Instruction { 00030 public: 00031 iAdd ():Instruction (10) { }; 00032 ~iAdd () { }; 00033 Data eval (Data num) { 00034 Data result; 00035 switch (rep) { 00036 case rDouble: 00037 result.dbl = acc.dbl + num.dbl; 00038 break; 00039 default: 00040 result.i = acc.i + num.i; 00041 }; 00042 return result; 00043 }; 00044 }; 00045 class iSub:public Instruction { 00046 public: 00047 iSub ():Instruction (10) { }; 00048 ~iSub () { }; 00049 Data eval (Data num) { 00050 Data result; 00051 switch (rep) { 00052 case rDouble: 00053 result.dbl = acc.dbl - num.dbl; 00054 break; 00055 default: 00056 result.i = acc.i - num.i; 00057 }; 00058 return result; 00059 }; 00060 }; 00061 class iMul:public Instruction { 00062 public: 00063 iMul ():Instruction (20) { }; 00064 ~iMul () { }; 00065 Data eval (Data num) { 00066 Data result; 00067 switch (rep) { 00068 case rDouble: 00069 result.dbl = acc.dbl * num.dbl; 00070 break; 00071 default: 00072 result.i = acc.i * num.i; 00073 }; 00074 return result; 00075 }; 00076 }; 00077 class iDiv:public Instruction { 00078 public: 00079 iDiv ():Instruction (20) { }; 00080 ~iDiv () { }; 00081 Data eval (Data num) { 00082 Data result; 00083 switch (rep) { 00084 case rDouble: 00085 result.dbl = acc.dbl / num.dbl; 00086 break; 00087 default: 00088 result.i = acc.i / num.i; 00089 }; 00090 return result; 00091 }; 00092 }; 00093 00094 // Immediate double instructions only 00095 class iSin:public Instruction { 00096 public: 00097 iSin ():Instruction () { }; 00098 ~iSin () { }; 00099 Data eval (Data num) { 00100 Data result; 00101 result.dbl = qSin(num.dbl); 00102 return result; 00103 }; 00104 }; 00105 class iCos:public Instruction { 00106 public: 00107 iCos ():Instruction () { }; 00108 ~iCos () { }; 00109 Data eval (Data num) { 00110 Data result; 00111 result.dbl = qCos(num.dbl); 00112 return result; 00113 }; 00114 }; 00115 class iTan:public Instruction { 00116 public: 00117 iTan ():Instruction () { }; 00118 ~iTan () {}; 00119 Data eval (Data num) { 00120 Data result; 00121 result.dbl = qTan(num.dbl); 00122 return result; 00123 }; 00124 }; 00125 #endif
1.4.2