/** * 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); }
@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(); }
/** * Creates a new complete constructor {@code ALetBeStExp} node with the given nodes as children. * @deprecated This method should not be used, use AstFactory instead. * The basic child nodes are removed from their previous parents. * @param bind_ the {@link PMultipleBind} node for the {@code bind} child of this {@link ALetBeStExp} node * @param suchThat_ the {@link PExp} node for the {@code suchThat} child of this {@link ALetBeStExp} node * @param value_ the {@link PExp} node for the {@code value} child of this {@link ALetBeStExp} node * @param def_ the {@link AMultiBindListDefinition} node for the {@code def} child of this {@link ALetBeStExp} node */ public ALetBeStExp(PType type_, ILexLocation location_, PMultipleBind bind_, PExp suchThat_, PExp value_, AMultiBindListDefinition def_) { super(type_,location_); this.setBind(bind_); this.setSuchThat(suchThat_); this.setValue(value_); this.setDef(def_); }
@Override public Value caseALetBeStExp(ALetBeStExp node, Context ctxt) throws AnalysisException { return evalLetBeSt(node, node.getLocation(), node.getDef(), node.getSuchThat(), node.getValue(), 4015, "expression", ctxt); }
@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; }
@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 void caseALetBeStExp(ALetBeStExp node) throws AnalysisException { if (!proceed(node)) { return; } node.getDef().apply(this); DefinitionInfo defInfo = new DefinitionInfo(node.getDef().getDefs(), af); openScope(defInfo, node); if (node.getSuchThat() != null) { node.getSuchThat().apply(this); } node.getValue().apply(this); endScope(defInfo); }
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 PExp caseALetBeStExp(ALetBeStExp exp, Integer lineno) throws AnalysisException { PExp found = findExpressionBaseCase(exp, lineno); if (found != null) { return found; } if (exp.getSuchThat() != null) { found = exp.getSuchThat().apply(THIS, lineno); if (found != null) { return found; } } return exp.getValue().apply(THIS, lineno); }
public POForAllContext(ALetBeStExp exp, IPogAssistantFactory assistantFactory) { this.bindings = cloneBinds(assistantFactory.createPMultipleBindAssistant().getMultipleBindList(exp.getBind())); }
public POForAllPredicateContext(ALetBeStExp exp, IPogAssistantFactory assistantFactory) { super(exp, assistantFactory); this.predicate = exp.getSuchThat(); }
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 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); }
/** * Creates a new tree field only constructor {@code ALetBeStExp TAG=letBeSt} node with the given nodes as children. * @deprecated This method should not be used, use AstFactory instead. * The basic child nodes are removed from their previous parents. * @param bind_ the {@link PMultipleBind} node for the {@code bind} child of this {@link ALetBeStExp} node * @param suchThat_ the {@link PExp} node for the {@code suchThat} child of this {@link ALetBeStExp} node * @param value_ the {@link PExp} node for the {@code value} child of this {@link ALetBeStExp} node * @param def_ the {@link AMultiBindListDefinition} node for the {@code def} child of this {@link ALetBeStExp} node */ public ALetBeStExp(ILexLocation location_, PMultipleBind bind_, PExp suchThat_, PExp value_, AMultiBindListDefinition def_) { super(null,location_); this.setBind(bind_); this.setSuchThat(suchThat_); this.setValue(value_); this.setDef(def_); }
/** * 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); }
@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; }
/** * 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); }
mergeReturns(retVal,inALetBeStExp(node)); if(node.getType() != null && !_visitedNodes.contains(node.getType())) mergeReturns(retVal,node.getType().apply(this)); if(node.getBind() != null && !_visitedNodes.contains(node.getBind())) mergeReturns(retVal,node.getBind().apply(this)); if(node.getSuchThat() != null && !_visitedNodes.contains(node.getSuchThat())) mergeReturns(retVal,node.getSuchThat().apply(this)); if(node.getValue() != null && !_visitedNodes.contains(node.getValue())) mergeReturns(retVal,node.getValue().apply(this)); if(node.getDef() != null && !_visitedNodes.contains(node.getDef())) mergeReturns(retVal,node.getDef().apply(this));
mergeReturns(retVal,inALetBeStExp(node, question)); if(node.getType() != null && !_visitedNodes.contains(node.getType())) mergeReturns(retVal,node.getType().apply(this, question)); if(node.getBind() != null && !_visitedNodes.contains(node.getBind())) mergeReturns(retVal,node.getBind().apply(this, question)); if(node.getSuchThat() != null && !_visitedNodes.contains(node.getSuchThat())) mergeReturns(retVal,node.getSuchThat().apply(this, question)); if(node.getValue() != null && !_visitedNodes.contains(node.getValue())) mergeReturns(retVal,node.getValue().apply(this, question)); if(node.getDef() != null && !_visitedNodes.contains(node.getDef())) mergeReturns(retVal,node.getDef().apply(this, question));
@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; }