/** * Provide additional information about the type of the variable, typically derived by analyzing * the initializer of the variable binding * * @param type the item type of the variable * @param cardinality the cardinality of the variable * @param constantValue the actual value of the variable, if this is known statically, otherwise null * @param properties additional static properties of the variable's initializer */ public void refineVariableType(ItemType type, int cardinality, GroundedValue<?> constantValue, int properties) { TypeHierarchy th = getConfiguration().getTypeHierarchy(); ItemType oldItemType = getItemType(); ItemType newItemType = oldItemType; if (th.isSubType(type, oldItemType)) { newItemType = type; } if (oldItemType instanceof NodeTest && type instanceof AtomicType) { // happens when all references are flattened newItemType = type; } int newcard = cardinality & getCardinality(); if (newcard == 0) { // this will probably lead to a type error later newcard = getCardinality(); } SequenceType seqType = SequenceType.makeSequenceType(newItemType, newcard); setStaticType(seqType, constantValue, properties); }
/** * Provide additional information about the type of the variable, typically derived by analyzing * the initializer of the variable binding * * @param type the item type of the variable * @param cardinality the cardinality of the variable * @param constantValue the actual value of the variable, if this is known statically, otherwise null * @param properties additional static properties of the variable's initializer */ public void refineVariableType(ItemType type, int cardinality, GroundedValue<?> constantValue, int properties) { TypeHierarchy th = getConfiguration().getTypeHierarchy(); ItemType oldItemType = getItemType(); ItemType newItemType = oldItemType; if (th.isSubType(type, oldItemType)) { newItemType = type; } if (oldItemType instanceof NodeTest && type instanceof AtomicType) { // happens when all references are flattened newItemType = type; } int newcard = cardinality & getCardinality(); if (newcard == 0) { // this will probably lead to a type error later newcard = getCardinality(); } SequenceType seqType = SequenceType.makeSequenceType(newItemType, newcard); setStaticType(seqType, constantValue, properties); }