1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
|
/*
* Copyright (c) 2021, Andreas Kling <kling@serenityos.org>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
#pragma once
#include <AK/FlyString.h>
#include <LibJS/Bytecode/Instruction.h>
#include <LibJS/Bytecode/Register.h>
#include <LibJS/Heap/Cell.h>
#include <LibJS/Runtime/Value.h>
namespace JS::Bytecode::Op {
class Load final : public Instruction {
public:
Load(Register dst, Value value)
: m_dst(dst)
, m_value(value)
{
}
virtual ~Load() override { }
virtual void execute(Bytecode::Interpreter&) const override;
virtual String to_string() const override;
private:
Register m_dst;
Value m_value;
};
class Add final : public Instruction {
public:
Add(Register dst, Register src1, Register src2)
: m_dst(dst)
, m_src1(src1)
, m_src2(src2)
{
}
virtual ~Add() override { }
virtual void execute(Bytecode::Interpreter&) const override;
virtual String to_string() const override;
private:
Register m_dst;
Register m_src1;
Register m_src2;
};
class Sub final : public Instruction {
public:
Sub(Register dst, Register src1, Register src2)
: m_dst(dst)
, m_src1(src1)
, m_src2(src2)
{
}
virtual ~Sub() override { }
virtual void execute(Bytecode::Interpreter&) const override;
virtual String to_string() const override;
private:
Register m_dst;
Register m_src1;
Register m_src2;
};
class NewString final : public Instruction {
public:
NewString(Register dst, String string)
: m_dst(dst)
, m_string(move(string))
{
}
virtual ~NewString() override { }
virtual void execute(Bytecode::Interpreter&) const override;
virtual String to_string() const override;
private:
Register m_dst;
String m_string;
};
class SetVariable final : public Instruction {
public:
SetVariable(FlyString identifier, Register src)
: m_identifier(move(identifier))
, m_src(src)
{
}
virtual ~SetVariable() override { }
virtual void execute(Bytecode::Interpreter&) const override;
virtual String to_string() const override;
private:
FlyString m_identifier;
Register m_src;
};
class GetVariable final : public Instruction {
public:
GetVariable(Register dst, FlyString identifier)
: m_dst(dst)
, m_identifier(move(identifier))
{
}
virtual ~GetVariable() override { }
virtual void execute(Bytecode::Interpreter&) const override;
virtual String to_string() const override;
private:
Register m_dst;
FlyString m_identifier;
};
}
|