Skip to content

Commit 4ca3dd1

Browse files
committed
[WIP] Implement live variable analysis
Signed-off-by: Adam Laszlo Kulcsar <[email protected]>
1 parent b0c5ec7 commit 4ca3dd1

File tree

6 files changed

+784
-3
lines changed

6 files changed

+784
-3
lines changed

src/interpreter/ByteCode.h

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
#ifndef __WalrusByteCode__
1818
#define __WalrusByteCode__
1919

20+
#include "Walrus.h"
2021
#if !defined(NDEBUG)
2122
#include <cinttypes>
2223
#include "runtime/Module.h"
@@ -663,6 +664,7 @@ class BinaryOperation : public ByteCode {
663664
const ByteCodeStackOffset* srcOffset() const { return m_srcOffset; }
664665
ByteCodeStackOffset dstOffset() const { return m_dstOffset; }
665666
void setDstOffset(ByteCodeStackOffset o) { m_dstOffset = o; }
667+
void setSrcOffset(ByteCodeStackOffset o, size_t index) { m_srcOffset[index] = o; }
666668
#if !defined(NDEBUG)
667669
void dump(size_t pos)
668670
{
@@ -705,6 +707,14 @@ class UnaryOperation : public ByteCode {
705707
}
706708
ByteCodeStackOffset srcOffset() const { return m_srcOffset; }
707709
ByteCodeStackOffset dstOffset() const { return m_dstOffset; }
710+
void setDstOffset(ByteCodeStackOffset newOffset)
711+
{
712+
m_dstOffset = newOffset;
713+
}
714+
void setSrcOffset(ByteCodeStackOffset newOffset)
715+
{
716+
m_srcOffset = newOffset;
717+
}
708718
#if !defined(NDEBUG)
709719
void dump(size_t pos)
710720
{
@@ -874,6 +884,14 @@ class Move32 : public ByteCode {
874884

875885
ByteCodeStackOffset srcOffset() const { return m_srcOffset; }
876886
ByteCodeStackOffset dstOffset() const { return m_dstOffset; }
887+
void setDstOffset(ByteCodeStackOffset newOffset)
888+
{
889+
m_dstOffset = newOffset;
890+
}
891+
void setSrcOffset(ByteCodeStackOffset newOffset)
892+
{
893+
m_srcOffset = newOffset;
894+
}
877895

878896
#if !defined(NDEBUG)
879897
void dump(size_t pos)
@@ -2037,6 +2055,7 @@ class GlobalGet32 : public ByteCode {
20372055
}
20382056

20392057
ByteCodeStackOffset dstOffset() const { return m_dstOffset; }
2058+
void setDstOffset(ByteCodeStackOffset o) { m_dstOffset = o; }
20402059
uint32_t index() const { return m_index; }
20412060

20422061
#if !defined(NDEBUG)
@@ -2255,7 +2274,7 @@ class End : public ByteCode {
22552274
{
22562275
}
22572276

2258-
ByteCodeStackOffset* resultOffsets() const
2277+
ByteCodeStackOffset* resultOffsets()
22592278
{
22602279
return reinterpret_cast<ByteCodeStackOffset*>(reinterpret_cast<size_t>(this) + sizeof(End));
22612280
}

0 commit comments

Comments
 (0)