aboutsummaryrefslogtreecommitdiffstats
path: root/moth
diff options
context:
space:
mode:
authorErik Verbruggen <erik.verbruggen@digia.com>2012-11-20 10:08:14 +0100
committerLars Knoll <lars.knoll@digia.com>2012-11-20 12:01:06 +0100
commite625c28b3957c680baea7127c079f9497fa11f0f (patch)
tree3310c008b7b898f54c9b2bc0a9d9ec0c6b992603 /moth
parent590b9491836fc5357393c5b89c2a8f82f5ec24b6 (diff)
Fix debug code and add some asserts.
Change-Id: I947a72ff43190d15fd4a2857ed97b75cc510db66 Reviewed-by: Lars Knoll <lars.knoll@digia.com>
Diffstat (limited to 'moth')
-rw-r--r--moth/qv4vme_moth.cpp16
1 files changed, 14 insertions, 2 deletions
diff --git a/moth/qv4vme_moth.cpp b/moth/qv4vme_moth.cpp
index a4033ab6d5..080d3953bc 100644
--- a/moth/qv4vme_moth.cpp
+++ b/moth/qv4vme_moth.cpp
@@ -56,12 +56,12 @@ static inline VM::Value *tempValue(QQmlJS::VM::ExecutionContext *context, QVecto
if (index < 0) {
kind = "arg";
pos = -index - 1;
- } else if (index < (int) context->varCount) {
+ } else if (index < (int) context->variableEnvironment->varCount) {
kind = "local";
pos = index;
} else {
kind = "temp";
- pos = index - context->varCount;
+ pos = index - context->variableEnvironment->varCount;
}
fprintf(stderr, " tempValue: index = %d : %s = %d, stack size = %d\n",
index, kind, pos, stack.size());
@@ -69,11 +69,23 @@ static inline VM::Value *tempValue(QQmlJS::VM::ExecutionContext *context, QVecto
if (index < 0) {
const int arg = -index - 1;
+
+ Q_ASSERT(arg >= 0);
+ Q_ASSERT((unsigned) arg < context->variableEnvironment->argumentCount);
+ Q_ASSERT(context->variableEnvironment->arguments);
+
return context->variableEnvironment->arguments + arg;
} else if (index < (int) context->variableEnvironment->varCount) {
+ Q_ASSERT(index >= 0);
+ Q_ASSERT(context->variableEnvironment->locals);
+
return context->variableEnvironment->locals + index;
} else {
int off = index - context->variableEnvironment->varCount;
+
+ Q_ASSERT(off >= 0);
+ Q_ASSERT(off < stack.size());
+
return stack.data() + off;
}
}