summaryrefslogtreecommitdiff
path: root/Source/JavaScriptCore/bytecode/Operands.h
diff options
context:
space:
mode:
authorAllan Sandfeld Jensen <allan.jensen@digia.com>2013-09-13 12:51:20 +0200
committerThe Qt Project <gerrit-noreply@qt-project.org>2013-09-19 20:50:05 +0200
commitd441d6f39bb846989d95bcf5caf387b42414718d (patch)
treee367e64a75991c554930278175d403c072de6bb8 /Source/JavaScriptCore/bytecode/Operands.h
parent0060b2994c07842f4c59de64b5e3e430525c4b90 (diff)
downloadqtwebkit-d441d6f39bb846989d95bcf5caf387b42414718d.tar.gz
Import Qt5x2 branch of QtWebkit for Qt 5.2
Importing a new snapshot of webkit. Change-Id: I2d01ad12cdc8af8cb015387641120a9d7ea5f10c Reviewed-by: Allan Sandfeld Jensen <allan.jensen@digia.com>
Diffstat (limited to 'Source/JavaScriptCore/bytecode/Operands.h')
-rw-r--r--Source/JavaScriptCore/bytecode/Operands.h30
1 files changed, 28 insertions, 2 deletions
diff --git a/Source/JavaScriptCore/bytecode/Operands.h b/Source/JavaScriptCore/bytecode/Operands.h
index 20f79ffd1..e7b3e241f 100644
--- a/Source/JavaScriptCore/bytecode/Operands.h
+++ b/Source/JavaScriptCore/bytecode/Operands.h
@@ -46,6 +46,8 @@ struct OperandValueTraits {
static void dump(const T& value, PrintStream& out) { value.dump(out); }
};
+enum OperandKind { ArgumentOperand, LocalOperand };
+
template<typename T, typename Traits = OperandValueTraits<T> >
class Operands {
public:
@@ -66,6 +68,28 @@ public:
T& local(size_t idx) { return m_locals[idx]; }
const T& local(size_t idx) const { return m_locals[idx]; }
+ template<OperandKind operandKind>
+ size_t sizeFor() const
+ {
+ if (operandKind == ArgumentOperand)
+ return numberOfArguments();
+ return numberOfLocals();
+ }
+ template<OperandKind operandKind>
+ T& atFor(size_t idx)
+ {
+ if (operandKind == ArgumentOperand)
+ return argument(idx);
+ return local(idx);
+ }
+ template<OperandKind operandKind>
+ const T& atFor(size_t idx) const
+ {
+ if (operandKind == ArgumentOperand)
+ return argument(idx);
+ return local(idx);
+ }
+
void ensureLocals(size_t size)
{
if (size <= m_locals.size())
@@ -192,15 +216,17 @@ private:
template<typename T, typename Traits>
void dumpOperands(const Operands<T, Traits>& operands, PrintStream& out)
{
- for (size_t argument = 0; argument < operands.numberOfArguments(); ++argument) {
- if (argument)
+ for (size_t argument = operands.numberOfArguments(); argument--;) {
+ if (argument != operands.numberOfArguments() - 1)
out.printf(" ");
+ out.print("arg", argument, ":");
Traits::dump(operands.argument(argument), out);
}
out.printf(" : ");
for (size_t local = 0; local < operands.numberOfLocals(); ++local) {
if (local)
out.printf(" ");
+ out.print("r", local, ":");
Traits::dump(operands.local(local), out);
}
}