]> gerrit.simantics Code Review - simantics/platform.git/blob - bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/internal/codegen/utils/SSAUtils.java
Merge branch 'feature/funcwrite'
[simantics/platform.git] / bundles / org.simantics.scl.compiler / src / org / simantics / scl / compiler / internal / codegen / utils / SSAUtils.java
1 package org.simantics.scl.compiler.internal.codegen.utils;
2
3 import org.simantics.scl.compiler.internal.codegen.references.Val;
4 import org.simantics.scl.compiler.internal.codegen.references.ValRef;
5 import org.simantics.scl.compiler.types.Type;
6 import org.simantics.scl.compiler.types.Types;
7
8 public class SSAUtils {
9
10     public static boolean representSameValue(Val a, ValRef b) {
11         if(b.getTypeParameters().length > 0)
12             return false;
13         return representSameValue(a, b.getBinding());
14     }
15     
16     public static boolean representSameValue(Val a, Val b) {
17         if(a == b)
18             return true;
19         Type aT = a.getType();
20         Type bT = b.getType();
21         if(!Types.equals(aT, bT))
22             return false;
23         return isSingletonType(aT);
24     }
25
26     public static boolean isSingletonType(Type type) {
27         type = Types.canonical(type);
28         return type == Types.UNIT || type == Types.PUNIT;
29     }
30     
31 }