--- /dev/null
+package org.simantics.scl.compiler.types.util;\r
+\r
+import org.simantics.scl.compiler.types.Skeletons;\r
+import org.simantics.scl.compiler.types.TMetaVar;\r
+import org.simantics.scl.compiler.types.Type;\r
+\r
+public class TypeTree<T> {\r
+ \r
+ public static class Case<T> {\r
+ public Type[] types;\r
+ public T result;\r
+ }\r
+ \r
+ private static class Node<T> {\r
+ Case<T>[] cases;\r
+ Branch<T>[] branches;\r
+\r
+ public Node(Case<T>[] cases) {\r
+ this.cases = cases;\r
+ this.branches = new Branch[cases[0].types.length];\r
+ }\r
+ \r
+ Branch<T> getBranch(int i) {\r
+ // TODO\r
+ return null;\r
+ }\r
+ }\r
+ \r
+ private static class Branch<T> {\r
+\r
+ public void improve(Iterator<T> iterator) {\r
+ // TODO Auto-generated method stub\r
+ \r
+ }\r
+ \r
+ }\r
+ \r
+ public static class Iterator<T> {\r
+ Node<T> node;\r
+ Type[] scrutinee;\r
+ \r
+ public Iterator(Node<T> node, Type[] scrutinee) {\r
+ this.node = node;\r
+ this.scrutinee = scrutinee;\r
+ }\r
+ \r
+ public void improve() {\r
+ for(int i=0;i<scrutinee.length;++i) {\r
+ Type type = scrutinee[i] = Skeletons.canonicalSkeleton(scrutinee[i]);\r
+ if(!(type instanceof TMetaVar)) {\r
+ Branch<T> branch = node.getBranch(i);\r
+ if(branch != null) {\r
+ branch.improve(this);\r
+ --i;\r
+ }\r
+ }\r
+ }\r
+ }\r
+ }\r
+ \r
+ Node<T> root;\r
+ \r
+ public TypeTree(Case<T>[] cases) {\r
+ this.root = new Node<T>(cases);\r
+ }\r
+ \r
+ public Iterator<T> iterator(Type ... scrutinee) {\r
+ return new Iterator<T>(root, scrutinee);\r
+ }\r
+}\r