bronsa / cinc Goto Github PK
View Code? Open in Web Editor NEW[MOVED] Clojure compiler in Clojure
Home Page: https://github.com/Bronsa/CinC
[MOVED] Clojure compiler in Clojure
Home Page: https://github.com/Bronsa/CinC
currently every node has an :env node, this is for consisntency but many nodes (such as :bindings) will never need it and having it makes the ast incredibly long and unreadable
There doesn't seem to be one.
implement primitive interfaces/invoke via invokePrim
(if x "foo" ((fn [] (throw (Exception. "")))))
should get tagged as String, propagate :untagged/untyped
Use :cast instead
Right now we use mostly :pre to report errors for ease of development.
Need to switch to ex-info everywhere and report line/column info aswell
Describe what they dissoc/assoc, the new nodes etc
there's no need to use them for the analysis, should revert to use an atom+map like original CinC and clojurescript
currently deftype expands to something like (let [](deftype* x ..) (import ns.x) ns.x)
Compiler.java can analyze this because the deftype gets build during analysis, completing analysis and emission.
Need to figure out a way to handle this in order not to get a ClassNotFoundException
remove all the (if const? (-analyze :const form env type) ..) instances and achieve the same results using an optional pass over the produced ast
As mentioned in http://dev.clojure.org/display/design/AST+children Rich has a requirement that the AST be walkable in a "generic" way, using a :children attribute of each node.
Unfortunately, keeping children up to date while doing a bunch of transformations is difficult, so the best thing to do would just be to add a generic "add-children" pass which is always (optionally?) executed at the end of analysis.
the hygienic transform makes (letfn (a [] 1) (b ) (a [] 2)) blow up instead of returning 2
The tag for the first :arg is [C (array of Class), which seems suspicious.
user=>(pprint (ana/analyze '(java.lang.String/valueOf (+ 1 1)) {}))
{:tag java.lang.String,
:args
[{:tag [C,
:op :invoke,
:form (+ 1 1),
:env
{:file
"C:\Users\joel-cohen\AppData\Local\Temp\form-init7760639548724569008.clj",
:line 1,
:column 49,
:context :expr},
:meta
{:tag clojure.lang.IPersistentMap,
:op :const,
:env
{:file
"C:\Users\joel-cohen\AppData\Local\Temp\form-init7760639548724569008.clj",
:context :expr},
:type :map,
:literal? true,
:form {:column 49, :line 1}},
:fn
{:form +,
:env
{:file
"C:\Users\joel-cohen\AppData\Local\Temp\form-init7760639548724569008.clj",
:context :expr},
:op :var,
:name +,
:ns clojure.core,
:assignable? false,
:var #<Var@2dcf4363:
#<core$PLUS clojure.core$PLUS@47229edd>>},
:args
[{:tag java.lang.Long,
:op :const,
:env
{:file
"C:\Users\joel-cohen\AppData\Local\Temp\form-init7760639548724569008.clj",
:context :expr},
:type :number,
:literal? true,
:form 1}
{:tag java.lang.Long,
:op :const,
:env
{:file
"C:\Users\joel-cohen\AppData\Local\Temp\form-init7760639548724569008.clj",
:context :expr},
:type :number,
:literal? true,
:form 1}]}],
:method valueOf,
:op :static-call,
:class java.lang.String,
:form (. java.lang.String (valueOf (+ 1 1))),
:env
{:file
"C:\Users\joel-cohen\AppData\Local\Temp\form-init7760639548724569008.clj",
:line 1,
:column 23}}
nil
this is currently broken in the clojure compiler.
This happens for primitive tagged functions that don't have any prim interface.
Currently metadata is only attached to the :form node for most of the AST nodes, we need to put it in a node everywhere
There are some passes that are repeated until nothing more can be done, those passes re-run everywhere they have already run recomputing the already-computed results, we should just leave there what's already there and only do the work that's needed
so that we don't reflect for (let [a "foo"] (.toString a))
mostly unbox on let/number literal
Currently cast/box handling is handled both by the box pass and in emit.
The cast/box info should only be set by the box pass
The current implementation is:
We should remove any usage of :eval, wrapping the top-level form with ((fn* [] ..)) in the eval function thus removing any need for an interpreted eval
Is there a performance cost?
Do I care?
(.-field obj)
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.