I've just committed a [LLVM](http://llvm.org) code generator for `flxc`.

    :::felix
    #!build/debug/bin/flxc -I build/debug/lib --import nugram.flxh --import 
flx.flxh
    >>> type int = "int";
    ... BOUND SYM:     type int<3> = "int";
    >>> fun add : int*int -> int = "%add";
    ... BOUND SYM:     fun add<4>: int<3>^2 -> int<3> = "%add";
    >>> fun foo (a:int, b:int, c:int) = { val d = a + b; return d + 1; }
    ... BOUND SYM:     fun foo<5>(val a<8>: int<3>,val b<9>: int<3>,val c<10>: 
int<3>): int<3>{
    ...   d<7> := (add<4> (a<8>, b<9>));
    ...   return (add<4> (d<7>, 1));}
    >>> val x = 1;
    ... BOUND SYM:     val x<11>: int<3>;
    ... BOUND EXE:     x<11> := 1;
    >>> val y = 2;
    ... BOUND SYM:     val y<12>: int<3>;
    ... BOUND EXE:     y<12> := 2;
    >>> val z = foo (x, y, 3);
    ... BOUND SYM:     val z<13>: int<3>;
    ... BOUND EXE:     z<13> := (foo<5> (x<11>, y<12>, 3));
    >>> ^D

And here's what it generates:

    :::llvm
    define void @__init__() {
    entry:
      %z = alloca i32                                 ; <i32*> [#uses=1]
      %y = alloca i32                                 ; <i32*> [#uses=1]
      %x = alloca i32                                 ; <i32*> [#uses=1]
      store i32 1, i32* %x
      store i32 2, i32* %y
      %foo = call i32 @foo(i32 1, i32 2, i32 3)       ; <i32> [#uses=1]
      store i32 %foo, i32* %z
      ret void
    }
    
    define i32 @foo(i32 %a, i32 %b, i32 %c) {
    entry:
      %d = alloca i32                                 ; <i32*> [#uses=1]
      %add = add i32 %a, %b                           ; <i32> [#uses=2]
      store i32 %add, i32* %d
      %add1 = add i32 %add, 1                         ; <i32> [#uses=1]
      ret i32 %add1
    }

Of course it doesn't actually execute the commands yet, but the output's so 
pretty!

------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day 
trial. Simplify your report design, integration and deployment - and focus on 
what you do best, core application coding. Discover what's new with 
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
_______________________________________________
Felix-language mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/felix-language

Reply via email to