public static SExpIR consIsExpQuoteType(SExpIR exp, AQuoteTypeIR quoteType) { AQuoteLiteralExpIR lit = new AQuoteLiteralExpIR(); lit.setType(quoteType); lit.setValue(quoteType.getValue()); AEqualsBinaryExpIR equals = new AEqualsBinaryExpIR(); equals.setType(new ABoolBasicTypeIR()); equals.setLeft(exp); equals.setRight(lit); return equals; }
@Override public List<SStmIR> getPostOuterBlockStms(AIdentifierVarExpIR setVar, List<SPatternIR> patterns) { AEqualsBinaryExpIR noMatches = new AEqualsBinaryExpIR(); noMatches.setType(new ABoolBasicTypeIR()); noMatches.setLeft(transAssist.getInfo().getExpAssistant().consIdVar(counterName, new AIntNumericBasicTypeIR())); noMatches.setRight(transAssist.getInfo().getExpAssistant().consIntLiteral(0)); AIfStmIR ifStm = new AIfStmIR(); ifStm.setIfExp(noMatches); ifStm.setThenStm(consIotaMultipleResultsError()); return packStm(ifStm); }
private ANotUnaryExpIR transNotEquals(ANotEqualsBinaryExpIR notEqual) { ANotUnaryExpIR notUnary = new ANotUnaryExpIR(); notUnary.setType(new ABoolBasicTypeIR()); AEqualsBinaryExpIR equal = new AEqualsBinaryExpIR(); equal.setType(new ABoolBasicTypeIR()); equal.setLeft(notEqual.getLeft().clone()); equal.setRight(notEqual.getRight().clone()); notUnary.setExp(equal); // Replace the "notEqual" expression with the transformed expression INode parent = notEqual.parent(); // It may be the case that the parent is null if we execute e.g. [1] <> [1] in isolation if (parent != null) { parent.replaceChild(notEqual, notUnary); notEqual.parent(null); } return notUnary; }
check.setType(new ABoolBasicTypeIR()); check.setLeft(var); check.setRight(valueToMatch);
@Override public void caseAExists1QuantifierExpIR(AExists1QuantifierExpIR node) throws AnalysisException { SStmIR enclosingStm = transAssistant.getEnclosingStm(node, "exists1 expression"); SExpIR predicate = node.getPredicate(); ITempVarGen tempVarNameGen = transAssistant.getInfo().getTempVarNameGen(); String var = tempVarNameGen.nextVarName(prefixes.exists1()); Exists1QuantifierStrategy strategy = consExists1QuantifierStrategy(predicate, tempVarNameGen, var); List<SMultipleBindIR> multipleSetBinds = filterBindList(node, node.getBindList()); ABlockStmIR block = transAssistant.consComplexCompIterationBlock(multipleSetBinds, tempVarNameGen, strategy, iteVarPrefixes); if (multipleSetBinds.isEmpty()) { ABoolLiteralExpIR exists1Result = transAssistant.getInfo().getExpAssistant().consBoolLiteral(false); transAssistant.replaceNodeWith(node, exists1Result); } else { AIdentifierVarExpIR counter = new AIdentifierVarExpIR(); counter.setType(new AIntNumericBasicTypeIR()); counter.setIsLocal(true); counter.setName(var); AEqualsBinaryExpIR exists1Result = new AEqualsBinaryExpIR(); exists1Result.setType(new ABoolBasicTypeIR()); exists1Result.setLeft(counter); exists1Result.setRight(transAssistant.getInfo().getExpAssistant().consIntLiteral(1)); transform(enclosingStm, block, exists1Result, node); block.apply(this); } }
public AEqualsBinaryExpIR consFieldComparison(ARecordDeclIR record, AFieldDeclIR field, String formalParamName) throws AnalysisException { // Example: fieldName == formalParamName.fieldName AEqualsBinaryExpIR fieldComparison = new AEqualsBinaryExpIR(); fieldComparison.setType(new ABoolBasicTypeIR()); AIdentifierVarExpIR instanceField = new AIdentifierVarExpIR(); instanceField.setType(field.getType().clone()); instanceField.setIsLocal(false); instanceField.setName(field.getName()); AFieldExpIR formalParamField = new AFieldExpIR(); formalParamField.setType(field.getType().clone()); AIdentifierVarExpIR formalParam = new AIdentifierVarExpIR(); ARecordTypeIR recordType = new ARecordTypeIR(); recordType.setName(consTypeName(record)); formalParam.setType(recordType); formalParam.setIsLocal(true); formalParam.setName(formalParamName); formalParamField.setObject(formalParam); formalParamField.setMemberName(field.getName()); fieldComparison.setLeft(instanceField); fieldComparison.setRight(formalParamField); return fieldComparison; }
nullCompare.setType(new ABoolBasicTypeIR()); nullCompare.setLeft(instanceVar); nullCompare.setRight(info.getExpAssistant().consNullExp());
hashcodeCompare.setType(new ABoolBasicTypeIR()); hashcodeCompare.setLeft(hashcodeVar); hashcodeCompare.setRight(consZero());