Decade alpha1

On the road to beta is the new Minils AST, for now :

* Heptagon and Obc AST changes,
* Java code generation,
* Recursives Qualnames,
* Various bug fixes,

* Added partial application for iterators,
For instance:
  ... = map<<n>> (f<<se>>)((t1, t1'))(t2, t3)
is translated to:
  for(int i =...)
    ... = f(t1, t1', t2[i], t3[i])
master
Léonard Gérard 14 years ago
parent 6b720e6c23
commit b913edcd5e

@ -184,14 +184,10 @@ and translate_act map pat
let true_act = Aassgn (x, mk_exp p.pat_ty (Epattern p)) in
let false_act = Aassgn (x, translate map e2) in
let cond = bound_check_expr idx bounds in
[ Acase (cond, [ ptrue, mk_block [true_act];
pfalse, mk_block [false_act] ]) ]
[ Acase (cond, [ ptrue, mk_block [true_act]; pfalse, mk_block [false_act] ]) ]
| Minils.Evarpat x, Minils.Eapp ({ Minils.a_op = Minils.Eupdate }, e1::e2::idx, _) ->
let x = Control.var_from_name map x in
(** TODO: remplacer par if 0 < e && e < n then for () ; o[e] = v; for () else o = a *)
| Minils.Evarpat x,
Minils.Eapp ({ Minils.a_op = Minils.Eupdate },
e1::e2::idx, _) ->
let x = var_from_name map x in
let bounds = Mls_utils.bounds_list e1.Minils.e_ty in
let idx = List.map (translate map) idx in
let action = Aassgn (pattern_of_idx_list x idx,

@ -0,0 +1,106 @@
package pipline_b;
import java.util.concurrent.Callable;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.Future;
public class Wanted_Normalized_movie {
protected final int N;;
protected Async_mean_factory mean_factory;;
protected Substr[] substr_inst;;
protected Future<Integer> v;;
protected boolean v_2;;
protected int[] v_4;;
protected boolean v_5;;
public Wanted_Normalized_movie (int N) {
this.mean_factory = new Async_mean_factory(N);
this.substr_inst = new Substr[N];
for (int i_3 = 0; i_3<N; i_3++) { this.substr_inst[i_3] = new Substr(); };
this.N = N;
}
public int[] step (int[] i) throws InterruptedException, ExecutionException {
int[] im = new int[N];
int[] v_6 = new int[N];
int v_3 = 0;
int trash = 0;
Future<Integer> m = null;
if (this.v_2) { v_3 = 0; }
else { v_3 = this.v.get(); };
if (this.v_5) { v_6 = i; }
else { v_6 = this.v_4; };
this.v_5 = false;
trash = v_3;
for (int i_2 = 0; i_2<N; i_2++) {
jeptagon.Pervasives.Tuple2<Integer, Integer> out = substr_inst[i_2].step(v_6[i_2], trash);
im[i_2] = out.c0;
trash = out.c1;
};
this.v_2 = false;
m = mean_factory.step(i);
this.v_4 = i;
this.v = m;
return im;
}
//params, class, step_result_type, step_args
public class Async_mean_factory {
Mean mean_inst;
int N;
Future<Integer> result;
public Async_mean_factory(int N) {
this.N = N;
this.mean_inst = new Mean(N);
}
public void reset () {
this.mean_inst = new Mean(N);
this.result = null;
}
public Future<Integer> step(int[] i) {
if (null != result) // Wait for the last result to be completed, null if nothing to wait for.
try {
result.get();
} catch (InterruptedException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
} catch (ExecutionException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
result = jeptagon.Pervasives.executor_cached.submit(new Async_mean_step(mean_inst, i));
return result;
}
class Async_mean_step implements Callable<Integer>{
int[] i;
Mean mean_inst;
public Async_mean_step(Mean mean_inst, int[] i) {
this.i = i;
this.mean_inst = mean_inst;
}
public Integer call () {
return mean_inst.step(i);
}
}
}
public static void main() {
}
public void reset () {
this.v_5 = true;
this.v_2 = true;
}
}

@ -0,0 +1,6 @@
#!/bin/bash
cp $1 build/
cd build
../../../heptc $2 $3 $4 $5 $6 -target java $1
cd ..

@ -0,0 +1,12 @@
node g () returns (y : int)
let
y = 3
tel
node f (x : int; c : bool) returns (z : int)
let
z = merge c (true -> (0 fby (g(z when true(c))))) (false -> 0)
tel

@ -0,0 +1,6 @@
#!/bin/bash
cp $@ build/
cd build
../../../heptc -target obc $@
cd ..

@ -0,0 +1,25 @@
fun sum (x,m: int) returns (s: int)
let
s = x + m
tel
fun substr (x,m: int) returns (d: int; m2:int)
let
d = x - m;
m2 = m;
tel
fun mean<<n: int>> (i: int^n) returns (m: int)
let
m = (fold (+) <<n>> (i,0)) /n
tel
node normalized_movie<<n: int>> (i: int^n) returns (im: int^n)
var m: int; trash: int;
let
m = mean<<n>>(i);
(im,trash) = mapfold substr <<n>> (i,m)
tel

@ -0,0 +1,30 @@
fun substr (x,m: int) returns (d: int; m2:int)
let
d = x - m;
m2 = m;
tel
fun mean<<n: int>> (i: int^n) returns (m: int)
let
m = (fold (+) <<n>> (i,0) )/n
tel
node normalized_movie<<n: int>> (i: int^n) returns (im: int^n)
var m: async int; trash: int;
let
m = async mean<<n>>(i);
(im,trash) = mapfold substr <<n>> (i fby i, 0 -> !(pre m))
tel
node main () returns (r:int)
var f: int^100; nf: int^100; x: int;
let
x = 0 fby x+1;
f = x^100;
nf = normalized_movie<<100>>(f);
r = mean<<100>>(nf)
tel

@ -0,0 +1,25 @@
fun sum (x,m: int) returns (s: int)
let
s = x + m
tel
fun substr (x,m: int) returns (d: int; m2:int)
let
d = x - m;
m2 = m;
tel
fun mean<<n: int>> (i: int^n) returns (m: int)
let
m = fold sum <<n>> (i,0)
tel
node normalized_movie<<n: int>> (i: int^n) returns (im: int^n)
var m: int; trash: int;
let
m = mean<<n>>(i);
(im,trash) = mapfold substr <<n>> (i fby i, 0 -> (pre m))
tel

@ -0,0 +1,24 @@
node lent(coeff:int) returns (y:int)
let
y = do_stuff(coeff);
tel
node rapide<<size:int>>() returns (z:int)
var y,cpt : int; big_step : bool;
let
big_step = cpt = 0;
cpt = size fby (if big_step then size else cpt - 1);
y = merge big_step
(true -> 0 -> (pre (lent(size))))
(false -> 0 fby y when false(big_step));
z = do_stuff(1) - y;
tel
node main() returns(r: int)
let
r = rapide<<1000>>();
tel

@ -0,0 +1,24 @@
node lent(coeff:int) returns (y:int)
let
y = do_stuff(coeff);
tel
node rapide<<size:int>>() returns (z:int)
var y : int; cpt : int; big_step : bool;
let
big_step = cpt = 0;
cpt = size fby (if big_step then size else cpt - 1);
y = merge big_step
(true -> 0 -> !(pre (async lent(size))))
(false -> 0 fby y when false(big_step));
z = do_stuff(1) - y;
tel
node main() returns(r: int)
let
r = rapide<<1000>>();
tel

@ -0,0 +1,7 @@
node f() returns ()
var t1,t2 : int^4;
let
t1 = [3, 5, 6, 7];
t2 = map (+) <<4>> (4^4,t1);
tel

@ -0,0 +1,12 @@
node counter(res: bool; tick: bool) returns (o: int)
let
o = if res then 0 else if tick then 1 -> pre o + 1 else 0 -> pre o;
tel
node counter2() returns (b: bool)
var t : async int;
let
t = async 0 fby async counter(false,true);
b = counter(false,true) -1 = !t;
tel

@ -0,0 +1,18 @@
node counter(res: bool; tick: bool) returns (o: int)
let
o = if res then 0 else if tick then 1 -> pre o + 1 else 0 -> pre o;
tel
node counter3() returns (t: async bool)
var last async t: int; cpt: int;
let
cpt = counter(false,true);
automaton
state I do
t = async counter(false,true)));
until true continue III
state III do
until cpt/3 = 0 continue I
end;
b = 0 fby cpt - 1 = 0 -> !t ;
tel
Loading…
Cancel
Save