|
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394 |
- package ops
-
- import (
- "fmt"
-
- "gitlink.org.cn/cloudream/jcs-pub/common/pkgs/ioswitch/dag"
- "gitlink.org.cn/cloudream/jcs-pub/common/pkgs/ioswitch/exec"
- )
-
- type Store struct {
- Var exec.VarID
- Key string
- }
-
- func (o *Store) Execute(ctx *exec.ExecContext, e *exec.Executor) error {
- v, err := e.BindVar(ctx.Context, o.Var)
- if err != nil {
- return err
- }
-
- e.Store(o.Key, v)
- return nil
- }
-
- func (o *Store) String() string {
- return fmt.Sprintf("Store %v as \"%v\"", o.Var, o.Key)
- }
-
- type StoreConst struct {
- Key string
- Value exec.VarValue
- }
-
- func (o *StoreConst) Execute(ctx *exec.ExecContext, e *exec.Executor) error {
- e.Store(o.Key, o.Value)
- return nil
- }
-
- func (o *StoreConst) String() string {
- return fmt.Sprintf("StoreConst %v: %v", o.Key, o.Value)
- }
-
- type StoreNode struct {
- dag.NodeBase
- Key string
- }
-
- func (b *GraphNodeBuilder) NewStore() *StoreNode {
- node := &StoreNode{}
- b.AddNode(node)
- return node
- }
-
- func (t *StoreNode) Store(key string, v *dag.ValueVar) {
- t.Key = key
- t.InputValues().Init(1)
- v.To(t, 0)
- }
-
- func (t *StoreNode) GenerateOp() (exec.Op, error) {
- return &Store{
- Var: t.InputValues().Get(0).VarID,
- Key: t.Key,
- }, nil
- }
-
- // func (t *StoreType) String() string {
- // return fmt.Sprintf("Store[%s]%v%v", t.StoreKey, formatStreamIO(node), formatValueIO(node))
- // }
-
- type StoreConstNode struct {
- dag.NodeBase
- Key string
- Value exec.VarValue
- }
-
- func (b *GraphNodeBuilder) NewStoreConst(key string, value exec.VarValue) *StoreConstNode {
- node := &StoreConstNode{
- Key: key,
- Value: value,
- }
- b.AddNode(node)
- return node
- }
-
- func (t *StoreConstNode) GenerateOp() (exec.Op, error) {
- return &StoreConst{
- Key: t.Key,
- Value: t.Value,
- }, nil
- }
-
- // func (t *StoreConstType) String() string {
- // return fmt.Sprintf("StoreConst[%s]%v%v", t.StoreKey, formatStreamIO(node), formatValueIO(node))
|