X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=blobdiff_plain;f=bundles%2Forg.simantics.scl.compiler%2Fsrc%2Forg%2Fsimantics%2Fscl%2Fcompiler%2Fconstants%2Fsingletons%2FNullCheck.java;fp=bundles%2Forg.simantics.scl.compiler%2Fsrc%2Forg%2Fsimantics%2Fscl%2Fcompiler%2Fconstants%2Fsingletons%2FNullCheck.java;h=7eded4ef6ad6491f0dca2d445189003d1ff8bbc4;hb=0ae2b770234dfc3cbb18bd38f324125cf0faca07;hp=3089a18621733ce115ab9b0c93c4692e9438d711;hpb=24e2b34260f219f0d1644ca7a138894980e25b14;p=simantics%2Fplatform.git diff --git a/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/constants/singletons/NullCheck.java b/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/constants/singletons/NullCheck.java index 3089a1862..7eded4ef6 100644 --- a/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/constants/singletons/NullCheck.java +++ b/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/constants/singletons/NullCheck.java @@ -1,49 +1,49 @@ -package org.simantics.scl.compiler.constants.singletons; - -import org.objectweb.asm.Label; -import org.simantics.scl.compiler.constants.ComparisonFunction; -import org.simantics.scl.compiler.constants.FunctionValue; -import org.simantics.scl.compiler.internal.codegen.continuations.Cont; -import org.simantics.scl.compiler.internal.codegen.references.Val; -import org.simantics.scl.compiler.internal.codegen.utils.MethodBuilder; -import org.simantics.scl.compiler.types.TVar; -import org.simantics.scl.compiler.types.Type; -import org.simantics.scl.compiler.types.Types; -import org.simantics.scl.compiler.types.kinds.Kinds; - -public class NullCheck extends FunctionValue implements ComparisonFunction { - private static final TVar A = Types.var(Kinds.STAR); - public static final NullCheck INSTANCE = - new NullCheck(); - - private NullCheck() { - super(new TVar[] {A}, Types.NO_EFFECTS, Types.BOOLEAN, A); - } - - @Override - public Type applyExact(MethodBuilder mb, Val[] parameters) { - parameters[0].push(mb); - Label join = mb.createLabel(); - Label isNull = mb.createLabel(); - mb.ifNullBranch(isNull, true); - mb.loadConstant(false); - mb.branch(join); - mb.setLocation(isNull); - mb.loadConstant(true); - mb.setLocation(join); - return getReturnType(); - } - - @Override - public void generateCondition(MethodBuilder mb, Val[] parameters, Cont then_, Cont else_) { - parameters[0].push(mb); - mb.ifNullBranch(mb.getLabel(then_), true); - mb.jump(else_); - mb.ensureExists(then_); - } - - @Override - public String toString() { - return "nullCheck"; - } -} +package org.simantics.scl.compiler.constants.singletons; + +import org.objectweb.asm.Label; +import org.simantics.scl.compiler.constants.ComparisonFunction; +import org.simantics.scl.compiler.constants.FunctionValue; +import org.simantics.scl.compiler.internal.codegen.continuations.Cont; +import org.simantics.scl.compiler.internal.codegen.references.Val; +import org.simantics.scl.compiler.internal.codegen.utils.MethodBuilder; +import org.simantics.scl.compiler.types.TVar; +import org.simantics.scl.compiler.types.Type; +import org.simantics.scl.compiler.types.Types; +import org.simantics.scl.compiler.types.kinds.Kinds; + +public class NullCheck extends FunctionValue implements ComparisonFunction { + private static final TVar A = Types.var(Kinds.STAR); + public static final NullCheck INSTANCE = + new NullCheck(); + + private NullCheck() { + super(new TVar[] {A}, Types.NO_EFFECTS, Types.BOOLEAN, A); + } + + @Override + public Type applyExact(MethodBuilder mb, Val[] parameters) { + parameters[0].push(mb); + Label join = mb.createLabel(); + Label isNull = mb.createLabel(); + mb.ifNullBranch(isNull, true); + mb.loadConstant(false); + mb.branch(join); + mb.setLocation(isNull); + mb.loadConstant(true); + mb.setLocation(join); + return getReturnType(); + } + + @Override + public void generateCondition(MethodBuilder mb, Val[] parameters, Cont then_, Cont else_) { + parameters[0].push(mb); + mb.ifNullBranch(mb.getLabel(then_), true); + mb.jump(else_); + mb.ensureExists(then_); + } + + @Override + public String toString() { + return "nullCheck"; + } +}