@Override public Boolean caseAValueDefinition(AValueDefinition node) throws AnalysisException { if (!(node.getPattern() != null && node.getPattern() instanceof AIdentifierPattern && isValidName(((AIdentifierPattern) node.getPattern()).getName()))) { invalidNodes.add(node); return false; } return true; }
@Override public LexNameList caseAValueDefinition(AValueDefinition node) throws AnalysisException { return af.createPPatternAssistant().getVariableNames(node.getPattern()); }
public ValueBindingObligation(AValueDefinition def, IPOContextStack ctxt, IPogAssistantFactory af) throws AnalysisException { this(def.getPattern(), def.getType(), def.getExpression(), ctxt, af); }
@Override public String caseAValueDefinition(AValueDefinition node, PrettyPrinterEnv question) throws AnalysisException { StringBuilder sb = new StringBuilder(question.getIdent()); sb.append(node.getPattern() + (node.getType() == null ? "" : ":" + node.getType().apply(typePrinter, question)) + (node.getExpression() != null ? " = " + node.getExpression() : ""));// node.toString()); return sb.toString() + ";"; }
if(node.getPattern() != null && !_visitedNodes.contains(node.getPattern())) node.getPattern().apply(this, question);
if(node.getPattern() != null && !_visitedNodes.contains(node.getPattern())) node.getPattern().apply(this);
if(node.getPattern() != null && !_visitedNodes.contains(node.getPattern())) node.getPattern().apply(this);
@Override public void caseAValueDefinition(AValueDefinition node, NewQuestion question) throws AnalysisException { if (node.getType() != null) { node.setType(af.createPTypeAssistant().typeResolve(node.getType(), null, question.rootVisitor, question.question)); af.createPPatternAssistant().typeResolve(node.getPattern(), question.rootVisitor, question.question); // af.createAValueDefinitionAssistant().updateDefs(node, question.question); updateDefs(node, question.question); } }
private AVarDeclIR consLocalVarDecl(AValueDefinition valueDef, IRInfo question) throws AnalysisException { STypeIR type = valueDef.getType().apply(question.getTypeVisitor(), question); SPatternIR pattern = valueDef.getPattern().apply(question.getPatternVisitor(), question); SExpIR exp = valueDef.getExpression().apply(question.getExpVisitor(), question); return consLocalVarDecl(valueDef, type, pattern, exp); }
if(node.getPattern() != null && !_visitedNodes.contains(node.getPattern())) mergeReturns(retVal,node.getPattern().apply(this));
if(node.getPattern() != null && !_visitedNodes.contains(node.getPattern())) mergeReturns(retVal,node.getPattern().apply(this, question));
@Override public SDeclIR caseAValueDefinition(AValueDefinition node, IRInfo question) throws AnalysisException { String access = node.getAccess().getAccess().toString(); String name = node.getPattern().toString(); boolean isStatic = true; boolean isFinal = true; PType type = node.getType(); PExp exp = node.getExpression(); STypeIR typeCg = type.apply(question.getTypeVisitor(), question); SExpIR expCg = exp.apply(question.getExpVisitor(), question); return question.getDeclAssistant().constructField(access, name, isStatic, isFinal, typeCg, expCg); }
@Override public NameValuePairList caseAValueDefinition(AValueDefinition def, Context initialContext) throws AnalysisException { Value v = null; try { // UpdatableValues are constantized as they cannot be updated. v = def.getExpression().apply(VdmRuntime.getExpressionEvaluator(), initialContext).convertTo(af.createPDefinitionAssistant().getType(def), initialContext).getConstant(); return af.createPPatternAssistant().getNamedValues(def.getPattern(), v, initialContext); } catch (ValueException e) { VdmRuntimeError.abort(def.getLocation(), e); } catch (PatternMatchException e) { VdmRuntimeError.abort(e, initialContext); } catch (AnalysisException e) { } return null; }
public void updateDefs(AValueDefinition node, TypeCheckInfo question) { PType type = node.getType(); PPattern pattern = node.getPattern(); List<PDefinition> newdefs = af.createPPatternAssistant().getDefinitions(pattern, type, node.getNameScope()); // The untyped definitions may have had "used" markers, so we copy // those into the new typed definitions, lest we get warnings. We // also mark the local definitions as "ValueDefintions" (proxies), // so that classes can be constructed correctly (values are statics). for (PDefinition d : newdefs) { for (PDefinition u : node.getDefs()) { if (u.getName().equals(d.getName())) { if (af.createPDefinitionAssistant().isUsed(u)) { af.createPDefinitionAssistant().markUsed(d); } break; } } ALocalDefinition ld = (ALocalDefinition) d; ld.setValueDefinition(node.clone()); } node.setDefs(newdefs); List<PDefinition> defs = node.getDefs(); af.createPDefinitionListAssistant().setAccessibility(defs, node.getAccess().clone()); af.createPDefinitionListAssistant().setClassDefinition(defs, node.getClassDefinition()); }
obligations.addAll(exp.apply(rootVisitor, question)); PPattern pattern = node.getPattern(); PType type = node.getType();