10.2.3 用于Values包的其它操作

LocalSnapshot

[1] 操作allPredecessors返回一个快照之前的快照集合,allSuccessors返回一个快照之后的所有快照。

context LocalSnapshot
def: allPredecessors() : Sequence(LocalSnapshot) =
        if pred->notEmpty() then
            pred->union(pred.allPredecessors())
        else
            Sequence {}
        endif
def: allSuccessors() : Sequence(LocalSnapshot) =
        if succ->notEmpty() then
            succ->union(succ.allSuccessors())
        else
            Sequence {}
        endif

ObjectValue

操作getCurrentValueOf产生对象历史上最近的快照中name参数所绑定的值。注意该值有可能是UndifinedValue。

context ObjectValue::getCurrentValueOf(n: String): Value
pre: -- none
post: result = history->last().bindings->any(name = n).value

[2] 操作outgoingMessages产生OclMessageValues序列,后者在对象的输出队列中位于上一次的后置条件快照和它对应的前置快照之间。

context OclExpEval::outgoingMessages() : Sequence( OclMessageValue )
pre: -- none
post:
let end: LocalSnapshot =
    history->last().allPredecessors()->select( isPost = true )->first() in
    let start: LocalSnapshot = end.pre in
        let inBetween: Sequence( LocalSnapshot ) =
            start.allSuccessors()->excluding( end.allSuccessors())->including( start ) in
                result = inBetween.outputQ->iterate (
                    -- creating a sequence with all elements present once
                    m : oclMessageValue;
                    res: Sequence( OclMessageValue ) = Sequence{}
                                | if not res->includes( m )
                                    then res->append( m )
                                    else res
                                  endif )
                )

TupleValue

[1] 操作getValueOf产生一个元组值中绑定到name参数的值。

context TupleValue::getValueOf(n: String): Value
pre: -- none
post: result = elements->any(name = n).value

results matching ""

    No results matching ""