Guarding agains big ints which are not implemented yet
This commit is contained in:
@@ -325,7 +325,8 @@ ast_float(Token *pos, F64 value){
|
|||||||
}
|
}
|
||||||
|
|
||||||
function Ast_Atom *
|
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);
|
AST_NEW(Atom, VALUE, pos, AST_EXPR | AST_ATOM);
|
||||||
result->type = untyped_int;
|
result->type = untyped_int;
|
||||||
result->int_val = integer;
|
result->int_val = integer;
|
||||||
|
|||||||
@@ -1,13 +1,13 @@
|
|||||||
|
|
||||||
unary_test :: ()
|
unary_test :: ()
|
||||||
int_val :: 1251525
|
int_val :: 125152553512512512512 // @todo
|
||||||
uns: U64 = -int_val
|
|
||||||
float_val :: 124.42
|
float_val :: 124.42
|
||||||
conversion: F64 = -+int_val
|
conversion: F64 = -+int_val
|
||||||
float2 := -float_val
|
float2 := -float_val
|
||||||
unsigned: Int = -+-+-int_val
|
unsigned: Int = -+-+-int_val
|
||||||
|
|
||||||
|
|
||||||
|
// uns: U64 = -int_val
|
||||||
// int_float: S64 = float_val
|
// int_float: S64 = float_val
|
||||||
// string :: -"Thing"
|
// string :: -"Thing"
|
||||||
// boolean :: -true
|
// boolean :: -true
|
||||||
|
|||||||
@@ -15,6 +15,7 @@ convert_untyped(Token *pos, Value a, Ast_Resolved_Type *new_type){
|
|||||||
assert(is_untyped(a.type));
|
assert(is_untyped(a.type));
|
||||||
assert(new_type);
|
assert(new_type);
|
||||||
|
|
||||||
|
assert(a.int_val <= S64MAX);
|
||||||
if(is_int(a.type) && is_int(new_type)){
|
if(is_int(a.type) && is_int(new_type)){
|
||||||
assert(a.type == untyped_int);
|
assert(a.type == untyped_int);
|
||||||
switch(new_type->kind){
|
switch(new_type->kind){
|
||||||
@@ -57,6 +58,7 @@ convert_untyped(Token *pos, Value a, Ast_Resolved_Type *new_type){
|
|||||||
|
|
||||||
function S64
|
function S64
|
||||||
value_get_int(Value value){
|
value_get_int(Value value){
|
||||||
|
assert(value.int_val <= S64MAX);
|
||||||
assert(is_float(value.type) || is_int(value.type));
|
assert(is_float(value.type) || is_int(value.type));
|
||||||
S64 result = 0;
|
S64 result = 0;
|
||||||
switch(value.type->kind){
|
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);
|
Value value = eval_unary(node->pos, node->op, op.value);
|
||||||
rewrite_into_const(node, Ast_Unary, value);
|
rewrite_into_const(node, Ast_Unary, value);
|
||||||
return operand_const_rvalue(value);
|
return operand_const_rvalue(value);
|
||||||
|
|
||||||
}
|
}
|
||||||
return operand_rvalue(op.type);
|
return operand_rvalue(op.type);
|
||||||
}break;
|
}break;
|
||||||
|
|||||||
Reference in New Issue
Block a user