inAAssignmentDefinition(node); if(node.getName() != null ) node.getName().apply(this); if(node.getClassDefinition() != null && !_visitedNodes.contains(node.getClassDefinition())) node.getClassDefinition().apply(this); if(node.getAccess() != null && !_visitedNodes.contains(node.getAccess())) node.getAccess().apply(this); if(node.getType() != null && !_visitedNodes.contains(node.getType())) node.getType().apply(this); if(node.getExpression() != null && !_visitedNodes.contains(node.getExpression())) node.getExpression().apply(this); if(node.getExpType() != null && !_visitedNodes.contains(node.getExpType())) node.getExpType().apply(this);
public static AAssignmentDefinition newAAssignmentDefinition( ILexNameToken name, PType type, PExp exp) { AAssignmentDefinition result = new AAssignmentDefinition(); initDefinition(result, Pass.VALUES, name.getLocation(), name, NameScope.STATE); result.setType(type); result.setExpression(exp); result.getLocation().executable(false); return result; }
/** * Creates a new complete constructor {@code AAssignmentDefinition} node with the given nodes as children. * @deprecated This method should not be used, use AstFactory instead. * The basic child nodes are removed from their previous parents. * @param expression_ the {@link PExp} node for the {@code expression} child of this {@link AAssignmentDefinition} node * @param expType_ the {@link PType} <b>graph</a> node for the {@code expType} child of this {@link AAssignmentDefinition} node. * <i>The parent of this {@code expType } will not be changed by adding it to this node.</i> */ public AAssignmentDefinition(ILexLocation location_, ILexNameToken name_, NameScope nameScope_, Boolean used_, SClassDefinition classDefinition_, AAccessSpecifierAccessSpecifier access_, PType type_, Pass pass_, PExp expression_, PType expType_) { super(location_,name_,nameScope_,used_,classDefinition_,access_,type_,pass_); this.setExpression(expression_); this.setExpType(expType_); }
private PDefinition readInstanceVariableDefinition() throws ParserException, LexException { LexToken token = lastToken(); if (token.is(VDMToken.INV)) { nextToken(); PExp exp = getExpressionReader().readExpression(); String str = getCurrentModule(); LexNameToken className = new LexNameToken(str, str, token.location); return AstFactory.newAClassInvariantDefinition(className.getInvName(token.location), exp); } else { AAccessSpecifierAccessSpecifier access = readAccessSpecifier(false, false); AAssignmentDefinition def = getStatementReader().readAssignmentDefinition(); AInstanceVariableDefinition ivd = AstFactory.newAInstanceVariableDefinition(def.getName(), def.getType(), def.getExpression()); def.getType().parent(ivd);// the type of ivd is graph but we trough away the assignment ivd.setAccess(access); return ivd; } }
@Override public NameValuePairList caseAAssignmentDefinition( AAssignmentDefinition 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 (AnalysisException e) { if (e instanceof ValueException) { VdmRuntimeError.abort(def.getLocation(), (ValueException) e); } return null; } }
@Override public PType caseAAssignmentDefinition(AAssignmentDefinition node, TypeCheckInfo question) throws AnalysisException { question.qualifiers = null; node.setType(question.assistantFactory.createPTypeAssistant().typeResolve(question.assistantFactory.createPDefinitionAssistant().getType(node), null, THIS, question)); ExcludedDefinitions.setExcluded(node); node.setExpType(node.getExpression().apply(THIS, question)); ExcludedDefinitions.clearExcluded(); question.assistantFactory.getTypeComparator().checkComposeTypes(node.getType(), question.env, false); if (node.getExpType() instanceof AVoidType) { TypeCheckerErrors.report(3048, "Expression does not return a value", node.getExpression().getLocation(), node.getExpression()); } if (!question.assistantFactory.getTypeComparator().compatible(node.getType(), node.getExpType())) { TypeCheckerErrors.report(3000, "Expression does not match declared type", node.getExpression().getLocation(), node); TypeCheckerErrors.detail2("Declared", node.getType(), "Expression", node.getExpType()); } return node.getType(); }
@Override public IProofObligationList caseAAssignmentDefinition( AAssignmentDefinition node, IPOContextStack question) throws AnalysisException { try { IProofObligationList obligations = new ProofObligationList(); PExp expression = node.getExpression(); PType type = node.getType(); PType expType = node.getExpType(); obligations.addAll(expression.apply(rootVisitor, question)); if (!assistantFactory.getTypeComparator().isSubType(question.checkType(expression, expType), type)) { TypeCompatibilityObligation sto = TypeCompatibilityObligation.newInstance(expression, type, expType, question, assistantFactory); if (sto != null) { obligations.add(sto); } } return obligations; } catch (Exception e) { throw new POException(node, e.getMessage()); } }
@Override public ValueList caseAAssignmentDefinition(AAssignmentDefinition def, ObjectContext ctxt) throws AnalysisException { return af.createPExpAssistant().getValues(def.getExpression(), ctxt); }
@Override public PType caseAAssignmentDefinition(AAssignmentDefinition node) throws AnalysisException { return node.getType(); }
@Override public LexNameList caseAAssignmentDefinition(AAssignmentDefinition node) throws AnalysisException { return new LexNameList(node.getName()); }
e.apply(this, question);
PType type = def.getType(); String name = def.getName().getName(); PExp exp = def.getExpression();
@Override public PExp caseAAssignmentDefinition(AAssignmentDefinition def, Integer lineno) throws AnalysisException { return af.createPExpAssistant().findExpression(def.getExpression(), lineno); }
e.apply(this);
inAAssignmentDefinition(node, question); if(node.getName() != null ) node.getName().apply(this, question); if(node.getClassDefinition() != null && !_visitedNodes.contains(node.getClassDefinition())) node.getClassDefinition().apply(this, question); if(node.getAccess() != null && !_visitedNodes.contains(node.getAccess())) node.getAccess().apply(this, question); if(node.getType() != null && !_visitedNodes.contains(node.getType())) node.getType().apply(this, question); if(node.getExpression() != null && !_visitedNodes.contains(node.getExpression())) node.getExpression().apply(this, question); if(node.getExpType() != null && !_visitedNodes.contains(node.getExpType())) node.getExpType().apply(this, question);
e.apply(this);
inAAssignmentDefinition(node); if(node.getName() != null ) node.getName().apply(this); if(node.getClassDefinition() != null && !_visitedNodes.contains(node.getClassDefinition())) node.getClassDefinition().apply(this); if(node.getAccess() != null && !_visitedNodes.contains(node.getAccess())) node.getAccess().apply(this); if(node.getType() != null && !_visitedNodes.contains(node.getType())) node.getType().apply(this); if(node.getExpression() != null && !_visitedNodes.contains(node.getExpression())) node.getExpression().apply(this); if(node.getExpType() != null && !_visitedNodes.contains(node.getExpType())) node.getExpType().apply(this);
mergeReturns(retVal,e.apply(this, question));
mergeReturns(retVal,inAAssignmentDefinition(node)); if(node.getName() != null ) mergeReturns(retVal,node.getName().apply(this)); if(node.getClassDefinition() != null && !_visitedNodes.contains(node.getClassDefinition())) mergeReturns(retVal,node.getClassDefinition().apply(this)); if(node.getAccess() != null && !_visitedNodes.contains(node.getAccess())) mergeReturns(retVal,node.getAccess().apply(this)); if(node.getType() != null && !_visitedNodes.contains(node.getType())) mergeReturns(retVal,node.getType().apply(this)); if(node.getExpression() != null && !_visitedNodes.contains(node.getExpression())) mergeReturns(retVal,node.getExpression().apply(this)); if(node.getExpType() != null && !_visitedNodes.contains(node.getExpType())) mergeReturns(retVal,node.getExpType().apply(this));
mergeReturns(retVal,e.apply(this));