X-Git-Url: https://gerrit.simantics.org/r/gitweb?p=simantics%2Fplatform.git;a=blobdiff_plain;f=bundles%2Forg.simantics.graph.compiler%2Fsrc%2Forg%2Fsimantics%2Fgraph%2Fcompiler%2Finternal%2Fprocedures%2FDefaultValueTyping.java;fp=bundles%2Forg.simantics.graph.compiler%2Fsrc%2Forg%2Fsimantics%2Fgraph%2Fcompiler%2Finternal%2Fprocedures%2FDefaultValueTyping.java;h=a6b54b4a57062977bbaf5c84473b68ecde1b6236;hp=0000000000000000000000000000000000000000;hb=969bd23cab98a79ca9101af33334000879fb60c5;hpb=866dba5cd5a3929bbeae85991796acb212338a08 diff --git a/bundles/org.simantics.graph.compiler/src/org/simantics/graph/compiler/internal/procedures/DefaultValueTyping.java b/bundles/org.simantics.graph.compiler/src/org/simantics/graph/compiler/internal/procedures/DefaultValueTyping.java new file mode 100644 index 000000000..a6b54b4a5 --- /dev/null +++ b/bundles/org.simantics.graph.compiler/src/org/simantics/graph/compiler/internal/procedures/DefaultValueTyping.java @@ -0,0 +1,44 @@ +package org.simantics.graph.compiler.internal.procedures; + +import gnu.trove.procedure.TIntObjectProcedure; +import gnu.trove.set.hash.TIntHashSet; + +import org.simantics.graph.compiler.internal.store.IPreValue; +import org.simantics.graph.compiler.internal.store.PreValueStore; +import org.simantics.graph.query.Path; +import org.simantics.graph.query.Paths; +import org.simantics.graph.store.GraphStore; + +public class DefaultValueTyping implements Runnable { + + GraphStore store; + Paths paths; + + public DefaultValueTyping(Paths paths, GraphStore store) { + this.paths = paths; + this.store = store; + } + + @Override + public void run() { + final int instanceOfId = store.identities.createPathToId(paths.InstanceOf); + final TIntHashSet + instanceOfDomain = store.statements.getRelationDomain(instanceOfId); + PreValueStore preValues = store.getStore(PreValueStore.class); + preValues.forEachPreValue(new TIntObjectProcedure() { + @Override + public boolean execute(int a, IPreValue b) { + if(!instanceOfDomain.contains(a)) { + Path defaultType = b.getDefaultType(paths); + if(defaultType != null) + store.statements.add(a, + instanceOfId, + store.identities.createPathToId(defaultType) + ); + } + return true; + } + }); + } + +}