Guarding agains big ints which are not implemented yet

This commit is contained in:
Krzosa Karol
2022-06-03 14:16:51 +02:00
parent c2f501bf36
commit 84b393ce2f
3 changed files with 6 additions and 4 deletions

View File

@@ -325,7 +325,8 @@ ast_float(Token *pos, F64 value){
}
function Ast_Atom *
ast_int(Token *pos, S64 integer){
ast_int(Token *pos, U64 integer){
assert(integer <= S64MAX);
AST_NEW(Atom, VALUE, pos, AST_EXPR | AST_ATOM);
result->type = untyped_int;
result->int_val = integer;

View File

@@ -1,13 +1,13 @@
unary_test :: ()
int_val :: 1251525
uns: U64 = -int_val
int_val :: 125152553512512512512 // @todo
float_val :: 124.42
conversion: F64 = -+int_val
float2 := -float_val
unsigned: Int = -+-+-int_val
// uns: U64 = -int_val
// int_float: S64 = float_val
// string :: -"Thing"
// boolean :: -true

View File

@@ -15,6 +15,7 @@ convert_untyped(Token *pos, Value a, Ast_Resolved_Type *new_type){
assert(is_untyped(a.type));
assert(new_type);
assert(a.int_val <= S64MAX);
if(is_int(a.type) && is_int(new_type)){
assert(a.type == untyped_int);
switch(new_type->kind){
@@ -57,6 +58,7 @@ convert_untyped(Token *pos, Value a, Ast_Resolved_Type *new_type){
function S64
value_get_int(Value value){
assert(value.int_val <= S64MAX);
assert(is_float(value.type) || is_int(value.type));
S64 result = 0;
switch(value.type->kind){
@@ -579,7 +581,6 @@ resolve_expr(Ast_Expr *ast, Ast_Resolved_Type *expected_type, Sym *lambda_to_res
Value value = eval_unary(node->pos, node->op, op.value);
rewrite_into_const(node, Ast_Unary, value);
return operand_const_rvalue(value);
}
return operand_rvalue(op.type);
}break;