Skip to content

Commit

Permalink
Support parsing ByStr (variable length str) type.
Browse files Browse the repository at this point in the history
  • Loading branch information
saeed-zil committed Nov 27, 2024
1 parent 1c41045 commit 0e0d9aa
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 3 deletions.
11 changes: 9 additions & 2 deletions src/simplified_representation/emitter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -131,9 +131,16 @@ impl AstConverting for SrEmitter {
fn emit_meta_identifier(
&mut self,
_mode: TreeTraversalMode,
_node: &NodeMetaIdentifier,
node: &NodeMetaIdentifier,
) -> Result<TraversalResult, String> {
Ok(TraversalResult::Continue)
match node {
NodeMetaIdentifier::ByteString => {
let symbol = SrIdentifier::new("ByStr".to_string(), SrIdentifierKind::Unknown);
self.stack.push(StackObject::IrIdentifier(symbol));
Ok(TraversalResult::SkipChildren)
}
_ => Ok(TraversalResult::Continue),
}
}
fn emit_variable_identifier(
&mut self,
Expand Down
1 change: 0 additions & 1 deletion src/type.rs
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,6 @@ impl From<SrType> for Type {
"Uint256" => Type::Uint256,
"String" => Type::String,
"ByStr" => Type::ByStr,
"ByStrX" => todo!(),
"BNum" => Type::BNum,
"Bool" => Type::Bool,
// TODO: Remove unwrap
Expand Down
1 change: 1 addition & 0 deletions tests/contracts/ByStr.scilla
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ scilla_version 0

contract AllByStrVariants
(
bystr : ByStr,
bystr32 : ByStr32,
raw_address: ByStr20,
library_address : ByStr20 with library end,
Expand Down
1 change: 1 addition & 0 deletions tests/full_contract_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ fn test_bystr_contract_parse() {
Contract {
name: "AllByStrVariants".to_string(),
init_params: FieldList(vec![
Field::new("bystr", Type::ByStr),
Field::new("bystr32", Type::ByStrX(32)),
Field::new("raw_address", Type::ByStr20),
Field::new(
Expand Down

0 comments on commit 0e0d9aa

Please sign in to comment.