public ACastUnaryExpIR consNextElementCall(STypeIR iteratorType, String iteratorName, STypeIR elementType, String nextElementMethod) { ACastUnaryExpIR cast = new ACastUnaryExpIR(); cast.setType(elementType.clone()); cast.setExp(consInstanceCall(iteratorType, iteratorName, elementType.clone(), nextElementMethod)); return cast; }
public ACastUnaryExpIR consNextElementCall(STypeIR instanceType, String instance, String member, ACompSeqExpIR seqComp) throws AnalysisException { STypeIR elementType = getSeqTypeCloned(seqComp).getSeqOf(); SExpIR nextCall = consInstanceCall(instanceType, instance, elementType.clone(), member); ACastUnaryExpIR cast = new ACastUnaryExpIR(); cast.setType(elementType.clone()); cast.setExp(nextCall); return cast; }
private ACastUnaryExpIR consObjId() { String paramName = tracePrefixes.callStmMethodParamName(); AIdentifierVarExpIR idVar = assist.getInfo().getExpAssistant().consIdVar(paramName, new AObjectTypeIR()); ACastUnaryExpIR castVar = new ACastUnaryExpIR(); castVar.setType(assist.consClassType(traceEnclosingClass)); castVar.setExp(idVar); return castVar; }
private AFieldNumberExpIR consTupleFieldExp( AIdentifierVarExpIR tuplePatternVar, int i, STypeIR currentType, boolean cast) { AFieldNumberExpIR fieldNumberExp = new AFieldNumberExpIR(); fieldNumberExp.setType(currentType.clone()); if (!cast) { fieldNumberExp.setTuple(tuplePatternVar.clone()); } else { ACastUnaryExpIR castedExp = new ACastUnaryExpIR(); castedExp.setType(tuplePatternVar.getType().clone()); castedExp.setExp(tuplePatternVar.clone()); fieldNumberExp.setTuple(castedExp); } fieldNumberExp.setField(new Long(1 + i)); return fieldNumberExp; }
private SExpIR correctTypes(SExpIR exp, STypeIR castedType) throws AnalysisException { if ((exp.getType() instanceof AUnknownTypeIR || exp.getType() instanceof AUnionTypeIR || castedType instanceof ATemplateTypeIR) && !(exp instanceof ACastUnaryExpIR) && !exp.getType().equals(castedType)) { ACastUnaryExpIR casted = new ACastUnaryExpIR(); casted.setType(castedType.clone()); casted.setExp(exp.clone()); transAssistant.replaceNodeWith(exp, casted); return casted; } return exp; }
public AAssignToExpStmIR castFieldObj(AAssignToExpStmIR assign, AFieldExpIR target, STypeIR possibleType) { ACastUnaryExpIR cast = new ACastUnaryExpIR(); cast.setType(possibleType.clone()); cast.setExp(target.getObject().clone()); AAssignToExpStmIR assignCopy = assign.clone(); AFieldExpIR fieldCopy = target.clone(); transAssistant.replaceNodeWith(fieldCopy.getObject(), cast); transAssistant.replaceNodeWith(assignCopy.getTarget(), fieldCopy); return assignCopy; }
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 SExpIR consStoreLookup(AIdentifierVarExpIR node, boolean noCast) { AClassTypeIR storeType = transAssistant.consClassType(tracePrefixes.storeClassName()); AIdentifierVarExpIR idArg = transAssistant.getInfo().getExpAssistant().consIdVar(idConstNameMap.get(node.getName()), new ANatNumericBasicTypeIR()); SExpIR call = transAssistant.consInstanceCall(storeType, tracePrefixes.storeVarName(), node.getType(), tracePrefixes.storeGetValueMethodName(), idArg); if (noCast || node.getType() instanceof AUnionTypeIR || node.getType() instanceof AUnknownTypeIR || node.getType() instanceof AObjectTypeIR) { return call; } else { ACastUnaryExpIR cast = new ACastUnaryExpIR(); cast.setType(node.getType().clone()); cast.setExp(call); return cast; } } }
private SExpIR consRecFieldExp(AIdentifierVarExpIR patternVar, int i, STypeIR currentType, boolean cast) { ARecordTypeIR recordType = (ARecordTypeIR) patternVar.getType(); AFieldDeclIR recordField = transAssistant.getInfo().getAssistantManager().getDeclAssistant().getFieldDecl(transAssistant.getInfo().getClasses(), recordType, i); String fieldName = recordField.getName(); AFieldExpIR fieldExp = consRecFieldExp(patternVar, currentType, fieldName); if (cast) { ACastUnaryExpIR casted = new ACastUnaryExpIR(); casted.setType(recordType.clone()); casted.setExp(fieldExp.getObject()); fieldExp.setObject(casted); } return fieldExp; }
@Override public SExpIR caseANarrowExp(ANarrowExp node, IRInfo question) throws AnalysisException { PExp exp = node.getTest(); PType type = null; if (node.getBasicType() != null) { type = node.getBasicType(); } else if (node.getTypedef() != null) { type = question.getTcFactory().createPDefinitionAssistant().getType(node.getTypedef()); } SExpIR expCg = exp.apply(question.getExpVisitor(), question); STypeIR typeCg; if (type != null) { typeCg = type.apply(question.getTypeVisitor(), question); } else { log.error("Could not find type of narrow expression"); typeCg = new AUnknownTypeIR(); typeCg.setSourceNode(new SourceNode(node)); } ACastUnaryExpIR cast = new ACastUnaryExpIR(); cast.setExp(expCg); cast.setType(typeCg); return cast; }
cast.setType(invParamCopy.getType().clone()); cast.setExp(paramVar.clone());
castTuple.setType(tupleType.clone()); castTuple.setExp(tuplePatternVar.clone()); tupleCheck.setTuple(castTuple);
cast.setType(etype); field.setObject(cast);
castedFieldExp.setType(currentType.clone()); castedFieldExp.setExp(obj.clone());
cast.setType(consClassType); cast.setExp(getInfo().getExpAssistant().consIdVar(traceTrans.getTracePrefixes().callStmMethodParamName(), consClassType.clone()));
castedVarExp.setType(currentType.clone()); castedVarExp.setExp(objExp.clone());