Skeleton for source language abstraction. There's SourceLanguage with several
subclasses, though they don't do much yet. SourceCode is now associated with a SourceLanguage. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@31544 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -14,6 +14,7 @@ SEARCH_SOURCE += [ FDirName $(SUBDIR) elf ] ;
|
||||
SEARCH_SOURCE += [ FDirName $(SUBDIR) files ] ;
|
||||
SEARCH_SOURCE += [ FDirName $(SUBDIR) gui team_window ] ;
|
||||
SEARCH_SOURCE += [ FDirName $(SUBDIR) model ] ;
|
||||
SEARCH_SOURCE += [ FDirName $(SUBDIR) source_language ] ;
|
||||
SEARCH_SOURCE += [ FDirName $(SUBDIR) types ] ;
|
||||
SEARCH_SOURCE += [ FDirName $(SUBDIR) util ] ;
|
||||
|
||||
@@ -107,6 +108,15 @@ Application Debugger :
|
||||
Thread.cpp
|
||||
ThreadInfo.cpp
|
||||
|
||||
# source_language
|
||||
CLanguage.cpp
|
||||
CLanguageFamily.cpp
|
||||
CppLanguage.cpp
|
||||
SourceLanguage.cpp
|
||||
SyntaxHighlighter.cpp
|
||||
UnsupportedLanguage.cpp
|
||||
X86AssemblyLanguage.cpp
|
||||
|
||||
# types
|
||||
TargetAddressRangeList.cpp
|
||||
|
||||
|
||||
@@ -20,6 +20,7 @@
|
||||
#include "StackFrame.h"
|
||||
#include "Statement.h"
|
||||
#include "TeamMemory.h"
|
||||
#include "X86AssemblyLanguage.h"
|
||||
|
||||
#include "disasm/DisassemblerX86.h"
|
||||
|
||||
@@ -104,6 +105,7 @@ struct ArchitectureX86::FromDwarfRegisterMap : RegisterMap {
|
||||
ArchitectureX86::ArchitectureX86(TeamMemory* teamMemory)
|
||||
:
|
||||
Architecture(teamMemory),
|
||||
fAssemblyLanguage(NULL),
|
||||
fToDwarfRegisterMap(NULL),
|
||||
fFromDwarfRegisterMap(NULL)
|
||||
{
|
||||
@@ -116,12 +118,18 @@ ArchitectureX86::~ArchitectureX86()
|
||||
fToDwarfRegisterMap->ReleaseReference();
|
||||
if (fFromDwarfRegisterMap != NULL)
|
||||
fFromDwarfRegisterMap->ReleaseReference();
|
||||
if (fAssemblyLanguage != NULL)
|
||||
fAssemblyLanguage->ReleaseReference();
|
||||
}
|
||||
|
||||
|
||||
status_t
|
||||
ArchitectureX86::Init()
|
||||
{
|
||||
fAssemblyLanguage = new(std::nothrow) X86AssemblyLanguage;
|
||||
if (fAssemblyLanguage == NULL)
|
||||
return B_NO_MEMORY;
|
||||
|
||||
try {
|
||||
_AddIntegerRegister(X86_REGISTER_EIP, "eip", B_UINT32_TYPE,
|
||||
REGISTER_TYPE_INSTRUCTION_POINTER, false);
|
||||
@@ -450,7 +458,8 @@ status_t
|
||||
ArchitectureX86::DisassembleCode(FunctionDebugInfo* function,
|
||||
const void* buffer, size_t bufferSize, DisassembledCode*& _sourceCode)
|
||||
{
|
||||
DisassembledCode* source = new(std::nothrow) DisassembledCode;
|
||||
DisassembledCode* source = new(std::nothrow) DisassembledCode(
|
||||
fAssemblyLanguage);
|
||||
if (source == NULL)
|
||||
return B_NO_MEMORY;
|
||||
Reference<DisassembledCode> sourceReference(source, true);
|
||||
|
||||
@@ -11,6 +11,9 @@
|
||||
#include "Register.h"
|
||||
|
||||
|
||||
class SourceLanguage;
|
||||
|
||||
|
||||
class ArchitectureX86 : public Architecture {
|
||||
public:
|
||||
ArchitectureX86(TeamMemory* teamMemory);
|
||||
@@ -67,6 +70,7 @@ private:
|
||||
|
||||
private:
|
||||
Array<Register> fRegisters;
|
||||
SourceLanguage* fAssemblyLanguage;
|
||||
ToDwarfRegisterMap* fToDwarfRegisterMap;
|
||||
FromDwarfRegisterMap* fFromDwarfRegisterMap;
|
||||
};
|
||||
|
||||
@@ -104,6 +104,14 @@ DebuggerImageDebugInfo::GetStatementAtSourceLocation(
|
||||
}
|
||||
|
||||
|
||||
status_t
|
||||
DebuggerImageDebugInfo::GetSourceLanguage(FunctionDebugInfo* function,
|
||||
SourceLanguage*& _language)
|
||||
{
|
||||
return B_UNSUPPORTED;
|
||||
}
|
||||
|
||||
|
||||
ssize_t
|
||||
DebuggerImageDebugInfo::ReadCode(target_addr_t address, void* buffer,
|
||||
size_t size)
|
||||
|
||||
@@ -39,6 +39,9 @@ public:
|
||||
const SourceLocation& sourceLocation,
|
||||
Statement*& _statement);
|
||||
|
||||
virtual status_t GetSourceLanguage(FunctionDebugInfo* function,
|
||||
SourceLanguage*& _language);
|
||||
|
||||
virtual ssize_t ReadCode(target_addr_t address, void* buffer,
|
||||
size_t size);
|
||||
|
||||
|
||||
@@ -17,7 +17,9 @@
|
||||
#include <AutoLocker.h>
|
||||
|
||||
#include "Architecture.h"
|
||||
#include "CLanguage.h"
|
||||
#include "CompilationUnit.h"
|
||||
#include "CppLanguage.h"
|
||||
#include "CpuState.h"
|
||||
#include "DebugInfoEntries.h"
|
||||
#include "Dwarf.h"
|
||||
@@ -36,6 +38,7 @@
|
||||
#include "Statement.h"
|
||||
#include "StringUtils.h"
|
||||
#include "TeamMemory.h"
|
||||
#include "UnsupportedLanguage.h"
|
||||
|
||||
|
||||
// #pragma mark - UnwindTargetInterface
|
||||
@@ -525,6 +528,40 @@ printf(" -> found statement!\n");
|
||||
}
|
||||
|
||||
|
||||
status_t
|
||||
DwarfImageDebugInfo::GetSourceLanguage(FunctionDebugInfo* _function,
|
||||
SourceLanguage*& _language)
|
||||
{
|
||||
DwarfFunctionDebugInfo* function
|
||||
= dynamic_cast<DwarfFunctionDebugInfo*>(_function);
|
||||
if (function == NULL)
|
||||
return B_BAD_VALUE;
|
||||
|
||||
SourceLanguage* language;
|
||||
CompilationUnit* unit = function->GetCompilationUnit();
|
||||
switch (unit->UnitEntry()->Language()) {
|
||||
case DW_LANG_C89:
|
||||
case DW_LANG_C:
|
||||
case DW_LANG_C99:
|
||||
language = new(std::nothrow) CLanguage;
|
||||
break;
|
||||
case DW_LANG_C_plus_plus:
|
||||
language = new(std::nothrow) CppLanguage;
|
||||
break;
|
||||
case 0:
|
||||
default:
|
||||
language = new(std::nothrow) UnsupportedLanguage;
|
||||
break;
|
||||
}
|
||||
|
||||
if (language == NULL)
|
||||
return B_NO_MEMORY;
|
||||
|
||||
_language = language;
|
||||
return B_OK;
|
||||
}
|
||||
|
||||
|
||||
ssize_t
|
||||
DwarfImageDebugInfo::ReadCode(target_addr_t address, void* buffer, size_t size)
|
||||
{
|
||||
|
||||
@@ -53,6 +53,9 @@ public:
|
||||
const SourceLocation& sourceLocation,
|
||||
Statement*& _statement);
|
||||
|
||||
virtual status_t GetSourceLanguage(FunctionDebugInfo* function,
|
||||
SourceLanguage*& _language);
|
||||
|
||||
virtual ssize_t ReadCode(target_addr_t address, void* buffer,
|
||||
size_t size);
|
||||
|
||||
|
||||
@@ -18,6 +18,7 @@ class FileSourceCode;
|
||||
class FunctionDebugInfo;
|
||||
class Image;
|
||||
class LocatableFile;
|
||||
class SourceLanguage;
|
||||
class SourceLocation;
|
||||
class StackFrame;
|
||||
class Statement;
|
||||
@@ -50,6 +51,9 @@ public:
|
||||
Statement*& _statement) = 0;
|
||||
// returns reference
|
||||
|
||||
virtual status_t GetSourceLanguage(FunctionDebugInfo* function,
|
||||
SourceLanguage*& _language) = 0;
|
||||
|
||||
virtual ssize_t ReadCode(target_addr_t address, void* buffer,
|
||||
size_t size) = 0;
|
||||
|
||||
|
||||
@@ -24,6 +24,7 @@
|
||||
#include "ImageDebugInfo.h"
|
||||
#include "LocatableFile.h"
|
||||
#include "SourceFile.h"
|
||||
#include "SourceLanguage.h"
|
||||
#include "SpecificImageDebugInfo.h"
|
||||
#include "StringUtils.h"
|
||||
|
||||
@@ -163,6 +164,11 @@ struct TeamDebugInfo::SourceFileEntry : public HashTableLink<SourceFileEntry> {
|
||||
return fFunctions.ItemAt(index - 1);
|
||||
}
|
||||
|
||||
Function* FunctionAt(int32 index) const
|
||||
{
|
||||
return fFunctions.ItemAt(index);
|
||||
}
|
||||
|
||||
private:
|
||||
typedef BObjectList<Function> FunctionList;
|
||||
|
||||
@@ -378,6 +384,20 @@ TeamDebugInfo::LoadSourceCode(LocatableFile* file, FileSourceCode*& _sourceCode)
|
||||
return B_OK;
|
||||
}
|
||||
|
||||
// get the source language from some function's image debug info
|
||||
Function* function = entry->FunctionAt(0);
|
||||
if (function == NULL)
|
||||
return B_ENTRY_NOT_FOUND;
|
||||
|
||||
FunctionDebugInfo* functionDebugInfo
|
||||
= function->FirstInstance()->GetFunctionDebugInfo();
|
||||
SourceLanguage* language;
|
||||
status_t error = functionDebugInfo->GetSpecificImageDebugInfo()
|
||||
->GetSourceLanguage(functionDebugInfo, language);
|
||||
if (error != B_OK)
|
||||
return error;
|
||||
Reference<SourceLanguage> languageReference(language, true);
|
||||
|
||||
// no source code yet
|
||||
// locker.Unlock();
|
||||
// TODO: It would be nice to unlock here, but we need to iterate through
|
||||
@@ -387,12 +407,12 @@ TeamDebugInfo::LoadSourceCode(LocatableFile* file, FileSourceCode*& _sourceCode)
|
||||
|
||||
// load the source file
|
||||
SourceFile* sourceFile;
|
||||
status_t error = fFileManager->LoadSourceFile(file, sourceFile);
|
||||
error = fFileManager->LoadSourceFile(file, sourceFile);
|
||||
if (error != B_OK)
|
||||
return error;
|
||||
|
||||
// create the source code
|
||||
sourceCode = new(std::nothrow) FileSourceCode(file, sourceFile);
|
||||
sourceCode = new(std::nothrow) FileSourceCode(file, sourceFile, language);
|
||||
sourceFile->ReleaseReference();
|
||||
if (sourceCode == NULL)
|
||||
return B_NO_MEMORY;
|
||||
|
||||
@@ -146,6 +146,8 @@ public:
|
||||
const char* CompilationDir() const
|
||||
{ return fCompilationDir; }
|
||||
|
||||
uint16 Language() const { return fLanguage; }
|
||||
|
||||
const DebugInfoEntryList& Types() const { return fTypes; }
|
||||
const DebugInfoEntryList& OtherChildren() const
|
||||
{ return fOtherChildren; }
|
||||
|
||||
@@ -13,6 +13,7 @@
|
||||
|
||||
#include <String.h>
|
||||
|
||||
#include "SourceLanguage.h"
|
||||
#include "Statement.h"
|
||||
|
||||
|
||||
@@ -29,10 +30,12 @@ struct DisassembledCode::Line {
|
||||
};
|
||||
|
||||
|
||||
DisassembledCode::DisassembledCode()
|
||||
DisassembledCode::DisassembledCode(SourceLanguage* language)
|
||||
:
|
||||
fLanguage(language),
|
||||
fLines(20, true)
|
||||
{
|
||||
fLanguage->AcquireReference();
|
||||
}
|
||||
|
||||
|
||||
@@ -40,6 +43,8 @@ DisassembledCode::~DisassembledCode()
|
||||
{
|
||||
for (int32 i = 0; Statement* statement = fStatements.ItemAt(i); i++)
|
||||
statement->RemoveReference();
|
||||
|
||||
fLanguage->ReleaseReference();
|
||||
}
|
||||
|
||||
|
||||
@@ -57,6 +62,13 @@ DisassembledCode::Unlock()
|
||||
}
|
||||
|
||||
|
||||
SourceLanguage*
|
||||
DisassembledCode::GetSourceLanguage() const
|
||||
{
|
||||
return fLanguage;
|
||||
}
|
||||
|
||||
|
||||
int32
|
||||
DisassembledCode::CountLines() const
|
||||
{
|
||||
|
||||
@@ -17,12 +17,14 @@ class ContiguousStatement;
|
||||
|
||||
class DisassembledCode : public SourceCode {
|
||||
public:
|
||||
DisassembledCode();
|
||||
DisassembledCode(SourceLanguage* language);
|
||||
~DisassembledCode();
|
||||
|
||||
virtual bool Lock();
|
||||
virtual void Unlock();
|
||||
|
||||
virtual SourceLanguage* GetSourceLanguage() const;
|
||||
|
||||
virtual int32 CountLines() const;
|
||||
virtual const char* LineAt(int32 index) const;
|
||||
|
||||
@@ -59,6 +61,7 @@ private:
|
||||
const ContiguousStatement* statement);
|
||||
|
||||
private:
|
||||
SourceLanguage* fLanguage;
|
||||
LineList fLines;
|
||||
StatementList fStatements;
|
||||
};
|
||||
|
||||
@@ -10,22 +10,27 @@
|
||||
|
||||
#include "LocatableFile.h"
|
||||
#include "SourceFile.h"
|
||||
#include "SourceLanguage.h"
|
||||
#include "SourceLocation.h"
|
||||
|
||||
|
||||
FileSourceCode::FileSourceCode(LocatableFile* file, SourceFile* sourceFile)
|
||||
FileSourceCode::FileSourceCode(LocatableFile* file, SourceFile* sourceFile,
|
||||
SourceLanguage* language)
|
||||
:
|
||||
fLock("source code"),
|
||||
fFile(file),
|
||||
fSourceFile(sourceFile)
|
||||
fSourceFile(sourceFile),
|
||||
fLanguage(language)
|
||||
{
|
||||
fFile->AcquireReference();
|
||||
fSourceFile->AcquireReference();
|
||||
fLanguage->AcquireReference();
|
||||
}
|
||||
|
||||
|
||||
FileSourceCode::~FileSourceCode()
|
||||
{
|
||||
fLanguage->ReleaseReference();
|
||||
fSourceFile->ReleaseReference();
|
||||
fFile->ReleaseReference();
|
||||
}
|
||||
@@ -65,6 +70,13 @@ FileSourceCode::Unlock()
|
||||
}
|
||||
|
||||
|
||||
SourceLanguage*
|
||||
FileSourceCode::GetSourceLanguage() const
|
||||
{
|
||||
return fLanguage;
|
||||
}
|
||||
|
||||
|
||||
int32
|
||||
FileSourceCode::CountLines() const
|
||||
{
|
||||
|
||||
@@ -20,7 +20,8 @@ class SourceFile;
|
||||
class FileSourceCode : public SourceCode {
|
||||
public:
|
||||
FileSourceCode(LocatableFile* file,
|
||||
SourceFile* sourceFile);
|
||||
SourceFile* sourceFile,
|
||||
SourceLanguage* language);
|
||||
virtual ~FileSourceCode();
|
||||
|
||||
status_t Init();
|
||||
@@ -30,6 +31,8 @@ public:
|
||||
virtual bool Lock();
|
||||
virtual void Unlock();
|
||||
|
||||
virtual SourceLanguage* GetSourceLanguage() const;
|
||||
|
||||
virtual int32 CountLines() const;
|
||||
virtual const char* LineAt(int32 index) const;
|
||||
|
||||
@@ -49,6 +52,7 @@ private:
|
||||
BLocker fLock;
|
||||
LocatableFile* fFile;
|
||||
SourceFile* fSourceFile;
|
||||
SourceLanguage* fLanguage;
|
||||
Array<SourceLocation> fSourceLocations;
|
||||
};
|
||||
|
||||
|
||||
@@ -12,6 +12,7 @@
|
||||
|
||||
|
||||
class LocatableFile;
|
||||
class SourceLanguage;
|
||||
class SourceLocation;
|
||||
class Statement;
|
||||
|
||||
@@ -25,6 +26,8 @@ public:
|
||||
virtual bool Lock() = 0;
|
||||
virtual void Unlock() = 0;
|
||||
|
||||
virtual SourceLanguage* GetSourceLanguage() const = 0;
|
||||
|
||||
virtual int32 CountLines() const = 0;
|
||||
virtual const char* LineAt(int32 index) const = 0;
|
||||
|
||||
|
||||
@@ -0,0 +1,24 @@
|
||||
/*
|
||||
* Copyright 2009, Ingo Weinhold, ingo_weinhold@gmx.de.
|
||||
* Distributed under the terms of the MIT License.
|
||||
*/
|
||||
|
||||
|
||||
#include "CLanguage.h"
|
||||
|
||||
|
||||
CLanguage::CLanguage()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
CLanguage::~CLanguage()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
const char*
|
||||
CLanguage::Name() const
|
||||
{
|
||||
return "C";
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
/*
|
||||
* Copyright 2009, Ingo Weinhold, ingo_weinhold@gmx.de.
|
||||
* Distributed under the terms of the MIT License.
|
||||
*/
|
||||
#ifndef C_LANGUAGE_H
|
||||
#define C_LANGUAGE_H
|
||||
|
||||
|
||||
#include "CLanguageFamily.h"
|
||||
|
||||
|
||||
class CLanguage : public CLanguageFamily {
|
||||
public:
|
||||
CLanguage();
|
||||
virtual ~CLanguage();
|
||||
|
||||
virtual const char* Name() const;
|
||||
};
|
||||
|
||||
|
||||
#endif // C_LANGUAGE_H
|
||||
@@ -0,0 +1,24 @@
|
||||
/*
|
||||
* Copyright 2009, Ingo Weinhold, ingo_weinhold@gmx.de.
|
||||
* Distributed under the terms of the MIT License.
|
||||
*/
|
||||
|
||||
#include "CLanguageFamily.h"
|
||||
|
||||
|
||||
CLanguageFamily::CLanguageFamily()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
CLanguageFamily::~CLanguageFamily()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
SyntaxHighlighter*
|
||||
CLanguageFamily::GetSyntaxHighlighter() const
|
||||
{
|
||||
// TODO:...
|
||||
return NULL;
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
/*
|
||||
* Copyright 2009, Ingo Weinhold, ingo_weinhold@gmx.de.
|
||||
* Distributed under the terms of the MIT License.
|
||||
*/
|
||||
#ifndef C_LANGUAGE_FAMILY_H
|
||||
#define C_LANGUAGE_FAMILY_H
|
||||
|
||||
|
||||
#include "SourceLanguage.h"
|
||||
|
||||
|
||||
class CLanguageFamily : public SourceLanguage {
|
||||
public:
|
||||
CLanguageFamily();
|
||||
virtual ~CLanguageFamily();
|
||||
|
||||
virtual SyntaxHighlighter* GetSyntaxHighlighter() const;
|
||||
};
|
||||
|
||||
|
||||
#endif // C_LANGUAGE_FAMILY_H
|
||||
@@ -0,0 +1,24 @@
|
||||
/*
|
||||
* Copyright 2009, Ingo Weinhold, ingo_weinhold@gmx.de.
|
||||
* Distributed under the terms of the MIT License.
|
||||
*/
|
||||
|
||||
|
||||
#include "CppLanguage.h"
|
||||
|
||||
|
||||
CppLanguage::CppLanguage()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
CppLanguage::~CppLanguage()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
const char*
|
||||
CppLanguage::Name() const
|
||||
{
|
||||
return "C++";
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
/*
|
||||
* Copyright 2009, Ingo Weinhold, ingo_weinhold@gmx.de.
|
||||
* Distributed under the terms of the MIT License.
|
||||
*/
|
||||
#ifndef CPP_LANGUAGE_H
|
||||
#define CPP_LANGUAGE_H
|
||||
|
||||
|
||||
#include "CLanguageFamily.h"
|
||||
|
||||
|
||||
class CppLanguage : public CLanguageFamily {
|
||||
public:
|
||||
CppLanguage();
|
||||
virtual ~CppLanguage();
|
||||
|
||||
virtual const char* Name() const;
|
||||
};
|
||||
|
||||
|
||||
#endif // CPP_LANGUAGE_H
|
||||
@@ -0,0 +1,19 @@
|
||||
/*
|
||||
* Copyright 2009, Ingo Weinhold, ingo_weinhold@gmx.de.
|
||||
* Distributed under the terms of the MIT License.
|
||||
*/
|
||||
|
||||
|
||||
#include "SourceLanguage.h"
|
||||
|
||||
|
||||
SourceLanguage::~SourceLanguage()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
SyntaxHighlighter*
|
||||
SourceLanguage::GetSyntaxHighlighter() const
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
/*
|
||||
* Copyright 2009, Ingo Weinhold, ingo_weinhold@gmx.de.
|
||||
* Distributed under the terms of the MIT License.
|
||||
*/
|
||||
#ifndef SOURCE_LANGUAGE_H
|
||||
#define SOURCE_LANGUAGE_H
|
||||
|
||||
|
||||
#include <Referenceable.h>
|
||||
|
||||
|
||||
class SyntaxHighlighter;
|
||||
|
||||
|
||||
class SourceLanguage : public Referenceable {
|
||||
public:
|
||||
virtual ~SourceLanguage();
|
||||
|
||||
virtual const char* Name() const = 0;
|
||||
|
||||
virtual SyntaxHighlighter* GetSyntaxHighlighter() const;
|
||||
// returns a reference,
|
||||
// may return NULL, if not available
|
||||
};
|
||||
|
||||
|
||||
#endif // SOURCE_LANGUAGE_H
|
||||
@@ -0,0 +1,31 @@
|
||||
/*
|
||||
* Copyright 2009, Ingo Weinhold, ingo_weinhold@gmx.de.
|
||||
* Distributed under the terms of the MIT License.
|
||||
*/
|
||||
|
||||
|
||||
#include "SyntaxHighlighter.h"
|
||||
|
||||
|
||||
// #pragma mark - SyntaxHighlightSource
|
||||
|
||||
|
||||
SyntaxHighlightSource::~SyntaxHighlightSource()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
// #pragma mark - SyntaxHighlightInfo
|
||||
|
||||
|
||||
SyntaxHighlightInfo::~SyntaxHighlightInfo()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
// #pragma mark - SyntaxHighlighter
|
||||
|
||||
|
||||
SyntaxHighlighter::~SyntaxHighlighter()
|
||||
{
|
||||
}
|
||||
@@ -0,0 +1,54 @@
|
||||
/*
|
||||
* Copyright 2009, Ingo Weinhold, ingo_weinhold@gmx.de.
|
||||
* Distributed under the terms of the MIT License.
|
||||
*/
|
||||
#ifndef SYNTAX_HIGHLIGHTER_H
|
||||
#define SYNTAX_HIGHLIGHTER_H
|
||||
|
||||
|
||||
#include <String.h>
|
||||
|
||||
#include <Referenceable.h>
|
||||
|
||||
|
||||
enum syntax_highlight_type {
|
||||
SYNTAX_HIGHLIGHT_NONE,
|
||||
SYNTAX_HIGHLIGHT_KEYWORD
|
||||
// TODO:...
|
||||
};
|
||||
|
||||
|
||||
class SyntaxHighlightSource : public Referenceable {
|
||||
virtual ~SyntaxHighlightSource();
|
||||
|
||||
virtual int32 CountLines() const = 0;
|
||||
virtual void GetLineAt(int32 index, BString& _line) const
|
||||
= 0;
|
||||
};
|
||||
|
||||
|
||||
class SyntaxHighlightInfo {
|
||||
virtual ~SyntaxHighlightInfo();
|
||||
|
||||
virtual int32 GetLineHighlightRanges(int32 line,
|
||||
int32* _columns,
|
||||
syntax_highlight_type* _types,
|
||||
int32 maxCount) = 0;
|
||||
// Returns number of filled in
|
||||
// (column, type) pairs.
|
||||
// Default is (0, SYNTAX_HIGHLIGHT_NONE)
|
||||
// and can be omitted.
|
||||
};
|
||||
|
||||
|
||||
class SyntaxHighlighter : public Referenceable {
|
||||
public:
|
||||
virtual ~SyntaxHighlighter();
|
||||
|
||||
virtual status_t ParseText(SyntaxHighlightSource* source,
|
||||
SyntaxHighlightInfo*& _info) = 0;
|
||||
// caller owns the returned info
|
||||
};
|
||||
|
||||
|
||||
#endif // SYNTAX_HIGHLIGHTER_H
|
||||
@@ -0,0 +1,14 @@
|
||||
/*
|
||||
* Copyright 2009, Ingo Weinhold, ingo_weinhold@gmx.de.
|
||||
* Distributed under the terms of the MIT License.
|
||||
*/
|
||||
|
||||
|
||||
#include "UnsupportedLanguage.h"
|
||||
|
||||
|
||||
const char*
|
||||
UnsupportedLanguage::Name() const
|
||||
{
|
||||
return "unsupported";
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
/*
|
||||
* Copyright 2009, Ingo Weinhold, ingo_weinhold@gmx.de.
|
||||
* Distributed under the terms of the MIT License.
|
||||
*/
|
||||
#ifndef UNSUPPORTED_LANGUAGE_H
|
||||
#define UNSUPPORTED_LANGUAGE_H
|
||||
|
||||
|
||||
#include "SourceLanguage.h"
|
||||
|
||||
|
||||
class UnsupportedLanguage : public SourceLanguage {
|
||||
public:
|
||||
virtual const char* Name() const;
|
||||
};
|
||||
|
||||
|
||||
#endif // UNSUPPORTED_LANGUAGE_H
|
||||
@@ -0,0 +1,32 @@
|
||||
/*
|
||||
* Copyright 2009, Ingo Weinhold, ingo_weinhold@gmx.de.
|
||||
* Distributed under the terms of the MIT License.
|
||||
*/
|
||||
|
||||
|
||||
#include "X86AssemblyLanguage.h"
|
||||
|
||||
|
||||
X86AssemblyLanguage::X86AssemblyLanguage()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
X86AssemblyLanguage::~X86AssemblyLanguage()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
const char*
|
||||
X86AssemblyLanguage::Name() const
|
||||
{
|
||||
return "x86 assembly";
|
||||
}
|
||||
|
||||
|
||||
SyntaxHighlighter*
|
||||
X86AssemblyLanguage::GetSyntaxHighlighter() const
|
||||
{
|
||||
// none available yet
|
||||
return NULL;
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
/*
|
||||
* Copyright 2009, Ingo Weinhold, ingo_weinhold@gmx.de.
|
||||
* Distributed under the terms of the MIT License.
|
||||
*/
|
||||
#ifndef X86_ASSEMBLY_LANGUAGE_H
|
||||
#define X86_ASSEMBLY_LANGUAGE_H
|
||||
|
||||
|
||||
#include "SourceLanguage.h"
|
||||
|
||||
|
||||
class X86AssemblyLanguage : public SourceLanguage {
|
||||
public:
|
||||
X86AssemblyLanguage();
|
||||
virtual ~X86AssemblyLanguage();
|
||||
|
||||
virtual const char* Name() const;
|
||||
|
||||
virtual SyntaxHighlighter* GetSyntaxHighlighter() const;
|
||||
};
|
||||
|
||||
|
||||
#endif // X86_ASSEMBLY_LANGUAGE_H
|
||||
Reference in New Issue
Block a user