void cacheable_function::useLegacyCache(XQueryDiagnostics* aDiag) { if (isUpdating() || isVariadic()) { if (aDiag) { aDiag->add_warning( NEW_XQUERY_WARNING(zwarn::ZWST0005_CACHING_NOT_POSSIBLE, WARN_PARAMS(getName()->getStringValue(), isUpdating() ? ZED(ZWST0005_UPDATING) : ZED(ZWST0005_VARIADIC)), WARN_LOC(theLoc))); } theHasCache = false; return; } if (isSequential() || !isDeterministic()) { if (aDiag) { aDiag->add_warning( NEW_XQUERY_WARNING(zwarn::ZWST0006_CACHING_MIGHT_NOT_BE_INTENDED, WARN_PARAMS(getName()->getStringValue(), (isSequential() ? "sequential" : "non-deterministic")), WARN_LOC(theLoc))); } } parseCachingAnnotations(aDiag); theHasCache = true; theIsCacheAutomatic = false; theCacheAcrossSnapshots = true; }
/*! \reimp */ bool QFSFileEngine::supportsExtension(Extension extension) const { Q_D(const QFSFileEngine); if (extension == AtEndExtension && d->fh && isSequential()) return true; if (extension == FastReadLineExtension && d->fh) return true; if (extension == FastReadLineExtension && d->fd != -1 && isSequential()) return true; if (extension == UnMapExtension || extension == MapExtension) return true; return false; }
/*! \overload Opens the existing file descriptor \a fd in the given \a mode. \a handleFlags may be used to specify additional options. Returns true if successful; otherwise returns false. When a QFile is opened using this function, behaviour of close() is controlled by the AutoCloseHandle flag. If AutoCloseHandle is specified, and this function succeeds, then calling close() closes the adopted handle. Otherwise, close() does not actually close the file, but only flushes it. The QFile that is opened using this function is automatically set to be in raw mode; this means that the file input/output functions are slow. If you run into performance issues, you should try to use one of the other open functions. \warning If \a fd is not a regular file, e.g, it is 0 (\c stdin), 1 (\c stdout), or 2 (\c stderr), you may not be able to seek(). In those cases, size() returns \c 0. See QIODevice::isSequential() for more information. \warning For Windows CE you may not be able to call seek(), setSize(), fileTime(). size() returns \c 0. \warning Since this function opens the file without specifying the file name, you cannot use this QFile with a QFileInfo. \sa close() */ bool QFile::open(int fd, OpenMode mode, FileHandleFlags handleFlags) { Q_D(QFile); if (isOpen()) { qWarning("QFile::open: File (%s) already open", qPrintable(fileName())); return false; } if (mode & Append) mode |= WriteOnly; unsetError(); if ((mode & (ReadOnly | WriteOnly)) == 0) { qWarning("QFile::open: File access not specified"); return false; } if (d->openExternalFile(mode, fd, handleFlags)) { QIODevice::open(mode); if (!(mode & Append) && !isSequential()) { qint64 pos = (qint64)QT_LSEEK(fd, QT_OFF_T(0), SEEK_CUR); if (pos != -1) { // Skip redundant checks in QFileDevice::seek(). QIODevice::seek(pos); } } return true; } return false; }
void Operator::outputVHDLEntity(std::ostream& o) { unsigned int i; if(isSequential() && getClkName().compare("") == 0) { std::cerr << "-- Can't find clock port for sequential component" << std::endl; } o << "entity " << uniqueName_ << " is" << endl; if (ioList_.size() > 0) { o << tab << "port ( " << endl; /* if(isSequential()) { o << getClkName() << " : in std_logic;" <<endl; std::string rst = getRstName(); if (rst.compare("") != 0) { o << rst << " : in std_logic;" <<endl; } } */ for (i=0; i<this->ioList_.size(); i++){ Signal* s = this->ioList_[i]; // if (i>0 || isSequential()) // align signal names // o<<" "; o<< tab << tab << tab << s->toVHDL(); if(i < this->ioList_.size()-1) o<<";" << endl; } o << endl << tab << ");"<<endl; } o << "end entity;" << endl << endl; }
qint64 QByteDeviceWrappingIoDevice::size() const { if (isSequential()) return 0; return byteDevice->size(); }
QIODevice_ptr ResourceLoader::Load (const QStringList& pathVariants, bool open) const { const auto& path = GetPath (pathVariants); if (path.isNull ()) return {}; if (CachePathContents_.contains (path)) { auto result = std::make_shared<QBuffer> (); result->setData (*CachePathContents_ [path]); if (open) result->open (QIODevice::ReadOnly); return result; } auto result = std::make_shared<QFile> (path); if (!result->isSequential () && result->size () < CachePathContents_.maxCost () / 2) { if (result->open (QIODevice::ReadOnly)) { const auto& data = result->readAll (); CachePathContents_.insert (path, new QByteArray { data }, data.size ()); result->close (); } } if (open) result->open (QIODevice::ReadOnly); return result; }
/*! \reimp */ qint64 KDSaveFile::bytesAvailable() const { if( !isSequential() ) return QIODevice::bytesAvailable(); else return d->tmpFile ? d->tmpFile->bytesAvailable() : QIODevice::bytesAvailable(); }
string Operator::buildVHDLRegisters() { ostringstream o,l; if (isSequential()){ if(getClkName().compare("") == 0) { std::cerr << "-- Can't find clock port for sequential component" << std::endl; return ""; } std::string clk = getClkName(); o << "-- clkname = " << clk << endl; o << tab << "process("<< clk <<") begin\n" << tab << tab << "if "<< clk << "'event and "<< clk <<"= '1' then\n"; for(unsigned int i=0; i<signalList_.size(); i++) { Signal *s = signalList_[i]; if(s->getLifeSpan() >0) { for(int j=1; j <= s->getLifeSpan(); j++) l << tab <<tab << tab << s->delayedName(j) << " <= " << s->delayedName(j-1) <<";" << endl; } } // when there are not registers then we don't need that process stmnt if (l.str().compare("") == 0) return l.str(); o << l.str(); o << tab << tab << "end if;\n"; o << tab << "end process;\n"; } return o.str(); }
string Operator::use(string name) throw(std::string) { ostringstream e; e << "ERROR in use(), "; // just in case if(isSequential()) { Signal *s; try { s=getSignalByName(name); } catch (string e2) { e << endl << tab << e2; throw e.str(); } if(s->getCycle() < 0) { e << "signal " << name<< " doesn't have (yet?) a valid cycle"; throw e.str(); } if(s->getCycle() > currentCycle_) { ostringstream e; e << "active cycle of signal " << name<< " is later than current cycle, cannot delay it"; throw e.str(); } // update the lifeSpan of s s->updateLifeSpan( currentCycle_ - s->getCycle() ); return s->delayedName( currentCycle_ - s->getCycle() ); } else return name; }
void Operator::syncCycleFromSignal(string name, bool report) throw(std::string) { ostringstream e; e << "ERROR in syncCycleFromSignal, "; // just in case if(isSequential()) { Signal* s; try { s=getSignalByName(name); } catch (string e2) { e << endl << tab << e2; throw e.str(); } if( s->getCycle() < 0 ) { ostringstream o; o << "signal " << name << " doesn't have (yet?) a valid cycle"; throw o.str(); } // advance cycle if needed if (s->getCycle()>currentCycle_) currentCycle_ = s->getCycle(); if(report) vhdl << tab << "----------------Synchro barrier, entering cycle " << currentCycle_ << "----------------" << endl ; // automatically update pipeline depth of the operator if (currentCycle_ > pipelineDepth_) pipelineDepth_ = currentCycle_; } }
bool QTemporaryFile_QtDShell::__override_isSequential(bool static_call) const { if (static_call) { return QFile::isSequential(); } else { return isSequential(); } }
bool QLocalSocket_QtDShell::__override_isSequential(bool static_call) const { if (static_call) { return QLocalSocket::isSequential(); } else { return isSequential(); } }
bool QIODevice_QtDShell::__override_isSequential(bool static_call) const { if (static_call) { return QIODevice::isSequential(); } else { return isSequential(); } }
void Operator::nextCycle(bool report) { if(isSequential()) { currentCycle_ ++; if(report) vhdl << tab << "----------------Synchro barrier, entering cycle " << currentCycle_ << "----------------" << endl ; // automatically update pipeline depth of the operator if (currentCycle_ > pipelineDepth_) pipelineDepth_ = currentCycle_; } }
/*! \internal */ bool QFileDevicePrivate::putCharHelper(char c) { #ifdef QT_NO_QOBJECT return QIODevicePrivate::putCharHelper(c); #else // Cutoff for code that doesn't only touch the buffer. int writeBufferSize = writeBuffer.size(); if ((openMode & QIODevice::Unbuffered) || writeBufferSize + 1 >= QFILE_WRITEBUFFER_SIZE #ifdef Q_OS_WIN || ((openMode & QIODevice::Text) && c == '\n' && writeBufferSize + 2 >= QFILE_WRITEBUFFER_SIZE) #endif ) { return QIODevicePrivate::putCharHelper(c); } if (!(openMode & QIODevice::WriteOnly)) { if (openMode == QIODevice::NotOpen) qWarning("QIODevice::putChar: Closed device"); else qWarning("QIODevice::putChar: ReadOnly device"); return false; } // Make sure the device is positioned correctly. const bool sequential = isSequential(); if (pos != devicePos && !sequential && !q_func()->seek(pos)) return false; lastWasWrite = true; int len = 1; #ifdef Q_OS_WIN if ((openMode & QIODevice::Text) && c == '\n') { ++len; *writeBuffer.reserve(1) = '\r'; } #endif // Write to buffer. *writeBuffer.reserve(1) = c; if (!sequential) { pos += len; devicePos += len; if (!buffer.isEmpty()) buffer.skip(len); } return true; #endif }
string Operator::instance(Operator* op, string instanceName){ ostringstream o; // TODO add checks here? Check that all the signals are covered for instance if(isSequential() && getClkName().compare("") == 0) { std::cerr << "-- Can't find clock port for sequential component" << std::endl; } o << tab << instanceName << ": " << op->getName(); if (isSequential()) o << " -- pipelineDepth="<< op->getPipelineDepth(); o << endl; o << tab << tab << "port map ("; // build vhdl and erase portMap_ map<string,string>::iterator it; /* if(isSequential()) { o << " clk => clk, " << endl; o << tab <<tab << " rst => rst, " << endl; } */ it=op->portMap_.begin(); // if(isSequential()) // o << tab << tab << " " ; // else o << " " ; o<< (*it).first << " => " << (*it).second; //op->portMap_.erase(it); it++; for ( ; it != op->portMap_.end(); it++ ) { o << "," << endl; o << tab << tab << " " << (*it).first << " => " << (*it).second; //op->portMap_.erase(it); } o << ");" << endl; // add the operator to the subcomponent list subComponents_[op->getName()] = op; return o.str(); }
void cacheable_function::useStrictlyDeterministicCache(XQueryDiagnostics* aDiag) { if (isUpdating() || isSequential() || isVariadic()) { if (aDiag) { aDiag->add_warning( NEW_XQUERY_WARNING(zwarn::ZWST0005_CACHING_NOT_POSSIBLE, WARN_PARAMS(getName()->getStringValue(), isUpdating() ? ZED(ZWST0005_UPDATING) : (isSequential() ? ZED(ZWST0005_SEQUENTIAL) : ZED(ZWST0005_VARIADIC))), WARN_LOC(theLoc))); } theHasCache = false; } else { parseCachingAnnotations(aDiag); theHasCache = true; theIsCacheAutomatic = false; theCacheAcrossSnapshots = false; } }
void Operator::inPortMap(Operator* op, string componentPortName, string actualSignalName) throw(std::string) { Signal* formal; ostringstream e; string name; e << "ERROR in inPortMap(), "; // just in case if(isSequential()) { Signal *s; try { s=getSignalByName(actualSignalName); } catch (string e2) { e << endl << tab << e2; throw e.str(); } if(s->getCycle() < 0) { ostringstream e; e << "signal " << actualSignalName<< " doesn't have (yet?) a valid cycle"; throw e.str(); } if(s->getCycle() > currentCycle_) { ostringstream e; e << "active cycle of signal " << actualSignalName<< " is later than current cycle, cannot delay it"; throw e.str(); } // update the lifeSpan of s s->updateLifeSpan( currentCycle_ - s->getCycle() ); name = s->delayedName( currentCycle_ - s->getCycle() ); } else name = actualSignalName; try { formal=op->getSignalByName(componentPortName); } catch (string e2) { e << endl << tab << e2; throw e.str(); } if (formal->type()!=Signal::in){ e << "signal " << componentPortName << " of component " << op->getName() << " doesn't seem to be an input port"; throw e.str(); } // add the mapping to the mapping list of Op op->portMap_[componentPortName] = name; }
void Operator::outputVHDL(std::ostream& o, std::string name) { if(isSequential() && getClkName().compare("") == 0) { std::cerr << "-- Can't find clock port for sequential component." << std::endl; } licence(o); stdLibs(o); outputVHDLEntity(o); newArchitecture(o,name); o << buildVHDLComponentDeclarations(); o << buildVHDLSignalDeclarations(); beginArchitecture(o); o<<buildVHDLRegisters(); o << vhdl.str(); endArchitecture(o); }
PlanIter_t external_function::codegen( CompilerCB* /*cb*/, static_context* sctx, const QueryLoc& loc, std::vector<PlanIter_t>& argv, expr& ann) const { return new ExtFunctionCallIterator(sctx, loc, argv, this, theImpl, isUpdating(), isSequential(), theNamespace, theModuleSctx); }
string Operator::declare(string name, const int width, bool isbus) throw(std::string) { Signal* s; ostringstream e; // check the signals doesn't already exist if(signalMap_.find(name) != signalMap_.end()) { e << "ERROR in declare(), signal " << name<< " already exists"; throw e.str(); } // construct the signal (lifeSpan and cycle are reset to 0 by the constructor) s = new Signal(name, Signal::wire, width, isbus); // define its cycle if(isSequential()) s->setCycle(this->currentCycle_); // add the signal to signalMap and signalList signalList_.push_back(s); signalMap_[name] = s ; return name; }
/*! \reimp */ bool QFSFileEngine::extension(Extension extension, const ExtensionOption *option, ExtensionReturn *output) { Q_D(QFSFileEngine); if (extension == AtEndExtension && d->fh && isSequential()) return feof(d->fh); if (extension == MapExtension) { const MapExtensionOption *options = (MapExtensionOption*)(option); MapExtensionReturn *returnValue = static_cast<MapExtensionReturn*>(output); returnValue->address = d->map(options->offset, options->size, options->flags); return (returnValue->address != 0); } if (extension == UnMapExtension) { UnMapExtensionOption *options = (UnMapExtensionOption*)option; return d->unmap(options->address); } return false; }
void cacheable_function::useDefaultCachingSettings() { if (isVariadic() || isUpdating() || isSequential() || !isDeterministic()) { theHasCache = false; } else { if (!haveAtomicArgumentsAndReturnType()) { theHasCache = false; } else { theHasCache = true; theIsCacheAutomatic = true; theCacheAcrossSnapshots = false; } } }
void Operator::outPortMap(Operator* op, string componentPortName, string actualSignalName) throw(std::string) { Signal* formal; Signal* s; ostringstream e; e << "ERROR in outPortMap(), "; // just in case // check the signals doesn't already exist if(signalMap_.find(actualSignalName) != signalMap_.end()) { e << "signal " << actualSignalName << " already exists"; throw e.str(); } try { formal=op->getSignalByName(componentPortName); } catch (string e2) { e << endl << tab << e2; throw e.str(); } if (formal->type()!=Signal::out){ e << "signal " << componentPortName << " of component " << op->getName() << " doesn't seem to be an output port"; throw e.str(); } int width = formal -> width(); bool isbus = formal -> isBus(); // construct the signal (lifeSpan and cycle are reset to 0 by the constructor) s = new Signal(actualSignalName, Signal::wire, width, isbus); // define its cycle if(isSequential()) s->setCycle( this->currentCycle_ + op->getPipelineDepth() ); // add the signal to signalMap and signalList signalList_.push_back(s); signalMap_[actualSignalName] = s ; // add the mapping to the mapping list of Op op->portMap_[componentPortName] = actualSignalName; }
bool DhQAbstractSocket::DvhisSequential() const { return isSequential(); }
bool QFile::rename(const QString &newName) { Q_D(QFile); if (d->fileName.isEmpty()) { qWarning("QFile::rename: Empty or null file name"); return false; } if (d->fileName == newName) { d->setError(QFile::RenameError, tr("Destination file is the same file.")); return false; } if (!exists()) { d->setError(QFile::RenameError, tr("Source file does not exist.")); return false; } // If the file exists and it is a case-changing rename ("foo" -> "Foo"), // compare Ids to make sure it really is a different file. if (QFile::exists(newName)) { if (d->fileName.compare(newName, Qt::CaseInsensitive) || QFileSystemEngine::id(QFileSystemEntry(d->fileName)) != QFileSystemEngine::id(QFileSystemEntry(newName))) { // ### Race condition. If a file is moved in after this, it /will/ be // overwritten. On Unix, the proper solution is to use hardlinks: // return ::link(old, new) && ::remove(old); d->setError(QFile::RenameError, tr("Destination file exists")); return false; } #ifndef QT_NO_TEMPORARYFILE // This #ifndef disables the workaround it encloses. Therefore, this configuration is not recommended. #ifdef Q_OS_LINUX // rename() on Linux simply does nothing when renaming "foo" to "Foo" on a case-insensitive // FS, such as FAT32. Move the file away and rename in 2 steps to work around. QTemporaryFile tempFile(d->fileName + QStringLiteral(".XXXXXX")); tempFile.setAutoRemove(false); if (!tempFile.open(QIODevice::ReadWrite)) { d->setError(QFile::RenameError, tempFile.errorString()); return false; } tempFile.close(); if (!d->engine()->rename(tempFile.fileName())) { d->setError(QFile::RenameError, tr("Error while renaming.")); return false; } if (tempFile.rename(newName)) { d->fileEngine->setFileName(newName); d->fileName = newName; return true; } d->setError(QFile::RenameError, tempFile.errorString()); // We need to restore the original file. if (!tempFile.rename(d->fileName)) { d->setError(QFile::RenameError, errorString() + QLatin1Char('\n') + tr("Unable to restore from %1: %2"). arg(QDir::toNativeSeparators(tempFile.fileName()), tempFile.errorString())); } return false; #endif // Q_OS_LINUX #endif // QT_NO_TEMPORARYFILE } unsetError(); close(); if(error() == QFile::NoError) { if (d->engine()->rename(newName)) { unsetError(); // engine was able to handle the new name so we just reset it d->fileEngine->setFileName(newName); d->fileName = newName; return true; } if (isSequential()) { d->setError(QFile::RenameError, tr("Will not rename sequential file using block copy")); return false; } QFile out(newName); if (open(QIODevice::ReadOnly)) { if (out.open(QIODevice::WriteOnly | QIODevice::Truncate)) { bool error = false; char block[4096]; qint64 bytes; while ((bytes = read(block, sizeof(block))) > 0) { if (bytes != out.write(block, bytes)) { d->setError(QFile::RenameError, out.errorString()); error = true; break; } } if (bytes == -1) { d->setError(QFile::RenameError, errorString()); error = true; } if(!error) { if (!remove()) { d->setError(QFile::RenameError, tr("Cannot remove source file")); error = true; } } if (error) { out.remove(); } else { d->fileEngine->setFileName(newName); setPermissions(permissions()); unsetError(); setFileName(newName); } close(); return !error; } close(); } d->setError(QFile::RenameError, out.isOpen() ? errorString() : out.errorString()); } return false; }
bool QFile::rename(const QString &newName) { Q_D(QFile); if (d->fileName.isEmpty()) { qWarning("QFile::rename: Empty or null file name"); return false; } if (QFile(newName).exists()) { // ### Race condition. If a file is moved in after this, it /will/ be // overwritten. On Unix, the proper solution is to use hardlinks: // return ::link(old, new) && ::remove(old); d->setError(QFile::RenameError, tr("Destination file exists")); return false; } unsetError(); close(); if(error() == QFile::NoError) { if (fileEngine()->rename(newName)) { unsetError(); // engine was able to handle the new name so we just reset it d->fileEngine->setFileName(newName); d->fileName = newName; return true; } if (isSequential()) { d->setError(QFile::RenameError, tr("Will not rename sequential file using block copy")); return false; } QFile out(newName); if (open(QIODevice::ReadOnly)) { if (out.open(QIODevice::WriteOnly | QIODevice::Truncate)) { bool error = false; char block[4096]; qint64 bytes; while ((bytes = read(block, sizeof(block))) > 0) { if (bytes != out.write(block, bytes)) { d->setError(QFile::RenameError, out.errorString()); error = true; break; } } if (bytes == -1) { d->setError(QFile::RenameError, errorString()); error = true; } if(!error) { if (!remove()) { d->setError(QFile::RenameError, tr("Cannot remove source file")); error = true; } } if (error) { out.remove(); } else { d->fileEngine->setFileName(newName); setPermissions(permissions()); unsetError(); setFileName(newName); } close(); return !error; } close(); } d->setError(QFile::RenameError, out.isOpen() ? errorString() : out.errorString()); } return false; }
bool DhQIODevice::DvhisSequential() const { return isSequential(); }