Skip to content

Commit

Permalink
adding automatic decompiling of compiled expressions... so it goes from
Browse files Browse the repository at this point in the history
formula->code->javasource although the java source is only useful for
debugging there is no need to save it since its so fast
  • Loading branch information
crowlogic committed Jan 19, 2024
1 parent 35ec273 commit ac8e1e8
Show file tree
Hide file tree
Showing 3 changed files with 118 additions and 98 deletions.
33 changes: 33 additions & 0 deletions src/main/java/arb/expressions/Decompiler.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
package arb.expressions;

import java.io.File;
import java.util.HashMap;
import java.util.Map;

import org.jetbrains.java.decompiler.main.decompiler.*;
import org.jetbrains.java.decompiler.main.extern.IFernflowerLogger;
import org.jetbrains.java.decompiler.main.extern.IResultSaver;

/**
* TODO: integrate this with {@link Expression}
*/
public class Decompiler
{
public static void main(String[] args)
{
IResultSaver saver = new DirectoryResultSaver(new File("."));

IFernflowerLogger logger = new PrintStreamLogger(System.out);

Map<String, Object> options = new HashMap<>();

BaseDecompiler decompiler = new BaseDecompiler(saver,
options,
logger);

File sourceClassFile = new File(args[0]);

decompiler.addSource(sourceClassFile);
decompiler.decompileContext();
}
}
180 changes: 83 additions & 97 deletions src/main/java/arb/functions/P.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,129 +7,115 @@
public class P implements
Function<Integer, RealPolynomial>
{
public Integer _c0;
public Integer _c1;
public Integer _c2;
public Integer _c0 = new Integer("0");
public Integer _c1 = new Integer("1");
public Integer _c2 = new Integer("2");
public Real α;
public Real β;
public Real r1;
public Real r2;
public RealPolynomial rp1;
public RealPolynomial rp2;
public RealPolynomial rp3;
public RealPolynomial rp4;
public Integer i1;
public RealPolynomial rp5;
public RealPolynomial rp6;
public Real r3;
public Real r4;
public Integer i2;
public RealPolynomial rp7;
public RealPolynomial rp8;
public RealPolynomial rp9;
public Real r5;
public Real r6;
public Real r1 = new Real();
public Real r2 = new Real();
public RealPolynomial rp1 = new RealPolynomial();
public RealPolynomial rp2 = new RealPolynomial();
public RealPolynomial rp3 = new RealPolynomial();
public RealPolynomial rp4 = new RealPolynomial();
public Integer i1 = new Integer();
public RealPolynomial rp5 = new RealPolynomial();
public RealPolynomial rp6 = new RealPolynomial();
public Real r3 = new Real();
public Real r4 = new Real();
public Integer i2 = new Integer();
public RealPolynomial rp7 = new RealPolynomial();
public RealPolynomial rp8 = new RealPolynomial();
public RealPolynomial rp9 = new RealPolynomial();
public Real r5 = new Real();
public Real r6 = new Real();
public Function<Integer, RealPolynomial> P;
public Function<Integer, RealPolynomial> A;
public Function<Real, Real> B;
public Function<Real, Real> C;
public Function<Real, Real> E;
public Function<Integer, RealPolynomial> A = new A();
public Function<Real, Real> B = new B();
public Function<Real, Real> C = new C();
public Function<Real, Real> E = new E();

public RealPolynomial evaluate(Integer in, int order, int bits, RealPolynomial result)
{
RealPolynomial var10000;
switch (in.getSignedValue())
return switch (in.getSignedValue())
{
case 0:
var10000 = result.set(_c1);
break;
case 1:
var10000 = C.evaluate(r1.set(_c1), order, bits, r2)
.mul(result.identity(), bits, rp1)
.sub(β, bits, rp2)
.add(α, bits, rp3)
.div(_c2, bits, result);
break;
default:
var10000 = A.evaluate(in, order, bits, rp4);
if (P == null)
case 0 ->
{
yield result.set(this._c1);
}
case 1 ->
{
yield ((Real) this.C.evaluate(this.r1.set(this._c1), order, bits, this.r2))
.mul(result.identity(),
bits,
this.rp1)
.sub(this.β, bits, this.rp2)
.add(this.α, bits, this.rp3)
.div(this._c2, bits, result);
}
default ->
{
RealPolynomial var5 = (RealPolynomial) this.A.evaluate(in, order, bits, this.rp4);
if (this.P == null)
{
P = new P(this);
this.P = new P(this);
}

var10000 = var10000.mul(P.evaluate(in.sub(_c1, bits, i1), order, bits, rp5), bits, rp6);
Real var10001 = B.evaluate(r3.set(in), order, bits, r4);
if (P == null)
var5 = var5.mul((RealPolynomial) this.P.evaluate(in.sub(this._c1, bits, this.i1), order, bits, this.rp5),
bits,
this.rp6);
Real var10001 = (Real) this.B.evaluate(this.r3.set(in), order, bits, this.r4);
if (this.P == null)
{
P = new P(this);
this.P = new P(this);
}

var10000 = var10000.sub(var10001.mul(P.evaluate(in.sub(_c2, bits, i2), order, bits, rp7), bits, rp8),
bits,
rp9)
.div(E.evaluate(r5.set(in), order, bits, r6), bits, result);
yield var5.sub(var10001.mul((RealPolynomial) this.P.evaluate(in.sub(this._c2, bits, this.i2),
order,
bits,
this.rp7),
bits,
this.rp8),
bits,
this.rp9)
.div((Real) this.E.evaluate(this.r5.set(in), order, bits, this.r6), bits, result);
}

return var10000;
};
}

public P()
{
_c0 = new Integer("0");
_c1 = new Integer("1");
_c2 = new Integer("2");
r1 = new Real();
r2 = new Real();
rp1 = new RealPolynomial();
rp2 = new RealPolynomial();
rp3 = new RealPolynomial();
rp4 = new RealPolynomial();
i1 = new Integer();
rp5 = new RealPolynomial();
rp6 = new RealPolynomial();
r3 = new Real();
r4 = new Real();
i2 = new Integer();
rp7 = new RealPolynomial();
rp8 = new RealPolynomial();
rp9 = new RealPolynomial();
r5 = new Real();
r6 = new Real();
A = new A();
B = new B();
C = new C();
E = new E();
}

public P(P var1)
{
this();
α = var1.α;
β = var1.β;
this.α = var1.α;
this.β = var1.β;
}

public void close()
{
_c0.close();
_c1.close();
_c2.close();
r1.close();
r2.close();
rp1.close();
rp2.close();
rp3.close();
rp4.close();
i1.close();
rp5.close();
rp6.close();
r3.close();
r4.close();
i2.close();
rp7.close();
rp8.close();
rp9.close();
r5.close();
r6.close();
P.close();
this._c0.close();
this._c1.close();
this._c2.close();
this.r1.close();
this.r2.close();
this.rp1.close();
this.rp2.close();
this.rp3.close();
this.rp4.close();
this.i1.close();
this.rp5.close();
this.rp6.close();
this.r3.close();
this.r4.close();
this.i2.close();
this.rp7.close();
this.rp8.close();
this.rp9.close();
this.r5.close();
this.r6.close();
this.P.close();
}
}
3 changes: 2 additions & 1 deletion src/main/java/module-info.java
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@
requires transitive io.fair_acc.chartfx;
requires transitive io.fair_acc.dataset;
requires transitive io.fair_acc.bench;
requires transitive org.fxyz3d.core;
requires transitive org.fxyz3d.core;
requires transitive vineflower;

exports arb;
exports arb.expressions;
Expand Down

0 comments on commit ac8e1e8

Please sign in to comment.