use new ostd features

master
Daniel Kolesa 2016-11-15 22:50:11 +01:00
parent 0307085c30
commit 79b1a031ca
4 changed files with 7 additions and 10 deletions

View File

@ -5,6 +5,7 @@
#include <ctype.h>
#include <ostd/memory.hh>
#include <ostd/limits.hh>
namespace cscript {
@ -353,7 +354,7 @@ lookupid:
numargs++;
break;
case 'b':
gs.gen_int(CsIntMin);
gs.gen_int(ostd::NumericLimitMin<CsInt>);
numargs++;
break;
case 'f':
@ -939,7 +940,7 @@ static void compile_cmd(
if (rep) {
break;
}
gs.gen_int(CsIntMin);
gs.gen_int(ostd::NumericLimitMin<CsInt>);
fakeargs++;
}
numargs++;

View File

@ -7,9 +7,6 @@
namespace cscript {
/* TODO: use actual numeric limits as soon as ostd has them */
constexpr CsInt const CsIntMin = -(~(1ULL << (sizeof(CsInt) * CHAR_BIT - 1))) - 1;
template<typename K, typename V>
using CsMap = ostd::Map<K, V>;

View File

@ -3,6 +3,7 @@
#include "cs_util.hh"
#include <ostd/memory.hh>
#include <ostd/limits.hh>
namespace cscript {
@ -320,7 +321,7 @@ static inline void callcommand(
if (rep) {
break;
}
args[i].set_int(CsIntMin);
args[i].set_int(ostd::NumericLimitMin<CsInt>);
fakeargs++;
} else {
args[i].force_int();

View File

@ -1,5 +1,3 @@
#include <limits.h>
/* c++ versions for overloaded math */
#include <stdlib.h>
#include <math.h>
@ -309,7 +307,7 @@ void cs_init_lib_math(CsState &cs) {
cs.new_command("<<", "i1V", [](auto &, auto args, auto &res) {
cs_mathop<CsInt>(
args, res, 0, [](CsInt val1, CsInt val2) {
return (val2 < CsInt(sizeof(CsInt) * CHAR_BIT))
return (val2 < CsInt(ostd::SizeInBits<CsInt>))
? (val1 << ostd::max(val2, CsInt(0)))
: 0;
}, CsMathNoop<CsInt>()
@ -319,7 +317,7 @@ void cs_init_lib_math(CsState &cs) {
cs_mathop<CsInt>(
args, res, 0, [](CsInt val1, CsInt val2) {
return val1 >> ostd::clamp(
val2, CsInt(0), CsInt(sizeof(CsInt) * CHAR_BIT)
val2, CsInt(0), CsInt(ostd::SizeInBits<CsInt>)
);
}, CsMathNoop<CsInt>()
);