@Override public List<PDefinition> caseAImplicitOperationDefinition( AImplicitOperationDefinition 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 PDefinition caseAImplicitOperationDefinition( AImplicitOperationDefinition 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 LexNameSet caseAImplicitOperationDefinition(AImplicitOperationDefinition node, FreeVarInfo info) throws AnalysisException { List<PDefinition> defs = new Vector<PDefinition>(); for (APatternListTypePair pltp : node.getParameterPatterns()) { defs.addAll(getDefinitions(pltp, NameScope.LOCAL)); } FreeVarInfo local = info.set(new FlatEnvironment(af, defs, info.env)); LexNameSet names = new LexNameSet(); if (node.getBody() != null) { names.addAll(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 NameValuePairList caseAImplicitOperationDefinition( AImplicitOperationDefinition 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); // Note, body may be null if it is really implicit. This is caught // when the function is invoked. The value is needed to implement // the pre_() expression for implicit functions. 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(AImplicitOperationDefinition 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.createAImplicitOperationDefinitionAssistant().getListParamPatternList(def)), cloneListType(((AOperationType) def.getType()).getParameters()), ((AOperationType) def.getType()).getResult().clone()); valuetree.setPredicate(ctxt.getPredWithContext(stitch)); }
@Override public void caseAImplicitOperationDefinition( AImplicitOperationDefinition node, Environment question) throws AnalysisException { node.setState(findStateDefinition(question, node)); if (node.getPrecondition() != null) { node.setPredef(af.createAImplicitOperationDefinitionAssistant().getPreDefinition(node, question)); af.createPDefinitionAssistant().markUsed(node.getPredef()); } if (node.getPostcondition() != null) { node.setPostdef(af.createAImplicitOperationDefinitionAssistant().getPostDefinition(node, question)); af.createPDefinitionAssistant().markUsed(node.getPostdef()); } }
node.getPredef().apply(this, 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)); ABooleanBasicType expected = AstFactory.newABooleanBasicType(node.getLocation()); qualified = node.getPredef().getBody().apply(question.assistantFactory.getQualificationVisitor(), new TypeCheckInfo(question.assistantFactory, pre, NameScope.NAMESANDSTATE));