Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

binaryimpl.cpp

Go to the documentation of this file.
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 #include "binaryimpl.h"
00022 #include "instruction.h"
00023 
00024 class iXOR : public Instruction {
00025 public:
00026     iXOR():Instruction(){};
00027     ~iXOR(){};
00028     Data eval(Data num) {
00029         Data result;
00030         result.i = num.i ^ acc.i;
00031         return result;
00032     };
00033 };
00034 class iAND : public Instruction {
00035 public:
00036     iAND():Instruction(){};
00037     ~iAND(){};
00038     Data eval(Data num) {
00039         Data result;
00040         result.i = num.i & acc.i;
00041         return result;
00042     };
00043 };
00044 class iNOT : public Instruction {    
00045 public:
00046     iNOT():Instruction(){};
00047     ~iNOT(){};
00048     Data eval(Data num) {
00049         Data result;
00050         result.i = ~ num.i;
00051         return result;
00052     };
00053 };
00054 class iOR : public Instruction {
00055 public:
00056     iOR():Instruction(){};
00057     ~iOR(){};
00058     Data eval(Data num) {
00059         Data result;
00060         result.i = num.i | acc.i;
00061         return result;
00062     };
00063 };
00064 class iLSH : public Instruction {
00065 public:
00066     iLSH():Instruction(){};
00067     ~iLSH(){};
00068     Data eval(Data num) {
00069         Data result;
00070         result.i = num.i << 1;
00071         return result;
00072     };
00073 };
00074 class iRSH : public Instruction {
00075 public:
00076     iRSH():Instruction(){};
00077     ~iRSH(){};
00078     Data eval(Data num) {
00079         Data result;
00080         result.i = num.i >> 1;
00081         return result;
00082     };
00083 };
00084 
00085 void FormBinaryImpl::val0Clicked() {
00086     engine->pushValue('0');
00087 }
00088 
00089 void FormBinaryImpl::val1Clicked() {
00090     engine->pushValue('1');
00091 }
00092 
00093 void FormBinaryImpl::XORClicked() {
00094     engine->pushInstruction(new iXOR());
00095 }
00096 void FormBinaryImpl::ANDClicked() {
00097     engine->pushInstruction(new iAND());
00098 }
00099 void FormBinaryImpl::NOTClicked() {
00100     engine->immediateInstruction(new iNOT());
00101 }
00102 void FormBinaryImpl::ORClicked() {
00103     engine->pushInstruction(new iOR());
00104 }
00105 void FormBinaryImpl::LSHClicked() {
00106     engine->immediateInstruction(new iLSH());
00107 }
00108 void FormBinaryImpl::RSHClicked() {
00109     engine->immediateInstruction(new iRSH());
00110 }

Generated on Sat Nov 5 16:18:01 2005 for OPIE by  doxygen 1.4.2