Пример #1
0
void ASTPrinter::printType(Expression const& _expression)
{
	if (_expression.annotation().type)
		*m_ostream << indentation() << "   Type: " << _expression.annotation().type->toString() << "\n";
	else
		*m_ostream << indentation() << "   Type unknown.\n";
}
Пример #2
0
char* UnOp_xml(const UnOp* term, unsigned indent) {
	/*
	 sc> ?x (3 - 1)!
	 
	 <fact>
	   <sub>
	     <int>3</int>
	     <int>1</int>
	   </sub>
	 </fact>
	 
	 2
	*/
	char* ret;
	char* a = Value_xml(term->a, indent + 1);
	
	asprintf(&ret,
			 "<%1$s>\n"
				 "%3$s%4$s\n" /* a */
			 "%2$s</%1$s>",
			 _unop_xml[term->type],
			 indentation(indent), indentation(indent + 1),
			 a);
	
	free(a);
	return ret;
}
Пример #3
0
void GenericLordArtefact::save( QTextStream * ts, int indent )
{
    indentation( ts, indent );
    *ts << "<artefact type=\"" << _type << "\">" << endl;

    indentation( ts, indent );
    *ts << "</artefact>" << endl;
    *ts << flush;
}
Пример #4
0
void ASTPrinter::printSourcePart(ASTNode const& _node)
{
	if (m_gasCosts.count(&_node))
		*m_ostream << indentation() << "   Gas costs: " << m_gasCosts.at(&_node) << endl;
	if (!m_source.empty())
	{
		SourceLocation const& location(_node.location());
		*m_ostream << indentation() << "   Source: "
				   << escaped(m_source.substr(location.start, location.end - location.start), false) << endl;
	}
}
Пример #5
0
// FOR who IN what WHERE where DO how
static bool iterate(struct context *context,
                    enum Opcode op,
                    struct program_state *state,
                    struct byte_array *program)
{
    struct byte_array *who = serial_decode_string(program);
    struct byte_array *where = serial_decode_string(program);
    struct byte_array *how = serial_decode_string(program);

#ifdef DEBUG
    DEBUGPRINT("%s %s\n",
               NUM_TO_STRING(opcodes, op),
               byte_array_to_string(who));
    if (!context->runtime) {
        if (where && where->length) {
            DEBUGPRINT("%s\tWHERE\n", indentation(context));
            display_code(context, where);
        }
        DEBUGPRINT("%s\tDO\n", indentation(context));
        display_code(context, how);
        return false;
    }
#endif

    bool comprehending = (op == VM_COM);
    struct variable *result = comprehending ? variable_new_list(context, NULL) : NULL;

    struct variable *what = variable_pop(context);
    uint32_t len = variable_length(context, what);
    for (int i=0; i<len; i++) {

        struct variable *that = list_get_int(context, what, i);
        set_named_variable(context, state, who, that);

        byte_array_reset(where);
        byte_array_reset(how);
        if (where && where->length)
            run(context, where, NULL, true);
        if (!where || !where->length || test_operand(context)) {

            if (run(context, how, NULL, true)) // true if run hit VM_RET
                return true;

            if (comprehending) {
                struct variable *item = (struct variable*)stack_pop(context->operand_stack);
                array_add(result->list, item);
            }
        }
    }

    if (comprehending)
        stack_push(context->operand_stack, result);
    return false;
}
Пример #6
0
char* Vector_verbose(const Vector* vec, unsigned indent) {
    char* ret;
    char* vals = ArgList_verbose(vec->vals, indent + 1);

    asprintf(&ret,
             "Vector <\n"
             "%2$s%3$s\n" /* vals */
             "%1$s>",
             indentation(indent), indentation(indent + 1),
             vals);

    free(vals);
    return ret;
}
Пример #7
0
QSize ConsoleItemDelegate::sizeHint(const QStyleOptionViewItem &option,
                                       const QModelIndex &index) const
{
    QStyleOptionViewItem opt = option;
    initStyleOption(&opt, index);

    const auto view = qobject_cast<const QTreeView*>(opt.widget);
    int level = 0;
    QModelIndex idx(index);
    while (idx.parent() != QModelIndex()) {
        idx = idx.parent();
        level++;
    }
    int width = view->width() - level * view->indentation() - view->verticalScrollBar()->width();

    const bool selected = (view->selectionModel()->currentIndex() == index);
    if (!selected && option.font == m_cachedFont && m_cachedHeight > 0)
        return QSize(width, m_cachedHeight);

    ConsoleItem::ItemType type = (ConsoleItem::ItemType)index.data(
                ConsoleItem::TypeRole).toInt();
    bool showTypeIcon = index.parent() == QModelIndex();
    bool showExpandableIcon = type == ConsoleItem::DefaultType;

    QRect rect(level * view->indentation(), 0, width, 0);
    ConsoleItemPositions positions(m_model, rect, opt.font, showTypeIcon, showExpandableIcon);

    QFontMetrics fm(option.font);
    qreal height = fm.height();

    if (selected) {
        QString str = index.data(Qt::DisplayRole).toString();

        QTextLayout tl(str, option.font);
        height = layoutText(tl, positions.textAreaWidth());
    }

    height += 2 * ConsoleItemPositions::ITEM_PADDING;

    if (height < positions.minimumHeight())
        height = positions.minimumHeight();

    if (!selected) {
        m_cachedHeight = height;
        m_cachedFont = option.font;
    }

    return QSize(width, height);
}
Пример #8
0
char* UnOp_verbose(const UnOp* term, unsigned indent) {
	char* ret;
	char* a = Value_verbose(term->a, indent + 1);
	
	asprintf(&ret,
			 "%3$s (\n"       /* Type */
				 "%2$s%4$s\n" /* a */
			 "%1$s)",
			 indentation(indent), indentation(indent + 1),
			 _unop_repr[term->type],
			 a);
	
	free(a);
	return ret;
}
Пример #9
0
void KDPropertyView::drawBranches(QPainter* painter, const QRect& rect, const QModelIndex& index) const
{
    QStyleOptionViewItem opt = viewOptions();
    QStyleOptionViewItem option = opt;
    const QAbstractItemModel * const m = model();

    if ( index.column() == 0 && m && m->data( index, KDPropertyModel::ChangedRole ) == true )
      option.font.setBold(true);

    /*
    if ( m && m->data(index,KDPropertyModel::SeparatorRole) == true ) {
        painter->fillRect(rect, option.palette.dark());
    } else if (selectionModel()->isSelected(index)) {
        painter->fillRect(rect, option.palette.brush(QPalette::Highlight));
    }
    */

    if( m && m->parent(index) == QModelIndex() ) {
      painter->fillRect(rect, option.palette.color(QPalette::AlternateBase));
    } else {
      QRect topr = QRect( rect.topLeft(), QPoint( rect.left()+indentation(), rect.bottom() ) );
      painter->fillRect( topr, option.palette.color(QPalette::AlternateBase));
      //painter->drawLine( rect.x()+indentation(), rect.top(), rect.x()+indentation(), rect.bottom());
      painter->fillRect( QRect( topr.topRight(), rect.bottomRight() ), option.palette.base());

      painter->setPen( option.palette.color(QPalette::AlternateBase) );
      painter->drawLine( topr.right(), rect.bottom(), rect.right(), rect.bottom());
    }

    if (m && m->hasChildren(index)) {
        static const int size = 9;
        opt.state |= QStyle::State_Children;
        opt.rect.setRect(rect.width() - (indentation() + size) / 2,
                         rect.y() + (rect.height() - size) / 2, size, size);
	if (isExpanded(index))
	  opt.state |= QStyle::State_Open;
	QColor bg;
	QVariant bgv = m->data( index,
				      Qt::BackgroundColorRole);
	if( qVariantCanConvert<QColor>(bgv) ) {
	  bg = qVariantValue<QColor>(bgv);
	} else {
	  bg = option.palette.color( QPalette::Background );
	}
        painter->fillRect(opt.rect, bg);
        style()->drawPrimitive(QStyle::PE_IndicatorBranch, &opt, painter, this);
    }
}
Пример #10
0
char* Vector_xml(const Vector* vec, unsigned indent) {
    /*
     sc> ?x <pi, 7 - 3, 4!>

     <vec>
       <var name="pi"/>
       <sub>
         <int>7</int>
         <int>3</int>
       </sub>
       <fact>
         <int>4</int>
       </fact>
     </vec>

     <3.14159265358979, 4, 24>
    */
    char* ret;
    char* vals = ArgList_xml(vec->vals, indent + 1);

    asprintf(&ret,
             "<vec>\n"
             "%2$s\n" /* vals */
             "%1$s</vec>",
             indentation(indent),
             vals);

    free(vals);
    return ret;
}
Пример #11
0
void PrettyPrinter::visitBlockNode(BlockNode *node)
{
	std::string indentation(m_indent, ' ');
	m_out << indentation << "{" << std::endl; m_indent += 4;
	printBlock(node);
	m_out << indentation << "}"; m_indent -= 4;
}
Пример #12
0
void RoutingPlan::displayNormalized( const unsigned level )
{
	string indentation( level, '\t' );

	if ( m_Exitpoint.isValid() )
	{
		DEBUG( indentation << "Move to exitpoint [" << m_Exitpoint.getDefinition() << "]" );
	}
	else
	{
		DEBUG( indentation << "Hold message [no more rules]" );
	}

	// display conditions
	DEBUG( indentation << "Fail conditions :" );
	for ( unsigned int i=0; i<m_FailConditions.size(); i++ )
	{
		DEBUG( indentation << "#" << i << " [" << m_FailConditions[ i ].ToString() << "]" );
	}

	DEBUG( indentation << "Success conditions :" );
	for ( unsigned int j=0; j<m_SuccessConditions.size(); j++ )
	{
		DEBUG( indentation << "#" << j << " [" << m_SuccessConditions[ j ].ToString() << "]" );
	}
}
Пример #13
0
ItemViewWidget::ItemViewWidget(QWidget *parent) : QTreeView(parent),
	m_headerWidget(new HeaderViewWidget(Qt::Horizontal, this)),
	m_model(NULL),
	m_viewMode(ListViewMode),
	m_sortOrder(Qt::AscendingOrder),
	m_sortColumn(-1),
	m_dragRow(-1),
	m_dropRow(-1),
	m_canGatherExpanded(false),
	m_isModified(false),
	m_isInitialized(false)
{
	m_treeIndentation = indentation();

	optionChanged(QLatin1String("Interface/ShowScrollBars"), SettingsManager::getValue(QLatin1String("Interface/ShowScrollBars")));
	setHeader(m_headerWidget);
	setItemDelegate(new ItemDelegate(true, this));
	setIndentation(0);
	setAllColumnsShowFocus(true);

	m_filterRoles.insert(Qt::DisplayRole);

	viewport()->setAcceptDrops(true);

	connect(SettingsManager::getInstance(), SIGNAL(valueChanged(QString,QVariant)), this, SLOT(optionChanged(QString,QVariant)));
	connect(this, SIGNAL(sortChanged(int,Qt::SortOrder)), m_headerWidget, SLOT(setSort(int,Qt::SortOrder)));
	connect(m_headerWidget, SIGNAL(sortChanged(int,Qt::SortOrder)), this, SLOT(setSort(int,Qt::SortOrder)));
	connect(m_headerWidget, SIGNAL(columnVisibilityChanged(int,bool)), this, SLOT(setColumnVisibility(int,bool)));
	connect(m_headerWidget, SIGNAL(sectionMoved(int,int,int)), this, SLOT(saveState()));
}
Пример #14
0
CategoryFilterWidget::CategoryFilterWidget(QWidget *parent)
    : QTreeView(parent)
{
    auto *proxyModel = new CategoryFilterProxyModel(this);
    proxyModel->setSortCaseSensitivity(Qt::CaseInsensitive);
    proxyModel->setSourceModel(new CategoryFilterModel(this));
    setModel(proxyModel);
    setFrameShape(QFrame::NoFrame);
    setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
    setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
    setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
    setUniformRowHeights(true);
    setHeaderHidden(true);
    setIconSize(Utils::Gui::smallIconSize());
#ifdef Q_OS_MAC
    setAttribute(Qt::WA_MacShowFocusRect, false);
#endif
    m_defaultIndentation = indentation();
    if (!BitTorrent::Session::instance()->isSubcategoriesEnabled())
        setIndentation(0);
    setContextMenuPolicy(Qt::CustomContextMenu);
    sortByColumn(0, Qt::AscendingOrder);
    setCurrentIndex(model()->index(0, 0));

    connect(this, &QTreeView::collapsed, this, &CategoryFilterWidget::callUpdateGeometry);
    connect(this, &QTreeView::expanded, this, &CategoryFilterWidget::callUpdateGeometry);
    connect(this, &QWidget::customContextMenuRequested, this, &CategoryFilterWidget::showMenu);
    connect(selectionModel(), &QItemSelectionModel::currentRowChanged
            , this, &CategoryFilterWidget::onCurrentRowChanged);
    connect(model(), &QAbstractItemModel::modelReset, this, &CategoryFilterWidget::callUpdateGeometry);
}
Пример #15
0
NavigatorTreeView::NavigatorTreeView(QWidget *parent)
    : QTreeView(parent)
{
    setStyle(new TableViewStyle(this));
    setMinimumWidth(240);
    setRootIsDecorated(false);
    setIndentation(indentation() * 0.5);
}
Пример #16
0
	void
	Rectangle::dump (const char* _name, unsigned int _level) const
	{
		std::string indentation(_level*2, ' ');	
		std::cout << indentation << _name << " = Rectangle" << std::endl;
		start.dump("start", _level+1);
		size.dump("size", _level+1);
	}
int QtTreePropertyBrowser::qt_metacall(QMetaObject::Call _c, int _id, void **_a)
{
    _id = QtAbstractPropertyBrowser::qt_metacall(_c, _id, _a);
    if (_id < 0)
        return _id;
    if (_c == QMetaObject::InvokeMetaMethod) {
        switch (_id) {
        case 0: collapsed((*reinterpret_cast< QtBrowserItem*(*)>(_a[1]))); break;
        case 1: expanded((*reinterpret_cast< QtBrowserItem*(*)>(_a[1]))); break;
        case 2: d_func()->slotCollapsed((*reinterpret_cast< const QModelIndex(*)>(_a[1]))); break;
        case 3: d_func()->slotExpanded((*reinterpret_cast< const QModelIndex(*)>(_a[1]))); break;
        case 4: d_func()->slotCurrentBrowserItemChanged((*reinterpret_cast< QtBrowserItem*(*)>(_a[1]))); break;
        case 5: d_func()->slotCurrentTreeItemChanged((*reinterpret_cast< QTreeWidgetItem*(*)>(_a[1])),(*reinterpret_cast< QTreeWidgetItem*(*)>(_a[2]))); break;
        default: ;
        }
        _id -= 6;
    }
#ifndef QT_NO_PROPERTIES
      else if (_c == QMetaObject::ReadProperty) {
        void *_v = _a[0];
        switch (_id) {
        case 0: *reinterpret_cast< int*>(_v) = indentation(); break;
        case 1: *reinterpret_cast< bool*>(_v) = rootIsDecorated(); break;
        case 2: *reinterpret_cast< bool*>(_v) = alternatingRowColors(); break;
        case 3: *reinterpret_cast< bool*>(_v) = isHeaderVisible(); break;
        case 4: *reinterpret_cast< ResizeMode*>(_v) = resizeMode(); break;
        case 5: *reinterpret_cast< int*>(_v) = splitterPosition(); break;
        case 6: *reinterpret_cast< bool*>(_v) = propertiesWithoutValueMarked(); break;
        }
        _id -= 7;
    } else if (_c == QMetaObject::WriteProperty) {
        void *_v = _a[0];
        switch (_id) {
        case 0: setIndentation(*reinterpret_cast< int*>(_v)); break;
        case 1: setRootIsDecorated(*reinterpret_cast< bool*>(_v)); break;
        case 2: setAlternatingRowColors(*reinterpret_cast< bool*>(_v)); break;
        case 3: setHeaderVisible(*reinterpret_cast< bool*>(_v)); break;
        case 4: setResizeMode(*reinterpret_cast< ResizeMode*>(_v)); break;
        case 5: setSplitterPosition(*reinterpret_cast< int*>(_v)); break;
        case 6: setPropertiesWithoutValueMarked(*reinterpret_cast< bool*>(_v)); break;
        }
        _id -= 7;
    } else if (_c == QMetaObject::ResetProperty) {
        _id -= 7;
    } else if (_c == QMetaObject::QueryPropertyDesignable) {
        _id -= 7;
    } else if (_c == QMetaObject::QueryPropertyScriptable) {
        _id -= 7;
    } else if (_c == QMetaObject::QueryPropertyStored) {
        _id -= 7;
    } else if (_c == QMetaObject::QueryPropertyEditable) {
        _id -= 7;
    } else if (_c == QMetaObject::QueryPropertyUser) {
        _id -= 7;
    }
#endif // QT_NO_PROPERTIES
    return _id;
}
Пример #18
0
void Calendar::save( QTextStream * ts, int indent )
{
	indentation( ts, indent );
	*ts << "<calendar>" << endl;

	for( uint i = 0; i < 5; i++ ) {
			indentation( ts, indent + 1 );
			*ts << "<value type=\"" << i << "\">";
			*ts << getDateByType( i ) << "</value>" << endl;
	}

	indentation( ts, indent + 1 );
	*ts << "<startcalendar>" << endl;

	for( uint i = 0; i < 5; i++ ) {
			indentation( ts, indent + 2 );
			*ts << "<value type=\"" << i << "\">";
			*ts << getInitialDateByType( i ) << "</value>" << endl;
	}
	indentation( ts, indent + 1 );
	*ts << "</startcalendar>" << endl;
	
	indentation( ts, indent + 1 );
	*ts << "<turn>" << getTurn() << "</turn>" << endl;
	indentation( ts, indent );
	*ts << "</calendar>" << endl;
	*ts << flush;

}
Пример #19
0
void pEditor::convertTabs()
{
    // get original text
    QString originalText = text();
    // all modifications must believe as only one action
    beginUndoAction();
    // get indent width
    const int indentWidth = indentationWidth() != 0 ? indentationWidth() : tabWidth();
    // iterate each line
    for ( int i = 0; i < lines(); i++ )
    {
        // remember if last line was troncate
        static bool lastLineWasTroncate = false;
        // get current line indent width
        int lineIndent = indentation( i );
        // check if need troncate
        int t = lineIndent /indentWidth;
        int r = lineIndent %indentWidth;
        if ( r != 0 && r != indentWidth )
        {
            r += indentWidth -r;
            lineIndent = ( t *indentWidth) +r;
            lastLineWasTroncate = true;
        }
        else if ( lastLineWasTroncate && lineIndent != 0 )
        {
            lastLineWasTroncate = indentation( i +1 ) == lineIndent;
            lineIndent  += indentWidth;
        }
        // remove indentation
        setIndentation( i, 0 );
        // restore it with possible troncate indentation
        setIndentation( i, lineIndent );
    }
    // end global undo action
    endUndoAction();
    // compare original and newer text
    if ( originalText == text() )
    {
        // clear undo buffer
        SendScintilla( SCI_EMPTYUNDOBUFFER );
        // set unmodified
        setModified( false );
    }
}
Пример #20
0
void ProjectAST::writeBack(QString &buffer)
{
	if ( isRule() )
		buffer += scopedID;
	else
		buffer += indentation();
	
	AST::writeBack(buffer);

}
Пример #21
0
void display_program(struct byte_array *program)
{
    struct context *context = context_new(false);

    INDENT
    DEBUGPRINT("%sprogram bytes:\n", indentation(context));

    INDENT
    for (int i=0; i<program->length; i++)
        DEBUGPRINT("%s%2d:%3d\n", indentation(context), i, program->data[i]);
    UNDENT

    DEBUGPRINT("%sprogram instructions:\n", indentation(context));
    byte_array_reset(program);
    display_code(context, program);

    UNDENT
    UNDENT
}
Пример #22
0
bool ASTPrinter::visit(VariableDeclaration const& _node)
{
	writeLine("VariableDeclaration \"" + _node.name() + "\"");
	*m_ostream << indentation() << (
		_node.annotation().type ?
		string("   Type: ") + _node.annotation().type->toString() :
		string("   Type unknown.")
	) << "\n";
	printSourcePart(_node);
	return goDeeper();
}
Пример #23
0
void QuestManager::save( QTextStream * ts, uint indent )
{
    indentation( ts, indent );
    (*ts) << "<quests>" << endl;

    if( _mainQuest ) {
        indentation( ts, indent + 1 );
        (*ts) << "<quest type=\"main\">" << endl;

        _mainQuest->save( ts, indent + 2 );

        indentation( ts, indent + 1 );
        (*ts) << "</quest>" << endl;
    }

    uint nbQuests = _quests.count();
    for( uint i = 0; i < nbQuests; i++ ) {
        indentation( ts, indent + 1 );
        (*ts) << "<quest>" << endl;

        ( _quests.at( i ) )->save( ts, indent + 2 );

        indentation( ts, indent + 1 );
        (*ts) << "</quest>" << endl;
    }

    indentation( ts, indent );
    (*ts) << "</quests>" << endl;
}
Пример #24
0
void PrettyPrinter::printBlock(BlockNode *node)
{
	printScope(node->scope());
	std::string indentation(m_indent, ' ');
	for (uint32_t i = 0; i != node->nodes(); ++i)
	{
		m_out << indentation;
		node->nodeAt(i)->visit(this);
		if (!node->nodeAt(i)->isIfNode() && !node->nodeAt(i)->isForNode() &&
			!node->nodeAt(i)->isWhileNode()) m_out << ";";
		m_out << std::endl;
	}
}
Пример #25
0
	out_stream &out_stream::operator <<(const newline_manipulator &)
	{
		std::stringstream stream;
		stream.fill(' ');
		stream.width(FILENAME_FIELD_WIDTH + 1 + LINE_FIELD_WIDTH);
		stream << "";

		*this << "\n";
		_current_line_length = 0;
		*this << stream.str() << DELIMITER << indentation();

		return *this;
	}
Пример #26
0
	out_stream::out_stream()
		:
		_current_line_length(0)
	{
		lock_output();

		std::stringstream stream;
		stream.fill(' ');
		stream.width(FILENAME_FIELD_WIDTH + 1 + LINE_FIELD_WIDTH);
		stream << "";

		*this << stream.str() << DELIMITER << indentation();
	}
Пример #27
0
//-----------------------------------------------------------------------------
std::string dolfin::indent(std::string block)
{
  std::string indentation("  ");
  std::stringstream s;

  s << indentation;
  for (uint i = 0; i < block.size(); ++i)
  {
    s << block[i];
    if (block[i] == '\n' && i < block.size() - 1)
      s << indentation;
  }

  return s.str();
}
Пример #28
0
NavigationTreeView::NavigationTreeView(QWidget *parent)
    : QTreeView(parent)
{
    setFrameStyle(QFrame::NoFrame);
    setIndentation(indentation() * 9/10);
    setUniformRowHeights(true);
    setTextElideMode(Qt::ElideNone);
    setAttribute(Qt::WA_MacShowFocusRect, false);

    setHeaderHidden(true);
    // We let the column adjust to contents, but note
    // the setting of a minimum size in resizeEvent()
    header()->setResizeMode(QHeaderView::ResizeToContents);
    header()->setStretchLastSection(false);
}
Пример #29
0
void PrettyPrinter::printScope(Scope *scope)
{
	std::string indentation(m_indent, ' ');
	//why constructor doesn't get const pointer?
	Scope::VarIterator ivar(scope);
	//Java-style iterators in C++?
	while (ivar.hasNext())
	{
		AstVar *var = ivar.next();
		m_out << indentation << typeToName(var->type()) << " "
		      << var->name() << ";" << std::endl;
	}
	
	Scope::FunctionIterator ifun(scope);
	while (ifun.hasNext()) ifun.next()->node()->visit(this);
}
Пример #30
0
WatchTreeView::WatchTreeView(WatchType type)
  : m_type(type), m_sliderPosition(0)
{
    setObjectName(QLatin1String("WatchWindow"));
    m_grabbing = false;
    setWindowTitle(tr("Locals and Expressions"));
    setIndentation(indentation() * 9/10);
    setUniformRowHeights(true);
    setItemDelegate(new WatchDelegate(this));
    setDragEnabled(true);
    setAcceptDrops(true);
    setDropIndicatorShown(true);

    connect(this, &QTreeView::expanded, this, &WatchTreeView::expandNode);
    connect(this, &QTreeView::collapsed, this, &WatchTreeView::collapseNode);
}