/** * Returns a deep clone of this {@link ARecordPatternIR} node. * @return a deep clone of this {@link ARecordPatternIR} node */ public ARecordPatternIR clone() { return new ARecordPatternIR( _sourceNode, _tag, _metaData, _typename, cloneList(_patterns), cloneNode(_type) ); }
/** * Creates a new complete constructor {@code ARecordPatternIR} 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 String} node for the {@code typename} child of this {@link ARecordPatternIR} node * @param patterns_ the {@link NodeList} node for the {@code patterns} child of this {@link ARecordPatternIR} node * @param type_ the {@link STypeIR} node for the {@code type} child of this {@link ARecordPatternIR} node */ public ARecordPatternIR(SourceNode sourceNode_, Object tag_, List<? extends ClonableString> metaData_, String typename_, List<? extends SPatternIR> patterns_, STypeIR type_) { super(sourceNode_,tag_,metaData_); this.setTypename(typename_); this.setPatterns(patterns_); this.setType(type_); }
/** * Called by the {@link ARecordPatternIR} node from {@link ARecordPatternIR#apply(IAnalysis)}. * @param node the calling {@link ARecordPatternIR} node */ public void caseARecordPatternIR(ARecordPatternIR node, Q question) throws AnalysisException { _visitedNodes.add(node); inARecordPatternIR(node, question); { List<SPatternIR> copy = new ArrayList<SPatternIR>(node.getPatterns()); for( SPatternIR e : copy) { if(!_visitedNodes.contains(e)) { e.apply(this, question); } } } if(node.getType() != null && !_visitedNodes.contains(node.getType())) { node.getType().apply(this, question); } outARecordPatternIR(node, question); }
@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; } }
private ARecordTypeIR consRecordType(ARecordPatternIR pat) { if(pat != null) { STypeIR patType = pat.getType(); if (patType instanceof ARecordTypeIR) { ARecordTypeIR recType = (ARecordTypeIR) patType; return recType.clone(); } else { ARecordTypeIR type = new ARecordTypeIR(); ATypeNameIR typeName = new ATypeNameIR(); typeName.setName(pat.getTypename()); typeName.setDefiningClass("?"); type.setName(typeName); log.warn("Could not determine defining class for record pattern " + pat); return type; } } else { return new ARecordTypeIR(); } }
STypeIR t = nextRecordPattern.getType();
ABlockStmIR fieldCheckBlock = consFieldCheckBlock(patternData, recordPatternVar, recordPattern.getPatterns(), types, checkRecordType && !declarePattern);
/** * Called by the {@link ARecordPatternIR} node from {@link ARecordPatternIR#apply(IAnalysis)}. * @param node the calling {@link ARecordPatternIR} node */ public void caseARecordPatternIR(ARecordPatternIR node) throws AnalysisException { _visitedNodes.add(node); inARecordPatternIR(node); { List<SPatternIR> copy = new ArrayList<SPatternIR>(node.getPatterns()); for( SPatternIR e : copy) { if(!_visitedNodes.contains(e)) { e.apply(this); } } } if(node.getType() != null && !_visitedNodes.contains(node.getType())) { node.getType().apply(this); } outARecordPatternIR(node); }
ARecordTypeIR recordType = (ARecordTypeIR) recordPattern.getType();
/** * Called by the {@link ARecordPatternIR} node from {@link ARecordPatternIR#apply(IIsaAnalysis)}. * @param node the calling {@link ARecordPatternIR} node */ public void caseARecordPatternIR(ARecordPatternIR node) throws AnalysisException { _visitedNodes.add(node); inARecordPatternIR(node); { List<SPatternIR> copy = new ArrayList<SPatternIR>(node.getPatterns()); for( SPatternIR e : copy) { if(!_visitedNodes.contains(e)) { e.apply(this); } } } if(node.getType() != null && !_visitedNodes.contains(node.getType())) { node.getType().apply(this); } outARecordPatternIR(node); }
/** * Creates a new tree field only constructor {@code ARecordPatternIR TAG=record} 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 String} node for the {@code typename} child of this {@link ARecordPatternIR} node * @param patterns_ the {@link NodeList} node for the {@code patterns} child of this {@link ARecordPatternIR} node * @param type_ the {@link STypeIR} node for the {@code type} child of this {@link ARecordPatternIR} node */ public ARecordPatternIR(String typename_, List<? extends SPatternIR> patterns_, STypeIR type_) { super(null,null,null); this.setTypename(typename_); this.setPatterns(patterns_); this.setType(type_); }
/** * Creates a deep clone of this {@link ARecordPatternIR} 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 ARecordPatternIR} node */ public ARecordPatternIR clone(Map<INode,INode> oldToNewMap) { ARecordPatternIR node = new ARecordPatternIR( _sourceNode, _tag, _metaData, _typename, cloneList(_patterns, oldToNewMap), cloneNode(_type, oldToNewMap) ); oldToNewMap.put(this, node); return node; }
@Override public void caseARecordPatternIR(ARecordPatternIR node, STypeIR question) throws AnalysisException { STypeIR type = node.getType(); storeType(node, type); if (type instanceof ARecordTypeIR) { ARecordTypeIR recType = (ARecordTypeIR) type; ARecordDeclIR rec = info.getDeclAssistant().findRecord(info.getClasses(), recType); if (rec.getFields().size() == node.getPatterns().size()) { for (int i = 0; i < node.getPatterns().size(); i++) { SPatternIR p = node.getPatterns().get(i); STypeIR t = rec.getFields().get(i).getType(); p.apply(this, t); } } else { log.error("Record patterns and record fields do not match in terms of size"); } } else { log.error("Expected record pattern to have a record type. Got: " + type); } }
/** * Called by the {@link ARecordPatternIR} node from {@link ARecordPatternIR#apply(IAnalysis)}. * @param node the calling {@link ARecordPatternIR} node */ public A caseARecordPatternIR(ARecordPatternIR node) throws AnalysisException { _visitedNodes.add(node); A retVal = createNewReturnValue(node); mergeReturns(retVal,inARecordPatternIR(node)); { List<SPatternIR> copy = new ArrayList<SPatternIR>(node.getPatterns()); for( SPatternIR e : copy) { if(!_visitedNodes.contains(e)) { mergeReturns(retVal,e.apply(this)); } } } if(node.getType() != null && !_visitedNodes.contains(node.getType())) { mergeReturns(retVal,node.getType().apply(this)); } mergeReturns(retVal,outARecordPatternIR(node)); return retVal; }
/** * Called by the {@link ARecordPatternIR} node from {@link ARecordPatternIR#apply(IAnalysis)}. * @param node the calling {@link ARecordPatternIR} node */ public A caseARecordPatternIR(ARecordPatternIR node, Q question) throws AnalysisException { _visitedNodes.add(node); A retVal = createNewReturnValue(node, question); mergeReturns(retVal,inARecordPatternIR(node, question)); { List<SPatternIR> copy = new ArrayList<SPatternIR>(node.getPatterns()); for( SPatternIR e : copy) { if(!_visitedNodes.contains(e)) { mergeReturns(retVal,e.apply(this, question)); } } } if(node.getType() != null && !_visitedNodes.contains(node.getType())) { mergeReturns(retVal,node.getType().apply(this, question)); } mergeReturns(retVal,outARecordPatternIR(node, question)); return retVal; }