X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=blobdiff_plain;f=bundles%2Forg.simantics.scl.compiler%2Fsrc%2Forg%2Fsimantics%2Fscl%2Fcompiler%2Ftypes%2Futil%2FTypeTree.java;fp=bundles%2Forg.simantics.scl.compiler%2Fsrc%2Forg%2Fsimantics%2Fscl%2Fcompiler%2Ftypes%2Futil%2FTypeTree.java;h=b41dba8cfd7b451df288ab40b4265115af7a6cfa;hb=9a175feb652b2b7bba7afa540831b9076be3c10e;hp=0000000000000000000000000000000000000000;hpb=0b72d3e4ec886838314ffeba0fa201e32c0aae3e;p=simantics%2Fplatform.git diff --git a/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/types/util/TypeTree.java b/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/types/util/TypeTree.java new file mode 100644 index 000000000..b41dba8cf --- /dev/null +++ b/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/types/util/TypeTree.java @@ -0,0 +1,70 @@ +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 { + + public static class Case { + public Type[] types; + public T result; + } + + private static class Node { + Case[] cases; + Branch[] branches; + + public Node(Case[] cases) { + this.cases = cases; + this.branches = new Branch[cases[0].types.length]; + } + + Branch getBranch(int i) { + // TODO + return null; + } + } + + private static class Branch { + + public void improve(Iterator iterator) { + // TODO Auto-generated method stub + + } + + } + + public static class Iterator { + Node node; + Type[] scrutinee; + + public Iterator(Node node, Type[] scrutinee) { + this.node = node; + this.scrutinee = scrutinee; + } + + public void improve() { + for(int i=0;i branch = node.getBranch(i); + if(branch != null) { + branch.improve(this); + --i; + } + } + } + } + } + + Node root; + + public TypeTree(Case[] cases) { + this.root = new Node(cases); + } + + public Iterator iterator(Type ... scrutinee) { + return new Iterator(root, scrutinee); + } +}