Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit a3b827e

Browse files
author
Ehsan M. Kermani
committed
Diplay the VM output
1 parent 41637d5 commit a3b827e

File tree

2 files changed

+3
-0
lines changed

2 files changed

+3
-0
lines changed

‎book/src/01_calculator/repl.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ added instructions [1, 0, 0, 1, 0, 1] from opcode OpConstant(1)
6363
added instructions [1, 0, 0, 1, 0, 1, 3] from opcode OpAdd
6464
added instructions [1, 0, 0, 1, 0, 1, 3, 2] from opcode OpPop
6565
byte code: Bytecode { instructions: [1, 0, 0, 1, 0, 1, 3, 2], constants: [Int(1), Int(2)] }
66+
3
6667
>> (1 + 2) - (8 - 10)
6768
Compiling the source: (1 + 2) - (8 - 10)
6869
[BinaryExpr { op: Minus, lhs: BinaryExpr { op: Plus, lhs: Int(1), rhs: Int(2) }, rhs: BinaryExpr { op: Minus, lhs: Int(8), rhs: Int(10) } }]
@@ -76,6 +77,7 @@ added instructions [1, 0, 0, 1, 0, 1, 3, 1, 0, 2, 1, 0, 3, 4] from opcode OpSub
7677
added instructions [1, 0, 0, 1, 0, 1, 3, 1, 0, 2, 1, 0, 3, 4, 4] from opcode OpSub
7778
added instructions [1, 0, 0, 1, 0, 1, 3, 1, 0, 2, 1, 0, 3, 4, 4, 2] from opcode OpPop
7879
byte code: Bytecode { instructions: [1, 0, 0, 1, 0, 1, 3, 1, 0, 2, 1, 0, 3, 4, 4, 2], constants: [Int(1), Int(2), Int(8), Int(10)] }
80+
5
7981
>>>
8082
CTRL-C
8183
```

‎calculator/src/bin/repl.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ fn main() {
3939
println!("byte code: {:?}", byte_code);
4040
let mut vm = VM::new(byte_code);
4141
vm.run();
42+
println!("{}", vm.pop_last());
4243
}
4344
}
4445
}

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /