@Override public PType caseAValueDefinition(AValueDefinition node) throws AnalysisException { // return AValueDefinitionAssistantTC.getType((AValueDefinition) node); return node.getType() != null ? node.getType() : node.getExpType() != null ? node.getExpType() : AstFactory.newAUnknownType(node.getLocation()); }
public static AValueDefinition newAValueDefinition(PPattern p, NameScope scope, PType type, PExp readExpression) { AValueDefinition result = new AValueDefinition(); // Definition initialization initDefinition(result, Pass.VALUES, p.getLocation(), null, scope); result.setPattern(p); result.setType(type); result.setExpression(readExpression); List<PDefinition> defs = new Vector<PDefinition>(); for (ILexNameToken var : af.createPPatternAssistant().getVariableNames(p)) { defs.add(AstFactory.newAUntypedDefinition(result.getLocation(), var, scope)); } result.setDefs(defs); return result; }
@Override public NameValuePairList caseAValueDefinition(AValueDefinition def, Context initialContext) throws AnalysisException { Value v = null; try { // UpdatableValues are constantized as they cannot be updated. v = def.getExpression().apply(VdmRuntime.getExpressionEvaluator(), initialContext).convertTo(af.createPDefinitionAssistant().getType(def), initialContext).getConstant(); return af.createPPatternAssistant().getNamedValues(def.getPattern(), v, initialContext); } catch (ValueException e) { VdmRuntimeError.abort(def.getLocation(), e); } catch (PatternMatchException e) { VdmRuntimeError.abort(e, initialContext); } catch (AnalysisException e) { } return null; }
TypeCheckerErrors.report(3051, "Expression does not match declared type", node.getLocation(), node); TypeCheckerErrors.detail2("Declared", type, "Expression", expType); PDefinition typedef = base.findType(named.getName(), node.getLocation().getModule()); TypeCheckerErrors.report(3052, "Value type visibility less than value definition", node.getLocation(), node);
PType compatible = set.getType(node.getLocation()); if (!assistantFactory.getTypeComparator().isSubType(type, compatible))