1 package org.simantics.scl.compiler.types.util;
3 import org.simantics.scl.compiler.types.Skeletons;
4 import org.simantics.scl.compiler.types.TMetaVar;
5 import org.simantics.scl.compiler.types.Type;
7 public class TypeTree<T> {
9 public static class Case<T> {
14 private static class Node<T> {
18 public Node(Case<T>[] cases) {
20 this.branches = new Branch[cases[0].types.length];
23 Branch<T> getBranch(int i) {
29 private static class Branch<T> {
31 public void improve(Iterator<T> iterator) {
32 // TODO Auto-generated method stub
38 public static class Iterator<T> {
42 public Iterator(Node<T> node, Type[] scrutinee) {
44 this.scrutinee = scrutinee;
47 public void improve() {
48 for(int i=0;i<scrutinee.length;++i) {
49 Type type = scrutinee[i] = Skeletons.canonicalSkeleton(scrutinee[i]);
50 if(!(type instanceof TMetaVar)) {
51 Branch<T> branch = node.getBranch(i);
63 public TypeTree(Case<T>[] cases) {
64 this.root = new Node<T>(cases);
67 public Iterator<T> iterator(Type ... scrutinee) {
68 return new Iterator<T>(root, scrutinee);