-
Notifications
You must be signed in to change notification settings - Fork 20
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
new emitter not based on fipp #25
Comments
I haven't tried it, but fipp should be able to run on ClojureCLR with the exception of the ednize namespace, which you don't need, right? The ednize namespace should be easy to port too, it's already the intentionally duplicated part for jvm and js targets. |
Oh, except maybe rrb vectors need to be ported too? |
Yes the rrb vectors are the culprit |
We are gonna keep the fipp emitter on the side but need another option for clr and other platforms |
@michalmarczyk: Would rrb on clr be difficult? Seems like it would require yet another full fork :-/ @kovasb: Are 2-3 finger trees available on clr? Can easily shadow deque.cljc to support that. |
Hey, sorry for the delay. Not sure how much effort that would be, but looking at deque.cljc sounds like a simple solution, though, and data.finger-tree seems very portable. Might be worth porting that first to see how much hassle that is and how much code sharing is possible. |
@kovasb If you want to take a crack at porting finger-trees, here's the old fipp deque impl that used it: brandonbloom/fipp@a2bd18a |
I'm using Gamma in Arcadia. Rather than porting fipp I stripped it out, and am using a janky little formatter function to make its output vaguely readable. gvec on clojure-clr is hella broken, also probably redundant, or at least in need of a fundamental rethink since the clr has real generics. We just commented it out for the Arcadia compiler, I think David Miller wants to gut or scrap it. He said it was one of, if not the, most difficult parts of the Clojure compiler to port. Need to check up on the latest development with all that but we're getting along fine without it; not sure if that has implications for rrb-vector tho. Here's the main modification I made to Gamma to get it working in Arcadia: (ns gamma.program ...)
...
(defn unfipp [x]
(->> x
(clojure.walk/prewalk
(fn [x]
(if (and (vector? x) (= (first x) :nest))
(drop 2 x)
x)))
flatten
(remove keyword?)
(apply str)))
(defn glsl [shader precision]
(let [p precision]
(str
(precision-defaults p)
(unfipp
(emit/emit (:ir shader) shader)))))
... and then for prettification: (defn- format-program [x]
(let [lines (-> x
(clojure.string/replace ";" ";\n")
(clojure.string/replace "{" "{\n")
(clojure.string/replace "}" "\n}\n")
clojure.string/split-lines)
indent-f (fn [indent s]
(-> (apply str (repeat indent "\t"))
(str s)))]
(first
(reduce
(fn [[bldg, indent] line]
(cond
(re-matches #"^\s*}.*" line)
[(str bldg (indent-f (dec indent) line) "\n")
(dec indent)]
(re-matches #".*{$" line)
[(str bldg (indent-f indent line) "\n")
(inc indent)]
:else
[(str bldg (indent-f indent line) "\n")
indent]))
["" 0]
lines)))) Works well enough so far as a stopgap, though I'm sure hugely composed terms would get nasty. |
Want a trivial emitter so we can port this to clojureclr
The text was updated successfully, but these errors were encountered: