|
- package ops
-
- import (
- "gitlink.org.cn/cloudream/jcs-pub/common/pkgs/ioswitch/dag"
- "gitlink.org.cn/cloudream/jcs-pub/common/pkgs/ioswitch/exec"
- )
-
- func init() {
- exec.UseOp[*ConstVar]()
- }
-
- type ConstVar struct {
- ID exec.VarID `json:"id"`
- Value exec.VarValue `json:"value"`
- }
-
- func (o *ConstVar) Execute(ctx *exec.ExecContext, e *exec.Executor) error {
- e.PutVar(o.ID, o.Value)
- return nil
- }
-
- func (o *ConstVar) String() string {
- 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
- }
|