xo-jit: refactor to support function pointer arguments.
This commit is contained in:
parent
2235bba872
commit
e246f12d70
6 changed files with 508 additions and 210 deletions
45
src/jit/activation_record.cpp
Normal file
45
src/jit/activation_record.cpp
Normal file
|
|
@ -0,0 +1,45 @@
|
|||
/* @file activation_record.cpp */
|
||||
|
||||
#include "activation_record.hpp"
|
||||
#include "xo/indentlog/print/tag.hpp"
|
||||
#include <iostream>
|
||||
|
||||
namespace xo {
|
||||
namespace jit {
|
||||
using std::cerr;
|
||||
using std::endl;
|
||||
|
||||
llvm::AllocaInst *
|
||||
activation_record::lookup_var(const std::string & x) const {
|
||||
|
||||
auto ix = frame_.find(x);
|
||||
|
||||
if (ix == frame_.end()) {
|
||||
cerr << "activation_record::lookup_var: no binding for variable x"
|
||||
<< xtag("x", x)
|
||||
<< endl;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
return ix->second;
|
||||
} /*lookup_var*/
|
||||
|
||||
llvm::AllocaInst *
|
||||
activation_record::alloc_var(const std::string & x,
|
||||
llvm::AllocaInst * alloca)
|
||||
{
|
||||
if (frame_.find(x) != frame_.end()) {
|
||||
cerr << "activation_record::alloc_var: variable x already present in frame"
|
||||
<< xtag("x", x)
|
||||
<< endl;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
frame_[x] = alloca;
|
||||
return alloca;
|
||||
} /*alloc_var*/
|
||||
} /*namespace jit*/
|
||||
} /*namespace xo*/
|
||||
|
||||
|
||||
/* end activation_record.cpp */
|
||||
Loading…
Add table
Add a link
Reference in a new issue