feat: SCC analysis (WIP)

This commit is contained in:
2025-06-15 17:23:32 +08:00
parent 7b6db44207
commit b2d2490327
13 changed files with 842 additions and 352 deletions

View File

@@ -5,7 +5,7 @@ use inkwell::context::Context;
use inkwell::execution_engine::ExecutionEngine;
use inkwell::module::Module;
use inkwell::types::{FloatType, FunctionType, IntType, PointerType, StructType};
use inkwell::values::{BasicValueEnum, FloatValue, FunctionValue, IntValue};
use inkwell::values::{BasicValueEnum, FloatValue, FunctionValue, IntValue, StructValue};
use crate::env::VmEnv;
use crate::eval::Engine;
@@ -180,7 +180,7 @@ impl<'ctx> Helpers<'ctx> {
self.int_type.const_int(int as _, false)
}
pub fn new_int(&self, int: i64) -> BasicValueEnum<'ctx> {
pub fn new_int(&self, int: i64) -> StructValue<'ctx> {
self.value_type
.const_named_struct(&[
self.int_type.const_int(ValueTag::Int as _, false).into(),
@@ -193,7 +193,7 @@ impl<'ctx> Helpers<'ctx> {
self.float_type.const_float(float)
}
pub fn new_float(&self, float: f64) -> BasicValueEnum<'ctx> {
pub fn new_float(&self, float: f64) -> StructValue<'ctx> {
self.value_type
.const_named_struct(&[
self.int_type.const_int(ValueTag::Float as _, false).into(),
@@ -202,7 +202,7 @@ impl<'ctx> Helpers<'ctx> {
.into()
}
pub fn new_bool(&self, bool: bool) -> BasicValueEnum<'ctx> {
pub fn new_bool(&self, bool: bool) -> StructValue<'ctx> {
self.value_type
.const_named_struct(&[
self.int_type.const_int(ValueTag::Bool as _, false).into(),
@@ -211,7 +211,7 @@ impl<'ctx> Helpers<'ctx> {
.into()
}
pub fn new_null(&self) -> BasicValueEnum<'ctx> {
pub fn new_null(&self) -> StructValue<'ctx> {
self.value_type
.const_named_struct(&[
self.int_type.const_int(ValueTag::Null as _, false).into(),
@@ -220,7 +220,7 @@ impl<'ctx> Helpers<'ctx> {
.into()
}
pub fn const_string(&self, string: *const u8) -> BasicValueEnum<'ctx> {
pub fn const_string(&self, string: *const u8) -> StructValue<'ctx> {
self.value_type
.const_named_struct(&[
self.int_type.const_int(ValueTag::String as _, false).into(),