Skip to content
This repository was archived by the owner on Jan 21, 2023. It is now read-only.

Commit cda291b

Browse files
committed
add opcode_num
1 parent 74e37bd commit cda291b

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

src/main.rs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,19 @@ impl Compiler {
1515
opcode_list.insert("OP_1", 0x51);
1616
opcode_list.insert("OP_2", 0x52);
1717
opcode_list.insert("OP_3", 0x53);
18+
opcode_list.insert("OP_4", 0x54);
19+
opcode_list.insert("OP_5", 0x55);
20+
opcode_list.insert("OP_6", 0x56);
21+
opcode_list.insert("OP_7", 0x57);
22+
opcode_list.insert("OP_8", 0x58);
23+
opcode_list.insert("OP_9", 0x59);
24+
opcode_list.insert("OP_10", 0x5a);
25+
opcode_list.insert("OP_11", 0x5b);
26+
opcode_list.insert("OP_12", 0x5c);
27+
opcode_list.insert("OP_13", 0x5d);
28+
opcode_list.insert("OP_14", 0x5e);
29+
opcode_list.insert("OP_15", 0x5f);
30+
opcode_list.insert("OP_16", 0x60);
1831
opcode_list.insert("OP_NOP", 0x61);
1932
opcode_list.insert("OP_DUP", 0x76);
2033
opcode_list.insert("OP_IF", 0x63);
@@ -137,6 +150,7 @@ impl<'borrow_code_lifetime> VM<'borrow_code_lifetime> {
137150
let mut if_code: Vec<i32> = vec![];
138151
let mut else_code: Vec<i32> = vec![];
139152

153+
// TODO: replace rspritn to count loop like OP_ELSE
140154
let after_if = self.codes.split_at(self.pc + 1).1;
141155
let codes_in_if_to_endif = after_if.rsplitn(2, |code| *code == Compiler::new().compile_single("OP_ENDIF")).last().unwrap();
142156

0 commit comments

Comments
 (0)