1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90
|
/*
* Copyright (c) 2009 Samit Basu
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
*/
#include "Interpreter.hpp"
#include "Array.hpp"
//@@Signature
//sfunction jitstat JITStatFunction
//inputs none
//outputs count
ArrayVector JITStatFunction(int nargout, const ArrayVector& arg, Interpreter* eval) {
return ArrayVector(Array(double(eval->JITCounter())));
}
//@@Signature
//sfunction jitcontrol JITControlFunction
//inputs flag
//outputs flag
//DOCBLOCK freemat_jitcontrol
ArrayVector JITControlFunction(int nargout, const ArrayVector& arg, Interpreter* eval) {
if (arg.size() < 1) {
JITControlFlag flag = eval->JITControl();
switch (flag)
{
case JITOff: return ArrayVector(Array(QString("off")));
case JITOn: return ArrayVector(Array(QString("on")));
case JITTrace: return ArrayVector(Array(QString("trace")));
}
} else {
if (!arg[0].isString())
throw Exception("jitcontrol function takes only a single, string argument");
QString txt = arg[0].asString().toUpper();
if (txt == "ON")
eval->setJITControl(JITOn);
else if (txt == "OFF")
eval->setJITControl(JITOff);
else if (txt == "TRACE")
eval->setJITControl(JITTrace);
else if (txt == "FLUSH")
{
ClearJITCache();
}
else
throw Exception("jitcontrol function argument needs to be 'on/off/trace/flush'");
}
return ArrayVector();
}
//@@Signature
//sfunction dbauto DbAutoFunction
//inputs flag
//outputs flag
//DOCBLOCK debug_dbauto
ArrayVector DbAutoFunction(int nargout, const ArrayVector& arg, Interpreter* eval) {
if (arg.size() < 1) {
if (eval->AutoStop())
return ArrayVector(Array(QString("on")));
else
return ArrayVector(Array(QString("off")));
} else {
if (!arg[0].isString())
throw Exception("dbauto function takes only a single, string argument");
QString txt = arg[0].asString().toUpper();
if (txt == "ON")
eval->setAutoStop(true);
else if (txt == "OFF")
eval->setAutoStop(false);
else
throw Exception("dbauto function argument needs to be 'on/off'");
}
return ArrayVector();
}
|