protected List<AInstanceVariableDefinition> collectState( AExplicitOperationDefinition node) throws AnalysisException { List<AInstanceVariableDefinition> r = new LinkedList<AInstanceVariableDefinition>(); List<PDefinition> stateDefs; if (node.getClassDefinition() != null) { stateDefs = node.getClassDefinition().getDefinitions(); } else { if (node.getState() != null) { stateDefs = node.getState().getStateDefs(); } else { return r; } } for (PDefinition d : stateDefs) { if (d instanceof AInstanceVariableDefinition) { r.add((AInstanceVariableDefinition) d); } } return r; }
public StateInvariantObligation(AExplicitOperationDefinition def, IPOContextStack ctxt, IPogAssistantFactory af) throws AnalysisException { super(def, POType.STATE_INV, ctxt, def.getLocation(), af); assistantFactory = af; // After def.getName() constructor body stitch = invDefs(def.getClassDefinition()); valuetree.setPredicate(ctxt.getPredWithContext(stitch)); }
private OperationValue(AExplicitOperationDefinition def, FunctionValue precondition, FunctionValue postcondition, AStateDefinition state, boolean async) { this.expldef = def; this.impldef = null; this.name = def.getName(); this.type = (AOperationType) def.getType(); this.paramPatterns = def.getParameterPatterns(); this.body = def.getBody(); this.precondition = precondition; this.postcondition = postcondition; this.state = state; this.classdef = def.getClassDefinition(); this.isAsync = async; traceRT = Settings.dialect == Dialect.VDM_RT && classdef != null && !(classdef instanceof ASystemClassDefinition) && !classdef.getName().getName().equals("CPU") && !classdef.getName().getName().equals("BUS") && !name.getName().equals("thread") && !name.getName().startsWith("inv_"); }
@SuppressWarnings("unchecked") public AExplicitFunctionDefinition getPreDefinition( AExplicitOperationDefinition d, Environment base) { List<List<PPattern>> parameters = new Vector<List<PPattern>>(); List<PPattern> plist = new Vector<PPattern>(); plist.addAll((List<PPattern>) d.getParameterPatterns().clone()); if (d.getState() != null) { plist.add(AstFactory.newAIdentifierPattern(d.getState().getName().clone())); } else if (base.isVDMPP() && !af.createPAccessSpecifierAssistant().isStatic(d.getAccess())) { plist.add(AstFactory.newAIdentifierPattern(d.getName().getSelfName())); } parameters.add(plist); APreOpExp preop = AstFactory.newAPreOpExp(d.getName().clone(), d.getPrecondition(), null, d.getState()); AExplicitFunctionDefinition def = AstFactory.newAExplicitFunctionDefinition(d.getName().getPreName(d.getPrecondition().getLocation()), NameScope.GLOBAL, null, af.createAOperationTypeAssistant().getPreType((AOperationType) d.getType(), d.getState(), d.getClassDefinition(), af.createPAccessSpecifierAssistant().isStatic(d.getAccess())), parameters, preop, null, null, false, null); // Operation precondition functions are effectively not static as // their expression can directly refer to instance variables, even // though at runtime these are passed via a "self" parameter. def.setAccess(af.createPAccessSpecifierAssistant().getStatic(def, false)); def.setClassDefinition(d.getClassDefinition()); return def; }
if(node.getClassDefinition() != null && !_visitedNodes.contains(node.getClassDefinition())) node.getClassDefinition().apply(this, question);
if(node.getClassDefinition() != null && !_visitedNodes.contains(node.getClassDefinition())) node.getClassDefinition().apply(this);
if(node.getClassDefinition() != null && !_visitedNodes.contains(node.getClassDefinition())) node.getClassDefinition().apply(this);
APostOpExp postop = AstFactory.newAPostOpExp(d.getName().clone(), d.getPrecondition(), d.getPostcondition(), null, d.getState()); AExplicitFunctionDefinition def = AstFactory.newAExplicitFunctionDefinition(d.getName().getPostName(d.getPostcondition().getLocation()), NameScope.GLOBAL, null, af.createAOperationTypeAssistant().getPostType((AOperationType) d.getType(), state, d.getClassDefinition(), af.createPAccessSpecifierAssistant().isStatic(d.getAccess())), parameters, postop, null, null, false, null); def.setClassDefinition(d.getClassDefinition()); return def;
if(node.getClassDefinition() != null && !_visitedNodes.contains(node.getClassDefinition())) mergeReturns(retVal,node.getClassDefinition().apply(this));
if(node.getClassDefinition() != null && !_visitedNodes.contains(node.getClassDefinition())) mergeReturns(retVal,node.getClassDefinition().apply(this, question));
@Override public void caseAExplicitOperationDefinition( AExplicitOperationDefinition node, NewQuestion question) throws AnalysisException { node.setType(af.createPTypeAssistant().typeResolve(node.getType(), null, question.rootVisitor, question.question)); if (question.question.env.isVDMPP()) { node.getName().setTypeQualifier(((AOperationType) node.getType()).getParameters()); if (node.getName().getName().equals(node.getClassDefinition().getName().getName())) { node.setIsConstructor(true); node.getClassDefinition().setHasContructors(true); } } if (node.getPrecondition() != null) { node.getPredef().apply(this, question); } if (node.getPostcondition() != null) { node.getPostdef().apply(this, question); } for (PPattern p : node.getParameterPatterns()) { af.createPPatternAssistant().typeResolve(p, question.rootVisitor, question.question); } }
if (node.getIsConstructor() && node.getClassDefinition() != null && node.getClassDefinition().getInvariant() != null)
if (ctype.getClassdef() != node.getClassDefinition()) + node.getClassDefinition().getName().getName(), node.getLocation(), node); if (!question.assistantFactory.getLexNameTokenAssistant().isEqual(ctype.getClassdef().getName(), node.getClassDefinition().getName())) + node.getClassDefinition().getName().getName(), node.getLocation(), node); + node.getClassDefinition().getName().getName(), node.getLocation(), node);