All non-class e2e tests passing.

This commit is contained in:
Jesse Brault 2026-07-03 16:58:35 -05:00
parent f15ff43df8
commit c69098db71
3 changed files with 22 additions and 9 deletions

View File

@ -9,14 +9,13 @@ use crate::ir::ir_operation::IrOperation;
use crate::ir::ir_parameter::IrParameter; use crate::ir::ir_parameter::IrParameter;
use crate::ir::ir_return::IrReturn; use crate::ir::ir_return::IrReturn;
use crate::ir::ir_statement::IrStatement; use crate::ir::ir_statement::IrStatement;
use crate::ir::ir_type_info::{IrTypeInfo, IrTypeInfoId}; use crate::ir::ir_type_info::IrTypeInfo;
use crate::ir::ir_variable::{IrVariable, IrVariableId}; use crate::ir::ir_variable::IrVariable;
use crate::ir::variable_locations::{VariableLocation, VariableLocations}; use crate::ir::variable_locations::{VariableLocation, VariableLocations};
use dvm_lib::instruction::{ use dvm_lib::instruction::{
AddOperand, Instruction, Location, LocationOrInteger, LocationOrNumber, MoveOperand, AddOperand, Instruction, Location, LocationOrInteger, LocationOrNumber, MoveOperand,
MultiplyOperand, PushOperand, ReturnOperand, SubtractOperand, MultiplyOperand, PushOperand, ReturnOperand, SubtractOperand,
}; };
use std::collections::HashMap;
struct FunctionAssemblyContext<'a> { struct FunctionAssemblyContext<'a> {
variable_locations: &'a VariableLocations, variable_locations: &'a VariableLocations,
@ -73,9 +72,15 @@ fn assemble_ir_assign(ir_assign: &IrAssign, ctx: &mut FunctionAssemblyContext) {
.get_variable_location(&ir_assign.destination()), .get_variable_location(&ir_assign.destination()),
); );
match ir_assign.initializer() { match ir_assign.initializer() {
IrOperation::GetFieldRef(_) => {} IrOperation::GetFieldRef(_) => {
IrOperation::GetFieldRefMut(_) => {} todo!()
IrOperation::ReadField(_) => {} }
IrOperation::GetFieldRefMut(_) => {
todo!()
}
IrOperation::ReadField(_) => {
todo!()
}
IrOperation::Load(ir_expression) => { IrOperation::Load(ir_expression) => {
let move_operand = to_move_operand(ir_expression, ctx); let move_operand = to_move_operand(ir_expression, ctx);
let instruction = Instruction::Move(move_operand, destination_location); let instruction = Instruction::Move(move_operand, destination_location);
@ -137,8 +142,11 @@ fn assemble_ir_assign(ir_assign: &IrAssign, ctx: &mut FunctionAssemblyContext) {
ctx.instructions.push(instruction); ctx.instructions.push(instruction);
} }
IrOperation::Call(_) => { IrOperation::Call(ir_call) => {
todo!() // pop top of stack after call into destination
assemble_ir_call(ir_call, ctx);
ctx.instructions
.push(Instruction::Pop(Some(destination_location)));
} }
IrOperation::Allocate(_) => { IrOperation::Allocate(_) => {
todo!() todo!()

View File

@ -1,3 +1,4 @@
use crate::ast::NodeId;
use crate::ast::assign_statement::AssignStatement; use crate::ast::assign_statement::AssignStatement;
use crate::ast::binary_expression::BinaryExpression; use crate::ast::binary_expression::BinaryExpression;
use crate::ast::call::Call; use crate::ast::call::Call;
@ -10,7 +11,6 @@ use crate::ast::let_statement::LetStatement;
use crate::ast::negative_expression::NegativeExpression; use crate::ast::negative_expression::NegativeExpression;
use crate::ast::parameter::Parameter; use crate::ast::parameter::Parameter;
use crate::ast::statement::Statement; use crate::ast::statement::Statement;
use crate::ast::NodeId;
use crate::diagnostic::Diagnostics; use crate::diagnostic::Diagnostics;
use crate::diagnostic_factories::symbol_not_found; use crate::diagnostic_factories::symbol_not_found;
use crate::semantic_analysis::scope::{Scope, ScopeId}; use crate::semantic_analysis::scope::{Scope, ScopeId};

View File

@ -266,6 +266,11 @@ fn resolve_types_negative_expression(
fn resolve_types_call(call: &Call, ctx: &mut ResolveTypesContext) { fn resolve_types_call(call: &Call, ctx: &mut ResolveTypesContext) {
resolve_types_expression(call.callee(), ctx); resolve_types_expression(call.callee(), ctx);
// get types of arguments
for argument in call.arguments() {
resolve_types_expression(argument, ctx);
}
let callee_type_info_id = ctx.nodes_to_type_infos[&call.callee().node_id()]; let callee_type_info_id = ctx.nodes_to_type_infos[&call.callee().node_id()];
let callee_type_info = &ctx.type_infos[callee_type_info_id]; let callee_type_info = &ctx.type_infos[callee_type_info_id];