Main.cpp 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. // Standard includes
  2. #include <cstdio>
  3. //LLVM includes
  4. #include "llvm/Support/TargetSelect.h"
  5. #include "KaleidoscopeJIT.h"
  6. // Local includes
  7. #include "Ast.h"
  8. #include "Parser.h"
  9. #include "JIT.h"
  10. using namespace parser;
  11. using namespace jit;
  12. namespace helper {
  13. // Cloning make_unique here until it's standard in C++14.
  14. // Using a namespace to avoid conflicting with MSVC's std::make_unique (which
  15. // ADL can sometimes find in unqualified calls).
  16. template <class T, class... Args>
  17. static
  18. typename std::enable_if<!std::is_array<T>::value, std::unique_ptr<T>>::type
  19. make_unique(Args &&... args) {
  20. return std::unique_ptr<T>(new T(std::forward<Args>(args)...));
  21. }
  22. }
  23. //===----------------------------------------------------------------------===//
  24. // "Library" functions that can be "extern'd" from user code.
  25. //===----------------------------------------------------------------------===//
  26. //===----------------------------------------------------------------------===//
  27. // Main driver code.
  28. //===----------------------------------------------------------------------===//
  29. int main() {
  30. InitializeNativeTarget();
  31. InitializeNativeTargetAsmPrinter();
  32. InitializeNativeTargetAsmParser();
  33. JITObjects::TheJIT = llvm::make_unique<llvm::orc::KaleidoscopeJIT>();
  34. jit::InitializeModule();
  35. // Prime the first token.
  36. getNextToken();
  37. // Run the main "interpreter loop" now.
  38. MainLoop();
  39. AstObjects::TheModule->dump();
  40. return 0;
  41. }