Fix bug with max-sized ints
This commit is contained in:
parent
dc5c5940ef
commit
50d3d60a7f
4 changed files with 5 additions and 4 deletions
|
@ -40,7 +40,7 @@ impl<'source> fmt::Display for AstNode<'source> {
|
|||
#[derive(Debug, PartialEq, Clone)]
|
||||
pub enum Expression<'source> {
|
||||
EmptyLiteral(),
|
||||
IntLiteral(i64),
|
||||
IntLiteral(i128),
|
||||
BoolLiteral(bool),
|
||||
Identifier(&'source str),
|
||||
UnaryOp(&'source str, Box<AstNode<'source>>),
|
||||
|
|
|
@ -109,7 +109,8 @@ fn visit_ast_node<'source>(
|
|||
EmptyLiteral() => add_var(&Type::Unit, types),
|
||||
IntLiteral(val) => {
|
||||
let var = add_var(&Type::Int, types);
|
||||
instructions.push(IrInstruction::new(ast.loc, LoadIntConst(*val, var.clone())));
|
||||
let val = *val as i64;
|
||||
instructions.push(IrInstruction::new(ast.loc, LoadIntConst(val, var.clone())));
|
||||
var
|
||||
}
|
||||
BoolLiteral(val) => {
|
||||
|
|
|
@ -275,7 +275,7 @@ fn parse_int_literal<'source>(pos: &mut usize, tokens: &[Token]) -> AstNode<'sou
|
|||
let expr = IntLiteral(
|
||||
token
|
||||
.text
|
||||
.parse::<i64>()
|
||||
.parse::<i128>()
|
||||
.unwrap_or_else(|_| panic!("Fatal parser error! Invalid value in token {token}")),
|
||||
);
|
||||
|
||||
|
|
|
@ -10,7 +10,7 @@ pub enum Type {
|
|||
|
||||
#[derive(PartialEq, PartialOrd, Debug, Copy, Clone)]
|
||||
pub enum Value {
|
||||
Int(i64),
|
||||
Int(i128),
|
||||
Bool(bool),
|
||||
Func(fn(&[Value]) -> Value),
|
||||
None(),
|
||||
|
|
Reference in a new issue