mirror of
https://github.com/beefytech/Beef.git
synced 2025-06-10 20:42:21 +02:00
Initial checkin
This commit is contained in:
parent
c74712dad9
commit
078564ac9e
3242 changed files with 1616395 additions and 0 deletions
71
IDEHelper/Compiler/BfFixits.h
Normal file
71
IDEHelper/Compiler/BfFixits.h
Normal file
|
@ -0,0 +1,71 @@
|
|||
#pragma once
|
||||
|
||||
#include "BfSystem.h"
|
||||
#include "BfAst.h"
|
||||
#include "BfParser.h"
|
||||
|
||||
NS_BF_BEGIN
|
||||
|
||||
class BfFixitFinder : public BfElementVisitor
|
||||
{
|
||||
public:
|
||||
static int FindLineStartAfter(BfSourceData* source, int idx)
|
||||
{
|
||||
bool hadBr = false;
|
||||
while (idx < source->mSrcLength)
|
||||
{
|
||||
char c = source->mSrc[idx];
|
||||
if (c == '\n')
|
||||
{
|
||||
idx++;
|
||||
break;
|
||||
}
|
||||
idx++;
|
||||
}
|
||||
return idx;
|
||||
}
|
||||
|
||||
static int FindLineStartAfter(BfAstNode* node)
|
||||
{
|
||||
return FindLineStartAfter(node->GetSourceData(), node->GetSrcEnd());
|
||||
}
|
||||
|
||||
static int FindLineStartBefore(BfSourceData* source, int idx)
|
||||
{
|
||||
bool hadBr = false;
|
||||
while (idx >= 0)
|
||||
{
|
||||
char c = source->mSrc[idx];
|
||||
if (c == '\n')
|
||||
{
|
||||
idx++;
|
||||
break;
|
||||
}
|
||||
idx--;
|
||||
}
|
||||
return idx;
|
||||
}
|
||||
|
||||
static int FindLineStartBefore(BfAstNode* node)
|
||||
{
|
||||
return FindLineStartBefore(node->GetSourceData(), node->GetSrcStart());
|
||||
}
|
||||
};
|
||||
|
||||
class BfUsingFinder : public BfFixitFinder
|
||||
{
|
||||
public:
|
||||
int mLastIdx;
|
||||
|
||||
public:
|
||||
BfUsingFinder()
|
||||
{
|
||||
mLastIdx = 0;
|
||||
}
|
||||
virtual void Visit(BfUsingDirective* usingDirective) override
|
||||
{
|
||||
mLastIdx = FindLineStartAfter(usingDirective->GetSourceData(), usingDirective->GetSrcEnd());
|
||||
}
|
||||
};
|
||||
|
||||
NS_BF_END
|
Loading…
Add table
Add a link
Reference in a new issue