Browse Source

Implement printing of booleans

pull/6/head
Ayke van Laethem 6 years ago
parent
commit
2777f8464e
No known key found for this signature in database GPG Key ID: E97FF5335DFDFDED
  1. 3
      compiler.go
  2. 8
      src/runtime/print.go

3
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())
}

8
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")
}
}

Loading…
Cancel
Save