void compiler::Script::handleElseIf(lang::Condition &condition) { // Pop the body fragment Fragment *body = current_fragment_.top(); current_fragment_.pop(); // Return the the continuation fragment getDialect()->gotoFragment(body, current_fragment_.top()); // Replace IF body fragment with the ELSEIF body fragment current_fragment_.push(newFragment()); // Create the jump to the current fragment if 'condition' is true getDialect()->conditionalJump(if_fragment_.top(), &condition, current_fragment_.top()); }
void compiler::Script::handleElse() { // Pop the body fragment Fragment *body = current_fragment_.top(); current_fragment_.pop(); // Return the the continuation fragment getDialect()->gotoFragment(body, current_fragment_.top()); // Replace IF body fragment with the ELSE body fragment current_fragment_.push(newFragment()); // Create the jump to the current fragment (unconditional jump) getDialect()->gotoFragment(if_fragment_.top(), current_fragment_.top()); }
void compiler::Script::handleEndIf() { // Finished adding the body of the IF, remove its fragment from the stack Fragment *body = current_fragment_.top(); current_fragment_.pop(); // Use the dialect to return the the appropriate fragment getDialect()->gotoFragment(body, current_fragment_.top()); // Handle any conditons that fall through // TODO: Compiler Optimisation: Don't do this if the is an ELSE statement getDialect()->gotoFragment(if_fragment_.top(), current_fragment_.top()); // Finished this IF block, so pop off the item from the stack if_fragment_.pop(); }
QString AbstractDb::getUniqueNewObjectName(const QString &attachedDbName) { QString dbName = getPrefixDb(attachedDbName, getDialect()); QSet<QString> existingNames; SqlQueryPtr results = exec(QString("SELECT name FROM %1.sqlite_master").arg(dbName)); foreach (SqlResultsRowPtr row, results->getAll()) existingNames << row->value(0).toString(); return randStrNotIn(16, existingNames, false); }
void compiler::Script::handleIf(lang::Condition &condition) { // Store the current fragment to place branch statements inside it, and then jump to the new fragment if_fragment_.push(current_fragment_.top()); // Don't need the old current fragment, as it was moved onto the if_fragment stack current_fragment_.pop(); // Create a fragment to resume execution at; this will take the place of the old current fragment current_fragment_.push(newFragment()); // Set a new fragment as the current fragment so we can put the body of the if inside it current_fragment_.push(newFragment()); // Dialect will handle the actual IF part getDialect()->conditionalJump(if_fragment_.top(), &condition, current_fragment_.top()); }
void compiler::Script::declare(std::string const &name, std::string const &type, int value) { // Use the dialect as a Type factory std::cout << "Declaring " << name << " of type " << type << " with value " << value << std::endl; symbols_[name] = getDialect()->createType(type.c_str(), value); }
lang::ImportHandler *compiler::Script::getImporter() { if (importer_ == nullptr) { importer_ = getDialect()->importer(*context_); } return importer_; }
ReadWriteLocker::Mode AbstractDb::getLockingMode(const QString &query, Flags flags) { return ReadWriteLocker::getMode(query, getDialect(), flags.testFlag(Flag::NO_LOCK)); }