Beispiel #1
0
void CView::println(CViewState& vs)
{
uint64_t yOffset = getLineOffset(vs);
std::string line;
	print1(yOffset,line);
	s.printfxy(0,vs.y+HEADER_LINES,"%s",line.c_str());
}
void LineLayer::setLineOffset(DataDrivenPropertyValue<float> value) {
    if (value == getLineOffset())
        return;
    auto impl_ = mutableImpl();
    impl_->paint.template get<LineOffset>().value = value;
    baseImpl = std::move(impl_);
    observer->onLayerChanged(*this);
}
Beispiel #3
0
	TextFileLocus calcLocusFromOffset(const char* string,const LineInfo* lineInfo,Uptr charOffset)
	{
		// Binary search the line starts for the last one before charIndex.
		Uptr minLineIndex = 0;
		Uptr maxLineIndex = lineInfo->numLineStarts - 1;
		while(maxLineIndex > minLineIndex)
		{
			const Uptr medianLineIndex = (minLineIndex + maxLineIndex + 1) / 2;
			if(charOffset < lineInfo->lineStarts[medianLineIndex])
			{
				maxLineIndex = medianLineIndex - 1;
			}
			else if(charOffset > lineInfo->lineStarts[medianLineIndex])
			{
				minLineIndex = medianLineIndex;
			}
			else
			{
				minLineIndex = maxLineIndex = medianLineIndex;
			}
		};
		TextFileLocus result;
		result.newlines = (U32)minLineIndex;

		// Count tabs and and spaces from the beginning of the line to charIndex.
		for(U32 index = lineInfo->lineStarts[result.newlines];index < charOffset;++index)
		{
			if(string[index] == '\t') { ++result.tabs; }
			else { ++result.characters; }
		}

		// Copy the full source line into the TextFileLocus for context.
		const Uptr lineStartOffset = getLineOffset(lineInfo,result.newlines);
		Uptr lineEndOffset = getLineOffset(lineInfo,result.newlines+1) - 1;
		result.sourceLine = std::string(string + lineStartOffset,lineEndOffset - lineStartOffset);

		return result;
	}
Beispiel #4
0
void CView::highlight(CViewState& vs,int b)
{
std::string elem;
uint64_t pos = getLineOffset(vs);
	m.getElem(pos,vs.x,vs.mode,elem);
	if(vs.mode) {
		s.reverse(b);
		s.printfxy(getElemPos(vs),vs.y+HEADER_LINES,"%s",elem.c_str());
		s.reverse(0);
	} else {
		if(vs.nibble == 0) s.reverse(b);
		s.printfxy(getElemPos(vs),vs.y+HEADER_LINES,"%c",elem[0]);
		s.reverse(0);
		if(vs.nibble == 1) s.reverse(b);
		s.printfxy(getElemPos(vs)+1,vs.y+HEADER_LINES,"%c",elem[1]);
		s.reverse(0);
	}
}
Beispiel #5
0
// gather statistics about creation and destructions of variables that are
//  used by the current function
void VarStatistics::calcLexicalScope(Funcsym *s, symtab_t* symtab)
{
    // sort line records and remove duplicate lines
    qsort(lineOffsets, cntUsedLineOffsets, sizeof(*lineOffsets), &cmpLineOffsets);
    int j = 0;
    for (int i = 1; i < cntUsedLineOffsets; i++)
        if (lineOffsets[i].linnum > lineOffsets[j].linnum)
            lineOffsets[++j] = lineOffsets[i];
    cntUsedLineOffsets = j + 1;

    cntUsedVarStats = 0;
    if (cntAllocLexVars < symtab->top)
    {
        isLexVar = (bool*) util_realloc(isLexVar, symtab->top, sizeof(*isLexVar));
        cntAllocLexVars = symtab->top;
    }
    memset(isLexVar, 0, symtab->top);

    SYMIDX si;
    for (si = 0; si < symtab->top; si++)
    {
        symbol *sa = symtab->tab[si];
        isLexVar[si] = isLexicalScopeVar(sa);
        if(isLexVar[si])
            markVarStats(sa->lnoscopestart, sa->lnoscopeend);
    }
    // todo: optimize out multiple blocks for multiple variables added and removed at the same locations

    Srcpos src = funcsym_p->Sfunc->Fstartline;
    for (int i = 0; i < cntUsedVarStats; i++)
        if (varStats[i].numDel > 0 || varStats[i].numNew > 0)
        {
            src.Slinnum = firstVarStatsLine + i;
            varStats[i].offset = getLineOffset (src);
        }
    sanitizeLineOffsets();

    // initialize iteration in ..._writeLexicalScope
    nextVarStatsLine = firstVarStatsLine;
}
void LineLayer::setLineOffset(PropertyValue<float> value, const optional<std::string>& klass) {
    if (value == getLineOffset(klass))
        return;
    impl->paint.lineOffset.set(value, klass);
    impl->observer->onLayerPaintPropertyChanged(*this);
}
Beispiel #7
0
int CView::getElemWidth(CViewState& vs)
{
	std::string elem;
	m.getElem(getLineOffset(vs), vs.x, vs.mode, elem);
	return elem.length();
}
Beispiel #8
0
void CView::status(CViewState& vs)
{
	uint64_t yOffset = getLineOffset(vs);
	uint64_t xOffset = m.getElemOffset(yOffset,vs.x);
	s.printfxy(0,0,"Addr: %08lx Size: %08lx",xOffset,vs.nLength);
}