File indexing completed on 2024-05-12 05:55:17

0001 // This file is part of the SpeedCrunch project
0002 // Copyright (C) 2004 Ariya Hidayat <ariya@kde.org>
0003 // Copyright (C) 2008, 2009, 2010, 2013 @heldercorreia
0004 // Copyright (C) 2015 Pol Welter <polwelter@gmail.com>
0005 //
0006 // This program is free software; you can redistribute it and/or
0007 // modify it under the terms of the GNU General Public License
0008 // as published by the Free Software Foundation; either version 2
0009 // of the License, or (at your option) any later version.
0010 //
0011 // This program is distributed in the hope that it will be useful,
0012 // but WITHOUT ANY WARRANTY; without even the implied warranty of
0013 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
0014 // GNU General Public License for more details.
0015 //
0016 // You should have received a copy of the GNU General Public License
0017 // along with this program; see the file COPYING.  If not, write to
0018 // the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
0019 // Boston, MA 02110-1301, USA.
0020 
0021 #ifndef CORE_OPCODE_H
0022 #define CORE_OPCODE_H
0023 
0024 #include<QString>
0025 
0026 
0027 class Opcode
0028 {
0029 public:
0030     enum  Type { Nop, Load, Ref, Function, Add, Sub, Neg, Mul, Div, Pow,
0031            Fact, Modulo, IntDiv, LSh, RSh, BAnd, BOr, Conv };
0032 
0033     Type type;
0034     unsigned index;
0035 
0036     // TODO: this is only needed for Conv Op. Maybe refactor this to a smarter place?
0037     // TODO: only keep a pointer to the string
0038     QString text;
0039 
0040     Opcode() : type(Nop), index(0) {}
0041     Opcode(Type t) : type(t), index(0) {}
0042     Opcode(Type t, QString txt) : type(t), index(0), text(txt) {}
0043     Opcode(Type t, unsigned i): type(t), index(i) {}
0044 };
0045 
0046 #endif // CORE_OPCODE_H