Fix UserPointer being completely monkeypatched, found the issue
This commit is contained in:
parent
10d62eb1f7
commit
836a532d8d
@ -1075,7 +1075,7 @@ impl ConstValue {
|
||||
ConstValue::U32(val) => LLVMConstInt(t, *val as u64, 1),
|
||||
ConstValue::U64(val) => LLVMConstInt(t, *val as u64, 1),
|
||||
ConstValue::U128(val) => LLVMConstInt(t, *val as u64, 1),
|
||||
ConstValue::StringPtr(val) => LLVMBuildGlobalString(
|
||||
ConstValue::Str(val) => LLVMBuildGlobalString(
|
||||
module.builder_ref,
|
||||
into_cstring(val).as_ptr(),
|
||||
c"string".as_ptr(),
|
||||
|
@ -439,7 +439,7 @@ pub enum ConstValue {
|
||||
U64(u64),
|
||||
U128(u128),
|
||||
Bool(bool),
|
||||
StringPtr(String),
|
||||
Str(String),
|
||||
F16(f32),
|
||||
F32B(f32),
|
||||
F32(f32),
|
||||
@ -505,12 +505,12 @@ impl InstructionValue {
|
||||
ArrayAlloca(ty, _) => Ok(Type::Ptr(Box::new(ty.clone()))),
|
||||
GetElemPtr(instr, _) => {
|
||||
let instr_ty = instr.get_type(builder)?;
|
||||
let Type::Ptr(inner_ty) = instr_ty else {
|
||||
let Type::Ptr(inner_ty) = &instr_ty else {
|
||||
panic!("GetStructElemPtr on non-pointer! ({:?})", &instr_ty)
|
||||
};
|
||||
match *inner_ty {
|
||||
match *inner_ty.clone() {
|
||||
Type::Array(elem_ty, _) => Ok(Type::Ptr(Box::new(*elem_ty.clone()))),
|
||||
_ => Ok(*inner_ty),
|
||||
_ => Ok(instr_ty),
|
||||
}
|
||||
}
|
||||
GetStructElemPtr(instr, idx) => {
|
||||
@ -562,7 +562,7 @@ impl ConstValue {
|
||||
ConstValue::U32(_) => U32,
|
||||
ConstValue::U64(_) => U64,
|
||||
ConstValue::U128(_) => U128,
|
||||
ConstValue::StringPtr(_) => Ptr(Box::new(I8)),
|
||||
ConstValue::Str(_) => Type::Ptr(Box::new(I8)),
|
||||
ConstValue::Bool(_) => Bool,
|
||||
ConstValue::F16(_) => F16,
|
||||
ConstValue::F32B(_) => F32B,
|
||||
|
@ -490,7 +490,7 @@ impl mir::Statement {
|
||||
.block
|
||||
.build(
|
||||
name,
|
||||
Instr::Alloca(ty.get_type(scope.type_values, scope.types)),
|
||||
Instr::Alloca(value.1.get_type(scope.type_values, scope.types)),
|
||||
)
|
||||
.unwrap()
|
||||
.maybe_location(&mut scope.block, location);
|
||||
@ -1167,7 +1167,7 @@ impl mir::Literal {
|
||||
mir::Literal::U64(val) => ConstValue::U64(val),
|
||||
mir::Literal::U128(val) => ConstValue::U128(val),
|
||||
mir::Literal::Bool(val) => ConstValue::Bool(val),
|
||||
mir::Literal::String(val) => ConstValue::StringPtr(val.clone()),
|
||||
mir::Literal::String(val) => ConstValue::Str(val.clone()),
|
||||
mir::Literal::Vague(VagueLiteral::Number(val)) => ConstValue::I32(val as i32),
|
||||
mir::Literal::Vague(VagueLiteral::Decimal(val)) => ConstValue::F32(val as f32),
|
||||
mir::Literal::F16(val) => ConstValue::F16(val),
|
||||
@ -1216,9 +1216,9 @@ impl TypeKind {
|
||||
let type_val = type_vals.get(n).unwrap().clone();
|
||||
Type::CustomType(type_val)
|
||||
}
|
||||
TypeKind::UserPtr(type_kind) => Type::Ptr(Box::new(Type::Ptr(Box::new(
|
||||
type_kind.get_type(type_vals, typedefs),
|
||||
)))),
|
||||
TypeKind::UserPtr(type_kind) => {
|
||||
Type::Ptr(Box::new(type_kind.get_type(type_vals, typedefs)))
|
||||
}
|
||||
TypeKind::CodegenPtr(type_kind) => {
|
||||
Type::Ptr(Box::new(type_kind.get_type(type_vals, typedefs)))
|
||||
}
|
||||
|
@ -1,10 +1,7 @@
|
||||
|
||||
import std::print;
|
||||
|
||||
fn main() -> i32 {
|
||||
let hello = "hello world";
|
||||
|
||||
print(hello);
|
||||
print("hello world");
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user