int ReminderGlue::FindReminder(lua_State* lua) { CheckArgument(lua, 1, LUA_TSTRING); CheckArgument(lua, 2, LUA_TSTRING); CheckArgument(lua, 3, LUA_TSTRING); UnicodeString server = AsUnicode(lua_tostring(lua, 1)); UnicodeString channel = AsUnicode(lua_tostring(lua, 2)); UnicodeString searchString = AsUnicode(lua_tostring(lua, 3)); ReminderManager::ReminderIteratorRange reminders = reminderManager_->FindReminders(server, channel, searchString); int reminderCount = std::distance(reminders.first, reminders.second); lua_createtable(lua, reminderCount, 0); int mainTableIndex = lua_gettop(lua); for (ReminderManager::ReminderIterator reminder = reminders.first; reminder != reminders.second; ++reminder) { lua_createtable(lua, 2, 0); int subTableIndex = lua_gettop(lua); lua_pushinteger(lua, reminder->Timestamp - time(0)); lua_rawseti(lua, subTableIndex, 1); lua_pushstring(lua, AsUtf8(reminder->Message).c_str()); lua_rawseti(lua, subTableIndex, 2); int currentMainIndex = std::distance(reminders.first, reminder) + 1; lua_rawseti(lua, mainTableIndex, currentMainIndex); } return 1; }
void TimerStat::start() { if(__CVC4_USE_STATISTICS) { CheckArgument(!d_running, *this, "timer already running"); clock_gettime(CLOCK_MONOTONIC, &d_start); d_running = true; } }/* TimerStat::start() */
int ReminderGlue::AddReminder(lua_State* lua) { CheckArgument(lua, 1, LUA_TNUMBER); CheckArgument(lua, 2, LUA_TSTRING); CheckArgument(lua, 3, LUA_TSTRING); CheckArgument(lua, 4, LUA_TSTRING); time_t seconds = lua_tointeger(lua, 1); UnicodeString server = AsUnicode(lua_tostring(lua, 2)); std::string channel = lua_tostring(lua, 3); UnicodeString message = AsUnicode(lua_tostring(lua, 4)); reminderManager_->CreateReminder(seconds, server, channel, message); return 0; }
static AstExpression CheckFunctionCall(AstExpression expr) { AstExpression arg; Type ty; AstNode *tail; int argNo, argFull; if (expr->kids[0]->op == OP_ID && LookupID(expr->kids[0]->val.p) == NULL) { expr->kids[0]->ty = DefaultFunctionType; expr->kids[0]->val.p = AddFunction(expr->kids[0]->val.p, DefaultFunctionType, TK_EXTERN); } else { expr->kids[0] = CheckExpression(expr->kids[0]); } expr->kids[0] = Adjust(expr->kids[0], 1); ty = expr->kids[0]->ty; if (! (IsPtrType(ty) && IsFunctionType(ty->bty))) { Error(&expr->coord, "The left operand must be function or function pointer"); ty = DefaultFunctionType; } else { ty = ty->bty; } tail = (AstNode *)&expr->kids[1]; arg = expr->kids[1]; argNo = 1; argFull = 0; while (arg != NULL && ! argFull) { *tail = (AstNode)CheckArgument((FunctionType)ty, arg, argNo, &argFull); tail = &(*tail)->next; arg = (AstExpression)arg->next; argNo++; } *tail = NULL; if (arg != NULL) { while (arg != NULL) { CheckExpression(arg); arg = (AstExpression)arg->next; } Error(&expr->coord, "Too many arguments"); } else if (argNo < LEN(((FunctionType)ty)->sig->params)) { Error(&expr->coord, "Too few arguments"); } expr->ty = ty->bty; return expr; }
void LogicInfo::disableReals() { CheckArgument(!d_locked, *this, "This LogicInfo is locked, and cannot be modified"); d_logicString = ""; d_reals = false; if(!d_integers) { disableTheory(THEORY_ARITH); } }
void TimerStat::stop() { if(__CVC4_USE_STATISTICS) { CheckArgument(d_running, *this, "timer not running"); ::timespec end; clock_gettime(CLOCK_MONOTONIC, &end); d_data += end - d_start; d_running = false; } }/* TimerStat::stop() */
void StatisticsRegistry::unregisterStat(Stat* s) throw(CVC4::IllegalArgumentException) { #ifdef CVC4_STATISTICS_ON StatSet& stats = current()->d_stats; CheckArgument(stats.find(s) != stats.end(), s, "Statistic `%s' was not registered with this registry.", s->getName().c_str()); stats.erase(s); #endif /* CVC4_STATISTICS_ON */ }/* StatisticsRegistry::unregisterStat() */
const Datatype& DatatypeType::getDatatype() const { NodeManagerScope nms(d_nodeManager); if( d_typeNode->isParametricDatatype() ) { CheckArgument( (*d_typeNode)[0].getKind() == kind::DATATYPE_TYPE, this); const Datatype& dt = (*d_typeNode)[0].getConst<Datatype>(); return dt; } else { return d_typeNode->getDatatype(); } }
void LogicInfo::enableTheory(theory::TheoryId theory) { CheckArgument(!d_locked, *this, "This LogicInfo is locked, and cannot be modified"); if(!d_theories[theory]) { if(isTrueTheory(theory)) { ++d_sharingTheories; } d_logicString = ""; d_theories[theory] = true; } }
Type& Type::operator=(const Type& t) { CheckArgument(d_typeNode != NULL, this, "Unexpected NULL typenode pointer!"); CheckArgument(t.d_typeNode != NULL, t, "Unexpected NULL typenode pointer!"); if(this != &t) { if(d_nodeManager == t.d_nodeManager) { NodeManagerScope nms(d_nodeManager); *d_typeNode = *t.d_typeNode; } else { // This happens more than you think---every time you set to or // from the null Type. It's tricky because each node manager // must be in play at the right time. NodeManagerScope nms1(d_nodeManager); *d_typeNode = TypeNode::null(); NodeManagerScope nms2(t.d_nodeManager); *d_typeNode = *t.d_typeNode; d_nodeManager = t.d_nodeManager; } } return *this; }
void LogicInfo::disableTheory(theory::TheoryId theory) { CheckArgument(!d_locked, *this, "This LogicInfo is locked, and cannot be modified"); if(d_theories[theory]) { if(isTrueTheory(theory)) { Assert(d_sharingTheories > 0); --d_sharingTheories; } if(theory == THEORY_BUILTIN || theory == THEORY_BOOL) { return; } d_logicString = ""; d_theories[theory] = false; } }
void LogicInfo::disableEverything() { CheckArgument(!d_locked, *this, "This LogicInfo is locked, and cannot be modified"); *this = LogicInfo(""); }
void LogicInfo::setLogicString(std::string logicString) throw(IllegalArgumentException) { CheckArgument(!d_locked, *this, "This LogicInfo is locked, and cannot be modified"); for(TheoryId id = THEORY_FIRST; id < THEORY_LAST; ++id) { d_theories[id] = false;// ensure it's cleared } d_sharingTheories = 0; // Below, ONLY use enableTheory()/disableTheory() rather than // accessing d_theories[] directly. This makes sure to set up // sharing properly. enableTheory(THEORY_BUILTIN); enableTheory(THEORY_BOOL); const char* p = logicString.c_str(); if(!strcmp(p, "QF_SAT") || *p == '\0') { // propositional logic only; we're done. p += 6; } else if(!strcmp(p, "QF_ALL_SUPPORTED")) { // the "all theories included" logic, no quantifiers enableEverything(); disableQuantifiers(); p += 16; } else if(!strcmp(p, "ALL_SUPPORTED")) { // the "all theories included" logic, with quantifiers enableEverything(); enableQuantifiers(); p += 13; } else { if(!strncmp(p, "QF_", 3)) { disableQuantifiers(); p += 3; } else { enableQuantifiers(); } if(!strncmp(p, "AX", 2)) { enableTheory(THEORY_ARRAY); p += 2; } else { if(*p == 'A') { enableTheory(THEORY_ARRAY); ++p; } if(!strncmp(p, "UF", 2)) { enableTheory(THEORY_UF); p += 2; } if(!strncmp(p, "BV", 2)) { enableTheory(THEORY_BV); p += 2; } if(!strncmp(p, "DT", 2)) { enableTheory(THEORY_DATATYPES); p += 2; } if(!strncmp(p, "IDL", 3)) { enableIntegers(); disableReals(); arithOnlyDifference(); p += 3; } else if(!strncmp(p, "RDL", 3)) { disableIntegers(); enableReals(); arithOnlyDifference(); p += 3; } else if(!strncmp(p, "IRDL", 4)) { // "IRDL" ?! --not very useful, but getLogicString() can produce // that string, so we really had better be able to read it back in. enableIntegers(); enableReals(); arithOnlyDifference(); p += 4; } else if(!strncmp(p, "LIA", 3)) { enableIntegers(); disableReals(); arithOnlyLinear(); p += 3; } else if(!strncmp(p, "LRA", 3)) { disableIntegers(); enableReals(); arithOnlyLinear(); p += 3; } else if(!strncmp(p, "LIRA", 4)) { enableIntegers(); enableReals(); arithOnlyLinear(); p += 4; } else if(!strncmp(p, "NIA", 3)) { enableIntegers(); disableReals(); arithNonLinear(); p += 3; } else if(!strncmp(p, "NRA", 3)) { disableIntegers(); enableReals(); arithNonLinear(); p += 3; } else if(!strncmp(p, "NIRA", 4)) { enableIntegers(); enableReals(); arithNonLinear(); p += 4; } } } if(*p != '\0') { stringstream err; err << "LogicInfo::setLogicString(): junk (\"" << p << "\") at end of logic string: " << logicString; IllegalArgument(logicString, err.str().c_str()); } // ensure a getLogic() returns the same thing as was set d_logicString = logicString; }
SubrangeType::SubrangeType(const Type& t) throw(IllegalArgumentException) : Type(t) { CheckArgument(isNull() || isSubrange(), this); }
Type FunctionType::getRangeType() const { NodeManagerScope nms(d_nodeManager); CheckArgument(isNull() || isFunction(), this); return makeType(d_typeNode->getRangeType()); }
void LogicInfo::enableReals() { CheckArgument(!d_locked, *this, "This LogicInfo is locked, and cannot be modified"); d_logicString = ""; enableTheory(THEORY_ARITH); d_reals = true; }
std::string LogicInfo::getLogicString() const { CheckArgument(d_locked, *this, "This LogicInfo isn't locked yet, and cannot be queried"); if(d_logicString == "") { LogicInfo qf_all_supported; qf_all_supported.disableQuantifiers(); qf_all_supported.lock(); if(hasEverything()) { d_logicString = "ALL_SUPPORTED"; } else if(*this == qf_all_supported) { d_logicString = "QF_ALL_SUPPORTED"; } else { size_t seen = 0; // make sure we support all the active theories stringstream ss; if(!isQuantified()) { ss << "QF_"; } if(d_theories[THEORY_ARRAY]) { ss << (d_sharingTheories == 1 ? "AX" : "A"); ++seen; } if(d_theories[THEORY_UF]) { ss << "UF"; ++seen; } if(d_theories[THEORY_BV]) { ss << "BV"; ++seen; } if(d_theories[THEORY_DATATYPES]) { ss << "DT"; ++seen; } if(d_theories[THEORY_ARITH]) { if(isDifferenceLogic()) { ss << (areIntegersUsed() ? "I" : ""); ss << (areRealsUsed() ? "R" : ""); ss << "DL"; } else { ss << (isLinear() ? "L" : "N"); ss << (areIntegersUsed() ? "I" : ""); ss << (areRealsUsed() ? "R" : ""); ss << "A"; } ++seen; } if(seen != d_sharingTheories) { Unhandled("can't extract a logic string from LogicInfo; at least one " "active theory is unknown to LogicInfo::getLogicString() !"); } if(seen == 0) { ss << "SAT"; } d_logicString = ss.str(); } } return d_logicString; }
void LogicInfo::arithOnlyDifference() { CheckArgument(!d_locked, *this, "This LogicInfo is locked, and cannot be modified"); d_logicString = ""; d_linear = true; d_differenceLogic = true; }
TupleType::TupleType(const Type& t) throw(IllegalArgumentException) : Type(t) { CheckArgument(isNull() || isTuple(), this); }
FunctionType::FunctionType(const Type& t) throw(IllegalArgumentException) : Type(t) { CheckArgument(isNull() || isFunction(), this); }
BitVectorType::BitVectorType(const Type& t) throw(IllegalArgumentException) : Type(t) { CheckArgument(isNull() || isBitVector(), this); }
BooleanType::BooleanType(const Type& t) throw(IllegalArgumentException) : Type(t) { CheckArgument(isNull() || isBoolean(), this); }
void Begin(int argc, char* argv[]) { char task[64], buffer[1024]; int i, cmdLength=0, cmdBegin=1, function; Task* workingtask = NULL; // vérification arguments function = CheckArgument(argv[1]); int AcceptNull = (function==_H||function==_CF||function==_R||function==_I||function==_LT||function==_LD); // début de traitement switch (AcceptNull) { // cas des commandes qui n'ont pas besoin d'une tache valide case true : { switch (function) { case _R : printf("-- number of running task"); TaskFunction = Running; break; case _CF : printf("-- open configuration file\n"); TaskFunction = OpenConfig; break; case _H : printf("-- help of the program\n"); TaskFunction = Help; break; case _I : printf("-- number of running instances"); TaskFunction = Instances; break; case _LT : printf("-- list all tasks\n"); TaskFunction = ListAllTasks; break; case _LD : printf("-- list loaded tasks\n"); TaskFunction = ListLoadedTasks; break; } break; } // cas des commandes nécessitant une tache valide default : { // nom de la tache if (function != _A && argc > 2) sprintf(task, "%s", argv[2]); else sprintf(task, "%s", DEFAULT_TASK); // pointeur sur celle-ci workingtask=GetTask(task); if (workingtask==NULL) { workingtask=LoadTask(task); if (workingtask==NULL) { workingtask=AddTask(task); if (workingtask==NULL) { // tache introuvable, plus de place fprintf(stderr, "*** unable to work on task %s, exit\n", task); exit(2); } } } // tache valide switch (function) { case _L : printf("-- list %s task\n", task); TaskFunction = ListTask; break; case _S : printf("-- start %s task\n", task); TaskFunction = StartTask; break; case _D : printf("-- delete last command in %s task\n", task); TaskFunction = DeleteLastCommand; break; case _X : printf("-- stop %s task\n", task); TaskFunction = StopTask; break; case _C : printf("-- clean %s task\n", task); TaskFunction = CleanTask; break; case _M : { if (argc > 3) sprintf(DEFAULT_EDITOR, "%s", argv[3]); printf("-- modify %s task\n", task); TaskFunction = ModifyTask; break; } case _T : cmdBegin+=2; case _A : { GetEnv("$PWD", addedCommand.wd); sprintf(addedCommand.cmd, "%s", argv[cmdBegin]); cmdLength = strlen(addedCommand.cmd); for (i=cmdBegin+1; i<argc; i++) { cmdLength += strlen(argv[i]); if (cmdLength >= 1023) { fprintf(stderr, "*** attention : command is too long (max. size 1024)\n"); fprintf(stderr, " possible unexpected behavior\n"); break; } sprintf(buffer, " %s", argv[i]); strncat(addedCommand.cmd, buffer, 1024); } printf("-- add '%s' to %s task\n", addedCommand.cmd, task); TaskFunction = AddToTask; break; } default : fprintf(stderr, "*** error while interpreting arguments : returning value %d\n", function); break; } break; } } TaskFunction(workingtask); if (workingtask!=NULL) { if ((!workingtask->exec) && (!workingtask->demand)) workingtask->inuse=0; } }
SortConstructorType::SortConstructorType(const Type& t) throw(IllegalArgumentException) : Type(t) { CheckArgument(isNull() || isSortConstructor(), this); }
RecordType::RecordType(const Type& t) throw(IllegalArgumentException) : Type(t) { CheckArgument(isNull() || isRecord(), this); }
unsigned int Integer::getUnsignedInt() const { // ensure there isn't overflow CheckArgument(fitsUnsignedInt(), this, "Overflow detected in Integer::getUnsignedInt()"); return cln::cl_I_to_uint(d_value); }
void LogicInfo::arithNonLinear() { CheckArgument(!d_locked, *this, "This LogicInfo is locked, and cannot be modified"); d_logicString = ""; d_linear = false; d_differenceLogic = false; }
SExprType::SExprType(const Type& t) throw(IllegalArgumentException) : Type(t) { CheckArgument(isNull() || isSExpr(), this); }
Arguments<U> Client<T,U>::ParseArguments(int argc, char *argv[], const size_t level, const GetMetric default_a_ld, const GetMetric default_b_ld, const GetMetric default_c_ld) { auto args = Arguments<U>{}; auto help = std::string{"\n* Options given/available:\n"}; // These are the options which are not for every client: they are optional for (auto &o: options_) { // Data-sizes if (o == kArgM) { args.m = GetArgument(argc, argv, help, kArgM, size_t{512}); } if (o == kArgN) { args.n = GetArgument(argc, argv, help, kArgN, size_t{512}); } if (o == kArgK) { args.k = GetArgument(argc, argv, help, kArgK, size_t{512}); } if (o == kArgKU) { args.ku = GetArgument(argc, argv, help, kArgKU, size_t{128}); } if (o == kArgKL) { args.kl = GetArgument(argc, argv, help, kArgKL, size_t{128}); } // Data-layouts if (o == kArgLayout) { args.layout = GetArgument(argc, argv, help, kArgLayout, Layout::kRowMajor); } if (o == kArgATransp) { args.a_transpose = GetArgument(argc, argv, help, kArgATransp, Transpose::kNo); } if (o == kArgBTransp) { args.b_transpose = GetArgument(argc, argv, help, kArgBTransp, Transpose::kNo); } if (o == kArgSide) { args.side = GetArgument(argc, argv, help, kArgSide, Side::kLeft); } if (o == kArgTriangle) { args.triangle = GetArgument(argc, argv, help, kArgTriangle, Triangle::kUpper); } if (o == kArgDiagonal) { args.diagonal = GetArgument(argc, argv, help, kArgDiagonal, Diagonal::kUnit); } // Vector arguments if (o == kArgXInc) { args.x_inc = GetArgument(argc, argv, help, kArgXInc, size_t{1}); } if (o == kArgYInc) { args.y_inc = GetArgument(argc, argv, help, kArgYInc, size_t{1}); } if (o == kArgXOffset) { args.x_offset = GetArgument(argc, argv, help, kArgXOffset, size_t{0}); } if (o == kArgYOffset) { args.y_offset = GetArgument(argc, argv, help, kArgYOffset, size_t{0}); } // Matrix arguments if (o == kArgALeadDim) { args.a_ld = GetArgument(argc, argv, help, kArgALeadDim, default_a_ld(args)); } if (o == kArgBLeadDim) { args.b_ld = GetArgument(argc, argv, help, kArgBLeadDim, default_b_ld(args)); } if (o == kArgCLeadDim) { args.c_ld = GetArgument(argc, argv, help, kArgCLeadDim, default_c_ld(args)); } if (o == kArgAOffset) { args.a_offset = GetArgument(argc, argv, help, kArgAOffset, size_t{0}); } if (o == kArgBOffset) { args.b_offset = GetArgument(argc, argv, help, kArgBOffset, size_t{0}); } if (o == kArgCOffset) { args.c_offset = GetArgument(argc, argv, help, kArgCOffset, size_t{0}); } if (o == kArgAPOffset) { args.ap_offset= GetArgument(argc, argv, help, kArgAPOffset, size_t{0}); } // Scalar result arguments if (o == kArgDotOffset) { args.dot_offset = GetArgument(argc, argv, help, kArgDotOffset, size_t{0}); } if (o == kArgNrm2Offset) { args.nrm2_offset = GetArgument(argc, argv, help, kArgNrm2Offset, size_t{0}); } if (o == kArgAsumOffset) { args.asum_offset = GetArgument(argc, argv, help, kArgAsumOffset, size_t{0}); } if (o == kArgImaxOffset) { args.imax_offset = GetArgument(argc, argv, help, kArgImaxOffset, size_t{0}); } // Scalar values if (o == kArgAlpha) { args.alpha = GetArgument(argc, argv, help, kArgAlpha, GetScalar<U>()); } if (o == kArgBeta) { args.beta = GetArgument(argc, argv, help, kArgBeta, GetScalar<U>()); } } // These are the options common to all routines args.platform_id = GetArgument(argc, argv, help, kArgPlatform, size_t{0}); args.device_id = GetArgument(argc, argv, help, kArgDevice, size_t{0}); args.precision = GetArgument(argc, argv, help, kArgPrecision, Precision::kSingle); #ifdef CLBLAST_REF_CLBLAS args.compare_clblas = GetArgument(argc, argv, help, kArgCompareclblas, 1); #else args.compare_clblas = 0; #endif #ifdef CLBLAST_REF_CBLAS args.compare_cblas = GetArgument(argc, argv, help, kArgComparecblas, 1); #else args.compare_cblas = 0; #endif args.step = GetArgument(argc, argv, help, kArgStepSize, size_t{1}); args.num_steps = GetArgument(argc, argv, help, kArgNumSteps, size_t{0}); args.num_runs = GetArgument(argc, argv, help, kArgNumRuns, size_t{10}); args.print_help = CheckArgument(argc, argv, help, kArgHelp); args.silent = CheckArgument(argc, argv, help, kArgQuiet); args.no_abbrv = CheckArgument(argc, argv, help, kArgNoAbbreviations); warm_up_ = CheckArgument(argc, argv, help, kArgWarmUp); // Prints the chosen (or defaulted) arguments to screen. This also serves as the help message, // which is thus always displayed (unless silence is specified). if (!args.silent) { fprintf(stdout, "%s\n", help.c_str()); } // Comparison against a non-BLAS routine is not supported if (level == 4) { // level-4 == level-X if (args.compare_clblas != 0 || args.compare_cblas != 0) { if (!args.silent) { fprintf(stdout, "* Disabling clBLAS and CPU BLAS comparisons for this non-BLAS routine\n\n"); } } args.compare_clblas = 0; args.compare_cblas = 0; } // Comparison against clBLAS or a CPU BLAS library is not supported in case of half-precision if (args.precision == Precision::kHalf) { if (args.compare_clblas != 0 || args.compare_cblas != 0) { if (!args.silent) { fprintf(stdout, "* Disabling clBLAS and CPU BLAS comparisons for half-precision\n\n"); } } args.compare_clblas = 0; args.compare_cblas = 0; } // Returns the arguments return args; }
ArrayType::ArrayType(const Type& t) throw(IllegalArgumentException) : Type(t) { CheckArgument(isNull() || isArray(), this); }