Add support for printing slices via print/println

With help from @aykevl.
This commit is contained in:
Federico G. Schwindt
2022-06-22 05:21:56 -06:00
committed by Ron Evans
parent 5fdb894760
commit ea36fea5a9
4 changed files with 33 additions and 8 deletions
+6
View File
@@ -1541,6 +1541,12 @@ func (b *builder) createBuiltin(argTypes []types.Type, argValues []llvm.Value, c
case *types.Pointer:
ptrValue := b.CreatePtrToInt(value, b.uintptrType, "")
b.createRuntimeCall("printptr", []llvm.Value{ptrValue}, "")
case *types.Slice:
bufptr := b.CreateExtractValue(value, 0, "")
buflen := b.CreateExtractValue(value, 1, "")
bufcap := b.CreateExtractValue(value, 2, "")
ptrValue := b.CreatePtrToInt(bufptr, b.uintptrType, "")
b.createRuntimeCall("printslice", []llvm.Value{ptrValue, buflen, bufcap}, "")
default:
return llvm.Value{}, b.makeError(pos, "unknown arg type: "+typ.String())
}