#include "LLLexer.h"
#include "llvm/DerivedTypes.h"
#include "llvm/Instruction.h"
+#include "llvm/LLVMContext.h"
#include "llvm/Support/MemoryBuffer.h"
#include "llvm/Support/MathExtras.h"
#include "llvm/Support/SourceMgr.h"
// Lexer definition.
//===----------------------------------------------------------------------===//
-LLLexer::LLLexer(MemoryBuffer *StartBuf, SourceMgr &sm, SMDiagnostic &Err)
- : CurBuf(StartBuf), ErrorInfo(Err), SM(sm), APFloatVal(0.0) {
+LLLexer::LLLexer(MemoryBuffer *StartBuf, SourceMgr &sm, SMDiagnostic &Err,
+ LLVMContext &C)
+ : CurBuf(StartBuf), ErrorInfo(Err), SM(sm), Context(C), APFloatVal(0.0) {
CurPtr = CurBuf->getBufferStart();
}
Error("bitwidth for integer type out of range!");
return lltok::Error;
}
- TyVal = IntegerType::get(NumBits);
+ TyVal = Context.getIntegerType(NumBits);
return lltok::Type;
}
class MemoryBuffer;
class Type;
class SMDiagnostic;
+ class LLVMContext;
class LLLexer {
const char *CurPtr;
MemoryBuffer *CurBuf;
SMDiagnostic &ErrorInfo;
SourceMgr &SM;
+ LLVMContext &Context;
// Information about the current token.
const char *TokStart;
std::string TheError;
public:
- explicit LLLexer(MemoryBuffer *StartBuf, SourceMgr &SM, SMDiagnostic &);
+ explicit LLLexer(MemoryBuffer *StartBuf, SourceMgr &SM, SMDiagnostic &,
+ LLVMContext &C);
~LLLexer() {}
lltok::Kind Lex() {
std::vector<GlobalValue*> NumberedVals;
public:
LLParser(MemoryBuffer *F, SourceMgr &SM, SMDiagnostic &Err, Module *m) :
- Context(m->getContext()), Lex(F, SM, Err), M(m) {}
+ Context(m->getContext()), Lex(F, SM, Err, m->getContext()), M(m) {}
bool Run();
LLVMContext& getContext() { return Context; }