bool ComputationDependencyGraph::checkInternalState() { bool isValid = true; lassert(!mDirtyPriorities.size()); for (auto it = mAllPriorities.begin(); it != mAllPriorities.end(); ++it) if (it->second != computePriorityFor(it->first)) { LOG_WARN << "ComputationDependencyGraph had " << prettyPrintString(it->second) << " as priority for " << prettyPrintString(it->first) << " instead of " << prettyPrintString(computePriorityFor(it->first)); isValid = false; } for (auto it = mRootToRootDependencies.getKeysToValues().begin(); it != mRootToRootDependencies.getKeysToValues().end();++it) if (mAllPriorities.find(it->first) == mAllPriorities.end() && !computePriorityFor(it->first).isNull()) { LOG_WARN << "ComputationDependencyGraph had dependencies for " << prettyPrintString(it->first) << " but no priority." ; isValid = false; } return isValid; }
std::string ArbitraryNativeConstantForCSTValue::description() { if (mAsImplval) return "ImplValContainer(" + prettyPrintString(mValue) + ")"; else return "TypedValue(type=" + prettyPrintString(mValue.type()) + ",data=" + prettyPrintString(mValue) + ")"; }
string ContinuationElement::toString(void) const { if (mContinuationPtr->mRequiresResult) return "[" + prettyPrintString(mFilter) + "] -> " + prettyPrintString(mTargetInstructionPtr->toString(true)); else return " -> " + prettyPrintString(mTargetInstructionPtr->toString(true)); }
VectorRecord VectorRecord::canonicallySliced( MemoryPool* inPool, VectorDataManager* inVDM, hash_type newVectorHash ) const { if (!mDataPtr) return VectorRecord(); VectorRecord res( mDataPtr->slice( indicesWithinHandle(), inPool, inVDM, newVectorHash ) ); lassert_dump( res.size() == size(), "Slicing a vector of size " << mDataPtr->size() << " with " << prettyPrintString(indicesWithinHandle()) << " produced " << res.size() << ". Expected " << indicesWithinHandle().size() << "\n\nHandle = " << mDataPtr ); return res; }
NativeType nativeTypeForCppmlTuple() { //get a list of types and offsets into the tuple ImmutableTreeVector<pair<NativeType, uword_t> > offsets = NativeTypeForCppmlTupleImpl<T, typename T::metadata>::get(); NativeType resultType = NativeType::Composite(); //build up the tuple type one field at a time for (long k = 0; k < offsets.size();k++) { if (offsets[k].second == resultType.packedSize()) resultType = resultType + offsets[k].first; else if (offsets[k].second < resultType.packedSize()) { //the sizes should have been linearly increasing lassert_dump(false, "inconsistent typing found: " + prettyPrintString(offsets)); } else { //add enough padding to compensate for the extra bytes that C++ places in between //members to get alignment resultType = resultType + NativeType::Composite( NativeType::Array( NativeType::Integer(8,false), offsets[k].second - resultType.packedSize() ) ); resultType = resultType + offsets[k].first; } } lassert(resultType.packedSize() <= sizeof(T)); if (resultType.packedSize() < sizeof(T)) resultType = resultType + NativeType::Composite( NativeType::Array( NativeType::Integer(8,false), sizeof(T) - resultType.packedSize() ) ); return resultType; }
Fora::ReturnValue<VectorRecord, VectorLoadRequest> VectorRecord::deepcopiedAndContiguous(MemoryPool* inPool, VectorDataManager* inVDM) const { if (!dataPtr()) return Fora::slot0(*this); lassert(!inPool->isBigVectorHandle()); VectorHandle* handle = dataPtr(); if (!allValuesAreLoaded()) return Fora::slot1(VectorLoadRequest(*this)); ForaValueArray* array = ForaValueArray::Empty(inPool); int64_t curIndex = 0; while (curIndex < size()) { TypedFora::Abi::ForaValueArraySlice slice = sliceForOffset(curIndex); lassert(slice.mapping().indexIsValid(curIndex)); lassert_dump( slice.array(), "We should have guaranteed that this value was loaded by calling 'allValuesAreLoaded'" ); Nullable<int64_t> unmappedIndex = slice.firstValueNotLoadedInRange( curIndex, slice.mapping().highIndex() ); lassert_dump( !unmappedIndex, "Index " << *unmappedIndex << " is unmapped in " << prettyPrintString(slice) << " of size " << size() ); if (slice.mapping().stride() == 1) { array->append( *slice.array(), slice.mapping().offsetForIndex(curIndex), slice.mapping().offsetForIndex(slice.mapping().highIndex()) ); } else { while (curIndex < slice.mapping().highIndex()) { int64_t indexInTarget = slice.mapping().offsetForIndex(curIndex); array->append(*slice.array(), indexInTarget, indexInTarget+1); curIndex++; } } curIndex = slice.mapping().highIndex(); } lassert(array->size() == size()); return Fora::slot0( VectorRecord( inPool->construct<VectorHandle>( Fora::BigVectorId(), Fora::PageletTreePtr(), array, inPool, vectorHandleHash() ) ) ); }
static int prettyPrintItem(FILE *out, const unsigned char *data, const unsigned char *end, unsigned int lv, PRBool raw) { int slen; int lenLen; const unsigned char *orig = data; int rv; while (data < end) { unsigned char code; PRBool indefinite; slen = prettyPrintTag(out, data, end, &code, lv, raw); if (slen < 0) return slen; data += slen; lenLen = prettyPrintLength(out, data, end, &slen, &indefinite, lv, raw); if (lenLen < 0) return lenLen; data += lenLen; /* * Just quit now if slen more bytes puts us off the end. */ if ((data + slen) > end) { PORT_SetError(SEC_ERROR_BAD_DER); return -1; } if (code & SEC_ASN1_CONSTRUCTED) { if (slen > 0 || indefinite) { slen = prettyPrintItem(out, data, slen == 0 ? end : data + slen, lv+1, raw); if (slen < 0) return slen; data += slen; } } else if (code == 0) { if (slen != 0 || lenLen != 1) { PORT_SetError(SEC_ERROR_BAD_DER); return -1; } break; } else { switch (code) { case SEC_ASN1_PRINTABLE_STRING: case SEC_ASN1_IA5_STRING: case SEC_ASN1_VISIBLE_STRING: rv = prettyPrintString(out, data, slen, lv+1, raw); if (rv < 0) return rv; break; case SEC_ASN1_UTC_TIME: rv = prettyPrintTime(out, data, slen, lv+1, raw, PR_TRUE); if (rv < 0) return rv; break; case SEC_ASN1_GENERALIZED_TIME: rv = prettyPrintTime(out, data, slen, lv+1, raw, PR_FALSE); if (rv < 0) return rv; break; case SEC_ASN1_OBJECT_ID: rv = prettyPrintObjectID(out, data, slen, lv+1, raw); if (rv < 0) return rv; break; case SEC_ASN1_BOOLEAN: /* could do nicer job */ case SEC_ASN1_INTEGER: /* could do nicer job */ case SEC_ASN1_BIT_STRING: /* could do nicer job */ case SEC_ASN1_OCTET_STRING: case SEC_ASN1_NULL: case SEC_ASN1_ENUMERATED: /* could do nicer job, as INTEGER */ case SEC_ASN1_UTF8_STRING: case SEC_ASN1_T61_STRING: /* print as printable string? */ case SEC_ASN1_UNIVERSAL_STRING: case SEC_ASN1_BMP_STRING: default: rv = prettyPrintLeaf(out, data, slen, lv+1); if (rv < 0) return rv; break; } data += slen; } } rv = prettyNewline(out); if (rv < 0) return rv; return data - orig; }