/** * Returns a deep clone of this {@link AIdentifierVarExpIR} node. * @return a deep clone of this {@link AIdentifierVarExpIR} node */ public AIdentifierVarExpIR clone() { return new AIdentifierVarExpIR( _sourceNode, _tag, _metaData, cloneNode(_type), _isLambda, _isLocal, _name ); }
/** * Creates a deep clone of this {@link AIdentifierVarExpIR} 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 AIdentifierVarExpIR} node */ public AIdentifierVarExpIR clone(Map<INode,INode> oldToNewMap) { AIdentifierVarExpIR node = new AIdentifierVarExpIR( _sourceNode, _tag, _metaData, cloneNode(_type, oldToNewMap), _isLambda, _isLocal, _name ); oldToNewMap.put(this, node); return node; }
private SVarExpIR consIdVar(String name, boolean isLambda, STypeIR typeCg, boolean isLocalDef) { AIdentifierVarExpIR varExp = new AIdentifierVarExpIR(); varExp.setType(typeCg); varExp.setIsLocal(isLocalDef); varExp.setName(name); varExp.setIsLambda(isLambda); return varExp; }
public AIdentifierVarExpIR consIdVar(String name, STypeIR type) { AIdentifierVarExpIR var = new AIdentifierVarExpIR(); var.setIsLambda(false); var.setIsLocal(true); var.setType(type); var.setName(name); return var; }
public AIdentifierVarExpIR consSuccessVar(String successVarName) { AIdentifierVarExpIR successVar = new AIdentifierVarExpIR(); successVar.setIsLambda(false); successVar.setIsLocal(true); successVar.setName(successVarName); successVar.setType(new ABoolBasicTypeIR()); return successVar; }
public AIdentifierVarExpIR consSetVar(String setName, SExpIR set) { if (set == null) { return null; } AIdentifierVarExpIR setVar = new AIdentifierVarExpIR(); STypeIR setType = set.getType().clone(); setVar.setType(setType); setVar.setName(setName); setVar.setIsLocal(true); return setVar; }
protected void replaceCompWithTransformation(SStmIR enclosingStm, ABlockStmIR block, STypeIR type, String var, SExpIR comp) { AIdentifierVarExpIR compResult = new AIdentifierVarExpIR(); compResult.setType(type.clone()); compResult.setName(var); compResult.setIsLambda(false); compResult.setIsLocal(true); transform(enclosingStm, block, compResult, comp); }
public AApplyExpIR consUtilCallUsingRecFields(ARecordDeclIR record, STypeIR returnType, String memberName) { LinkedList<AFieldDeclIR> fields = record.getFields(); AApplyExpIR call = consUtilCall(returnType, memberName); LinkedList<SExpIR> args = call.getArgs(); for (AFieldDeclIR field : fields) { AIdentifierVarExpIR nextArg = new AIdentifierVarExpIR(); nextArg.setName(field.getName()); nextArg.setType(field.getType().clone()); nextArg.setIsLocal(false); args.add(nextArg); } return call; } }
public ACallObjectExpStmIR consInstanceCallStm(STypeIR instanceType, String instanceName, String memberName, SExpIR... args) { AIdentifierVarExpIR instance = new AIdentifierVarExpIR(); instance.setName(instanceName); instance.setType(instanceType.clone()); instance.setIsLocal(true); ACallObjectExpStmIR call = new ACallObjectExpStmIR(); call.setType(new AVoidTypeIR()); call.setFieldName(memberName); call.setObj(instance); for (SExpIR arg : args) { call.getArgs().add(arg); } return call; }
public SExpIR consBoolCheck(String boolVarName, boolean negate) { AIdentifierVarExpIR boolVarExp = new AIdentifierVarExpIR(); boolVarExp.setType(new ABoolBasicTypeIR()); boolVarExp.setIsLocal(true); boolVarExp.setName(boolVarName); if (negate) { ANotUnaryExpIR negated = new ANotUnaryExpIR(); negated.setType(new ABoolBasicTypeIR()); negated.setExp(boolVarExp); return negated; } else { return boolVarExp; } }
public AIfStmIR consConditionalIncrement(String counterName, SExpIR predicate) { AIdentifierVarExpIR col = new AIdentifierVarExpIR(); col.setType(new AIntNumericBasicTypeIR()); col.setIsLambda(false); col.setIsLocal(true); col.setName(counterName); AIncrementStmIR inc = new AIncrementStmIR(); inc.setVar(col); AIfStmIR ifStm = new AIfStmIR(); ifStm.setIfExp(predicate); ifStm.setThenStm(inc); return ifStm; }
public SExpIR consLessThanCheck(String varName, long value) { AIdentifierVarExpIR left = new AIdentifierVarExpIR(); left.setType(new AIntNumericBasicTypeIR()); left.setIsLocal(true); left.setName(varName); AIntLiteralExpIR right = info.getExpAssistant().consIntLiteral(value); ALessNumericBinaryExpIR less = new ALessNumericBinaryExpIR(); less.setType(new ABoolBasicTypeIR()); less.setLeft(left); less.setRight(right); return less; }
public APlainCallStmIR consCallStm(AFieldDeclIR field) { APlainCallStmIR call = new APlainCallStmIR(); AExternalTypeIR classType = new AExternalTypeIR(); classType.setName(JavaFormat.UTILS_FILE); AIdentifierVarExpIR argument = new AIdentifierVarExpIR(); argument.setType(field.getType().clone()); argument.setIsLocal(false); argument.setName(field.getName()); call.setType(classType.clone()); call.setName("hashcode"); call.setClassType(classType.clone()); call.getArgs().add(argument); return call; }
@Override protected List<SStmIR> getConditionalAdd(AIdentifierVarExpIR setVar, List<SPatternIR> patterns, SPatternIR pattern) { AIdentifierVarExpIR mapCompResult = new AIdentifierVarExpIR(); mapCompResult.setType(compType.clone()); mapCompResult.setName(idPattern.getName()); mapCompResult.setIsLambda(false); mapCompResult.setIsLocal(true); AMapCompAddStmIR add = new AMapCompAddStmIR(); add.setMap(mapCompResult); add.setElement(first.clone()); return consConditionalAdd(mapCompResult, add); } }
@Override protected List<SStmIR> getConditionalAdd(AIdentifierVarExpIR setVar, List<SPatternIR> patterns, SPatternIR pattern) { AIdentifierVarExpIR seqCompResult = new AIdentifierVarExpIR(); seqCompResult.setType(compType.clone()); seqCompResult.setName(idPattern.getName()); seqCompResult.setIsLambda(false); seqCompResult.setIsLocal(true); ASeqCompAddStmIR add = new ASeqCompAddStmIR(); add.setSeq(seqCompResult); add.setElement(first.clone()); return consConditionalAdd(seqCompResult, add); }
@Override protected List<SStmIR> getConditionalAdd(AIdentifierVarExpIR setVar, List<SPatternIR> patterns, SPatternIR pattern) { AIdentifierVarExpIR setCompResult = new AIdentifierVarExpIR(); setCompResult.setType(compType.clone()); setCompResult.setName(idPattern.getName()); setCompResult.setIsLambda(false); setCompResult.setIsLocal(true); ASetCompAddStmIR add = new ASetCompAddStmIR(); add.setSet(setCompResult); add.setElement(first.clone()); return consConditionalAdd(setCompResult, add); } }
private AAssignToExpStmIR declareAndAssignIdVarAssignment( ABlockStmIR declBlock, SPatternIR currentPattern, STypeIR currentType, SExpIR valueToMatch) { AIdentifierPatternIR currentId = (AIdentifierPatternIR) currentPattern; AVarDeclIR idVarDecl = transAssistant.getInfo().getDeclAssistant().consLocalVarDecl(currentType.clone(), currentPattern.clone(), new AUndefinedExpIR()); declBlock.getLocalDefs().add(idVarDecl); AIdentifierVarExpIR var = new AIdentifierVarExpIR(); var.setType(currentType.clone()); var.setName(currentId.getName()); var.setIsLocal(true); var.setIsLambda(false); AAssignToExpStmIR localAssignment = new AAssignToExpStmIR(); localAssignment.setTarget(var); localAssignment.setExp(valueToMatch); return localAssignment; }
public AAddrNotEqualsBinaryExpIR consParamNotNullComp( AIdentifierVarExpIR param) { AAddrNotEqualsBinaryExpIR fieldComparison = new AAddrNotEqualsBinaryExpIR(); fieldComparison.setType(new ABoolBasicTypeIR()); AIdentifierVarExpIR instanceField = new AIdentifierVarExpIR(); instanceField.setType(param.getType().clone()); instanceField.setIsLocal(true); instanceField.setName(param.getName()); fieldComparison.setLeft(instanceField); fieldComparison.setRight(info.getExpAssistant().consNullExp()); return fieldComparison; }
public ABlockStmIR consVarFromCastedExp(ARecordDeclIR record, String formalParamName, String varName) throws AnalysisException { // Construct a local var in a statement: RecordType varName = ((RecordType) formalParamName); ARecordTypeIR recordType = new ARecordTypeIR(); recordType.setName(consTypeName(record)); AIdentifierPatternIR idPattern = new AIdentifierPatternIR(); idPattern.setName(varName); ACastUnaryExpIR cast = new ACastUnaryExpIR(); cast.setType(recordType.clone()); AIdentifierVarExpIR varExp = new AIdentifierVarExpIR(); varExp.setType(new AObjectTypeIR()); varExp.setName(formalParamName); varExp.setIsLocal(true); cast.setExp(varExp); AVarDeclIR localVar = info.getDeclAssistant().consLocalVarDecl(recordType, idPattern, cast); ABlockStmIR stm = new ABlockStmIR(); stm.getLocalDefs().add(localVar); return stm; }
public AIsOfClassExpIR consInstanceOf(ARecordDeclIR record, String formalParamName) { // Example: objRef instanceof classType ADefaultClassDeclIR enclosingClass = record.getAncestor(ADefaultClassDeclIR.class); ATypeNameIR typeName = new ATypeNameIR(); typeName.setDefiningClass(enclosingClass.getName()); typeName.setName(record.getName()); ARecordTypeIR recordType = new ARecordTypeIR(); recordType.setName(typeName); AIdentifierVarExpIR objRef = new AIdentifierVarExpIR(); objRef.setType(new AObjectTypeIR()); objRef.setIsLocal(true); objRef.setName(formalParamName); AIsOfClassExpIR instanceOfExp = new AIsOfClassExpIR(); instanceOfExp.setType(new ABoolBasicTypeIR()); instanceOfExp.setExp(objRef); instanceOfExp.setCheckedType(recordType); return instanceOfExp; }