In a situation with multiple changesets, dr-add-to-rule-set is not implemented correctly as demonstrated by the following tests:


module add-rules
imports libstrategolib

strategies

main =
test1
; test2
; test3
; test4

test1 =
say(!“test1:” )
; dr-get-rule-set(|“Test1”)
; dr-set-rule(|“Test1”, 1, 1)
; dr-add-rule(|“Test1”, 1, 2)
; dr-add-rule(|“Test1”, 1, 3)
; dr-print-rule-set(|“Test1”)
; dr-lookup-all-rules(|“Test1”, 1)
; debug(!"test1 res: ")

test2 =
say(!“test2:” )
; dr-get-rule-set(|“Test2”)
; dr-set-rule(|“Test2”, 1, 1)
; dr-start-change-set(|“Test2”)
; dr-add-rule(|“Test2”, 1, 2)
; dr-start-change-set(|“Test2”)
; dr-add-rule(|“Test2”, 1, 3)
; dr-print-rule-set(|“Test2”)
; dr-lookup-all-rules(|“Test2”, 1)
; debug(!"test2 res: ")

test3 =
say(!“Test3:” )
; dr-get-rule-set(|“Test3”)
; dr-set-rule(|“Test3”, 1, 1)
; dr-add-rule(|“Test3”, 1, 2)
; dr-add-rule(|“Test3”, 1, 3)
; dr-print-rule-set(|“Test3”)
; dr-lookup-rule(|“Test3”, 1)
; debug(!"test3 res: ")

test4 =
say(!“test4:” )
; dr-get-rule-set(|“Test4”)
; dr-set-rule(|“Test4”, 1, 1)
; dr-start-change-set(|“Test4”)
; dr-add-rule(|“Test4”, 1, 2)
; dr-start-change-set(|“Test4”)
; dr-add-rule(|“Test4”, 1, 3)
; dr-print-rule-set(|“Test4”)
; dr-lookup-rule(|“Test4”, 1)
; debug(!"test4 res: ")
———————————————–

The problem is the call <hashtable-get(|key)> tbl2 in add2 below. Instead of doing a get in the hashtable of the rulescope, it should do a lookup in the ruleset rs; this may actually be easy to fix.


dr-add-to-rule-set(add1 : ATerm * Hashtable * ATerm * ATerm * ATerm -> ATerm
| label, key, value) =
?[ChangeSet(labelset, rmset, tbl1) | rs]
; where(
let add2(|scpid, tbl2, key, value) =
add1(|scpid, tbl2, key, value)
<+ {values:
![value | <hashtable-get(|(scpid, key))> tbl1] => values
; if <hashtable-get(|key)> tbl2 => values then
<hashtable-remove(|(scpid, key))> tbl1
else
<hashtable-put(|(scpid, key), values)> tbl1
end }
<+ (<hashtable-get(|key)> tbl2 <+ ![])
; values -> <hashtable-put(|(scpid, key), [value | values])> tbl1 \r
in if <iset-contains(|label)> labelset then
<fetch-elem(?RuleScope(_,tbl@Hashtable(hptr)))> rs
; add2(|hptr, tbl, key, value)
else
<dr-add-to-rule-set(add2 | label, key, value)> rs
end
end
)
———————————————–

(Reported by Bogdan Dumitriu)

Submitted on 20 February 2006 at 23:55

On 27 April 2006 at 15:11 Jira commented:

STR-511, bdumitriu:
dr-set-in-rule-set suffers from the same problem. See STR-528 for details.


On 8 May 2006 at 12:51 Jira commented:

STR-511, bdumitriu:
Now dr-lookup-rule-in-scope is used to properly handle multiple change sets.

Log in to post comments