PageRenderTime 34ms CodeModel.GetById 12ms app.highlight 17ms RepoModel.GetById 1ms app.codeStats 1ms

/JIT/opcodes/name.cc

http://unladen-swallow.googlecode.com/
C++ | 62 lines | 53 code | 9 blank | 0 comment | 0 complexity | 407f7b2d5f4fc1cea02ecba4250c6420 MD5 | raw file
 1#include "Python.h"
 2
 3#include "JIT/opcodes/name.h"
 4#include "JIT/llvm_fbuilder.h"
 5
 6#include "llvm/BasicBlock.h"
 7#include "llvm/Function.h"
 8#include "llvm/Instructions.h"
 9
10using llvm::BasicBlock;
11using llvm::ConstantInt;
12using llvm::Function;
13using llvm::Type;
14using llvm::Value;
15
16namespace py {
17
18OpcodeName::OpcodeName(LlvmFunctionBuilder *fbuilder) :
19    fbuilder_(fbuilder), state_(fbuilder->state())
20{
21}
22
23void
24OpcodeName::LOAD_NAME(int index)
25{
26    Value *result = this->state_->CreateCall(
27        this->state_->GetGlobalFunction<PyObject *(PyFrameObject*, int)>(
28            "_PyEval_LoadName"),
29        this->fbuilder_->frame(),
30        ConstantInt::get(
31            PyTypeBuilder<int>::get(this->fbuilder_->context()), index));
32    this->fbuilder_->PropagateExceptionOnNull(result);
33    this->fbuilder_->Push(result);
34}
35
36void
37OpcodeName::STORE_NAME(int index)
38{
39    Value *to_store = this->fbuilder_->Pop();
40    Value *err = this->state_->CreateCall(
41        this->state_->GetGlobalFunction<int(PyFrameObject*, int, PyObject*)>(
42            "_PyEval_StoreName"),
43        this->fbuilder_->frame(),
44        ConstantInt::get(
45            PyTypeBuilder<int>::get(this->fbuilder_->context()), index),
46        to_store);
47    this->fbuilder_->PropagateExceptionOnNonZero(err);
48}
49
50void
51OpcodeName::DELETE_NAME(int index)
52{
53    Value *err = this->state_->CreateCall(
54        this->state_->GetGlobalFunction<int(PyFrameObject*, int)>(
55            "_PyEval_DeleteName"),
56        this->fbuilder_->frame(),
57        ConstantInt::get(
58            PyTypeBuilder<int>::get(this->fbuilder_->context()), index));
59    this->fbuilder_->PropagateExceptionOnNonZero(err);
60}
61
62}