C
C#10mo ago
Theos

❔ LLVM problem with creating number

public (Context, LLVMValueRef) VisitNumber(Context ctx, NumberAST expr)
{
LLVMTypeRef typeRef = LLVMTypeRef.Double;
if (expr.Type == typeof(long)) typeRef = LLVMTypeRef.Int64;
else if (expr.Type == typeof(int)) typeRef = LLVMTypeRef.Int32;
else if (expr.Type == typeof(short)) typeRef = LLVMTypeRef.Int16;
else if (expr.Type == typeof(sbyte)) typeRef = LLVMTypeRef.Int8;

else if (expr.Type == typeof(ulong)) typeRef = LLVMTypeRef.Int64;
else if (expr.Type == typeof(uint)) typeRef = LLVMTypeRef.Int32;
else if (expr.Type == typeof(ushort)) typeRef = LLVMTypeRef.Int16;
else if (expr.Type == typeof(byte)) typeRef = LLVMTypeRef.Int8;


return new(ctx, LLVMValueRef.CreateConstIntOfString(typeRef, expr.Value, 10));
}
public (Context, LLVMValueRef) VisitNumber(Context ctx, NumberAST expr)
{
LLVMTypeRef typeRef = LLVMTypeRef.Double;
if (expr.Type == typeof(long)) typeRef = LLVMTypeRef.Int64;
else if (expr.Type == typeof(int)) typeRef = LLVMTypeRef.Int32;
else if (expr.Type == typeof(short)) typeRef = LLVMTypeRef.Int16;
else if (expr.Type == typeof(sbyte)) typeRef = LLVMTypeRef.Int8;

else if (expr.Type == typeof(ulong)) typeRef = LLVMTypeRef.Int64;
else if (expr.Type == typeof(uint)) typeRef = LLVMTypeRef.Int32;
else if (expr.Type == typeof(ushort)) typeRef = LLVMTypeRef.Int16;
else if (expr.Type == typeof(byte)) typeRef = LLVMTypeRef.Int8;


return new(ctx, LLVMValueRef.CreateConstIntOfString(typeRef, expr.Value, 10));
}
var res = VisitNumber(ctx, new("10")).Item2; for some reason the result is {i0 0} Any ideas why?
2 Replies
Theos
Theos10mo ago
bump
Accord
Accord10mo ago
Looks like nothing has happened here. I will mark this as stale and this post will be archived until there is new activity.