Skip to content

Commit

Permalink
fix 256 bit number
Browse files Browse the repository at this point in the history
  • Loading branch information
He1pa committed Feb 21, 2024
1 parent 985afce commit 5c74794
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 3 deletions.
2 changes: 1 addition & 1 deletion smart_ir/src/runtime/stdlib/ir_type.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ typedef enum IRRuntimeType {
IR_RUNTIME_TYPE_I256 = 17,
} IRRuntimeType;

#define IRRuntimeIntegerTypeMaxEnum IR_RUNTIME_TYPE_I256
#define DefaultIRRuntimeIntegerTypeMaxEnum IR_RUNTIME_TYPE_I128

inline bool
__attribute__((artificial)) __attribute__((always_inline))
Expand Down
2 changes: 1 addition & 1 deletion smart_ir/src/runtime/stdlib/json.c
Original file line number Diff line number Diff line change
Expand Up @@ -445,7 +445,7 @@ ir_builtin_json_decode_map(uint32_t runtime_class_offset, cJSON *obj)
char *key = elem->string;
if (TABLE_KEY_IS_INT(ret)) {
struct vector *int_str = vector_new(__strlen(key), 1, key);
if (ret->key_runtime_ty <= IR_RUNTIME_TYPE_U256) {
if (ret->key_runtime_ty <= IR_RUNTIME_TYPE_U128 || ret->key_runtime_ty == IR_RUNTIME_TYPE_U256) {
key = (char *)ir_builtin_str_to_u256(int_str);
}
else {
Expand Down
3 changes: 2 additions & 1 deletion smart_ir/src/runtime/stdlib/qhashtbl.h
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,8 @@ struct qhashtbl_obj_s {
qhashtbl_obj_t *next; /*!< for chaining next collision object */
};

#define TABLE_KEY_IS_INT(tbl) ((tbl)->key_runtime_ty <= IRRuntimeIntegerTypeMaxEnum)
#define TABLE_KEY_IS_BIG_INT(tbl) ((tbl)->key_runtime_ty == IR_RUNTIME_TYPE_U256 || (tbl)->key_runtime_ty == IR_RUNTIME_TYPE_I256)
#define TABLE_KEY_IS_INT(tbl) (((tbl)->key_runtime_ty <= DefaultIRRuntimeIntegerTypeMaxEnum) || (TABLE_KEY_IS_BIG_INT(tbl)))

#ifdef __cplusplus
}
Expand Down

0 comments on commit 5c74794

Please sign in to comment.