aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/compile.cpp2
-rw-r--r--src/llvm.cpp7
2 files changed, 4 insertions, 5 deletions
diff --git a/src/compile.cpp b/src/compile.cpp
index 4d8e98d..554fab6 100644
--- a/src/compile.cpp
+++ b/src/compile.cpp
@@ -130,7 +130,7 @@ compile_dot(CEnv& cenv, const ATuple* dot) throw()
const ALiteral<int32_t>* index = (ALiteral<int32_t>*)(*++i);
assert(index->tag() == T_INT32);
CVal tupVal = resp_compile(cenv, tup);
- return cenv.engine()->compileDot(cenv, tupVal, index->val);
+ return cenv.engine()->compileDot(cenv, tupVal, index->val + 1); // + 1 to skip RTTI
}
static CVal
diff --git a/src/llvm.cpp b/src/llvm.cpp
index c7d03a8..6975861 100644
--- a/src/llvm.cpp
+++ b/src/llvm.cpp
@@ -326,7 +326,7 @@ LLVMEngine::compileCons(CEnv& cenv, const AType* type, CVal rtti, const vector<C
CVal
LLVMEngine::compileDot(CEnv& cenv, CVal tup, int32_t index)
{
- Value* ptr = builder.CreateStructGEP(llVal(tup), index + 1, "dotPtr"); // +1 to skip RTTI
+ Value* ptr = builder.CreateStructGEP(llVal(tup), index, "dotPtr");
return builder.CreateLoad(ptr, 0, "dotVal");
}
@@ -424,9 +424,8 @@ LLVMEngine::compileMatch(CEnv& cenv, const ATuple* match)
{
LLVMEngine* engine = reinterpret_cast<LLVMEngine*>(cenv.engine());
IfState state = compileIfStart(cenv);
- Value* matchee = llVal(resp_compile(cenv, match->list_ref(1)));
- Value* rttiPtr = builder.CreateStructGEP(matchee, 0, "matchRTTIPtr");
- Value* rtti = builder.CreateLoad(rttiPtr, 0, "matchRTTI");
+ CVal matchee = resp_compile(cenv, match->list_ref(1));
+ Value* rtti = llVal(compileDot(cenv, matchee, 0));
size_t idx = 1;
for (ATuple::const_iterator i = match->iter_at(2); i != match->end(); ++idx) {