Пример #1
0
  public static void test1() {
    MathFunc x = FX.x;
    MathFunc y = FX.y;
    MathFunc xy = x.S(y);

    FuncClassLoader<CompiledFunc> fcl = new FuncClassLoader<CompiledFunc>();
    ClassGen genClass = BytecodeUtils.genClass(xy, null, "add", true, false);
    CompiledFunc fxy = fcl.newInstance(genClass);
    System.out.println(fxy.apply(1.0, 2.0));

    System.out.println(xy.compile(new String[] {"y", "x"}).apply(1.0, 2.0));
  }
Пример #2
0
  public static void test2() {
    MathFunc x = FX.x;
    MathFunc y = FX.y;
    MathFunc xy = x.M(y);
    System.out.println(xy);
    HashMap<String, MathFunc> map = new HashMap<String, MathFunc>();
    map.put(x.getVarNames().get(0), FX.r.A(FX.s));
    map.put(y.getVarNames().get(0), FX.r.S(FX.s));
    MathFunc xy2 = xy.compose(map);
    System.out.println(xy2);

    System.out.println(FX.r.A(FX.s).M(FX.r.S(FX.s)));

    FuncClassLoader<CompiledFunc> fcl = new FuncClassLoader<CompiledFunc>();
    ClassGen genClass = BytecodeUtils.genClass(xy2, null, "add2", true, false);
    CompiledFunc fxy2 = fcl.newInstance(genClass);
    System.out.println(fxy2.apply(4.0, 2.0));
  }