| @@ -1,6 +1,7 @@ | |||||
| package ops | package ops | ||||
| import ( | import ( | ||||
| "gitlink.org.cn/cloudream/common/pkgs/ioswitch/dag" | |||||
| "gitlink.org.cn/cloudream/common/pkgs/ioswitch/exec" | "gitlink.org.cn/cloudream/common/pkgs/ioswitch/exec" | ||||
| ) | ) | ||||
| @@ -21,3 +22,31 @@ func (o *ConstVar) Execute(ctx *exec.ExecContext, e *exec.Executor) error { | |||||
| func (o *ConstVar) String() string { | func (o *ConstVar) String() string { | ||||
| return "ConstVar" | return "ConstVar" | ||||
| } | } | ||||
| type ConstNode struct { | |||||
| dag.NodeBase | |||||
| Value exec.VarValue | |||||
| } | |||||
| func (b *GraphNodeBuilder) NewConst(val exec.VarValue) *ConstNode { | |||||
| node := &ConstNode{ | |||||
| Value: val, | |||||
| } | |||||
| b.AddNode(node) | |||||
| node.OutputValues().Init(node, 1) | |||||
| return node | |||||
| } | |||||
| func (t *ConstNode) Output() dag.ValueOutputSlot { | |||||
| return dag.ValueOutputSlot{ | |||||
| Node: t, | |||||
| Index: 0, | |||||
| } | |||||
| } | |||||
| func (t *ConstNode) GenerateOp() (exec.Op, error) { | |||||
| return &DropStream{ | |||||
| Input: t.Output().Var().VarID, | |||||
| }, nil | |||||
| } | |||||