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