klee
Context.cpp
Go to the documentation of this file.
1//===-- Context.cpp -------------------------------------------------------===//
2//
3// The KLEE Symbolic Virtual Machine
4//
5// This file is distributed under the University of Illinois Open Source
6// License. See LICENSE.TXT for details.
7//
8//===----------------------------------------------------------------------===//
9
10#include "Context.h"
11
12#include "klee/Expr/Expr.h"
13
14#include "llvm/IR/Type.h"
15#include "llvm/IR/DerivedTypes.h"
16
17#include <cassert>
18
19using namespace klee;
20
21static bool Initialized = false;
23
24void Context::initialize(bool IsLittleEndian, Expr::Width PointerWidth) {
25 assert(!Initialized && "Duplicate context initialization!");
27 Initialized = true;
28}
29
31 assert(Initialized && "Context has not been initialized!");
32 return TheContext;
33}
34
35// FIXME: This is a total hack, just to avoid a layering issue until this stuff
36// moves out of Expr.
37
39 return SExtExpr::create(e, Context::get().getPointerWidth());
40}
41
43 return ZExtExpr::create(e, Context::get().getPointerWidth());
44}
45
47 return ConstantExpr::create(v, Context::get().getPointerWidth());
48}
static Context TheContext
Definition: Context.cpp:22
static bool Initialized
Definition: Context.cpp:21
static ref< ConstantExpr > create(uint64_t v, Width w)
Definition: Expr.h:1079
Context - Helper class for storing global information about a KLEE run.
Definition: Context.h:18
Expr::Width PointerWidth
The pointer width of the target architecture.
Definition: Context.h:23
bool IsLittleEndian
Whether the target architecture is little endian or not.
Definition: Context.h:20
static const Context & get()
get - Return the global singleton instance of the Context.
Definition: Context.cpp:30
static ref< Expr > createZExtToPointerWidth(ref< Expr > e)
Definition: Context.cpp:42
static ref< Expr > createSExtToPointerWidth(ref< Expr > e)
Definition: Context.cpp:38
static ref< ConstantExpr > createPointer(uint64_t v)
Definition: Context.cpp:46
unsigned Width
The type of an expression is simply its width, in bits.
Definition: Expr.h:97
Definition: main.cpp:291