Force origins should be a primitive, not a hack
Currently the
Submitted by Gabriël Konat on 9 July 2013 at 00:09origin-track-forced
strategy abuses the fact that theone
strategy tracks origins by constructing a list and then applying theone
strategy. This has the overhead of constructing and deconstructing a list. If it was implemented as a primitive that gets and sets origins, the overhead of list construction and deconstruction is removed.
Issue Log
Implemented a primitive for preserving origins and annotations in https://github.com/metaborg/mb-exec/commit/18953f5c24770e06a2fe3c6697bbe5954eed43e0.
The
SSL_preserve_annotations_attachments
primitive throws an exception when the term is not mutable.Caused by: org.strategoxt.lang.StrategoException: Exception in execution of primitive 'SSL_preserve_annotations_attachments' at org.strategoxt.lang.StackSaver.invokeStackFriendly(StackSaver.java:77) at org.strategoxt.lang.Context.invokeStrategyCLI(Context.java:178) at org.strategoxt.strj.Main.mainNoExit(Main.java:2786) ... 65 more Caused by: org.strategoxt.lang.StrategoException: Exception in execution of primitive 'SSL_preserve_annotations_attachments' at org.strategoxt.lang.Context.invokePrimitive(Context.java:240) at org.strategoxt.lang.Context.invokePrimitive(Context.java:216) at org.strategoxt.strc.preserve_annotations_attachments_1_0.invoke(preserve_annotations_attachments_1_0.java:25) ... 69 more Caused by: java.lang.IllegalArgumentException: Target term is not mutable and does not support attachments at org.spoofax.terms.AbstractTermFactory.copyAttachments(AbstractTermFactory.java:150) at org.spoofax.interpreter.library.ssl.SSL_preserve_annotations_attachments.call(SSL_preserve_annotations_attachments.java:28) ... 72 more
For example, apparently this desugar rule results in an immutable term, which causes
preserve-annotations-attachments(desugar)
to throw.desugar: List([]) -> Op("Nil", [])
Would it be possible to let
SSL_preserve_annotations_attachments
make a mutable clone of such an immutable term, and use that instead?
Log in to post comments