@Override public PExp caseAAtomicStm(AAtomicStm stm, Integer lineno) throws AnalysisException { PExp found = null; for (AAssignmentStm stmt : stm.getAssignments()) { found = stmt.apply(THIS, lineno); if (found != null) { break; } } return found; }
if(node.getType() != null && !_visitedNodes.contains(node.getType())) node.getType().apply(this, question); if(node.getTarget() != null && !_visitedNodes.contains(node.getTarget())) node.getTarget().apply(this, question); if(node.getExp() != null && !_visitedNodes.contains(node.getExp())) node.getExp().apply(this, question); if(node.getTargetType() != null && !_visitedNodes.contains(node.getTargetType())) node.getTargetType().apply(this, question); if(node.getExpType() != null && !_visitedNodes.contains(node.getExpType())) node.getExpType().apply(this, question); if(node.getClassDefinition() != null && !_visitedNodes.contains(node.getClassDefinition())) node.getClassDefinition().apply(this, question); if(node.getStateDefinition() != null && !_visitedNodes.contains(node.getStateDefinition())) node.getStateDefinition().apply(this, question);
@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(); }
private PExp extractInv(AAtomicStm atom) { AAssignmentStm x = atom.getAssignments().get(0); if (x.getClassDefinition() != null) { return invDefs(x.getClassDefinition()); } else { return invDefs(x.getStateDefinition()); } }
if (!node.getInConstructor() && node.getClassDefinition() != null && node.getClassDefinition().getInvariant() != null || node.getStateDefinition() != null && node.getStateDefinition().getInvExpression() != null) obligations.addAll(node.getTarget().apply(rootVisitor, question)); obligations.addAll(node.getExp().apply(rootVisitor, question)); if (!aF.getTypeComparator().isSubType(question.checkType(node.getExp(), node.getExpType()), node.getTargetType())) TypeCompatibilityObligation sto = TypeCompatibilityObligation.newInstance(node.getExp(), node.getTargetType(), node.getExpType(), question, aF); if (sto != null)
throws AnalysisException BreakpointManager.getBreakpoint(node).check(node.getLocation(), ctxt); Value newval = node.getExp().apply(VdmRuntime.getStatementEvaluator(), ctxt); Value oldval = node.getTarget().apply(VdmRuntime.getStatementEvaluator(), ctxt); oldval.set(node.getLocation(), newval.convertTo(node.getTargetType(), ctxt), ctxt); } catch (ValueException e) VdmRuntimeError.abort(node.getLocation(), e); + node.getTarget().toString() + "\"" + " val: \"" + node.getTarget().toString() + "\"" + " val: \""
public StateInvariantObligation(AAssignmentStm ass, IPOContextStack ctxt, IPogAssistantFactory af) throws AnalysisException super(ass, POType.STATE_INV, ctxt, ass.getLocation(), af); assistantFactory = af; if (ass.getClassDefinition() != null) PExp old_invs = invDefs(ass.getClassDefinition()); 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); } else AStateDefinition def = ass.getStateDefinition(); ALetDefExp letExp = new ALetDefExp(); letExp.setType(def.getInvExpression().getType().clone());
@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; }
stmt.apply(mainVisitor, question); // collect the assignments if (!stmt.getInConstructor() && stmt.getClassDefinition() != null && stmt.getClassDefinition().getInvariant() != null || stmt.getStateDefinition() != null && stmt.getStateDefinition().getInvExpression() != null)
@Override public PExp caseAAssignmentStm(AAssignmentStm stm, Integer lineno) throws AnalysisException { return af.createPExpAssistant().findExpression(stm.getExp(), lineno); }
@Override public PTypeSet caseAAssignmentStm(AAssignmentStm statement) throws AnalysisException { // TODO We don't know what an expression call will raise return new PTypeSet(AstFactory.newAUnknownType(statement.getLocation()), af); }
private PExp makeInvApplyExp(AAtomicStm atom) { AStateDefinition stateDef = atom.getAssignments().get(0).getStateDefinition(); if (stateDef == null) { return extractInv(atom); } String stateName = getStateName(stateDef); List<PExp> arglist = new Vector<PExp>(); for (AFieldField f : stateDef.getFields()) { arglist.add(getVarExp(f.getTagname().clone(), stateDef.clone(),f.getType())); } PExp mkExp = AstExpressionFactory.newAMkTypeExp(new LexNameToken("", stateName, null), stateDef.getRecordType().clone(), arglist); AApplyExp invApplyExp = getApplyExp(getVarExp(stateDef.getInvdef().getName().clone(), stateDef.getInvdef().clone(), stateDef.getInvdef().getType().clone()), new ABooleanBasicType(), mkExp); invApplyExp.getRoot().setType(stateDef.getInvdef().getType().clone()); return invApplyExp; }
stmt.getLocation().hit(); targets.add(stmt.getTarget().apply(VdmRuntime.getStatementEvaluator(), ctxt)); values.add(stmt.getExp().apply(VdmRuntime.getStatementEvaluator(), ctxt).convertTo(stmt.getTargetType(), ctxt)); } catch (ValueException e)
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(); }
@Override public LexNameSet caseAAssignmentStm(AAssignmentStm node, FreeVarInfo info) throws AnalysisException { LexNameSet names = new LexNameSet(); names.addAll(node.getExp().apply(this, info)); return names; }
if(node.getType() != null && !_visitedNodes.contains(node.getType())) node.getType().apply(this); if(node.getTarget() != null && !_visitedNodes.contains(node.getTarget())) node.getTarget().apply(this); if(node.getExp() != null && !_visitedNodes.contains(node.getExp())) node.getExp().apply(this); if(node.getTargetType() != null && !_visitedNodes.contains(node.getTargetType())) node.getTargetType().apply(this); if(node.getExpType() != null && !_visitedNodes.contains(node.getExpType())) node.getExpType().apply(this); if(node.getClassDefinition() != null && !_visitedNodes.contains(node.getClassDefinition())) node.getClassDefinition().apply(this); if(node.getStateDefinition() != null && !_visitedNodes.contains(node.getStateDefinition())) node.getStateDefinition().apply(this);
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); }
@Override public PStm caseAAtomicStm(AAtomicStm stm, Integer lineno) throws AnalysisException { PStm found = findStatementBaseCase(stm, lineno); if (found != null) { return found; } for (AAssignmentStm stmt : stm.getAssignments()) { found = stmt.apply(THIS, lineno);// PStmAssistantInterpreter.findStatement(stmt, lineno); if (found != null) { break; } } return found; }
if(node.getType() != null && !_visitedNodes.contains(node.getType())) node.getType().apply(this); if(node.getTarget() != null && !_visitedNodes.contains(node.getTarget())) node.getTarget().apply(this); if(node.getExp() != null && !_visitedNodes.contains(node.getExp())) node.getExp().apply(this); if(node.getTargetType() != null && !_visitedNodes.contains(node.getTargetType())) node.getTargetType().apply(this); if(node.getExpType() != null && !_visitedNodes.contains(node.getExpType())) node.getExpType().apply(this); if(node.getClassDefinition() != null && !_visitedNodes.contains(node.getClassDefinition())) node.getClassDefinition().apply(this); if(node.getStateDefinition() != null && !_visitedNodes.contains(node.getStateDefinition())) node.getStateDefinition().apply(this);