public POForAllContext(ALetBeStExp exp, IPogAssistantFactory assistantFactory) { this.bindings = cloneBinds(assistantFactory.createPMultipleBindAssistant().getMultipleBindList(exp.getBind())); }
@Override public void caseALetBeStExp(ALetBeStExp node) throws AnalysisException { if (inUnsupportedContext(node)) { info.addUnsupportedNode(node, "Generation of a let be st expression is only supported within operations/functions"); } node.getBind().apply(this); }
@Override public PType caseALetBeStExp(ALetBeStExp node, TypeCheckInfo question) throws AnalysisException { Entry<PType, AMultiBindListDefinition> res = typecheckLetBeSt(node, node.getLocation(), node.getBind(), node.getSuchThat(), node.getValue(), question); node.setDef(res.getValue()); node.setType(res.getKey()); return node.getType(); }
/** * Called by the {@link ALetBeStExp} node from {@link ALetBeStExp#apply(IAnalysis)}. * @param node the calling {@link ALetBeStExp} node */ public void caseALetBeStExp(ALetBeStExp node, Q question) throws AnalysisException { _visitedNodes.add(node); inALetBeStExp(node, question); if(node.getType() != null && !_visitedNodes.contains(node.getType())) { node.getType().apply(this, question); } if(node.getBind() != null && !_visitedNodes.contains(node.getBind())) { node.getBind().apply(this, question); } if(node.getSuchThat() != null && !_visitedNodes.contains(node.getSuchThat())) { node.getSuchThat().apply(this, question); } if(node.getValue() != null && !_visitedNodes.contains(node.getValue())) { node.getValue().apply(this, question); } if(node.getDef() != null && !_visitedNodes.contains(node.getDef())) { node.getDef().apply(this, question); } outALetBeStExp(node, question); }
/** * Called by the {@link ALetBeStExp} node from {@link ALetBeStExp#apply(IPOFAnalysis)}. * @param node the calling {@link ALetBeStExp} node */ public void caseALetBeStExp(ALetBeStExp node) throws AnalysisException { _visitedNodes.add(node); inALetBeStExp(node); if(node.getType() != null && !_visitedNodes.contains(node.getType())) { node.getType().apply(this); } if(node.getBind() != null && !_visitedNodes.contains(node.getBind())) { node.getBind().apply(this); } if(node.getSuchThat() != null && !_visitedNodes.contains(node.getSuchThat())) { node.getSuchThat().apply(this); } if(node.getValue() != null && !_visitedNodes.contains(node.getValue())) { node.getValue().apply(this); } if(node.getDef() != null && !_visitedNodes.contains(node.getDef())) { node.getDef().apply(this); } outALetBeStExp(node); }
/** * Called by the {@link ALetBeStExp} node from {@link ALetBeStExp#apply(IAnalysis)}. * @param node the calling {@link ALetBeStExp} node */ public void caseALetBeStExp(ALetBeStExp node) throws AnalysisException { _visitedNodes.add(node); inALetBeStExp(node); if(node.getType() != null && !_visitedNodes.contains(node.getType())) { node.getType().apply(this); } if(node.getBind() != null && !_visitedNodes.contains(node.getBind())) { node.getBind().apply(this); } if(node.getSuchThat() != null && !_visitedNodes.contains(node.getSuchThat())) { node.getSuchThat().apply(this); } if(node.getValue() != null && !_visitedNodes.contains(node.getValue())) { node.getValue().apply(this); } if(node.getDef() != null && !_visitedNodes.contains(node.getDef())) { node.getDef().apply(this); } outALetBeStExp(node); }
public LetBeExistsObligation(ALetBeStExp exp, IPOContextStack ctxt, IPogAssistantFactory af) throws AnalysisException { super(exp, POType.LET_BE_EXISTS, ctxt, exp.getBind().getLocation(), af); /** * let <binds> be st <predicate> in <exp> produces exists <binds> & <predicate> */ AExistsExp exists = new AExistsExp(); List<PMultipleBind> bindList = new Vector<PMultipleBind>(); bindList.add(exp.getBind().clone()); exists.setBindList(bindList); if (exp.getSuchThat() != null) { exists.setPredicate(exp.getSuchThat().clone()); } else { // we just use true since we cannot have // exists by itself ABooleanConstExp replacementNothing_exp = new ABooleanConstExp(); replacementNothing_exp.setValue(new LexBooleanToken(true, null)); exists.setPredicate(replacementNothing_exp); } stitch = exists; valuetree.setPredicate(ctxt.getPredWithContext(exists)); }
@Override public LexNameSet caseALetBeStExp(ALetBeStExp node, FreeVarInfo info) throws AnalysisException { PDefinition def = AstFactory.newAMultiBindListDefinition(node.getLocation(), af.createPMultipleBindAssistant().getMultipleBindList(node.getBind())); FreeVarInfo local = info.set(new FlatEnvironment(af, def, info.env)); LexNameSet names = node.getBind().apply(this, local); if (node.getSuchThat() != null) { names.addAll(node.getSuchThat().apply(this, local)); } names.addAll(node.getValue().apply(this, local)); return names; }
@Override public ValueList caseALetBeStExp(ALetBeStExp exp, ObjectContext ctxt) throws AnalysisException { ValueList list = ctxt.assistantFactory.createPMultipleBindAssistant().getValues(exp.getBind(), ctxt); if (exp.getSuchThat() != null) { list.addAll(exp.getSuchThat().apply(THIS, ctxt)); } list.addAll(exp.getValue().apply(THIS, ctxt)); return list; }
public LexNameList caseALetBeStExp(ALetBeStExp expression) throws org.overture.ast.analysis.AnalysisException { LexNameList list = expression.getBind().apply(this); if (expression.getSuchThat() != null) { list.addAll(af.createPExpAssistant().getOldNames(expression.getSuchThat())); } list.addAll(af.createPExpAssistant().getOldNames(expression.getValue())); return list; }
@Override public SExpIR caseALetBeStExp(ALetBeStExp node, IRInfo question) throws AnalysisException { PMultipleBind multipleBind = node.getBind(); SMultipleBindIR multipleBindCg = multipleBind.apply(question.getMultipleBindVisitor(), question); PType type = node.getType(); PExp suchThat = node.getSuchThat(); PExp value = node.getValue(); STypeIR typeCg = type.apply(question.getTypeVisitor(), question); SExpIR suchThatCg = suchThat != null ? suchThat.apply(question.getExpVisitor(), question) : null; SExpIR valueCg = value.apply(question.getExpVisitor(), question); ALetBeStExpIR letBeStExp = new ALetBeStExpIR(); AHeaderLetBeStIR header = question.getExpAssistant().consHeader(multipleBindCg, suchThatCg); letBeStExp.setType(typeCg); letBeStExp.setHeader(header); letBeStExp.setValue(valueCg); return letBeStExp; }
@Override // RWL See [1] pg.95 public IProofObligationList caseALetBeStExp(ALetBeStExp node, IPOContextStack question) throws AnalysisException { IProofObligationList obligations = new ProofObligationList(); obligations.add(new LetBeExistsObligation(node, question, aF)); obligations.addAll(node.getBind().apply(rootVisitor, question)); PExp suchThat = node.getSuchThat(); if (suchThat != null) { question.push(new POForAllContext(node, aF)); obligations.addAll(suchThat.apply(mainVisitor, question)); question.pop(); } question.push(new POForAllPredicateContext(node, aF)); obligations.addAll(node.getValue().apply(mainVisitor, question)); question.pop(); return obligations; }