MCPcopy
hub / github.com/tinygo-org/tinygo / createMakeInterface

Method createMakeInterface

compiler/interface.go:85–92  ·  view source on GitHub ↗

createMakeInterface emits the LLVM IR for the *ssa.MakeInterface instruction. It tries to put the type in the interface value, but if that's not possible, it will do an allocation of the right size and put that in the interface value field. An interface value is a {typecode, value} tuple named runt

(val llvm.Value, typ types.Type, pos token.Pos)

Source from the content-addressed store, hash-verified

83//
84// An interface value is a {typecode, value} tuple named runtime._interface.
85func (b *builder) createMakeInterface(val llvm.Value, typ types.Type, pos token.Pos) llvm.Value {
86 itfValue := b.emitPointerPack([]llvm.Value{val})
87 itfType := b.getTypeCode(typ)
88 itf := llvm.Undef(b.getLLVMRuntimeType("_interface"))
89 itf = b.CreateInsertValue(itf, itfType, 0, "")
90 itf = b.CreateInsertValue(itf, itfValue, 1, "")
91 return itf
92}
93
94// extractValueFromInterface extract the value from an interface value
95// (runtime._interface) under the assumption that it is of the type given in

Callers 4

createMapLookupMethod · 0.95
createMapUpdateMethod · 0.95
createMapDeleteMethod · 0.95
createExprMethod · 0.95

Calls 3

emitPointerPackMethod · 0.95
getTypeCodeMethod · 0.80
getLLVMRuntimeTypeMethod · 0.80

Tested by

no test coverage detected