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%2Fvalues%2FTreeValue.java;fp=bundles%2Forg.simantics.graph.compiler%2Fsrc%2Forg%2Fsimantics%2Fgraph%2Fcompiler%2Finternal%2Fvalues%2FTreeValue.java;h=94509e32d34079d3dcc7cd268763f59bd2daebcf;hp=84d36149145c216e0609adc6f354d3e1251b0e11;hb=0ae2b770234dfc3cbb18bd38f324125cf0faca07;hpb=24e2b34260f219f0d1644ca7a138894980e25b14 diff --git a/bundles/org.simantics.graph.compiler/src/org/simantics/graph/compiler/internal/values/TreeValue.java b/bundles/org.simantics.graph.compiler/src/org/simantics/graph/compiler/internal/values/TreeValue.java index 84d361491..94509e32d 100644 --- a/bundles/org.simantics.graph.compiler/src/org/simantics/graph/compiler/internal/values/TreeValue.java +++ b/bundles/org.simantics.graph.compiler/src/org/simantics/graph/compiler/internal/values/TreeValue.java @@ -1,78 +1,78 @@ -package org.simantics.graph.compiler.internal.values; - -import java.util.Collection; - -import org.antlr.runtime.tree.Tree; -import org.simantics.databoard.binding.Binding; -import org.simantics.graph.compiler.internal.parsing.GraphParser; -import org.simantics.graph.compiler.internal.store.IPreValue; -import org.simantics.graph.compiler.internal.translation.DataValueTranslator; -import org.simantics.graph.query.Path; -import org.simantics.graph.query.Paths; -import org.simantics.ltk.ISource; -import org.simantics.ltk.Location; -import org.simantics.ltk.Problem; -import org.simantics.ltk.antlr.ANTLRUtils; - -public class TreeValue implements IPreValue { - - ISource source; - Tree tree; - - public TreeValue(ISource source, Tree tree) { - this.source = source; - this.tree = tree; - } - - @Override - public Object toValue(Binding binding, Collection problems) { - return new DataValueTranslator(source, problems).translate(tree, binding); - } - - public Tree getTree() { - return tree; - } - - @Override - public Path getDefaultType(Paths paths) { - Tree b = this.tree; - while(b.getType() == GraphParser.TUPLE && b.getChildCount() == 1) - b = b.getChild(0); - - switch(b.getType()) { - case GraphParser.INT: return paths.Integer; - case GraphParser.FLOAT: return paths.Double; - case GraphParser.STRING: return paths.String; - case GraphParser.TRUE: - case GraphParser.FALSE: return paths.Boolean; - case GraphParser.VARIANT: return paths.Variant; - case GraphParser.ARRAY: - if(b.getChildCount() > 0) { - switch(b.getChild(0).getType()) { - case GraphParser.INT: - case GraphParser.FLOAT: - for(int i=0;i problems) { + return new DataValueTranslator(source, problems).translate(tree, binding); + } + + public Tree getTree() { + return tree; + } + + @Override + public Path getDefaultType(Paths paths) { + Tree b = this.tree; + while(b.getType() == GraphParser.TUPLE && b.getChildCount() == 1) + b = b.getChild(0); + + switch(b.getType()) { + case GraphParser.INT: return paths.Integer; + case GraphParser.FLOAT: return paths.Double; + case GraphParser.STRING: return paths.String; + case GraphParser.TRUE: + case GraphParser.FALSE: return paths.Boolean; + case GraphParser.VARIANT: return paths.Variant; + case GraphParser.ARRAY: + if(b.getChildCount() > 0) { + switch(b.getChild(0).getType()) { + case GraphParser.INT: + case GraphParser.FLOAT: + for(int i=0;i