public static AInstanceVariableDefinition newAInstanceVariableDefinition( ILexNameToken name, PType type, PExp expression) { AInstanceVariableDefinition result = new AInstanceVariableDefinition(); // Definition initialization initDefinition(result, Pass.VALUES, name.getLocation(), name, NameScope.VARSANDSTATE); result.setType(type); result.setExpression(expression); if (result.getLocation() != null) { result.getLocation().executable(false); } result.setOldname(name.getOldName()); result.setInitialized(!(expression instanceof AUndefinedExp)); return result; }
public void initializedCheck(AInstanceVariableDefinition ivd) { if (!ivd.getInitialized() && !af.createPAccessSpecifierAssistant().isStatic(ivd.getAccess())) { TypeCheckerErrors.warning(5001, "Instance variable '" + ivd.getName() + "' is not initialized", ivd.getLocation(), ivd); } } }
@Override public NameValuePairList caseAInstanceVariableDefinition( AInstanceVariableDefinition def, Context initialContext) throws AnalysisException { try { Value v = def.getExpression().apply(VdmRuntime.getExpressionEvaluator(), initialContext); if (!v.isUndefined()) { v = v.convertTo(def.getType(), initialContext); } return new NameValuePairList(new NameValuePair(def.getName(), v.getUpdatable(null))); } catch (ValueException e) { VdmRuntimeError.abort(def.getLocation(), e); return null; } catch (AnalysisException e) { // TODO Auto-generated catch block e.printStackTrace(); return null; } }
+ node.getName(), node.getLocation(), node); TypeCheckerErrors.report(3000, "Expression does not match declared type", node.getLocation(), node); TypeCheckerErrors.detail2("Declared", question.assistantFactory.createPDefinitionAssistant().getType(node), "Expression", node.getExpType());