|
@@ -2,8 +2,11 @@ package rules
|
|
|
|
|
|
import (
|
|
|
"fmt"
|
|
|
+ "fw/cp/constant"
|
|
|
+ "fw/cp/constant/operation"
|
|
|
"fw/cp/node"
|
|
|
"fw/cp/statement"
|
|
|
+ "fw/rt2"
|
|
|
"fw/rt2/context"
|
|
|
"fw/rt2/frame"
|
|
|
"fw/rt2/nodeframe"
|
|
@@ -11,6 +14,24 @@ import (
|
|
|
"reflect"
|
|
|
)
|
|
|
|
|
|
+func incSeq(f frame.Frame) (seq frame.Sequence, ret frame.WAIT) {
|
|
|
+ n := rt2.Utils.NodeOf(f)
|
|
|
+ op := node.New(constant.DYADIC).(node.OperationNode)
|
|
|
+ op.SetOperation(operation.PLUS)
|
|
|
+ op.SetLeft(n.Left())
|
|
|
+ op.SetRight(n.Right())
|
|
|
+ rt2.Utils.Push(rt2.Utils.New(op), f)
|
|
|
+ seq = func(f frame.Frame) (seq frame.Sequence, ret frame.WAIT) {
|
|
|
+ sc := f.Domain().Discover(context.SCOPE).(scope.Manager)
|
|
|
+ sc.Update(n.Left().Object(), func(interface{}) interface{} {
|
|
|
+ return rt2.Utils.DataOf(f)[op]
|
|
|
+ })
|
|
|
+ return frame.End()
|
|
|
+ }
|
|
|
+ ret = frame.LATER
|
|
|
+ return seq, ret
|
|
|
+}
|
|
|
+
|
|
|
func assignSeq(f frame.Frame) (seq frame.Sequence, ret frame.WAIT) {
|
|
|
var fu nodeframe.FrameUtils
|
|
|
a := fu.NodeOf(f)
|
|
@@ -60,8 +81,15 @@ func assignSeq(f frame.Frame) (seq frame.Sequence, ret frame.WAIT) {
|
|
|
fmt.Println(reflect.TypeOf(a.Left()))
|
|
|
panic("wrong left")
|
|
|
}
|
|
|
+ case statement.INC:
|
|
|
+ switch a.Left().(type) {
|
|
|
+ case node.VariableNode, node.ParameterNode:
|
|
|
+ seq, ret = incSeq(f)
|
|
|
+ default:
|
|
|
+ panic(fmt.Sprintln("wrong left", reflect.TypeOf(a.Left())))
|
|
|
+ }
|
|
|
default:
|
|
|
- panic("wrong statement")
|
|
|
+ panic(fmt.Sprintln("wrong statement", a.(node.AssignNode).Statement()))
|
|
|
}
|
|
|
return seq, ret
|
|
|
}
|