@Override public List<PDefinition> caseAExplicitOperationDefinition( AExplicitOperationDefinition node) throws AnalysisException { List<PDefinition> defs = new Vector<PDefinition>(); defs.add(node); if (Settings.dialect == Dialect.VDM_SL || Settings.release == Release.CLASSIC) { if (node.getPredef() != null) { defs.add(node.getPredef()); } if (node.getPostdef() != null) { defs.add(node.getPostdef()); } } return defs; }
@Override public PExp caseAExplicitOperationDefinition( AExplicitOperationDefinition def, Integer lineno) throws AnalysisException { if (def.getPredef() != null) { PExp found = def.getPredef().apply(THIS, lineno); if (found != null) { return found; } } if (def.getPostdef() != null) { PExp found = def.getPostdef().apply(THIS, lineno); if (found != null) { return found; } } return af.createPStmAssistant().findExpression(def.getBody(), lineno); }
@Override public LexNameSet caseAExplicitOperationDefinition(AExplicitOperationDefinition node, FreeVarInfo info) throws AnalysisException { List<PDefinition> defs = new Vector<PDefinition>(); if (node.getParamDefinitions() != null) { defs.addAll(node.getParamDefinitions()); } FreeVarInfo local = info.set(new FlatEnvironment(af, defs, info.env)); LexNameSet names = node.getBody().apply(this, local); if (node.getPredef() != null) { names.addAll(node.getPredef().apply(this, local)); } if (node.getPostdef() != null) { names.addAll(node.getPostdef().apply(this, local)); } return names; }
@Override public PDefinition caseAExplicitOperationDefinition( AExplicitOperationDefinition node, Newquestion question) throws AnalysisException { if (af.createPDefinitionAssistant().findNameBaseCase(node, question.sought, question.scope) != null) { return node; } if (Settings.dialect == Dialect.VDM_SL || Settings.release == Release.CLASSIC) { PDefinition predef = node.getPredef(); if (predef != null && predef.apply(this, question) != null) { return predef; } PDefinition postdef = node.getPostdef(); if (postdef != null && postdef.apply(this, question) != null) { return postdef; } } return null; }
@Override public NameValuePairList caseAExplicitOperationDefinition( AExplicitOperationDefinition def, Context initialContext) throws AnalysisException { NameValuePairList nvl = new NameValuePairList(); FunctionValue prefunc = def.getPredef() == null ? null : new FunctionValue(def.getPredef(), null, null, null); FunctionValue postfunc = def.getPostdef() == null ? null : new FunctionValue(def.getPostdef(), null, null, null); OperationValue op = new OperationValue(def, prefunc, postfunc, def.getState(), af); op.isConstructor = def.getIsConstructor(); op.isStatic = af.createPAccessSpecifierAssistant().isStatic(def.getAccess()); nvl.add(new NameValuePair(def.getName(), op)); if (def.getPredef() != null) { prefunc.isStatic = af.createPAccessSpecifierAssistant().isStatic(def.getAccess()); nvl.add(new NameValuePair(def.getPredef().getName(), prefunc)); } if (def.getPostdef() != null) { postfunc.isStatic = af.createPAccessSpecifierAssistant().isStatic(def.getAccess()); nvl.add(new NameValuePair(def.getPostdef().getName(), postfunc)); } return nvl; }
public ParameterPatternObligation(AExplicitOperationDefinition def, IPOContextStack ctxt, IPogAssistantFactory af) throws AnalysisException { super(def, POType.OPERATION_PATTERNS, ctxt, def.getLocation(), af); this.assistantFactory = af; stitch = generate(def.getPredef(), cloneListPatternList(assistantFactory.createAExplicitOperationDefinitionAssistant().getParamPatternList(def)), cloneListType(((AOperationType) def.getType()).getParameters()), ((AOperationType) def.getType()).getResult().clone()); valuetree.setPredicate(ctxt.getPredWithContext(stitch)); }
@Override public void caseAExplicitOperationDefinition( AExplicitOperationDefinition node, Environment question) throws AnalysisException { node.setState(findStateDefinition(question, node)); if (node.getPrecondition() != null) { node.setPredef(af.createAExplicitOperationDefinitionAssistant().getPreDefinition(node, question)); af.createPDefinitionAssistant().markUsed(node.getPredef()); // ORIGINAL CODE } if (node.getPostcondition() != null) { node.setPostdef(af.createAExplicitOperationDefinitionAssistant().getPostDefinition(node, question)); af.createPDefinitionAssistant().markUsed(node.getPostdef()); } }
@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.getPredef() != null) pre.setEnclosingDefinition(node.getPredef()); pre.setFunctional(true); PType b = node.getPredef().getBody().apply(THIS, new TypeCheckInfo(question.assistantFactory, pre, NameScope.NAMESANDSTATE)); qualified = node.getPredef().getBody().apply(question.assistantFactory.getQualificationVisitor(), new TypeCheckInfo(question.assistantFactory, pre, NameScope.NAMESANDSTATE));