func (c *Compiler) emitChanRecv(frame *Frame, unop *ssa.UnOp) llvm.Value {
	valueType := c.getLLVMType(unop.X.Type().(*types.Chan).Elem())
	ch := c.getValue(frame, unop.X)

	// Allocate memory to receive into.
	valueAlloca, valueAllocaCast, valueAllocaSize := c.createTemporaryAlloca(valueType, "chan.value")

	// Do the receive.
	coroutine := c.createRuntimeCall("getCoroutine", nil, "")
	valueSize := llvm.ConstInt(c.uintptrType, c.targetData.TypeAllocSize(valueType), false)
	c.createRuntimeCall("chanRecv", []llvm.Value{coroutine, ch, valueAllocaCast, valueSize}, "")
	received := c.builder.CreateLoad(valueAlloca, "chan.received")
	c.emitLifetimeEnd(valueAllocaCast, valueAllocaSize)

	if unop.CommaOk {
		commaOk := c.createRuntimeCall("getTaskPromiseData", []llvm.Value{coroutine}, "chan.commaOk.wide")
		commaOk = c.builder.CreateTrunc(commaOk, c.ctx.Int1Type(), "chan.commaOk")
		tuple := llvm.Undef(c.ctx.StructType([]llvm.Type{valueType, c.ctx.Int1Type()}, false))
		tuple = c.builder.CreateInsertValue(tuple, received, 0, "")
		tuple = c.builder.CreateInsertValue(tuple, commaOk, 1, "")
		return tuple
	} else {
		return received
	}
}
// emitChanRecv emits a pseudo chan receive operation. It is lowered to the
// actual channel receive operation during goroutine lowering.
emitChanRecv emits a pseudo chan receive operation. It is lowered to the
actual channel receive operation during goroutine lowering.
// emitChanRecv emits a pseudo chan receive operation . It is lowered to the // actual channel receive operation during goroutine lowering .
func (c *Compiler) emitChanRecv(frame *Frame, unop *ssa.UnOp) llvm.Value {
	valueType := c.getLLVMType(unop.X.Type().(*types.Chan).Elem())
	ch := c.getValue(frame, unop.X)
	valueAlloca, valueAllocaCast, valueAllocaSize := c.createTemporaryAlloca(valueType, "chan.value")
	coroutine := c.createRuntimeCall("getCoroutine", nil, "")
	valueSize := llvm.ConstInt(c.uintptrType, c.targetData.TypeAllocSize(valueType), false)
	c.createRuntimeCall("chanRecv", []llvm.Value{coroutine, ch, valueAllocaCast, valueSize}, "")
	received := c.builder.CreateLoad(valueAlloca, "chan.received")
	c.emitLifetimeEnd(valueAllocaCast, valueAllocaSize)
	if unop.CommaOk {
		commaOk := c.createRuntimeCall("getTaskPromiseData", []llvm.Value{coroutine}, "chan.commaOk.wide")
		commaOk = c.builder.CreateTrunc(commaOk, c.ctx.Int1Type(), "chan.commaOk")
		tuple := llvm.Undef(c.ctx.StructType([]llvm.Type{valueType, c.ctx.Int1Type()}, false))
		tuple = c.builder.CreateInsertValue(tuple, received, 0, "")
		tuple = c.builder.CreateInsertValue(tuple, commaOk, 1, "")
		return tuple
	} else {
		return received
	}
}
func ( c * Compiler ) emitChanRecv ( frame * Frame , unop * ssa . UnOp ) llvm . Value { valueType := c . getLLVMType ( unop . X . Type ( ) . ( * types . Chan ) . Elem ( ) ) ch := c . getValue ( frame , unop . X ) valueAlloca , valueAllocaCast , valueAllocaSize := c . createTemporaryAlloca ( valueType , " " ) coroutine := c . createRuntimeCall ( " " , nil , " " ) valueSize := llvm . ConstInt ( c . uintptrType , c . targetData . TypeAllocSize ( valueType ) , false ) c . createRuntimeCall ( " " , [ ] llvm . Value { coroutine , ch , valueAllocaCast , valueSize } , " " ) received := c . builder . CreateLoad ( valueAlloca , " " ) c . emitLifetimeEnd ( valueAllocaCast , valueAllocaSize ) if unop . CommaOk { commaOk := c . createRuntimeCall ( " " , [ ] llvm . Value { coroutine } , " " ) commaOk = c . builder . CreateTrunc ( commaOk , c . ctx . Int1Type ( ) , " " ) tuple := llvm . Undef ( c . ctx . StructType ( [ ] llvm . Type { valueType , c . ctx . Int1Type ( ) } , false ) ) tuple = c . builder . CreateInsertValue ( tuple , received , 0 , " " ) tuple = c . builder . CreateInsertValue ( tuple , commaOk , 1 , " " ) return tuple } else { return received } }
emitChanRecv emits a pseudo chan receive operation.
emitChanRecv emits a pseudo chan receive operation .
// Allocate memory to receive into. // Do the receive.