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

instruction.h

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 #ifndef INSTRUCTION_H
00021 #define INSTRUCTION_H
00022 
00023 /* Internal representation of data
00024 The first four types indicate an int,
00025 that is, Data.i, and are incompatible
00026 with the other two types.
00027 
00028 - Plugin is responsible for telling engine
00029 which Rep to use at any given time
00030 - Instructions from that plugin only
00031 have to handle that representation
00032 - Engine is responsible for error-checking
00033 according to its current rep and display */
00034 enum Representation {
00035     rBin,
00036     rOct,
00037     rDec,
00038     rHex,
00039     rDouble,
00040     rFraction
00041 };
00042 
00043 // An atom of data
00044 union Data {
00045     int i;
00046     double dbl;
00047     struct Fraction {
00048         int numerator, denominator;
00049     } fraction;
00050 };
00051 
00052 // Instruction base class
00053 class Instruction {
00054 public:
00055   Instruction (int p = 0) {
00056     precedence = p;
00057   };
00058 
00059   virtual ~ Instruction () {};
00060 
00061   virtual Data eval(Data) = 0;
00062     void setRep(Representation r) { rep = r; };
00063 
00064   Representation rep;
00065   Data acc;
00066   int precedence;
00067 };
00068 
00069 #endif

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