summaryrefslogtreecommitdiff
path: root/Source/JavaScriptCore/bytecode/Operands.h
diff options
context:
space:
mode:
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);
}
}