JumpInstruction.cpp

Go to the documentation of this file.
00001 /*
00002 // $Id: //open/dev/fennel/calculator/JumpInstruction.cpp#2 $
00003 // Fennel is a library of data storage and processing components.
00004 // Copyright (C) 2005-2009 The Eigenbase Project
00005 // Copyright (C) 2004-2009 SQLstream, Inc.
00006 // Copyright (C) 2009-2009 LucidEra, Inc.
00007 //
00008 // This program is free software; you can redistribute it and/or modify it
00009 // under the terms of the GNU General Public License as published by the Free
00010 // Software Foundation; either version 2 of the License, or (at your option)
00011 // any later version approved by The Eigenbase Project.
00012 //
00013 // This program is distributed in the hope that it will be useful,
00014 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00015 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00016 // GNU General Public License for more details.
00017 //
00018 // You should have received a copy of the GNU General Public License
00019 // along with this program; if not, write to the Free Software
00020 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00021 //
00022 // Instruction->Jump
00023 */
00024 #include "fennel/common/CommonPreamble.h"
00025 #include "fennel/calculator/Calculator.h"
00026 #include "fennel/calculator/JumpInstruction.h"
00027 
00028 #include "boost/lexical_cast.hpp"
00029 using boost::lexical_cast;
00030 
00031 FENNEL_BEGIN_CPPFILE("$Id: //open/dev/fennel/calculator/JumpInstruction.cpp#2 $");
00032 
00033 void
00034 JumpInstruction::describeHelper(
00035     string &out,
00036     bool values,
00037     const char* longName,
00038     const char* shortName) const
00039 {
00040     out = longName;
00041     out += " To Addr: ";
00042     out += boost::lexical_cast<std::string>(mJumpTo);
00043     out += " ";
00044     out += shortName;
00045     out += " ";
00046 
00047     if (mOp && mOp->isValid()) {
00048         out += mOp->toString();
00049         if (values) {
00050             out += " ( ";
00051             if (mOp->isNull()) {
00052                 out += "NULL";
00053             } else {
00054                 out += mOp->valueToString();
00055             }
00056             out += " ) ";
00057         }
00058     }
00059 }
00060 
00061 
00062 const char *
00063 Jump::longName()
00064 {
00065     return "Jump";
00066 }
00067 const char *
00068 Jump::shortName()
00069 {
00070     return "JMP";
00071 }
00072 int
00073 Jump::numArgs()
00074 {
00075     return 0;  // PC is not counted
00076 }
00077 void
00078 Jump::describe(string& out, bool values) const {
00079     describeHelper(out, values, longName(), shortName());
00080 }
00081 
00082 const char *
00083 JumpTrue::longName()
00084 {
00085     return "JumpTrue";
00086 }
00087 const char *
00088 JumpTrue::shortName()
00089 {
00090     return "JMPT";
00091 }
00092 int
00093 JumpTrue::numArgs()
00094 {
00095     return 1;  // PC is not counted
00096 }
00097 void
00098 JumpTrue::describe(string& out, bool values) const {
00099     describeHelper(out, values, longName(), shortName());
00100 }
00101 
00102 const char *
00103 JumpFalse::longName()
00104 {
00105     return "JumpFalse";
00106 }
00107 const char *
00108 JumpFalse::shortName()
00109 {
00110     return "JMPF";
00111 }
00112 int
00113 JumpFalse::numArgs()
00114 {
00115     return 1;  // PC is not counted
00116 }
00117 void
00118 JumpFalse::describe(string& out, bool values) const {
00119     describeHelper(out, values, longName(), shortName());
00120 }
00121 
00122 const char *
00123 JumpNull::longName()
00124 {
00125     return "JumpNull";
00126 }
00127 const char *
00128 JumpNull::shortName()
00129 {
00130     return "JMPN";
00131 }
00132 int
00133 JumpNull::numArgs()
00134 {
00135     return 1;  // PC is not counted
00136 }
00137 void
00138 JumpNull::describe(string& out, bool values) const {
00139     describeHelper(out, values, longName(), shortName());
00140 }
00141 
00142 const char *
00143 JumpNotNull::longName()
00144 {
00145     return "JumpNotNull";
00146 }
00147 const char *
00148 JumpNotNull::shortName()
00149 {
00150     return "JMPNN";
00151 }
00152 int
00153 JumpNotNull::numArgs()
00154 {
00155     return 1;  // PC is not counted
00156 }
00157 void
00158 JumpNotNull::describe(string& out, bool values) const {
00159     describeHelper(out, values, longName(), shortName());
00160 }
00161 
00162 FENNEL_END_CPPFILE("$Id: //open/dev/fennel/calculator/JumpInstruction.cpp#2 $");
00163 
00164 // End JumpInstruction.cpp

Generated on Mon Jun 22 04:00:17 2009 for Fennel by  doxygen 1.5.1