Created
December 8, 2011 04:59
-
-
Save satyr/1446167 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{Fun, Unary} = Coco.ast | |
uplus = -> it instanceof Unary and it.op is \+ | |
<- Coco.on \compile | |
<- it.ast.traverseChildren ..., true | |
# +-> | |
if uplus it and (fun = it.it) instanceof Fun | |
delete it[k] for k in it | |
fun = it <<< {fun.__proto__, ...fun} | |
# <-+ | |
else if uplus it.head and not it.tails.1 and | |
(call = it.getCall!) and (fun = call.args.0) instanceof Fun | |
callee = it.head.it | |
# <-+ f x, ... | |
if callee.getCall! | |
{call.args} = that | |
break if a.filler for a, pos of call.args | |
call.args[pos] = fun | |
callee.=head | |
it.head = callee | |
else return | |
Object.defineProperty fun, \void value: true | |
void |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment