X-Git-Url: https://gerrit.simantics.org/r/gitweb?p=simantics%2Fplatform.git;a=blobdiff_plain;f=bundles%2Forg.simantics.modeling%2Fsrc%2Forg%2Fsimantics%2Fmodeling%2FSCLTypeUtils.java;h=eeabbd960b4e6583bc0a05d35d2b89998e5f8883;hp=c94b1be1b2dbaeb43c96b934d551024bb5d2be8a;hb=c0941146a40af9df766b514fd4238aa20ec2ff4f;hpb=1dfeb7d5c49b1391cd9d877e1eddab18995cb151 diff --git a/bundles/org.simantics.modeling/src/org/simantics/modeling/SCLTypeUtils.java b/bundles/org.simantics.modeling/src/org/simantics/modeling/SCLTypeUtils.java index c94b1be1b..eeabbd960 100644 --- a/bundles/org.simantics.modeling/src/org/simantics/modeling/SCLTypeUtils.java +++ b/bundles/org.simantics.modeling/src/org/simantics/modeling/SCLTypeUtils.java @@ -13,6 +13,7 @@ import org.simantics.databoard.type.LongType; import org.simantics.databoard.type.StringType; import org.simantics.db.layer0.request.PropertyInfo; import org.simantics.scl.compiler.types.TCon; +import org.simantics.scl.compiler.types.TVar; import org.simantics.scl.compiler.types.Type; import org.simantics.scl.compiler.types.Types; import org.simantics.scl.compiler.types.kinds.Kinds; @@ -23,6 +24,8 @@ public class SCLTypeUtils { private static final Logger LOGGER = LoggerFactory.getLogger(SCLTypeUtils.class); private static final THashMap TYPE_MAP = new THashMap(); + private static final TVar STAR = Types.var(Kinds.STAR); + private static void add(TCon type) { TYPE_MAP.put(type.name, type); } @@ -57,9 +60,19 @@ public class SCLTypeUtils { TYPE_MAP.put("Vector Float", Types.vector(Types.FLOAT)); TYPE_MAP.put("Vector Double", Types.vector(Types.DOUBLE)); TYPE_MAP.put("Vector String", Types.vector(Types.STRING)); - - add(Types.BYTE_ARRAY); + TYPE_MAP.put("ByteArray", Types.BYTE_ARRAY); + + // #83: L0.typeResource + TCon variable = Types.con("Simantics/Variables", "Variable"); + add(variable); + TYPE_MAP.put("Variable -> Resource -> Resource", + Types.functionE(new Type[] {variable, Types.RESOURCE}, Types.READ_GRAPH, Types.RESOURCE)); + add((TCon)Types.RESOURCE); + add(Types.con("Simantics/ChangeInformation", "ChangeInformation")); // MOD.ChangeInformation + add(Types.con("Simantics/GUID", "GUID")); // L0.GUID + add(Types.con("Simantics/Variables", "StructuredProperty")); // L0.methods + add(Types.con("Simantics/Variables", "ValueAccessor")); // L0.ValueAccessor add(Types.con("Simantics/Variables", "VariableMap")); } @@ -72,7 +85,7 @@ public class SCLTypeUtils { Type type = TYPE_MAP.get(typeText); if(type == null) { LOGGER.warn("SCLTypeUtils.getType cannot transform '" + typeText + "' to type. Returns a as default."); - return Types.var(Kinds.STAR); + return STAR; } return type; } @@ -96,18 +109,23 @@ public class SCLTypeUtils { return Types.list(getType(((ArrayType)dataType).componentType)); else { LOGGER.warn("SCLTypeUtils.getType cannot transform data type '" + dataType + "' to type. Returns a as default."); - return Types.var(Kinds.STAR); + return STAR; } } - public static Type getType(PropertyInfo propertyInfo) { + public static Type getType(PropertyInfo propertyInfo, boolean warnOfNoTypeInformation) { if(propertyInfo.requiredValueType != null) return getType(propertyInfo.requiredValueType); else if(propertyInfo.requiredDatatype != null) return getType(propertyInfo.requiredDatatype); else { - LOGGER.warn(propertyInfo.name + " doesn't have type information. Returns a as default."); - return Types.var(Kinds.STAR); + if (warnOfNoTypeInformation) + LOGGER.warn(propertyInfo.name + " doesn't have type information. Returns a as default."); + return STAR; } } + + public static Type getType(PropertyInfo propertyInfo) { + return getType(propertyInfo, propertyInfo.isHasProperty); + } }