inASetRangeSetExp(node, question); if(node.getType() != null && !_visitedNodes.contains(node.getType())) node.getType().apply(this, question); if(node.getSetType() != null && !_visitedNodes.contains(node.getSetType())) node.getSetType().apply(this, question); if(node.getFirst() != null && !_visitedNodes.contains(node.getFirst())) node.getFirst().apply(this, question); if(node.getLast() != null && !_visitedNodes.contains(node.getLast())) node.getLast().apply(this, question); if(node.getFtype() != null && !_visitedNodes.contains(node.getFtype())) node.getFtype().apply(this, question); if(node.getLtype() != null && !_visitedNodes.contains(node.getLtype())) node.getLtype().apply(this, question);
/** * Creates a new complete constructor {@code ASetRangeSetExp} 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 first_ the {@link PExp} node for the {@code first} child of this {@link ASetRangeSetExp} node * @param last_ the {@link PExp} node for the {@code last} child of this {@link ASetRangeSetExp} node * @param ftype_ the {@link PType} <b>graph</a> node for the {@code ftype} child of this {@link ASetRangeSetExp} node. * <i>The parent of this {@code ftype } will not be changed by adding it to this node.</i> * @param ltype_ the {@link PType} <b>graph</a> node for the {@code ltype} child of this {@link ASetRangeSetExp} node. * <i>The parent of this {@code ltype } will not be changed by adding it to this node.</i> */ public ASetRangeSetExp(PType type_, ILexLocation location_, SSetType setType_, PExp first_, PExp last_, PType ftype_, PType ltype_) { super(type_,location_,setType_); this.setFirst(first_); this.setLast(last_); this.setFtype(ftype_); this.setLtype(ltype_); }
@Override public IProofObligationList caseASetRangeSetExp(ASetRangeSetExp node, IPOContextStack question) throws AnalysisException { PExp last = node.getLast(); PExp first = node.getFirst(); IProofObligationList obligations = first.apply(mainVisitor, question); obligations.addAll(last.apply(mainVisitor, question)); return obligations; }
@Override public PType caseASetRangeSetExp(ASetRangeSetExp node, TypeCheckInfo question) throws AnalysisException { PExp first = node.getFirst(); PExp last = node.getLast(); question.qualifiers = null; node.setFtype(first.apply(THIS, question.newConstraint(null))); question.qualifiers = null; node.setLtype(last.apply(THIS, question.newConstraint(null))); PType ftype = node.getFtype(); PType ltype = node.getLtype(); if (!question.assistantFactory.createPTypeAssistant().isNumeric(ftype)) { TypeCheckerErrors.report(3166, "Set range type must be a number", first.getLocation(), ftype); ftype = AstFactory.newAIntNumericBasicType(node.getLocation()); } SNumericBasicType ntype = question.assistantFactory.createPTypeAssistant().getNumeric(ftype); if (question.assistantFactory.createSNumericBasicTypeAssistant().getWeight(ntype) > 1) { ftype = AstFactory.newAIntNumericBasicType(node.getLocation()); // Caused by ceiling/floor } if (!question.assistantFactory.createPTypeAssistant().isNumeric(ltype)) { TypeCheckerErrors.report(3167, "Set range type must be a number", last.getLocation(), ltype); } node.setType(AstFactory.newASetSetType(first.getLocation(), ftype)); return question.assistantFactory.createPTypeAssistant().possibleConstraint(question.constraint, node.getType(), node.getLocation()); }
PType itype = AstFactory.newAIntNumericBasicType(exp.getLocation()); PExp s = oneType(true, range.getFirst(), itype, range.getFtype()); s = oneType(true, range.getFirst(), stype.getSetof(), range.getFtype()); s = oneType(true, range.getLast(), itype, range.getLtype()); s = oneType(true, range.getLast(), stype.getSetof(), range.getLtype());
@Override public SExpIR caseASetRangeSetExp(ASetRangeSetExp node, IRInfo question) throws AnalysisException { PType type = node.getType(); PExp firstExp = node.getFirst(); PExp lastExp = node.getLast(); STypeIR typeCg = type.apply(question.getTypeVisitor(), question); SExpIR firstExpCg = firstExp.apply(question.getExpVisitor(), question); SExpIR lastExpCg = lastExp.apply(question.getExpVisitor(), question); ARangeSetExpIR setRange = new ARangeSetExpIR(); setRange.setType(typeCg); setRange.setFirst(firstExpCg); setRange.setLast(lastExpCg); return setRange; }
@Override public Value caseASetRangeSetExp(ASetRangeSetExp node, Context ctxt) throws AnalysisException { BreakpointManager.getBreakpoint(node).check(node.getLocation(), ctxt); try { long from = (long) Math.ceil(node.getFirst().apply(VdmRuntime.getExpressionEvaluator(), ctxt).realValue(ctxt)); long to = (long) Math.floor(node.getLast().apply(VdmRuntime.getExpressionEvaluator(), ctxt).realValue(ctxt)); ValueSet set = new ValueSet(); for (long i = from; i <= to; i++) { set.addNoCheck(new IntegerValue(i)); } return new SetValue(set); } catch (ValueException e) { return VdmRuntimeError.abort(node.getLocation(), e); } }
inASetRangeSetExp(node); if(node.getType() != null && !_visitedNodes.contains(node.getType())) node.getType().apply(this); if(node.getSetType() != null && !_visitedNodes.contains(node.getSetType())) node.getSetType().apply(this); if(node.getFirst() != null && !_visitedNodes.contains(node.getFirst())) node.getFirst().apply(this); if(node.getLast() != null && !_visitedNodes.contains(node.getLast())) node.getLast().apply(this); if(node.getFtype() != null && !_visitedNodes.contains(node.getFtype())) node.getFtype().apply(this); if(node.getLtype() != null && !_visitedNodes.contains(node.getLtype())) node.getLtype().apply(this);
@Override public PExp caseASetRangeSetExp(ASetRangeSetExp exp, Integer lineno) throws AnalysisException { PExp found = findExpressionBaseCase(exp, lineno); if (found != null) { return found; } found = exp.getFirst().apply(THIS, lineno); if (found != null) { return found; } found = exp.getLast().apply(THIS, lineno); if (found != null) { return found; } return null; }
inASetRangeSetExp(node); if(node.getType() != null && !_visitedNodes.contains(node.getType())) node.getType().apply(this); if(node.getSetType() != null && !_visitedNodes.contains(node.getSetType())) node.getSetType().apply(this); if(node.getFirst() != null && !_visitedNodes.contains(node.getFirst())) node.getFirst().apply(this); if(node.getLast() != null && !_visitedNodes.contains(node.getLast())) node.getLast().apply(this); if(node.getFtype() != null && !_visitedNodes.contains(node.getFtype())) node.getFtype().apply(this); if(node.getLtype() != null && !_visitedNodes.contains(node.getLtype())) node.getLtype().apply(this);
mergeReturns(retVal,inASetRangeSetExp(node, question)); if(node.getType() != null && !_visitedNodes.contains(node.getType())) mergeReturns(retVal,node.getType().apply(this, question)); if(node.getSetType() != null && !_visitedNodes.contains(node.getSetType())) mergeReturns(retVal,node.getSetType().apply(this, question)); if(node.getFirst() != null && !_visitedNodes.contains(node.getFirst())) mergeReturns(retVal,node.getFirst().apply(this, question)); if(node.getLast() != null && !_visitedNodes.contains(node.getLast())) mergeReturns(retVal,node.getLast().apply(this, question)); if(node.getFtype() != null && !_visitedNodes.contains(node.getFtype())) mergeReturns(retVal,node.getFtype().apply(this, question)); if(node.getLtype() != null && !_visitedNodes.contains(node.getLtype())) mergeReturns(retVal,node.getLtype().apply(this, question));
mergeReturns(retVal,inASetRangeSetExp(node)); if(node.getType() != null && !_visitedNodes.contains(node.getType())) mergeReturns(retVal,node.getType().apply(this)); if(node.getSetType() != null && !_visitedNodes.contains(node.getSetType())) mergeReturns(retVal,node.getSetType().apply(this)); if(node.getFirst() != null && !_visitedNodes.contains(node.getFirst())) mergeReturns(retVal,node.getFirst().apply(this)); if(node.getLast() != null && !_visitedNodes.contains(node.getLast())) mergeReturns(retVal,node.getLast().apply(this)); if(node.getFtype() != null && !_visitedNodes.contains(node.getFtype())) mergeReturns(retVal,node.getFtype().apply(this)); if(node.getLtype() != null && !_visitedNodes.contains(node.getLtype())) mergeReturns(retVal,node.getLtype().apply(this));