在Promela Spin中将char转换回mtype

时间:2014-05-09 15:14:06

标签: spin promela

让我们说,例如,我有以下

mtype = {ONE, TWO, THREE} ;
mtype array[3] ;
mtype test ;
test = array[0] ;
printf("Test is %e\n", test) ;

我得到了

Test is 1

我理解是因为底层变量是char类型。但是,我想得到那个char的mtype,有没有办法将char引用回mtype?

1 个答案:

答案 0 :(得分:0)

您尚未使用有效值初始化array[3]。这是我得到的:

== foo.pml ==
mtype = {ONE, TWO, THREE};
mtype array[3];
mtype test;

init {
  array[0] = TWO;   // initialize!
  test = array[0];
  printf ("Test is '%e'\n", test);
}

$ spin foo.pml 
      Test is 'TWO'
1 process created

如果我然后修改foo.pml以删除array[0]的初始化,则输出为:

$ spin foo.pml 
      Test is '0'
1 process created