C#C
C#3y 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));
}

var res = VisitNumber(ctx, new("10")).Item2;
for some reason the result is
{i0 0}
Any ideas why?
Was this page helpful?