@Override public PType caseAIntLiteralExp(AIntLiteralExp node, TypeCheckInfo question) { if (node.getValue().getValue() < 0) { node.setType(AstFactory.newAIntNumericBasicType(node.getLocation())); } else if (node.getValue().getValue() == 0) { node.setType(AstFactory.newANatNumericBasicType(node.getLocation())); } else { node.setType(AstFactory.newANatOneNumericBasicType(node.getLocation())); } return question.assistantFactory.createPTypeAssistant().checkConstraint(question.constraint, node.getType(), node.getLocation()); }
public static AIntLiteralExp newAIntLiteralExp(LexIntegerToken value) { AIntLiteralExp result = new AIntLiteralExp(); initExpression(result, value.location); result.setValue(value); return result; }
/** * Returns a deep clone of this {@link AIntLiteralExp} node. * @return a deep clone of this {@link AIntLiteralExp} node */ public AIntLiteralExp clone() { return new AIntLiteralExp( _type, _location, cloneNode(_value) ); }
/** * Called by the {@link AIntLiteralExp} node from {@link AIntLiteralExp#apply(IAnalysis)}. * @param node the calling {@link AIntLiteralExp} node */ public void caseAIntLiteralExp(AIntLiteralExp node) throws AnalysisException { _visitedNodes.add(node); inAIntLiteralExp(node); if(node.getType() != null && !_visitedNodes.contains(node.getType())) { node.getType().apply(this); } if(node.getValue() != null ) { node.getValue().apply(this); } outAIntLiteralExp(node); }
@Override public String caseAIntLiteralExp(AIntLiteralExp node, IndentTracker question) throws AnalysisException { return Long.toString(node.getValue().getValue()); }
@Override public Value caseAIntLiteralExp(AIntLiteralExp node, Context ctxt) throws AnalysisException { BreakpointManager.getBreakpoint(node).check(node.getLocation(), ctxt); try { return NumericValue.valueOf(node.getValue().getValue(), ctxt); } catch (ValueException e) { return VdmRuntimeError.abort(node.getLocation(), e); } }
/** * Creates a new complete constructor {@code AIntLiteralExp} 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 value_ the {@link ILexIntegerToken} node for the {@code value} child of this {@link AIntLiteralExp} node */ public AIntLiteralExp(PType type_, ILexLocation location_, ILexIntegerToken value_) { super(type_,location_); this.setValue(value_); }
public NonZeroObligation(ILexLocation location, PExp exp, IPOContextStack ctxt, IPogAssistantFactory af) throws AnalysisException { super(exp, POType.NON_ZERO, ctxt, location, af); // exp <> 0 AIntLiteralExp zeroExp = getIntLiteral(0); zeroExp.setType(new AIntNumericBasicType()); ANotEqualBinaryExp notEqualsExp = AstExpressionFactory.newANotEqualBinaryExp(exp.clone(), zeroExp); stitch = notEqualsExp; valuetree.setPredicate(ctxt.getPredWithContext(notEqualsExp)); } }
/** * Called by the {@link AIntLiteralExp} node from {@link AIntLiteralExp#apply(IAnalysis)}. * @param node the calling {@link AIntLiteralExp} node */ public void caseAIntLiteralExp(AIntLiteralExp node, Q question) throws AnalysisException { _visitedNodes.add(node); inAIntLiteralExp(node, question); if(node.getType() != null && !_visitedNodes.contains(node.getType())) { node.getType().apply(this, question); } if(node.getValue() != null ) { node.getValue().apply(this, question); } outAIntLiteralExp(node, question); }
private boolean neverZero(PExp exp) { if (exp instanceof AIntLiteralExp) { AIntLiteralExp il_Exp = (AIntLiteralExp) exp; if (il_Exp.getValue().getValue() != 0) { return true; } } if (exp instanceof ARealLiteralExp) { ARealLiteralExp rl_Exp = (ARealLiteralExp) exp; if (rl_Exp.getValue().getValue() != 0) { return true; } } return false; }
/** * Creates a deep clone of this {@link AIntLiteralExp} node while putting all * old node-new node relations in the map {@code oldToNewMap}. * @param oldToNewMap the map filled with the old node-new node relation * @return a deep clone of this {@link AIntLiteralExp} node */ public AIntLiteralExp clone(Map<INode,INode> oldToNewMap) { AIntLiteralExp node = new AIntLiteralExp( _type, _location, cloneNode(_value, oldToNewMap) ); oldToNewMap.put(this, node); return node; }
/** * Creates a new tree field only constructor {@code AIntLiteralExp TAG=intLiteral} 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 value_ the {@link ILexIntegerToken} node for the {@code value} child of this {@link AIntLiteralExp} node */ public AIntLiteralExp(ILexLocation location_, ILexIntegerToken value_) { super(null,location_); this.setValue(value_); }
/** * Called by the {@link AIntLiteralExp} node from {@link AIntLiteralExp#apply(IPOFAnalysis)}. * @param node the calling {@link AIntLiteralExp} node */ public void caseAIntLiteralExp(AIntLiteralExp node) throws AnalysisException { _visitedNodes.add(node); inAIntLiteralExp(node); if(node.getType() != null && !_visitedNodes.contains(node.getType())) { node.getType().apply(this); } if(node.getValue() != null ) { node.getValue().apply(this); } outAIntLiteralExp(node); }
speed = frequencyExp.getValue().getValue(); } else if (exp instanceof ARealLiteralExp)
/** * Generate an AIntLiteral from a long. */ protected AIntLiteralExp getIntLiteral(long i) { AIntLiteralExp number = new AIntLiteralExp(); ILexIntegerToken literal = new LexIntegerToken(i, null); number.setValue(literal); return number; }
/** * Called by the {@link AIntLiteralExp} node from {@link AIntLiteralExp#apply(IAnalysis)}. * @param node the calling {@link AIntLiteralExp} node */ public A caseAIntLiteralExp(AIntLiteralExp node, Q question) throws AnalysisException { _visitedNodes.add(node); A retVal = createNewReturnValue(node, question); mergeReturns(retVal,inAIntLiteralExp(node, question)); if(node.getType() != null && !_visitedNodes.contains(node.getType())) { mergeReturns(retVal,node.getType().apply(this, question)); } if(node.getValue() != null ) { mergeReturns(retVal,node.getValue().apply(this, question)); } mergeReturns(retVal,outAIntLiteralExp(node, question)); return retVal; }
public PExp caseAIntegerPattern(AIntegerPattern node) throws AnalysisException { AIntLiteralExp exp = new AIntLiteralExp(); exp.setValue(node.getValue().clone()); addPossibleType(exp, node); return exp; }
/** * Called by the {@link AIntLiteralExp} node from {@link AIntLiteralExp#apply(IAnalysis)}. * @param node the calling {@link AIntLiteralExp} node */ public A caseAIntLiteralExp(AIntLiteralExp node) throws AnalysisException { _visitedNodes.add(node); A retVal = createNewReturnValue(node); mergeReturns(retVal,inAIntLiteralExp(node)); if(node.getType() != null && !_visitedNodes.contains(node.getType())) { mergeReturns(retVal,node.getType().apply(this)); } if(node.getValue() != null ) { mergeReturns(retVal,node.getValue().apply(this)); } mergeReturns(retVal,outAIntLiteralExp(node)); return retVal; }
public SeqApplyObligation(PStateDesignator root, PExp arg, IPOContextStack ctxt, IPogAssistantFactory af) throws AnalysisException { super(root, POType.SEQ_APPLY, ctxt, root.getLocation(), af); // arg >0 AIntLiteralExp zeroExp = new AIntLiteralExp(); zeroExp.setValue(new LexIntegerToken(0, null)); AGreaterNumericBinaryExp grExp = AstExpressionFactory.newAGreaterNumericBinaryExp(arg.clone(), zeroExp); // len(root) ALenUnaryExp lenExp = new ALenUnaryExp(); PExp stateExp = root.apply(new StateDesignatorToExpVisitor()); lenExp.setExp(stateExp.clone()); // len(root)+1 AIntLiteralExp oneExp = new AIntLiteralExp(); oneExp.setValue(new LexIntegerToken(1, null)); APlusNumericBinaryExp plusExp = AstExpressionFactory.newAPlusNumericBinaryExp(lenExp, oneExp); // arg <= len(root) +1 ALessEqualNumericBinaryExp lteExp = AstExpressionFactory.newALessEqualNumericBinaryExp(arg.clone(), plusExp); // arg > 0 and arg <= len(root)+1 AAndBooleanBinaryExp andExp = AstExpressionFactory.newAAndBooleanBinaryExp(grExp, lteExp); stitch = andExp; valuetree.setPredicate(ctxt.getPredWithContext(stitch)); } }
@Override public SExpIR caseAIntLiteralExp(AIntLiteralExp node, IRInfo question) throws AnalysisException { PType type = node.getType(); long value = node.getValue().getValue(); STypeIR typeCg = type.apply(question.getTypeVisitor(), question); AIntLiteralExpIR intLitCg = new AIntLiteralExpIR(); intLitCg.setType(typeCg); intLitCg.setValue(value); return intLitCg; }