Clue: an ANSI C Compiler targetting high-level languages
cluecc.sourceforge.net
cluecc.sourceforge.net
The code: http://basecase.org/trivium/trivium.js
Demo: http://basecase.org/trivium/
Honestly, I lost interest once I got it working with simple test strings. If you do something cool with it, let me know!
Edit: Looking at it again, my code is badly undercommented – sorry. But if you follow along with the Trivium specification (http://www.ecrypt.eu.org/stream/ciphers/trivium/trivium.pdf), which is a model of clarity, it should all make sense mod renaming of variables etc. The outstanding bug is that it assumes that any sequence of 16-bit values can be taken as a UTF-16 string, which is not true. Will e-mail you some general thoughts when I have a few minutes.
Just trying it out now, the function:
int foo(int bar)
{
return bar & 0x01;
}
compiles to: clue_real_t _foo(clue_real_t fp, clue_optr_t stack, clue_real_t FLOAT0) {
clue_real_t sp;
clue_real_t FLOAT1;
clue_real_t FLOAT2;
sp = 0;
sp = fp + sp;
FLOAT1 = 1;
FLOAT2 = (clue_realint_t) FLOAT0 & (clue_realint_t) FLOAT1;
return FLOAT2;
}I'd love to see an updated version of that benchmark table with scores for V8, Nitro, and TraceMonkey.