Skip to content

Commit

Permalink
remove code
Browse files Browse the repository at this point in the history
  • Loading branch information
edg-l committed Dec 9, 2024
1 parent 29e1a42 commit 1e0bbae
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 44 deletions.
52 changes: 11 additions & 41 deletions src/codegen/expressions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,50 +17,20 @@ pub fn compile_expr<'ctx: 'parent, 'parent>(
block: &'parent Block<'ctx>,
expr: &Expr,
) -> Value<'ctx, 'parent> {
let location = Location::unknown(ctx.ctx);
let i64_type: Type = IntegerType::new(ctx.ctx, 64).into();
match expr {
Expr::Number(value) => {
let value = block
.append_operation(arith::constant(
ctx.ctx,
IntegerAttribute::new(IntegerType::new(ctx.ctx, 64).into(), *value).into(),
location,
))
.result(0)
.unwrap()
.into();

value
Expr::Number(_value) => {
todo!()
}
Expr::Variable(name) => {
let local_ptr = *locals.get(name).unwrap();
let value = block
.append_operation(llvm::load(
ctx.ctx,
local_ptr,
i64_type,
location,
Default::default(),
))
.result(0)
.unwrap()
.into();

value
}
Expr::Op(lhs_expr, opcode, rhs_expr) => {
let lhs = compile_expr(ctx, locals, block, lhs_expr);
let rhs = compile_expr(ctx, locals, block, rhs_expr);

match opcode {
Opcode::Mul => todo!(),
Opcode::Div => todo!(),
Opcode::Add => todo!(),
Opcode::Sub => todo!(),
Opcode::Eq => todo!(),
Opcode::Neq => todo!(),
}
todo!()
}
Expr::Op(lhs_expr, opcode, rhs_expr) => match opcode {
Opcode::Mul => todo!(),
Opcode::Div => todo!(),
Opcode::Add => todo!(),
Opcode::Sub => todo!(),
Opcode::Eq => todo!(),
Opcode::Neq => todo!(),
},
}
}
2 changes: 1 addition & 1 deletion src/codegen/ifelse_stmt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,5 @@ pub fn compile_if<'ctx, 'parent>(
block: &'parent Block<'ctx>,
stmt: &IfStmt,
) {
let cond = compile_expr(ctx, locals, block, &stmt.cond);
todo!()
}
3 changes: 1 addition & 2 deletions src/codegen/let_stmt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,5 @@ pub fn compile_let<'ctx: 'parent, 'parent>(
block: &'parent Block<'ctx>,
stmt: &LetStmt,
) {
let value = compile_expr(ctx, locals, block, &stmt.expr);
locals.insert(stmt.variable.clone(), value);
todo!()
}
1 change: 1 addition & 0 deletions src/codegen/return_stmt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,5 @@ pub fn compile_return<'ctx, 'parent>(
block: &'parent Block<'ctx>,
stmt: &ReturnStmt,
) {
todo!()
}

0 comments on commit 1e0bbae

Please sign in to comment.