@Override public SStmIR caseAAssignmentStm(AAssignmentStm node, IRInfo question) throws AnalysisException { PStateDesignator target = node.getTarget(); PExp exp = node.getExp(); SStateDesignatorIR targetCg = target.apply(question.getStateDesignatorVisitor(), question); SExpIR expCg = exp.apply(question.getExpVisitor(), question); AAssignmentStmIR assignment = new AAssignmentStmIR(); assignment.setTarget(targetCg); assignment.setExp(expCg); return assignment; }
public AssignmentContext(AAssignmentStm node, IPogAssistantFactory af, IPOContextStack ctxt) throws AnalysisException { super(ctxt); String hash = node.getTarget().apply(af.getStateDesignatorNameGetter()); t = null; for (ILexNameToken n : last_vars.keySet()) { if (n.getName().equals(hash)) { t = last_vars.get(n).getName().clone(); break; } } if (t == null) { t = new LexNameToken("", hash, null); } subLast = new Substitution(new LexNameToken("", hash, null), node.getExp().clone()); sub = new Substitution(t, node.getExp().clone()); this.visitor = af.getVarSubVisitor(); }
public StateInvariantObligation(AAtomicStm atom, IPOContextStack ctxt, IPogAssistantFactory af) throws AnalysisException { super(atom, POType.STATE_INV, ctxt, atom.getLocation(), af); assistantFactory = af; PExp invApplyExp = makeInvApplyExp(atom); PExp invApplyExpForSub = invApplyExp.clone(); List<Substitution> subs = new LinkedList<Substitution>(); for (AAssignmentStm asgn : atom.getAssignments()) { String hash = asgn.getTarget().apply(af.getStateDesignatorNameGetter()); subs.add(new Substitution(hash, asgn.getExp().clone())); } IVariableSubVisitor varSubVisitor = af.getVarSubVisitor(); for (Substitution sub : subs) { invApplyExpForSub = invApplyExpForSub.apply(varSubVisitor, sub); } stitch = AstExpressionFactory.newAImpliesBooleanBinaryExp(invApplyExp, invApplyExpForSub); valuetree.setPredicate(stitch); }
hash = ass.getTarget().apply(af.getStateDesignatorNameGetter()); Substitution sub = new Substitution(new LexNameToken("", hash, null), ass.getExp().clone()); PExp new_invs = old_invs.clone().apply(af.getVarSubVisitor(), sub);
@Override public PType caseAAssignmentStm(AAssignmentStm node, TypeCheckInfo question) throws AnalysisException { node.setTargetType(node.getTarget().apply(THIS, new TypeCheckInfo(question.assistantFactory, question.env))); node.setExpType(node.getExp().apply(THIS, new TypeCheckInfo(question.assistantFactory, question.env, question.scope, null, node.getTargetType(), null))); if (!question.assistantFactory.getTypeComparator().compatible(node.getTargetType(), node.getExpType())) { TypeCheckerErrors.report(3239, "Incompatible types in assignment", node.getLocation(), node); TypeCheckerErrors.detail2("Target", node.getTarget().getType(), "Expression", node.getExp().getType()); } node.setClassDefinition(question.env.findClassDefinition()); node.setStateDefinition(question.env.findStateDefinition()); AClassTypeAssistantTC assist = question.assistantFactory.createAClassTypeAssistant(); node.setInConstructor(assist.inConstructor(question.env)); if (node.getInConstructor()) { // Mark assignment target as initialized (so no warnings) PDefinition state; state = targetDefinition(node.getTarget(), question); if (state instanceof AInstanceVariableDefinition) { AInstanceVariableDefinition iv = (AInstanceVariableDefinition) state; iv.setInitialized(true); } } node.setType(AstFactory.newAVoidType(node.getLocation())); return node.getType(); }
obligations.addAll(node.getTarget().apply(rootVisitor, question)); obligations.addAll(node.getExp().apply(rootVisitor, question));
targets.add(stmt.getTarget().apply(VdmRuntime.getStatementEvaluator(), ctxt)); values.add(stmt.getExp().apply(VdmRuntime.getStatementEvaluator(), ctxt).convertTo(stmt.getTargetType(), ctxt)); } catch (ValueException e)