use of stanhebben.zenscript.util.MethodOutput in project ZenScript by CraftTweaker.
the class CastingRuleArrayArray method compile.
@Override
public void compile(IEnvironmentMethod method) {
MethodOutput output = method.getOutput();
Type fromType = from.getBaseType().toASMType();
Type toType = to.getBaseType().toASMType();
int result = output.local(to.toASMType());
output.dup();
output.arrayLength();
output.newArray(toType);
output.storeObject(result);
output.iConst0();
Label lbl = new Label();
output.label(lbl);
// stack: original index
output.dupX1();
output.dupX1();
output.arrayLoad(fromType);
// stack: original index value
if (base != null)
base.compile(method);
output.loadObject(result);
output.dupX2();
output.dupX2();
output.arrayStore(toType);
output.pop();
// stack: original index
output.iConst1();
output.iAdd();
output.dupX1();
output.arrayLength();
output.ifICmpGE(lbl);
output.pop();
output.pop();
output.loadObject(result);
}
use of stanhebben.zenscript.util.MethodOutput in project ZenScript by CraftTweaker.
the class CastingRuleNullableVirtualMethod method compile.
@Override
public void compile(IEnvironmentMethod method) {
MethodOutput output = method.getOutput();
Label lblNotNull = new Label();
Label lblAfter = new Label();
output.dup();
output.ifNonNull(lblNotNull);
output.pop();
output.aConstNull();
output.goTo(lblAfter);
output.label(lblNotNull);
this.method.invokeVirtual(method.getOutput());
output.label(lblAfter);
}
use of stanhebben.zenscript.util.MethodOutput in project ZenScript by CraftTweaker.
the class CastingAnyString method compile.
@Override
public void compile(IEnvironmentMethod method) {
MethodOutput output = method.getOutput();
Label lblNonNull = new Label();
Label lblAfter = new Label();
output.dup();
output.ifNonNull(lblNonNull);
output.pop();
output.aConstNull();
output.goTo(lblAfter);
output.label(lblNonNull);
output.invokeInterface(IAny.class, "asString", String.class);
output.label(lblAfter);
}
use of stanhebben.zenscript.util.MethodOutput in project ZenScript by CraftTweaker.
the class CastingNotNull method compile.
@Override
public void compile(IEnvironmentMethod method) {
MethodOutput output = method.getOutput();
Label labelElse = new Label();
Label labelAfter = new Label();
output.ifNull(labelElse);
output.iConst1();
output.goTo(labelAfter);
output.label(labelElse);
output.iConst0();
output.label(labelAfter);
}
use of stanhebben.zenscript.util.MethodOutput in project ZenScript by CraftTweaker.
the class CastingRuleNullableStaticMethod method compile.
@Override
public void compile(IEnvironmentMethod method) {
MethodOutput output = method.getOutput();
Label lblNotNull = new Label();
Label lblAfter = new Label();
output.dup();
output.ifNonNull(lblNotNull);
output.pop();
output.aConstNull();
output.goTo(lblAfter);
output.label(lblNotNull);
if (base != null) {
base.compile(method);
}
this.method.invokeStatic(method.getOutput());
output.label(lblAfter);
}
Aggregations