use new ostd features
parent
0307085c30
commit
79b1a031ca
|
@ -5,6 +5,7 @@
|
||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
|
|
||||||
#include <ostd/memory.hh>
|
#include <ostd/memory.hh>
|
||||||
|
#include <ostd/limits.hh>
|
||||||
|
|
||||||
namespace cscript {
|
namespace cscript {
|
||||||
|
|
||||||
|
@ -353,7 +354,7 @@ lookupid:
|
||||||
numargs++;
|
numargs++;
|
||||||
break;
|
break;
|
||||||
case 'b':
|
case 'b':
|
||||||
gs.gen_int(CsIntMin);
|
gs.gen_int(ostd::NumericLimitMin<CsInt>);
|
||||||
numargs++;
|
numargs++;
|
||||||
break;
|
break;
|
||||||
case 'f':
|
case 'f':
|
||||||
|
@ -939,7 +940,7 @@ static void compile_cmd(
|
||||||
if (rep) {
|
if (rep) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
gs.gen_int(CsIntMin);
|
gs.gen_int(ostd::NumericLimitMin<CsInt>);
|
||||||
fakeargs++;
|
fakeargs++;
|
||||||
}
|
}
|
||||||
numargs++;
|
numargs++;
|
||||||
|
|
|
@ -7,9 +7,6 @@
|
||||||
|
|
||||||
namespace cscript {
|
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>
|
template<typename K, typename V>
|
||||||
using CsMap = ostd::Map<K, V>;
|
using CsMap = ostd::Map<K, V>;
|
||||||
|
|
||||||
|
|
|
@ -3,6 +3,7 @@
|
||||||
#include "cs_util.hh"
|
#include "cs_util.hh"
|
||||||
|
|
||||||
#include <ostd/memory.hh>
|
#include <ostd/memory.hh>
|
||||||
|
#include <ostd/limits.hh>
|
||||||
|
|
||||||
namespace cscript {
|
namespace cscript {
|
||||||
|
|
||||||
|
@ -320,7 +321,7 @@ static inline void callcommand(
|
||||||
if (rep) {
|
if (rep) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
args[i].set_int(CsIntMin);
|
args[i].set_int(ostd::NumericLimitMin<CsInt>);
|
||||||
fakeargs++;
|
fakeargs++;
|
||||||
} else {
|
} else {
|
||||||
args[i].force_int();
|
args[i].force_int();
|
||||||
|
|
|
@ -1,5 +1,3 @@
|
||||||
#include <limits.h>
|
|
||||||
|
|
||||||
/* c++ versions for overloaded math */
|
/* c++ versions for overloaded math */
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <math.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.new_command("<<", "i1V", [](auto &, auto args, auto &res) {
|
||||||
cs_mathop<CsInt>(
|
cs_mathop<CsInt>(
|
||||||
args, res, 0, [](CsInt val1, CsInt val2) {
|
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)))
|
? (val1 << ostd::max(val2, CsInt(0)))
|
||||||
: 0;
|
: 0;
|
||||||
}, CsMathNoop<CsInt>()
|
}, CsMathNoop<CsInt>()
|
||||||
|
@ -319,7 +317,7 @@ void cs_init_lib_math(CsState &cs) {
|
||||||
cs_mathop<CsInt>(
|
cs_mathop<CsInt>(
|
||||||
args, res, 0, [](CsInt val1, CsInt val2) {
|
args, res, 0, [](CsInt val1, CsInt val2) {
|
||||||
return val1 >> ostd::clamp(
|
return val1 >> ostd::clamp(
|
||||||
val2, CsInt(0), CsInt(sizeof(CsInt) * CHAR_BIT)
|
val2, CsInt(0), CsInt(ostd::SizeInBits<CsInt>)
|
||||||
);
|
);
|
||||||
}, CsMathNoop<CsInt>()
|
}, CsMathNoop<CsInt>()
|
||||||
);
|
);
|
||||||
|
|
Loading…
Reference in New Issue