X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=blobdiff_plain;f=bundles%2Forg.simantics.scl.compiler%2Fsrc%2Forg%2Fsimantics%2Fscl%2Fcompiler%2Fconstants%2FLongConstant.java;fp=bundles%2Forg.simantics.scl.compiler%2Fsrc%2Forg%2Fsimantics%2Fscl%2Fcompiler%2Fconstants%2FLongConstant.java;h=ac270ea4dc0c2d84995e8ded5cc7b50e4d5985eb;hb=969bd23cab98a79ca9101af33334000879fb60c5;hp=0000000000000000000000000000000000000000;hpb=866dba5cd5a3929bbeae85991796acb212338a08;p=simantics%2Fplatform.git diff --git a/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/constants/LongConstant.java b/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/constants/LongConstant.java new file mode 100644 index 000000000..ac270ea4d --- /dev/null +++ b/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/constants/LongConstant.java @@ -0,0 +1,68 @@ +package org.simantics.scl.compiler.constants; + +import org.cojen.classfile.TypeDesc; +import org.objectweb.asm.Label; +import org.simantics.scl.compiler.internal.codegen.continuations.Cont; +import org.simantics.scl.compiler.internal.codegen.references.IVal; +import org.simantics.scl.compiler.internal.codegen.utils.MethodBuilder; +import org.simantics.scl.compiler.internal.codegen.utils.TransientClassBuilder; +import org.simantics.scl.compiler.types.Types; + +public class LongConstant extends Constant { + long value; + + public LongConstant(long value) { + super(Types.LONG); + this.value = value; + } + + @Override + public void push(MethodBuilder mb) { + mb.loadConstant(value); + } + + @Override + public String toString() { + return String.valueOf(value); + } + + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + (int) (value ^ (value >>> 32)); + return result; + } + + @Override + public boolean equals(Object obj) { + if (this == obj) + return true; + if (obj == null) + return false; + if (getClass() != obj.getClass()) + return false; + LongConstant other = (LongConstant) obj; + if (value != other.value) + return false; + return true; + } + + @Override + public void deconstruct(MethodBuilder mb, IVal parameter, Cont success, + Label failure) { + mb.push(parameter, Types.LONG); + mb.loadConstant(value); + mb.ifComparisonBranch(failure, "!=", TypeDesc.LONG); + mb.jump(success); + } + + public int constructorTag() { + return 0; + } + + @Override + public Object realizeValue(TransientClassBuilder classBuilder) { + return value; + } +}