Browse Source

Updated the C++/CLI parser to the new ASTContext class.

pull/86/head
triton 12 years ago
parent
commit
6da5347e32
  1. 6
      src/Parser/Options.h
  2. 13
      src/Parser/Parser.cpp
  3. 6
      src/Parser/Parser.h

6
src/Parser/Options.h

@ -31,7 +31,7 @@ public ref struct ParserOptions
// C/C++ header file name. // C/C++ header file name.
System::String^ FileName; System::String^ FileName;
CppSharp::AST::Library^ Library; CppSharp::AST::ASTContext^ ASTContext;
int ToolSetToUse; int ToolSetToUse;
System::String^ TargetTriple; System::String^ TargetTriple;
@ -77,8 +77,10 @@ public ref struct ParserResult
} }
ParserResultKind Kind; ParserResultKind Kind;
CppSharp::AST::Library^ Library;
List<ParserDiagnostic>^ Diagnostics; List<ParserDiagnostic>^ Diagnostics;
CppSharp::AST::ASTContext^ ASTContext;
CppSharp::AST::NativeLibrary^ Library;
}; };
enum class SourceLocationKind enum class SourceLocationKind

13
src/Parser/Parser.cpp

@ -33,7 +33,7 @@
//-----------------------------------// //-----------------------------------//
Parser::Parser(ParserOptions^ Opts) : Lib(Opts->Library), Opts(Opts), Index(0) Parser::Parser(ParserOptions^ Opts) : Lib(Opts->ASTContext), Opts(Opts), Index(0)
{ {
} }
@ -2207,7 +2207,7 @@ void Parser::HandleDiagnostics(ParserResult^ res)
ParserResult^ Parser::ParseHeader(const std::string& File) ParserResult^ Parser::ParseHeader(const std::string& File)
{ {
auto res = gcnew ParserResult(); auto res = gcnew ParserResult();
res->Library = Lib; res->ASTContext = Lib;
if (File.empty()) if (File.empty())
{ {
@ -2297,7 +2297,7 @@ ParserResultKind Parser::ParseArchive(llvm::StringRef File,
return ParserResultKind::Error; return ParserResultKind::Error;
auto LibName = clix::marshalString<clix::E_UTF8>(File); auto LibName = clix::marshalString<clix::E_UTF8>(File);
auto NativeLib = Lib->FindOrCreateLibrary(LibName); auto NativeLib = Symbols->FindOrCreateLibrary(LibName);
for(auto it = Archive.begin_symbols(); it != Archive.end_symbols(); ++it) for(auto it = Archive.begin_symbols(); it != Archive.end_symbols(); ++it)
{ {
@ -2322,7 +2322,7 @@ ParserResultKind Parser::ParseSharedLib(llvm::StringRef File,
return ParserResultKind::Error; return ParserResultKind::Error;
auto LibName = clix::marshalString<clix::E_UTF8>(File); auto LibName = clix::marshalString<clix::E_UTF8>(File);
auto NativeLib = Lib->FindOrCreateLibrary(LibName); auto NativeLib = Symbols->FindOrCreateLibrary(LibName);
llvm::error_code ec; llvm::error_code ec;
for(auto it = Object->begin_symbols(); it != Object->end_symbols(); it.increment(ec)) for(auto it = Object->begin_symbols(); it != Object->end_symbols(); it.increment(ec))
@ -2351,10 +2351,11 @@ ParserResultKind Parser::ParseSharedLib(llvm::StringRef File,
return ParserResultKind::Success; return ParserResultKind::Success;
} }
ParserResult^ Parser::ParseLibrary(const std::string& File) ParserResult^ Parser::ParseLibrary(const std::string& File)
{ {
auto res = gcnew ParserResult(); auto res = gcnew ParserResult();
res->Library = Lib; res->Library = gcnew CppSharp::AST::NativeLibrary();
res->Library->FileName = clix::marshalString<clix::E_UTF8>(File);
if (File.empty()) if (File.empty())
{ {

6
src/Parser/Parser.h

@ -5,6 +5,8 @@
* *
************************************************************************/ ************************************************************************/
#using <CppSharp.AST.dll>
#include <llvm/Support/Host.h> #include <llvm/Support/Host.h>
#include <clang/Frontend/CompilerInstance.h> #include <clang/Frontend/CompilerInstance.h>
#include <clang/Frontend/CompilerInvocation.h> #include <clang/Frontend/CompilerInvocation.h>
@ -26,6 +28,7 @@
#include "CXXABI.h" #include "CXXABI.h"
#include "Options.h" #include "Options.h"
#include <vcclr.h>
#include <string> #include <string>
typedef std::string String; typedef std::string String;
@ -100,7 +103,8 @@ protected:
void HandleDiagnostics(ParserResult^ res); void HandleDiagnostics(ParserResult^ res);
int Index; int Index;
gcroot<CppSharp::AST::Library^> Lib; gcroot<CppSharp::AST::ASTContext^> Lib;
gcroot<CppSharp::AST::SymbolContext^> Symbols;
gcroot<ParserOptions^> Opts; gcroot<ParserOptions^> Opts;
llvm::OwningPtr<clang::CompilerInstance> C; llvm::OwningPtr<clang::CompilerInstance> C;
clang::ASTContext* AST; clang::ASTContext* AST;

Loading…
Cancel
Save