Skip to content
This repository has been archived by the owner on Oct 21, 2022. It is now read-only.

Replaced mysterous bool's in opcodes with u8 #147

Merged
merged 3 commits into from
Jan 17, 2018

Conversation

icefoxen
Copy link
Contributor

@icefoxen icefoxen commented Jan 17, 2018

I suppose, looking at the code, a bool is always represented as u8, which is what we want anyway, but since these values are not bools but placeholder integers that must currently always be 0, having them be bools is kind of strange.

Replaced the reading/writing of them with VarUint7, which is maybe almost as invalid, but works.

Resolves #145.

Sorry I keep PR'ing API-breaking changes! 😅

I suppose, looking at the code, a bool is always represented as u8,
which is what we want anyway, but since these values are not bools but
placeholder integers that must currently always be 0, having them be
bools is kind of strange.

Replaced the reading/writing of them with VarUint7, which is maybe almost
as invalid, but works.

Resolves issue paritytech#145.
@pepyakin
Copy link
Contributor

Can we have read of exactly u8?

@icefoxen
Copy link
Contributor Author

There's none built in but it would be easy to add.

@pepyakin
Copy link
Contributor

Although I'm happy to land this changes, it would be cool to do it with exactly u8. This way we would closer follow the spec!

@icefoxen
Copy link
Contributor Author

Sure, no problem.

@icefoxen
Copy link
Contributor Author

Done.

@pepyakin
Copy link
Contributor

Oh, sorry, I meant to read not VarUint8, but just Uint8 as it seems to be more aligned with the spec. I should have to be more clear.

@pepyakin
Copy link
Contributor

Ah, I see, this is only the name issue!

/// 8-bit unsigned integer, NOT encoded in LEB128;
/// it's just a single byte.
#[derive(Debug, Copy, Clone)]
pub struct VarUint8(u8);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you please rename it to Uint8 to be more aligned with existing Uint32/Uint64?

@@ -756,10 +756,10 @@ impl Serialize for Opcode {
VarUint32::from(offset).serialize(writer)?;
}),
CurrentMemory(flag) => op!(writer, 0x3f, {
VarUint1::from(flag).serialize(writer)?;
VarUint7::from(flag).serialize(writer)?;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess we want to use Uint8 here (and below and above)

…length

Also fixed a couple other small parts I missed.
@icefoxen
Copy link
Contributor Author

Derp, thank you. I guess I'm a little slow this afternoon. Let me know if there's anything else I missed!

@pepyakin pepyakin merged commit 975078f into paritytech:master Jan 17, 2018
@pepyakin
Copy link
Contributor

Nice! Thanks for your pull request!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants