private ABlockStmIR initPattern(boolean declare, SPatternIR pattern, STypeIR type, SExpIR actualValue, AIdentifierPatternIR idPattern) { ABlockStmIR patternBlock = new ABlockStmIR(); if (declare) { AVarDeclIR patternDecl = transAssistant.getInfo().getDeclAssistant().consLocalVarDecl(type.clone(), idPattern.clone(), actualValue.clone()); patternBlock.getLocalDefs().add(patternDecl); } else { transAssistant.replaceNodeWith(pattern, idPattern); } return patternBlock; }
private ABlockStmIR consIdVarDeclaration(PatternInfo currentInfo, SPatternIR currentPattern) { AIdentifierPatternIR idPattern = (AIdentifierPatternIR) currentPattern; AVarDeclIR idPatternDecl = transAssistant.getInfo().getDeclAssistant().consLocalVarDecl(currentInfo.getType().clone(), idPattern.clone(), currentInfo.getActualValue().clone()); ABlockStmIR wrappingStatement = new ABlockStmIR(); wrappingStatement.getLocalDefs().add(idPatternDecl); return wrappingStatement; }
@Override public List<AVarDeclIR> getOuterBlockDecls(AIdentifierVarExpIR setVar, List<SPatternIR> patterns) throws AnalysisException { SExpIR emptyCollection = getEmptyCollection(); emptyCollection.setType(compType.clone()); AVarDeclIR compResultInit = transAssist.getInfo().getDeclAssistant().consLocalVarDecl(compType.clone(), idPattern.clone(), emptyCollection); return packDecl(compResultInit); } }
@Override public void caseALocalPatternAssignmentStmIR( ALocalPatternAssignmentStmIR node) throws AnalysisException { AVarDeclIR nextElementDecl = node.getNextElementDecl(); SPatternIR pattern = nextElementDecl.getPattern(); if (pattern instanceof AIdentifierPatternIR) { return; } if (pattern instanceof AIgnorePatternIR) { AIdentifierPatternIR idPattern = getIdPattern(config.getIgnorePatternPrefix()); transAssistant.replaceNodeWith(node.getTarget(), idPattern); transAssistant.replaceNodeWith(pattern, idPattern.clone()); return; } DeclarationTag tag = fetchTag(node); ABlockStmIR replacementBlock = consPatternHandlingInIterationBlock(nextElementDecl, tag, node.getExp()); transAssistant.replaceNodeWith(node, replacementBlock); }
AVarDeclIR patternDecl = transAssistant.getInfo().getDeclAssistant().consLocalVarDecl(actualValue.getType().clone(), idPattern.clone(), actualValue.clone()); block.getLocalDefs().add(patternDecl);