-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor(codegen): introduce external function in code section
- Loading branch information
Showing
10 changed files
with
77 additions
and
123 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
//! External Function for the code section. | ||
use opcodes::ShangHai as OpCode; | ||
|
||
/// External function in code section. | ||
#[derive(PartialEq, Eq, Debug, Clone, Hash)] | ||
pub struct ExtFunc { | ||
/// Stack input. | ||
pub stack_out: u8, | ||
/// Stack output. | ||
pub stack_in: u8, | ||
/// The bytecode of the external function. | ||
pub bytecode: Vec<u8>, | ||
} | ||
|
||
impl ExtFunc { | ||
/// Function select. | ||
pub fn select() -> Self { | ||
Self { | ||
stack_in: 2, | ||
stack_out: 1, | ||
bytecode: [ | ||
OpCode::JUMPDEST, | ||
OpCode::POP, | ||
OpCode::PUSH1, | ||
OpCode::Data(0x06), | ||
OpCode::ADD, | ||
OpCode::JUMP, | ||
] | ||
.iter() | ||
.copied() | ||
.map(|op| op.into()) | ||
.collect(), | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -74,7 +74,7 @@ impl JumpTable { | |
} | ||
} | ||
|
||
Ok((k, *v)) | ||
Ok((k, v.clone())) | ||
}) | ||
.collect::<Result<_>>()?; | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters