FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
pythonvm-rust/src/processor/frame.rs at wordcode · progval/pythonvm-rust · GitHub
progval
pythonvm-rust
Repository navigation
Code
Issues
2
(2)
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
pythonvm-rust
/
src
/
processor
/
frame.rs
Copy path
More file actions
More file actions
Latest commit
History
History
History
40 lines (36 loc) · 1.26 KB
Breadcrumbs
pythonvm-rust
/
src
/
processor
/
frame.rs
Copy path
File metadata and controls
40 lines (36 loc) · 1.26 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
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
use
std
::
collections
::
HashMap
;
use
std
::
rc
::
Rc
;
use
std
::
cell
::
RefCell
;
use
super
::
super
::
varstack
::
VectorVarStack
;
use
super
::
super
::
objects
::
{
ObjectRef
,
Code
}
;
use
super
::
instructions
::
{
Instruction
,
InstructionDecoder
}
;
#
[
derive
(
Debug
)
]
pub
enum
Block
{
Loop
(
usize
,
usize
)
,
// begin, end
TryExcept
(
usize
,
usize
)
,
// begin, end
ExceptPopGoto
(
ObjectRef
,
usize
,
usize
)
,
// If an exception matchs the first arg matches, pop n elements from the stack and set the PC to the second arg
}
#
[
derive
(
Debug
)
]
pub
struct
Frame
{
pub
object
:
ObjectRef
,
pub
var_stack
:
VectorVarStack
<
ObjectRef
>
,
pub
block_stack
:
Vec
<
Block
>
,
pub
locals
:
Rc
<
RefCell
<
HashMap
<
String
,
ObjectRef
>
>
>
,
pub
instructions
:
Vec
<
Instruction
>
,
pub
code
:
Code
,
pub
program_counter
:
usize
,
}
impl
Frame
{
pub
fn
new
(
object
:
ObjectRef
,
code
:
Code
,
locals
:
Rc
<
RefCell
<
HashMap
<
String
,
ObjectRef
>
>
>
)
->
Frame
{
let
instructions
:
Vec
<
Instruction
>
=
InstructionDecoder
::
new
(
code
.
code
.
iter
(
)
)
.
into_iter
(
)
.
collect
(
)
;
Frame
{
object
:
object
,
var_stack
:
VectorVarStack
::
new
(
)
,
block_stack
:
Vec
::
new
(
)
,
locals
:
locals
,
instructions
:
instructions
,
code
:
code
,
program_counter
:
0
,
}
}
}
Back
|
FazBrowse Home
|
New Git URL