public CompStrategy(TransAssistantIR transformationAssistant, SExpIR predicate, String varName, STypeIR compType, ILanguageIterator langIterator, ITempVarGen tempGen, IterationVarPrefixes iteVarPrefixes) { super(transformationAssistant, langIterator, tempGen, iteVarPrefixes); this.predicate = predicate; AIdentifierPatternIR idPattern = new AIdentifierPatternIR(); idPattern.setName(varName); this.idPattern = idPattern; this.compType = compType; }
public String getName(SPatternIR id) { if (!(id instanceof AIdentifierPatternIR)) { log.error("Expected identifier pattern " + "to be an identifier pattern at this point. Got: " + id); return null; } return ((AIdentifierPatternIR) id).getName(); }
/** * Essentially this.toString().equals(o.toString()). **/ @Override public boolean equals(Object o) { if (o != null && o instanceof AIdentifierPatternIR) { return toString().equals(o.toString()); } return false; }
/** * Creates a new complete constructor {@code AIdentifierPatternIR} 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 name_ the {@link String} node for the {@code name} child of this {@link AIdentifierPatternIR} node */ public AIdentifierPatternIR(SourceNode sourceNode_, Object tag_, List<? extends ClonableString> metaData_, String name_) { super(sourceNode_,tag_,metaData_); this.setName(name_); }
/** * Returns a deep clone of this {@link AIdentifierPatternIR} node. * @return a deep clone of this {@link AIdentifierPatternIR} node */ public AIdentifierPatternIR clone() { return new AIdentifierPatternIR( _sourceNode, _tag, _metaData, _name ); }
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; }
/** * Creates a new tree field only constructor {@code AIdentifierPatternIR TAG=identifier} 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 name_ the {@link String} node for the {@code name} child of this {@link AIdentifierPatternIR} node */ public AIdentifierPatternIR(String name_) { super(null,null,null); this.setName(name_); }
/** * Creates a deep clone of this {@link AIdentifierPatternIR} 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 AIdentifierPatternIR} node */ public AIdentifierPatternIR clone(Map<INode,INode> oldToNewMap) { AIdentifierPatternIR node = new AIdentifierPatternIR( _sourceNode, _tag, _metaData, _name ); oldToNewMap.put(this, node); return node; }
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; }
public AIdentifierPatternIR consIdPattern(String name) { AIdentifierPatternIR idPattern = new AIdentifierPatternIR(); idPattern.setName(name); return idPattern; }
public String getMethodCondArgName(SPatternIR pattern) { // By now all patterns should be identifier patterns if (pattern instanceof AIdentifierPatternIR) { String paramName = ((AIdentifierPatternIR) pattern).getName(); if (jmlGen.getJavaGen().getInfo().getExpAssistant().isOld(paramName)) { paramName = toJmlOldExp(paramName); } else if (jmlGen.getJavaGen().getInfo().getExpAssistant().isResult(paramName)) { // The type checker prohibits use of 'RESULT' as name of a user specified identifier paramName = JmlGenerator.JML_RESULT; } return paramName; } else { log.error("Expected formal parameter pattern to be an indentifier pattern. Got: " + pattern); return "UNKNOWN"; } }
@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 SPatternIR caseAIdentifierPattern(AIdentifierPattern node, IRInfo question) throws AnalysisException { String name = node.getName().getName(); AIdentifierPatternIR idCg = new AIdentifierPatternIR(); idCg.setName(name); return idCg; }
String idConstName = idConstNameMap.get(idToReg.getName()); block.getStatements().add(transAssist.wrap(storeAssistant.consIdConstDecl(idConstName))); storeAssistant.appendStoreRegStms(block, idToReg.getName(), idConstName, false); traceVars.add(this.transAssist.getInfo().getExpAssistant().consIdVar(idToReg.getName(), PatternTypeFinder.getType(typeFinder, idToReg))); ACallObjectExpStmIR addCall = transAssist.consInstanceCallStm(instanceType, id.getName(), tracePrefixes.addMethodName(), subject); block.getStatements().add(addCall);
@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); }
private AIdentifierPatternIR getIdPattern(String namePrefix) { String name = transAssistant.getInfo().getTempVarNameGen().nextVarName(namePrefix); AIdentifierPatternIR idPattern = new AIdentifierPatternIR(); idPattern.setName(name); return idPattern; }
storeAssistant.getIdConstNameMap().put(occ.getName(), idConstName); outer.getLocalDefs().add(storeAssistant.consIdConstDecl(idConstName)); storeAssistant.appendStoreRegStms(declBlock, occ.getName(), idConstName, false); traceVars.add(getInfo().getExpAssistant().consIdVar(occ.getName(), PatternTypeFinder.getType(typeFinder, occ)));
@Override public List<AVarDeclIR> getOuterBlockDecls(AIdentifierVarExpIR setVar, List<SPatternIR> patterns) throws AnalysisException { if (firstBind) { IRInfo info = transAssist.getInfo(); AIdentifierPatternIR resId = new AIdentifierPatternIR(); resId.setName(resultVarName); List<AVarDeclIR> decls = new LinkedList<>(); STypeIR elemType = transAssist.getElementType(setVar.getType()); AUndefinedExpIR initExp = info.getExpAssistant().consUndefinedExp(); decls.add(info.getDeclAssistant().consLocalVarDecl(elemType, resId, initExp)); AIdentifierPatternIR countId = new AIdentifierPatternIR(); countId.setName(counterName); decls.add(consCounterDecl(info, countId)); return decls; } else { return null; } }
this.paramName = ((AIdentifierPatternIR) param.getPattern()).getName();