@Override public PType caseAStateDefinition(AStateDefinition node) throws AnalysisException { return ((AStateDefinition) node).getRecordType(); }
protected void stateInPost(List<PMultipleBind> exists_binds, List<PExp> postArglist, PDefinition stateDefinition) { AVariableExp varExp; // replace with super call if (stateDefinition instanceof AStateDefinition) { varExp = getVarExp(NEW_STATE_ARG,stateDefinition.clone()); AStateDefinition aStateDefinition = (AStateDefinition) stateDefinition; varExp.setType(aStateDefinition.getRecordType().clone()); exists_binds.addAll(getMultipleTypeBindList(aStateDefinition.getRecordType().clone(), NEW_STATE_ARG)); } else { varExp = getVarExp(NEW_SELF_ARG,stateDefinition.clone()); varExp.setType(stateDefinition.getType().clone()); exists_binds.addAll(getMultipleTypeBindList(stateDefinition.getType().clone(), NEW_SELF_ARG)); } postArglist.add(varExp); }
protected void stateInPre(List<PExp> args, PDefinition stateDefinition) { AVariableExp varExp; if (stateDefinition instanceof AStateDefinition) { varExp = getVarExp(OLD_STATE_ARG,stateDefinition.clone()); varExp.setType(((AStateDefinition) stateDefinition).getRecordType().clone()); } else { varExp = getVarExp(OLD_SELF_ARG,stateDefinition.clone()); varExp.setType(stateDefinition.getType().clone()); } args.add(varExp); }
protected void addStateBinds(LinkedList<PMultipleBind> r) { if (stateDefinition != null) { ATypeMultipleBind tmBind2 = new ATypeMultipleBind(); AIdentifierPattern pattern = new AIdentifierPattern(); if (stateDefinition instanceof AStateDefinition) { AStateDefinition def = (AStateDefinition) stateDefinition; tmBind2.setType(def.getRecordType().clone()); pattern.setName(OLD_STATE_ARG.clone()); } else { SClassDefinition def = (SClassDefinition) stateDefinition; tmBind2.setType(def.getClasstype().clone()); pattern.setName(OLD_SELF_ARG.clone()); } List<PPattern> plist = new LinkedList<PPattern>(); plist.add(pattern); tmBind2.setPlist(plist); r.add(tmBind2); } }
if(node.getRecordType() != null && !_visitedNodes.contains(node.getRecordType())) node.getRecordType().apply(this);
if(node.getRecordType() != null && !_visitedNodes.contains(node.getRecordType())) node.getRecordType().apply(this, question);
if(node.getRecordType() != null && !_visitedNodes.contains(node.getRecordType())) node.getRecordType().apply(this);
recordDefinition = AstFactory.newALocalDefinition(result.getLocation(), name, NameScope.STATE, result.getRecordType()); recordDefinition.setUsed(true); // Can't be exported anyway stateDefs.add(recordDefinition); recordDefinition = AstFactory.newALocalDefinition(result.getLocation(), name.getOldName(), NameScope.OLDSTATE, result.getRecordType()); recordDefinition.setUsed(true); // Can't be exported anyway stateDefs.add(recordDefinition);
@Override public void caseAStateDefinition(AStateDefinition node, NewQuestion question) throws AnalysisException { for (AFieldField f : node.getFields()) { try { f.apply(THIS, new NewQuestion(question.rootVisitor, question.question)); } catch (TypeCheckException e) { question.question.assistantFactory.createPTypeAssistant().unResolve(f.getType()); throw e; } } node.setRecordType(af.createPTypeAssistant().typeResolve(node.getRecordType(), null, question.rootVisitor, question.question)); if (node.getInvPattern() != null) { node.getInvdef().apply(this, question); ARecordInvariantType rtype = (ARecordInvariantType) node.getRecordType(); rtype.setInvDef(node.getInvdef()); } if (node.getInitPattern() != null) { node.getInitdef().apply(this, question); } }
if(node.getRecordType() != null && !_visitedNodes.contains(node.getRecordType())) mergeReturns(retVal,node.getRecordType().apply(this));
if(node.getRecordType() != null && !_visitedNodes.contains(node.getRecordType())) mergeReturns(retVal,node.getRecordType().apply(this, question));
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; }
public State(AStateDefinition definition) { this.definition = definition; NameValuePairList fieldvalues = new NameValuePairList(); for (AFieldField f : definition.getFields()) { fieldvalues.add(new NameValuePair(f.getTagname(), UpdatableValue.factory(new ValueListenerList(this)))); } ARecordInvariantType rt = (ARecordInvariantType) definition.getRecordType(); this.context = new Context(Interpreter.getInstance().getAssistantFactory(), definition.getLocation(), "module state", null); this.recordValue = UpdatableValue.factory(new RecordValue(rt, fieldvalues, context), new ValueListenerList(this)); this.context.put(definition.getName(), recordValue); this.context.putList(fieldvalues); }
List<PDefinition> invDefs = new Vector<PDefinition>(); AEqualsDefinition local = new AEqualsDefinition(); local.setExpType(def.getRecordType().clone()); local.setPattern(def.getInvPattern().clone()); local.setName(def.getName().clone()); AVariableExp varExp = getVarExp(def.getName(), def.clone()); varExp.setType(def.getRecordType().clone()); local.setTest(varExp); invDefs.add(local);
varExp.setType(((AStateDefinition) stateDefinition).getRecordType().clone()); postArglist.add(varExp); AVariableExp varExp2 = getVarExp(NEW_STATE_ARG,stateDefinition.clone()); varExp2.setType(((AStateDefinition) stateDefinition).getRecordType().clone()); postArglist.add(varExp2); } else
} else if (typeDef instanceof AStateDefinition) rec = ((AStateDefinition) typeDef).getRecordType(); } else
if (state != null && state.getRecordType().equals(rec))