Id�es pour l'IR de Photon 3 aout 2011 ------------------------- E ::= let V = LETOP in E | if IFOP then E else E | iflet V = IFLETOP then E else E | goto V(P,...) ;; the dynamic type of V is "block" | call V(P,...) ;; the dynamic type of V is "function" | return V(P,...) ;; the dynamic type of V is "continuation" V ::= C ::= | | | null | undefined | global | handler P ::= C | V | block(V,...) { E } | function(V,...) { E } | continuation(V,...) { E } LETOP ::= P | get_prop(P_1,P_2) | put_prop(P_1,P_2,P_3) | del_prop(P_1,P_2) | fix_add_wrap(P_1,P_2) | fix_sub_wrap(P_1,P_2) | fix_mul_wrap(P_1,P_2) | fix_div_wrap(P_1,P_2) | let_prim(,P,...) IFOP ::= is_fix(P) | fix_eq(P_1,P_2) | fix_lt(P_1,P_2) | fix_le(P_1,P_2) | fix_gt(P_1,P_2) | fix_ge(P_1,P_2) | is_flo(P) | flo_eq(P_1,P_2) | flo_lt(P_1,P_2) | flo_le(P_1,P_2) | flo_gt(P_1,P_2) | flo_ge(P_1,P_2) | is_false(P) | if_prim(,P,...) IFLETOP ::= fix_add_no_ovf(P_1,P_2) | fix_sub_no_ovf(P_1,P_2) | fix_mul_no_ovf(P_1,P_2) | fix_div_no_ovf(P_1,P_2) | iflet_prim(,P,...) Exemples: #1: var z = f(1); compiles to: block(ret) { let t1 = get_prop(global,"f") in let c = continuation(r) { let t2 = put_prop(global,"z",r) in return ret(undefined) } in call t1(c,1) } #2: var z = x + y; compiles to: block(ret) { let t1 = let_prim("js_get_prop",global,"x") in let t2 = let_prim("js_get_prop",global,"y") in let r = let_prim("js_add",t1,t2) in let t3 = let_prim("js_put_prop",global,"z",r) in return ret(undefined) } #3: var z = x + y; compiles to: block(ret) { let t1 = get_prop(global,"x") in let t2 = get_prop(global,"y") in let b1 = block(r) { let t3 = put_prop(global,"z",r) in return ret(undefined) } in let b2 = block() { let t4 = get_prop(handler,"gen_add") in let c = continuation(r2) { goto b1(ret,r2) } in call t4(c,t1,t2) } in if is_fix(t1) then if is_fix(t2) then iflet t5 = fix_add_no_ovf(t1,t2) then goto b1(ret,t5) else goto b2(ret) else goto b2(ret) else goto b2(ret) } Quelques exemples de r�gles de compilation: 1) exemple simple let V = let_prim("js_get_prop",X,Y) in Z => let V = get_prop(X,Y) in Z 2) exemple avec annotations de type let V = let_prim("js_add",X:any,Y:any) in Z => let b = block() { let V:any = let_prim("js_add_gen",X,Y) in Z } in if is_fix(X) then if is_fix(Y) then iflet V:fix = fix_add_no_ovf(X,Y) then Z else goto b() else goto b() else goto b() 3) exemple avec annotations de type plus fines let V = let_prim("js_add",X:fix,Y:fix) in Z => let b = block() { let V:any = let_prim("js_add_gen",X,Y) in Z } in iflet V:fix = fix_add_no_ovf(X,Y) then Z else goto b()