@Override public String caseAIntLiteralExp(AIntLiteralExp node, IndentTracker question) throws AnalysisException { return Long.toString(node.getValue().getValue()); }
public PExp caseAIntegerPattern(AIntegerPattern node) throws AnalysisException { AIntLiteralExp exp = new AIntLiteralExp(); exp.setValue(node.getValue().clone()); addPossibleType(exp, node); return exp; }
/** * Sets the {@code _field} child of this {@link AFieldNumberExp} node. * @param value the new {@code _field} child of this {@link AFieldNumberExp} node */ public void setField(ILexIntegerToken value) { if (this._field != null) { this._field.parent(null); } if (value != null) { if (value.parent() != null) { value.parent().removeChild(value); } value.parent(this); } this._field = value; }
@Override public Value caseAFieldNumberExp(AFieldNumberExp node, Context ctxt) throws AnalysisException { BreakpointManager.getBreakpoint(node).check(node.getLocation(), ctxt); node.getField().getLocation().hit(); try { ValueList fields = node.getTuple().apply(VdmRuntime.getExpressionEvaluator(), ctxt).tupleValue(ctxt); Value r = fields.get((int) node.getField().getValue() - 1); if (r == null) { VdmRuntimeError.abort(node.getLocation(), 4007, "No such field in tuple: #" + node.getField(), ctxt); } return r; } catch (ValueException e) { return VdmRuntimeError.abort(node.getLocation(), e); } }
/** * Called by the {@link AIntegerPattern} node from {@link AIntegerPattern#apply(IAnalysis)}. * @param node the calling {@link AIntegerPattern} node */ public void caseAIntegerPattern(AIntegerPattern node, Q question) throws AnalysisException { _visitedNodes.add(node); inAIntegerPattern(node, question); { List<PDefinition> copy = new ArrayList<PDefinition>(node.getDefinitions()); for( PDefinition e : copy) { if(!_visitedNodes.contains(e)) { e.apply(this, question); } } } if(node.getValue() != null ) { node.getValue().apply(this, question); } outAIntegerPattern(node, question); }
public static PExp newAFieldNumberExp(PExp tuple, LexIntegerToken field) { AFieldNumberExp result = new AFieldNumberExp(); result.setLocation(tuple.getLocation()); result.setTuple(tuple); result.setField(field); result.getField().getLocation().executable(true); return result; }
@Override public PType caseAFieldNumberExp(AFieldNumberExp node, TypeCheckInfo question) throws AnalysisException { PExp tuple = node.getTuple(); question.qualifiers = null; PType type = tuple.apply(THIS, question.newConstraint(null)); node.setType(type); if (!question.assistantFactory.createPTypeAssistant().isProduct(type)) { TypeCheckerErrors.report(3094, "Field '#" + node.getField() + "' applied to non-tuple type", tuple.getLocation(), tuple); node.setType(AstFactory.newAUnknownType(node.getLocation())); return node.getType(); } AProductType product = question.assistantFactory.createPTypeAssistant().getProduct(type); long fn = node.getField().getValue(); if (fn > product.getTypes().size() || fn < 1) { TypeCheckerErrors.report(3095, "Field number does not match tuple size", node.getField().getLocation(), node.getField()); node.setType(AstFactory.newAUnknownType(node.getLocation())); return node.getType(); } node.setType(product.getTypes().get((int) fn - 1)); return node.getType(); }
/** * Called by the {@link AIntegerPattern} node from {@link AIntegerPattern#apply(IAnalysis)}. * @param node the calling {@link AIntegerPattern} node */ public void caseAIntegerPattern(AIntegerPattern node) throws AnalysisException { _visitedNodes.add(node); inAIntegerPattern(node); { List<PDefinition> copy = new ArrayList<PDefinition>(node.getDefinitions()); for( PDefinition e : copy) { if(!_visitedNodes.contains(e)) { e.apply(this); } } } if(node.getValue() != null ) { node.getValue().apply(this); } outAIntegerPattern(node); }
@Override public PType caseAIntegerPattern(AIntegerPattern pattern) throws AnalysisException { return typeOf(pattern.getValue().getValue(), pattern.getLocation()); }
/** * Called by the {@link AIntegerPattern} node from {@link AIntegerPattern#apply(IPOFAnalysis)}. * @param node the calling {@link AIntegerPattern} node */ public void caseAIntegerPattern(AIntegerPattern node) throws AnalysisException { _visitedNodes.add(node); inAIntegerPattern(node); { List<PDefinition> copy = new ArrayList<PDefinition>(node.getDefinitions()); for( PDefinition e : copy) { if(!_visitedNodes.contains(e)) { e.apply(this); } } } if(node.getValue() != null ) { node.getValue().apply(this); } outAIntegerPattern(node); }
/** * Sets the {@code _value} child of this {@link AIntLiteralExp} node. * @param value the new {@code _value} child of this {@link AIntLiteralExp} node */ public void setValue(ILexIntegerToken value) { if (this._value != null) { this._value.parent(null); } if (value != null) { if (value.parent() != null) { value.parent().removeChild(value); } value.parent(this); } this._value = value; }
@Override public SPatternIR caseAIntegerPattern(AIntegerPattern node, IRInfo question) throws AnalysisException { long value = node.getValue().getValue(); AIntPatternIR intPatternCg = new AIntPatternIR(); intPatternCg.setValue(value); return intPatternCg; }
/** * 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); }
/** * Sets the {@code _value} child of this {@link AIntegerPattern} node. * @param value the new {@code _value} child of this {@link AIntegerPattern} node */ public void setValue(ILexIntegerToken value) { if (this._value != null) { this._value.parent(null); } if (value != null) { if (value.parent() != null) { value.parent().removeChild(value); } value.parent(this); } this._value = value; }
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; }
/** * 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); }
@Override public List<NameValuePairList> caseAIntegerPattern(AIntegerPattern pattern, Newquestion question) throws AnalysisException { List<NameValuePairList> result = new Vector<NameValuePairList>(); try { if (question.expval.intValue(question.ctxt) != pattern.getValue().getValue()) { VdmRuntimeError.patternFail(4111, "Integer pattern match failed", pattern.getLocation()); } } catch (ValueException e) { VdmRuntimeError.patternFail(e, pattern.getLocation()); } result.add(new NameValuePairList()); return result; }
/** * 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); }
@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; }
/** * Called by the {@link AIntegerPattern} node from {@link AIntegerPattern#apply(IAnalysis)}. * @param node the calling {@link AIntegerPattern} node */ public A caseAIntegerPattern(AIntegerPattern node, Q question) throws AnalysisException { _visitedNodes.add(node); A retVal = createNewReturnValue(node, question); mergeReturns(retVal,inAIntegerPattern(node, question)); { List<PDefinition> copy = new ArrayList<PDefinition>(node.getDefinitions()); for( PDefinition e : copy) { if(!_visitedNodes.contains(e)) { mergeReturns(retVal,e.apply(this, question)); } } } if(node.getValue() != null ) { mergeReturns(retVal,node.getValue().apply(this, question)); } mergeReturns(retVal,outAIntegerPattern(node, question)); return retVal; }