Dynamic rules lifetime
Dynamic rules lose their value in between builders (and also in between analysis phase and calling a builder) in Spoofax.
Steps to reproduce:
1) create new Spoofax language project
2) add builders:
rules debug-set-index: (selected, position, ast, path, project-path) -> None() with rules(Index := ["foo", "bar"]) debug-show-index: (selected, position, ast, path, project-path) -> (filename, result) with filename := <guarantee-extension(|"index.aterm")> path; result := <Index;debug(!"stored index ") <+ !"Index is emtpy"> //TODO: why is the index empty?
menus menu: "Dynamic Rules" (openeditor) action: "debug-set-index" = debug-set-index action: "debug-show-index" = debug-show-index
3) create a new language file, call first builder, call second builder.
Expected output: file with
Actual output: file with
Index is emtpy
Spoofax version:Submitted by Daco Harkes on 26 September 2016 at 10:42
Eclipse: org.eclipse.platform.ide 4.6.0.I20160606-1100 Spoofax: org.metaborg.spoofax.eclipse 22.214.171.12460919-225254-master System: Mac OS X x86_64 10.11.6
Possible work around: store in file.
Actually not: attachments get lost.
It should reuse the dynamic rules between invocations on the same language and project, so this is probably a bug. Unfortunately, the code that maintains Stratego dynamic rules is very hacky and I do not know how to do this.
Log in to post comments