/** * Now, a couple of patterns involve recursive calls to AND their components. * * @param node * @return * @throws AnalysisException */ @Override public Boolean caseARecordPattern(ARecordPattern node) throws AnalysisException { return alwaysMatches(node.getPlist()); }
@Override public void caseARecordPattern(ARecordPattern pattern) throws AnalysisException { pattern.getType().apply(THIS); pattern.setResolved(false); }
public static ARecordPattern newARecordPattern(ILexNameToken typename, List<PPattern> list) { ARecordPattern result = new ARecordPattern(); initPattern(result, typename.getLocation()); result.setPlist(list); result.setTypename(typename); result.setType(AstFactory.getAUnresolvedType(typename)); return result; }
/** * Creates a new complete constructor {@code ARecordPattern} 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 typename_ the {@link ILexNameToken} node for the {@code typename} child of this {@link ARecordPattern} node * @param plist_ the {@link NodeList} node for the {@code plist} child of this {@link ARecordPattern} node * @param type_ the {@link PType} <b>graph</a> node for the {@code type} child of this {@link ARecordPattern} node. * <i>The parent of this {@code type } will not be changed by adding it to this node.</i> */ public ARecordPattern(ILexLocation location_, List<? extends PDefinition> definitions_, Boolean resolved_, ILexNameToken typename_, List<? extends PPattern> plist_, PType type_) { super(location_,definitions_,resolved_); this.setTypename(typename_); this.setPlist(plist_); this.setType(type_); }
List<PDefinition> copy = new ArrayList<PDefinition>(node.getDefinitions()); for( PDefinition e : copy) if(node.getTypename() != null ) node.getTypename().apply(this); List<PPattern> copy = new ArrayList<PPattern>(node.getPlist()); for( PPattern e : copy) if(node.getType() != null && !_visitedNodes.contains(node.getType())) node.getType().apply(this);
} catch (ValueException e) VdmRuntimeError.patternFail(e, pattern.getLocation()); if (!question.ctxt.assistantFactory.getTypeComparator().compatible(pattern.getType(), exprec.type)) VdmRuntimeError.patternFail(4114, "Record type does not match pattern", pattern.getLocation()); if (fields.size() != pattern.getPlist().size()) VdmRuntimeError.patternFail(4115, "Record expression does not match pattern", pattern.getLocation()); int psize = pattern.getPlist().size(); int[] counts = new int[psize]; int i = 0; for (PPattern p : pattern.getPlist()) List<NameValuePairList> finalResults = new Vector<NameValuePairList>(); if (pattern.getPlist().isEmpty()) VdmRuntimeError.patternFail(4116, "Values do not match record pattern", pattern.getLocation()); VdmRuntimeError.patternFail(4116, "Values do not match record pattern", pattern.getLocation());
@Override public void caseARecordPattern(ARecordPattern pattern, NewQuestion question) throws AnalysisException { if (pattern.getResolved()) { return; } else { pattern.setResolved(true); } try { af.createPPatternListAssistant().typeResolve(pattern.getPlist(), question.rootVisitor, question.question); pattern.setType(af.createPTypeAssistant().typeResolve(pattern.getType(), null, question.rootVisitor, question.question)); } catch (TypeCheckException e) { af.createPPatternAssistant().unResolve(pattern); throw e; } }
@Override public SPatternIR caseARecordPattern(ARecordPattern node, IRInfo question) throws AnalysisException { String typeName = node.getTypename().getName(); PType type = node.getType(); STypeIR typeCg = type.apply(question.getTypeVisitor(), question); ARecordPatternIR recordPatternCg = new ARecordPatternIR(); recordPatternCg.setTypename(typeName); recordPatternCg.setType(typeCg); for (PPattern currentPattern : node.getPlist()) { SPatternIR patternCg = currentPattern.apply(question.getPatternVisitor(), question); if (patternCg != null) { recordPatternCg.getPatterns().add(patternCg); } else { return null; } } return recordPatternCg; } }
/** * Now, compound patterns involve recursive calls to expand their pattern components to expressions. * * @param node * @return * @throws AnalysisException */ public PExp caseARecordPattern(ARecordPattern node) throws AnalysisException { AMkTypeExp mkExp = new AMkTypeExp(); mkExp.setTypeName(node.getTypename().clone()); List<PExp> args = new Vector<PExp>(); for (PPattern p : node.getPlist()) { args.add(p.apply(this).clone()); } addPossibleType(mkExp, node); mkExp.setArgs(args); return mkExp; }
@Override public PType caseARecordPattern(ARecordPattern pattern) throws AnalysisException { return pattern.getType(); }
List<PDefinition> copy = new ArrayList<PDefinition>(node.getDefinitions()); for( PDefinition e : copy) if(node.getTypename() != null ) node.getTypename().apply(this, question); List<PPattern> copy = new ArrayList<PPattern>(node.getPlist()); for( PPattern e : copy) if(node.getType() != null && !_visitedNodes.contains(node.getType())) node.getType().apply(this, question);
PType type = pattern.getType(); TypeCheckerErrors.report(3200, "Mk_ expression is not a record type", pattern.getLocation(), pattern); TypeCheckerErrors.detail("Type", type); return defs; TypeCheckerErrors.report(3201, "Matching expression is not a compatible record type", pattern.getLocation(), pattern); TypeCheckerErrors.detail2("Pattern type", type, "Expression type", question.ptype); return defs; if (pattype.getFields().size() != pattern.getPlist().size()) TypeCheckerErrors.report(3202, "Record pattern argument/field count mismatch", pattern.getLocation(), pattern); } else for (PPattern p : pattern.getPlist())
List<PDefinition> copy = new ArrayList<PDefinition>(node.getDefinitions()); for( PDefinition e : copy) if(node.getTypename() != null ) node.getTypename().apply(this); List<PPattern> copy = new ArrayList<PPattern>(node.getPlist()); for( PPattern e : copy) if(node.getType() != null && !_visitedNodes.contains(node.getType())) node.getType().apply(this);
@Override public Boolean caseARecordPattern(ARecordPattern pattern) throws AnalysisException { return isConstrained(pattern.getPlist()); }
List<PDefinition> copy = new ArrayList<PDefinition>(node.getDefinitions()); for( PDefinition e : copy) if(node.getTypename() != null ) mergeReturns(retVal,node.getTypename().apply(this)); List<PPattern> copy = new ArrayList<PPattern>(node.getPlist()); for( PPattern e : copy) if(node.getType() != null && !_visitedNodes.contains(node.getType())) mergeReturns(retVal,node.getType().apply(this));
@Override public List<AIdentifierPattern> caseARecordPattern(ARecordPattern pattern) throws AnalysisException { List<AIdentifierPattern> list = new Vector<AIdentifierPattern>(); for (PPattern p : pattern.getPlist()) { list.addAll(p.apply(THIS)); } return list; }
List<PDefinition> copy = new ArrayList<PDefinition>(node.getDefinitions()); for( PDefinition e : copy) if(node.getTypename() != null ) mergeReturns(retVal,node.getTypename().apply(this, question)); List<PPattern> copy = new ArrayList<PPattern>(node.getPlist()); for( PPattern e : copy) if(node.getType() != null && !_visitedNodes.contains(node.getType())) mergeReturns(retVal,node.getType().apply(this, question));
@Override public Boolean caseARecordPattern(ARecordPattern pattern) throws AnalysisException { return af.createPPatternListAssistant().isSimple(pattern.getPlist()); }
@Override public Boolean caseARecordPattern(ARecordPattern pattern) throws AnalysisException { return af.createPPatternListAssistant().alwaysMatches(pattern.getPlist()); }
@Override public LexNameList caseARecordPattern(ARecordPattern pattern) throws AnalysisException { LexNameList list = new LexNameList(); for (PPattern p : pattern.getPlist()) { list.addAll(af.createPPatternAssistant().getAllVariableNames(p)); } return list; }