C
C#9mo 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?
5 Replies
Tvde1
Tvde19mo ago
How is CreateConstIntOfString implemented? Is this something you made yourself or an existing library?
Accord
Accord9mo ago
Was this issue resolved? If so, run /close - otherwise I will mark this as stale and this post will be archived until there is new activity.
Theos
Theos9mo ago
its from LLVMSharp library
Accord
Accord9mo ago
Was this issue resolved? If so, run /close - otherwise I will mark this as stale and this post will be archived until there is new activity.