--- /dev/null
+package org.simantics.graph.compiler.internal.procedures;\r
+\r
+import gnu.trove.procedure.TIntObjectProcedure;\r
+import gnu.trove.set.hash.TIntHashSet;\r
+\r
+import org.simantics.graph.compiler.internal.store.IPreValue;\r
+import org.simantics.graph.compiler.internal.store.PreValueStore;\r
+import org.simantics.graph.query.Path;\r
+import org.simantics.graph.query.Paths;\r
+import org.simantics.graph.store.GraphStore;\r
+\r
+public class DefaultValueTyping implements Runnable {\r
+\r
+ GraphStore store;\r
+ Paths paths;\r
+ \r
+ public DefaultValueTyping(Paths paths, GraphStore store) {\r
+ this.paths = paths;\r
+ this.store = store;\r
+ }\r
+\r
+ @Override\r
+ public void run() {\r
+ final int instanceOfId = store.identities.createPathToId(paths.InstanceOf);\r
+ final TIntHashSet \r
+ instanceOfDomain = store.statements.getRelationDomain(instanceOfId);\r
+ PreValueStore preValues = store.getStore(PreValueStore.class);\r
+ preValues.forEachPreValue(new TIntObjectProcedure<IPreValue>() { \r
+ @Override\r
+ public boolean execute(int a, IPreValue b) {\r
+ if(!instanceOfDomain.contains(a)) {\r
+ Path defaultType = b.getDefaultType(paths);\r
+ if(defaultType != null)\r
+ store.statements.add(a, \r
+ instanceOfId,\r
+ store.identities.createPathToId(defaultType)\r
+ );\r
+ }\r
+ return true;\r
+ }\r
+ });\r
+ } \r
+\r
+}\r