diff --git a/src/compiler/ast.rs b/src/compiler/ast.rs index cd50a55..da7790c 100644 --- a/src/compiler/ast.rs +++ b/src/compiler/ast.rs @@ -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>), diff --git a/src/compiler/ir_generator.rs b/src/compiler/ir_generator.rs index 76c8e52..6b900be 100644 --- a/src/compiler/ir_generator.rs +++ b/src/compiler/ir_generator.rs @@ -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) => { diff --git a/src/compiler/parser/mod.rs b/src/compiler/parser/mod.rs index b616bb6..4077ba1 100644 --- a/src/compiler/parser/mod.rs +++ b/src/compiler/parser/mod.rs @@ -275,7 +275,7 @@ fn parse_int_literal<'source>(pos: &mut usize, tokens: &[Token]) -> AstNode<'sou let expr = IntLiteral( token .text - .parse::() + .parse::() .unwrap_or_else(|_| panic!("Fatal parser error! Invalid value in token {token}")), ); diff --git a/src/compiler/variable.rs b/src/compiler/variable.rs index 2f565f0..979d175 100644 --- a/src/compiler/variable.rs +++ b/src/compiler/variable.rs @@ -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(),