Fix #814: raise on div-0, add inf isinf nan isnan

This commit is contained in:
Nicolas Williams committed 2015-06-17 19:58:55 -05:00
1 parent bdc1feb50e
commit b9c2a326ba
8 files changed
+477 -388

No files matched your search

+7
View File
@@ -2,6 +2,7 @@
#define _GNU_SOURCE // for strdup
#endif
#include <assert.h>
#include <math.h>
#include <string.h>
#include <stdlib.h>
#include "compile.h"
@@ -161,6 +162,12 @@ int block_is_const(block b) {
return (block_is_single(b) && b.first->op == LOADK);
}
int block_is_const_inf(block b) {
return (block_is_single(b) && b.first->op == LOADK &&
jv_get_kind(b.first->imm.constant) == JV_KIND_NUMBER &&
isinf(jv_number_value(b.first->imm.constant)));
}
jv_kind block_const_kind(block b) {
assert(block_is_const(b));
return jv_get_kind(b.first->imm.constant);