From 2777f8464ed1a39d159fec67a6fe78e60b230b3f Mon Sep 17 00:00:00 2001 From: Ayke van Laethem Date: Wed, 22 Aug 2018 00:54:39 +0200 Subject: [PATCH] Implement printing of booleans --- compiler.go | 3 ++- src/runtime/print.go | 8 ++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/compiler.go b/compiler.go index 297fb454..ce68b27f 100644 --- a/compiler.go +++ b/compiler.go @@ -1008,7 +1008,8 @@ func (c *Compiler) parseBuiltin(frame *Frame, args []ssa.Value, callName string) panic("undefined: " + name) } c.builder.CreateCall(fn, []llvm.Value{value}, "") - continue + } else if typ.Kind() == types.Bool { + c.builder.CreateCall(c.mod.NamedFunction("runtime.printbool"), []llvm.Value{value}, "") } else { return llvm.Value{}, errors.New("unknown basic arg type: " + typ.String()) } diff --git a/src/runtime/print.go b/src/runtime/print.go index c4fd074c..91fcd1e6 100644 --- a/src/runtime/print.go +++ b/src/runtime/print.go @@ -101,3 +101,11 @@ func printptr(ptr uintptr) { ptr <<= 4 } } + +func printbool(b bool) { + if b { + printstring("true") + } else { + printstring("false") + } +}