builtin: real/imag/complex; c/math/cmplx; patch: math/cmplx

This commit is contained in:
xushiwei
2024-06-20 10:00:47 +08:00
parent 1566a834e1
commit de6535b722
9 changed files with 274 additions and 24 deletions

View File

@@ -66,6 +66,21 @@ func (b Builder) getField(x Expr, idx int) Expr {
// -----------------------------------------------------------------------------
func (b Builder) Complex(r, i Expr) Expr {
if debugInstr {
log.Printf("Complex %v, %v\n", r.impl, i.impl)
}
prog := b.Prog
var t Type
switch kind := r.raw.Type.Underlying().(*types.Basic).Kind(); kind {
case types.Float64:
t = prog.Complex128()
case types.Float32:
t = prog.Complex64()
}
return b.aggregateValue(t, r.impl, i.impl)
}
// MakeString creates a new string from a C string pointer and length.
func (b Builder) MakeString(cstr Expr, n ...Expr) (ret Expr) {
if debugInstr {