fail_closure.xml 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. <?xml version="1.0" ?>
  2. <test>
  3. <statechart>
  4. <!-- closures are currently not supported -->
  5. <!-- TODO: support them OR statically detect them and throw a ModelError indicating they're not supported -->
  6. <datamodel><![CDATA[
  7. counter = func(i:int) {
  8. return func {
  9. i += 1;
  10. return i;
  11. };
  12. };
  13. increment = counter(0);
  14. x = 0;
  15. ]]></datamodel>
  16. <inport name="in">
  17. <event name="start"/>
  18. </inport>
  19. <outport name="out">
  20. <event name="done"/>
  21. </outport>
  22. <root initial="s1">
  23. <state id="s1">
  24. <onentry>
  25. <!-- calling 'increment', the statement "i += 1" will cause a runtime error
  26. since the stack frame of 'counter', containing variable 'i' is no longer there -->
  27. <code>
  28. x = increment();
  29. </code>
  30. </onentry>
  31. <transition cond="x == 1" target="/s2"/>
  32. </state>
  33. <state id="s2">
  34. <onentry>
  35. <code>
  36. x = increment();
  37. </code>
  38. </onentry>
  39. <transition cond="x == 2" target="/s3"/>
  40. </state>
  41. <state id="s3">
  42. <onentry>
  43. <raise event="done"/>
  44. </onentry>
  45. </state>
  46. </root>
  47. </statechart>
  48. <input>
  49. <event port="in" name="start" time="0 d"/>
  50. </input>
  51. <output>
  52. <big_step>
  53. <event port="out" name="done"/>
  54. </big_step>
  55. </output>
  56. </test>