mirror of
https://github.com/BX-Team/DivineMC.git
synced 2026-01-01 05:06:40 +00:00
fix compile
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
package com.ishland.c2me.opts.dfc.common.ast;
|
||||
|
||||
import com.ishland.c2me.opts.dfc.common.ast.binary.AddNode;
|
||||
import com.ishland.c2me.opts.dfc.common.ast.binary.DivNode;
|
||||
import com.ishland.c2me.opts.dfc.common.ast.binary.MaxNode;
|
||||
import com.ishland.c2me.opts.dfc.common.ast.binary.MaxShortNode;
|
||||
import com.ishland.c2me.opts.dfc.common.ast.binary.MinNode;
|
||||
@@ -75,6 +76,7 @@ public class McToAst {
|
||||
case CUBE -> new CubeNode(toAst(f.input()));
|
||||
case HALF_NEGATIVE -> new NegMulNode(toAst(f.input()), 0.5);
|
||||
case QUARTER_NEGATIVE -> new NegMulNode(toAst(f.input()), 0.25);
|
||||
case INVERT -> new DivNode(new ConstantNode(1.0), toAst(f.input()));
|
||||
case SQUEEZE -> new SqueezeNode(toAst(f.input()));
|
||||
};
|
||||
case DensityFunctions.RangeChoice f -> new RangeChoiceNode(toAst(f.input()), f.minInclusive(), f.maxExclusive(), toAst(f.whenInRange()), toAst(f.whenOutOfRange()));
|
||||
|
||||
@@ -0,0 +1,53 @@
|
||||
package com.ishland.c2me.opts.dfc.common.ast.binary;
|
||||
|
||||
import com.ishland.c2me.opts.dfc.common.ast.AstNode;
|
||||
import com.ishland.c2me.opts.dfc.common.ast.EvalType;
|
||||
import com.ishland.c2me.opts.dfc.common.gen.BytecodeGen;
|
||||
import org.objectweb.asm.Type;
|
||||
import org.objectweb.asm.commons.InstructionAdapter;
|
||||
|
||||
public class DivNode extends AbstractBinaryNode {
|
||||
public DivNode(AstNode left, AstNode right) {
|
||||
super(left, right);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected AstNode newInstance(AstNode left, AstNode right) {
|
||||
return new DivNode(left, right);
|
||||
}
|
||||
|
||||
@Override
|
||||
public double evalSingle(int x, int y, int z, EvalType type) {
|
||||
return this.left.evalSingle(x, y, z, type) / this.right.evalSingle(x, y, z, type);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void evalMulti(double[] res, int[] x, int[] y, int[] z, EvalType type) {
|
||||
double[] res1 = new double[res.length];
|
||||
this.left.evalMulti(res, x, y, z, type);
|
||||
this.right.evalMulti(res1, x, y, z, type);
|
||||
for (int i = 0; i < res1.length; i++) {
|
||||
res[i] /= res1[i];
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void doBytecodeGenSingle(BytecodeGen.Context context, InstructionAdapter m, BytecodeGen.Context.LocalVarConsumer localVarConsumer) {
|
||||
super.doBytecodeGenSingle(context, m, localVarConsumer);
|
||||
m.div(Type.DOUBLE_TYPE);
|
||||
m.areturn(Type.DOUBLE_TYPE);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void bytecodeGenMultiBody(InstructionAdapter m, int idx, int res1) {
|
||||
m.load(1, InstructionAdapter.OBJECT_TYPE);
|
||||
m.load(idx, Type.INT_TYPE);
|
||||
m.dup2();
|
||||
m.aload(Type.DOUBLE_TYPE);
|
||||
m.load(res1, InstructionAdapter.OBJECT_TYPE);
|
||||
m.load(idx, Type.INT_TYPE);
|
||||
m.aload(Type.DOUBLE_TYPE);
|
||||
m.div(Type.DOUBLE_TYPE);
|
||||
m.astore(Type.DOUBLE_TYPE);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user