deimos-lang/dmc-lib/src/ast/integer_literal.rs

30 lines
661 B
Rust

use crate::ast::function::FunctionLoweringContext;
use crate::ir::ir_expression::IrExpression;
use crate::source_range::SourceRange;
pub struct IntegerLiteral {
value: i32,
source_range: SourceRange,
}
impl IntegerLiteral {
pub fn new(value: i32, source_range: SourceRange) -> Self {
Self {
value,
source_range,
}
}
pub fn value(&self) -> i32 {
self.value
}
pub fn lower_to_ir(&self, context: &mut FunctionLoweringContext) -> IrExpression {
IrExpression::IntegerLiteral(self.value)
}
pub fn source_range(&self) -> &SourceRange {
&self.source_range
}
}